From d1cf66fb5aa92906f95c59b5e0ebdbfb24a5eb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 17 Dec 2025 15:23:46 +0000 Subject: [PATCH 1/2] fix config for qwen --- onnx_diagnostic/ci_models/export_qwen25_vl.py | 4 ++++ .../patches/_patch_transformers_qwen2_5.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/onnx_diagnostic/ci_models/export_qwen25_vl.py b/onnx_diagnostic/ci_models/export_qwen25_vl.py index 88ee13b8..028176f7 100644 --- a/onnx_diagnostic/ci_models/export_qwen25_vl.py +++ b/onnx_diagnostic/ci_models/export_qwen25_vl.py @@ -280,6 +280,10 @@ def main( ).eval() data = dict(model=model) config = model.config + if not hasattr(config, "bos_token_id") or not config.bos_token_id: + config.bos_token_id = 151643 + if not hasattr(config, "eos_token_id") or not config.eos_token_id: + config.eos_token_id = 151645 else: print("-- random model") data = get_untrained_model(model_id, second_input=second_input, verbose=1) diff --git a/onnx_diagnostic/torch_export_patches/patches/_patch_transformers_qwen2_5.py b/onnx_diagnostic/torch_export_patches/patches/_patch_transformers_qwen2_5.py index c30ea92f..4678bbe0 100644 --- a/onnx_diagnostic/torch_export_patches/patches/_patch_transformers_qwen2_5.py +++ b/onnx_diagnostic/torch_export_patches/patches/_patch_transformers_qwen2_5.py @@ -256,10 +256,21 @@ def qwen_sdpa_attention( return attn_output def qwen_version_selector(opset: int, *args: torch.Tensor) -> Tuple[str, torch.dtype]: + import onnx_ir + first_float_tensor = next( a for a in args - if a is not None and a.dtype in {torch.float16, torch.float32, torch.bfloat16} + if a is not None + and a.dtype + in { + torch.float16, + torch.float32, + torch.bfloat16, + onnx_ir.DataType.BFLOAT16, + onnx_ir.DataType.FLOAT16, + onnx_ir.DataType.FLOAT, + } ) dtype = first_float_tensor.dtype strategy = patched_Qwen2_5_VLVisionAttention.STRATEGY_FOR_ATTENTION() From b771e942d3bbd9a16d0ce5e39e83273132382c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 17 Dec 2025 15:33:54 +0000 Subject: [PATCH 2/2] fixes --- onnx_diagnostic/helpers/log_helper.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/onnx_diagnostic/helpers/log_helper.py b/onnx_diagnostic/helpers/log_helper.py index 3736103c..796be4a8 100644 --- a/onnx_diagnostic/helpers/log_helper.py +++ b/onnx_diagnostic/helpers/log_helper.py @@ -1921,9 +1921,7 @@ def first_err(df: pandas.DataFrame) -> pandas.Series: return lambdas[formula] if formula == "onnx_n_nodes_no_cst": - return lambda df: gdf(df, "onnx_n_nodes", 0) - gdf( - df, "op_onnx__Constant", 0 - ).fillna(0) + return lambda df: gdf(df, "onnx_n_nodes", 0) - gdf(df, "op_onnx__Constant", 0) if formula == "peak_gpu_torch": return lambda df: gdf(df, "mema_gpu_5_after_export") - gdf(df, "mema_gpu_4_reset") if formula == "peak_gpu_nvidia":