9494 "qwen3_vl_text" : "qwen3_vl" ,
9595 "qwen3_5" : "qwen2_5_vl" ,
9696 "qwen3_5_vl" : "qwen2_5_vl" ,
97+ # MiniCPM uses standard 1D decoder position IDs (unlike Qwen-VL MRoPE).
98+ # The phi3v multimodal runtime provides that contract; callers supply
99+ # HF-preprocessed packed pixels through Generator.set_inputs().
100+ "minicpmv4_6" : "phi3v" ,
97101}
98102
99103_GEMMA4_MODEL_TYPES = frozenset (
108112# must preprocess with the HuggingFace processor and feed tensors via
109113# ``Generator.set_inputs`` (see examples/gemma4_unified_ort_genai.py).
110114_GEMMA4_UNIFIED_MODEL_TYPES = frozenset ({"gemma4_unified" , "gemma4_unified_text" })
115+ _MINICPM_MODEL_TYPES = frozenset ({"minicpmv4_6" })
111116# gemma-3 multimodal. build() unwraps the composite HF config to its text
112117# sub-config, so at export time ``config.model_type`` is "gemma3_text" (not
113118# "gemma3").
145150 "merges.txt" , # BPE
146151 "vocab.json" , # BPE
147152 "chat_template.jinja" , # Chat template for ORT GenAI
153+ # Preserve HuggingFace processor metadata for VLMs whose preprocessing
154+ # cannot be represented by an ort-extensions image_processor.json.
155+ "preprocessor_config.json" ,
148156]
149157
150158
@@ -558,6 +566,17 @@ def _write_vision_processor_config(
558566 model_type ,
559567 )
560568 return None
569+ if model_type in _MINICPM_MODEL_TYPES :
570+ # MiniCPM needs adaptive slicing and NaViT horizontal patch packing.
571+ # ort-extensions has no equivalent transform, so preserving the HF
572+ # processor output and injecting it through set_inputs is the only
573+ # numerically faithful runtime path.
574+ logger .info (
575+ "Skipping image_processor.json for %s "
576+ "(use MiniCPMV4_6Processor + Generator.set_inputs)" ,
577+ model_type ,
578+ )
579+ return None
561580
562581 vision_model_type = getattr (vision , "model_type" , None )
563582 is_pixtral = vision_model_type == "pixtral" or model_type in _PIXTRAL_MODEL_TYPES
@@ -1018,6 +1037,12 @@ def _write_genai_config(
10181037 model_type = getattr (config , "model_type" , "" )
10191038 vision_input_mapping = _introspect_inputs (pkg , "vision_encoder" )
10201039 embedding_input_mapping = _introspect_inputs (pkg , "embedding" )
1040+ if model_type in _MINICPM_MODEL_TYPES and vision_input_mapping is not None :
1041+ # ORT GenAI's VisionInputs schema only accepts its predefined
1042+ # semantic keys. ``target_sizes`` remains an ONNX graph input
1043+ # and is supplied as a named tensor through set_inputs().
1044+ vision_input_mapping .pop ("target_sizes" , None )
1045+
10211046 # spatial_merge_size and config_filename are config-level
10221047 # properties that cannot be inferred from the graph.
10231048 vision_kwargs : dict [str , Any ] = {}
@@ -1026,6 +1051,10 @@ def _write_genai_config(
10261051 vision_kwargs ["spatial_merge_size" ] = getattr (
10271052 vision_cfg , "spatial_merge_size" , 2
10281053 )
1054+ elif model_type in _MINICPM_MODEL_TYPES :
1055+ # MiniCPM performs both 2x2 merges inside the ONNX vision
1056+ # graph and consumes HF-prepacked pixels, not Qwen grid_thw.
1057+ vision_kwargs ["spatial_merge_size" ] = None
10291058 elif has_speech :
10301059 vision_kwargs ["spatial_merge_size" ] = None
10311060 # Gemma3n shares gemma3's fixed-resize branch in
0 commit comments