@@ -569,28 +569,36 @@ def output_decode(generated_ids, input_shape):
569569
570570 export_path = args .export_path
571571
572- # Check for VLMs by looking for vision_config in model config or language_model attribute
573- is_vlm = False
574- try :
575- is_vlm = hasattr (full_model .config , "vision_config" ) or hasattr (
576- full_model , "language_model"
577- )
578- except Exception :
579- # Fallback to the original check if config access fails
580- is_vlm = hasattr (full_model , "language_model" )
572+ # Check for VLMs by looking for various multimodal indicators in model config
573+ config = full_model .config
574+ is_vlm = (
575+ hasattr (config , "vision_config" ) # Standard vision config (e.g., Qwen2.5-VL)
576+ or hasattr (full_model , "language_model" ) # Language model attribute (e.g., LLaVA)
577+ or getattr (config , "model_type" , "" ) == "phi4mm" # Phi-4 multimodal
578+ or hasattr (config , "vision_lora" ) # Vision LoRA configurations
579+ or hasattr (config , "audio_processor" ) # Audio processing capabilities
580+ or (
581+ hasattr (config , "embd_layer" ) and hasattr (config .embd_layer , "image_embd_layer" )
582+ ) # Image embedding layers
583+ )
581584
582585 if is_vlm :
583- # Save original model config and the preprocessor config to the export path for VLMs.
584-
585- print (f"Saving original model and processor configs to { export_path } " )
586+ # Save original model config and the processor config to the export path for VLMs.
587+ print (f"Saving original model config to { export_path } " )
586588
587589 AutoConfig .from_pretrained (
588590 args .pyt_ckpt_path , trust_remote_code = args .trust_remote_code
589591 ).save_pretrained (export_path )
590592
591- AutoProcessor .from_pretrained (
592- args .pyt_ckpt_path , trust_remote_code = args .trust_remote_code
593- ).save_pretrained (export_path )
593+ # Try to save processor config if available
594+ try :
595+ print (f"Saving processor config to { export_path } " )
596+ AutoProcessor .from_pretrained (
597+ args .pyt_ckpt_path , trust_remote_code = args .trust_remote_code
598+ ).save_pretrained (export_path )
599+ except Exception as e :
600+ print (f"Warning: Could not save processor config: { e } " )
601+ print ("This is normal for some VLM architectures that don't use AutoProcessor" )
594602
595603 if model_type == "mllama" :
596604 full_model_config = model .config
0 commit comments