@@ -1227,6 +1227,180 @@ class FakeConfig:
12271227 assert model ["vision" ]["patch_size" ] == 16
12281228 assert model ["vision" ]["window_size" ] == 64
12291229
1230+ def test_qwen35_vl_uses_native_qwen35_runtime_type (self , tmp_path ):
1231+ import dataclasses
1232+
1233+ from mobius ._model_package import ModelPackage
1234+ from mobius .integrations .ort_genai .auto_export import write_ort_genai_config
1235+
1236+ @dataclasses .dataclass
1237+ class FakeVision :
1238+ image_size : int = 448
1239+ patch_size : int = 16
1240+ spatial_merge_size : int = 2
1241+ window_size : int = 112
1242+
1243+ @dataclasses .dataclass
1244+ class FakeConfig :
1245+ model_type : str = "qwen3_5_vl"
1246+ vocab_size : int = 248064
1247+ hidden_size : int = 2048
1248+ num_hidden_layers : int = 2
1249+ num_attention_heads : int = 16
1250+ num_key_value_heads : int = 8
1251+ head_dim : int = 128
1252+ image_token_id : int = 248056
1253+ vision_start_token_id : int = 248053
1254+ video_token_id : int = 248057
1255+ tokens_per_second : float = 2.0
1256+ temporal_patch_size : int = 2
1257+ vision : FakeVision = dataclasses .field (default_factory = FakeVision )
1258+
1259+ pkg = ModelPackage (
1260+ {
1261+ "decoder" : _mock_model (),
1262+ "vision_encoder" : _mock_model (),
1263+ "embedding" : _mock_model (),
1264+ },
1265+ config = FakeConfig (),
1266+ )
1267+
1268+ result = write_ort_genai_config (pkg , str (tmp_path ), ep = "trt-rtx" )
1269+
1270+ with open (result ["genai_config" ]) as f :
1271+ data = json .load (f )
1272+ model = data ["model" ]
1273+ assert model ["type" ] == "qwen3_5"
1274+ assert model ["image_token_id" ] == 248056
1275+ assert model ["vision_start_token_id" ] == 248053
1276+ assert model ["video_token_id" ] == 248057
1277+ assert model ["vision" ]["patch_size" ] == 16
1278+ assert model ["vision" ]["window_size" ] == 112
1279+ assert model ["vision" ]["tokens_per_second" ] == pytest .approx (2.0 )
1280+ assert (
1281+ model ["decoder" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1282+ "enable_cuda_graph"
1283+ ]
1284+ == "1"
1285+ )
1286+ assert (
1287+ model ["vision" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1288+ "enable_cuda_graph"
1289+ ]
1290+ == "0"
1291+ )
1292+ assert (
1293+ model ["embedding" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1294+ "enable_cuda_graph"
1295+ ]
1296+ == "0"
1297+ )
1298+ assert (
1299+ model ["embedding" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1300+ "nv_profile_min_shapes"
1301+ ]
1302+ == "input_ids:1x1,image_features:0x1024"
1303+ )
1304+ assert (
1305+ model ["embedding" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1306+ "nv_profile_opt_shapes"
1307+ ]
1308+ == "input_ids:1x226,image_features:192x1024"
1309+ )
1310+ assert (
1311+ model ["embedding" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1312+ "nv_profile_max_shapes"
1313+ ]
1314+ == "input_ids:1x1024,image_features:2520x1024"
1315+ )
1316+ assert (
1317+ model ["vision" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1318+ "nv_profile_min_shapes"
1319+ ]
1320+ == "pixel_values:600x1536"
1321+ )
1322+ assert (
1323+ model ["vision" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1324+ "nv_profile_opt_shapes"
1325+ ]
1326+ == "pixel_values:600x1536"
1327+ )
1328+ assert (
1329+ model ["vision" ]["session_options" ]["provider_options" ][0 ]["NvTensorRtRtx" ][
1330+ "nv_profile_max_shapes"
1331+ ]
1332+ == "pixel_values:600x1536"
1333+ )
1334+
1335+ def test_qwen36_vl_hf_parent_type_maps_to_qwen35_runtime (self , tmp_path ):
1336+ import dataclasses
1337+
1338+ from mobius ._model_package import ModelPackage
1339+ from mobius .integrations .ort_genai .auto_export import write_ort_genai_config
1340+
1341+ @dataclasses .dataclass
1342+ class FakeVision :
1343+ image_size : int = 448
1344+ patch_size : int = 16
1345+ spatial_merge_size : int = 2
1346+
1347+ @dataclasses .dataclass
1348+ class FakeConfig :
1349+ # build_transformers_model unwraps Qwen3.6 VL to the text sub-config,
1350+ # but write_ort_genai_config must preserve the multimodal HF parent
1351+ # type and map it to ORT GenAI's native qwen3_5 runtime.
1352+ model_type : str = "qwen3_5_moe_text"
1353+ vocab_size : int = 248064
1354+ hidden_size : int = 2048
1355+ num_hidden_layers : int = 2
1356+ num_attention_heads : int = 16
1357+ num_key_value_heads : int = 8
1358+ head_dim : int = 128
1359+ image_token_id : int = 248056
1360+ vision_start_token_id : int = 248053
1361+ video_token_id : int = 248057
1362+ tokens_per_second : float = 2.0
1363+ temporal_patch_size : int = 2
1364+ vision : FakeVision = dataclasses .field (default_factory = FakeVision )
1365+
1366+ pkg = ModelPackage (
1367+ {
1368+ "decoder" : _mock_model (),
1369+ "vision_encoder" : _mock_model (),
1370+ "embedding" : _mock_model (),
1371+ },
1372+ config = FakeConfig (),
1373+ )
1374+
1375+ hf_config = mock .MagicMock (
1376+ model_type = "qwen3_5_moe" ,
1377+ bos_token_id = 248044 ,
1378+ eos_token_id = 248044 ,
1379+ pad_token_id = 248044 ,
1380+ )
1381+ with (
1382+ mock .patch ("transformers.AutoConfig.from_pretrained" , return_value = hf_config ),
1383+ mock .patch (
1384+ "mobius.integrations.ort_genai.auto_export._load_generation_config" ,
1385+ return_value = None ,
1386+ ),
1387+ mock .patch (
1388+ "mobius.integrations.ort_genai.auto_export._copy_tokenizer_files" ,
1389+ return_value = [],
1390+ ),
1391+ mock .patch ("transformers.AutoProcessor.from_pretrained" , side_effect = OSError ),
1392+ ):
1393+ result = write_ort_genai_config (
1394+ pkg ,
1395+ str (tmp_path ),
1396+ hf_model_id = "Qwen/Qwen3.6-35B-A3B" ,
1397+ )
1398+
1399+ with open (result ["genai_config" ]) as f :
1400+ data = json .load (f )
1401+ assert data ["model" ]["type" ] == "qwen3_5"
1402+ assert data ["model" ]["vision" ]["patch_size" ] == 16
1403+
12301404 def test_mage_vl_is_rejected_before_writing_runtime_artifacts (self , tmp_path ):
12311405 import dataclasses
12321406
0 commit comments