Skip to content

[qwen] Propagate onnxruntime-genai#2186: Qwen3.5-MoE text-only model type and TRT-RTX swiglu_limit - #382

Merged
xadupre merged 3 commits into
mainfrom
copilot/xadupre-372-propagate
Jun 17, 2026
Merged

[qwen] Propagate onnxruntime-genai#2186: Qwen3.5-MoE text-only model type and TRT-RTX swiglu_limit#382
xadupre merged 3 commits into
mainfrom
copilot/xadupre-372-propagate

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Ports the builder-relevant changes from microsoft/onnxruntime-genai#2186 into the Qwen3.5-MoE builder. The upstream PR's other changes target C++ runtime files (model_type.h, config.cpp) and Python examples that are not part of this builder-only repository.

Changes

  • Text-only model type (Qwen35MoeTextModel.__init__): select Qwen3_5_Moe_textForCausalLM when is_text_only, otherwise Qwen3_5_MoeForConditionalGeneration. The base builder strips the For… suffix and lowercases, so text-only LLM exports now emit genai-config model.type = qwen3_5_moe_text.
  • TRT-RTX swiglu_limit fallback: when unset and ep == "trt-rtx", default to +inf to preserve "no clamp" behavior, since TRT-RTX QMoE builds require the attribute to be present.
  • Test: added test_qwen3_5_moe_fp32_cpu_text_only_model_type asserting model.type == qwen3_5_moe_text for an exclude_embeds=False build; _build_model now forwards **extra_options.
self.model_type = "Qwen3_5_Moe_textForCausalLM" if self.is_text_only else "Qwen3_5_MoeForConditionalGeneration"

if self.moe_attrs.get("swiglu_limit") is None and self.ep == "trt-rtx":
    self.moe_attrs["swiglu_limit"] = float("inf")

The default (non-text-only) path is unchanged and still yields qwen3_5_moe.

CI fix: Qwen2.5-Omni 2D position_ids

The Fast Tests workflow was red on transformers ≥ 5 due to a pre-existing failure in the Qwen2.5-Omni thinker (RuntimeError: Invalid rank for input: position_ids Got: 2 Expected: 3). The thinker is exported as a standalone text decoder and driven by ORT-GenAI, which feeds 2D [B, S] position_ids, but the graph (inherited from Qwen25VLTextModel) declared 3D [3, B, S].

  • Added an expand_position_ids flag on Qwen25VLTextModel (default False). When set, make_inputs_and_outputs declares a 2D position_ids input and make_mrope_position_ids expands it to 3D inside the graph (Unsqueeze + Tile, built once and reused per layer) for the mRoPE subgraph. Qwen25OmniThinkerModel sets the flag to True; genuine Qwen2.5-VL / Qwen3-VL keep 3D position_ids unchanged.
  • Threaded an onnx_position_ids_2d parameter through run_mrope_vl_prefill_and_decode_check / run_vl_random_weights_test in ext_test_case.py (feeds 2D position_ids to ONNX while keeping the 3D feed to PyTorch), and updated the Qwen2.5-Omni tests to feed 2D position_ids.

Copilot AI changed the title [WIP] Propagate changes from pull request 2186 Propagate onnxruntime-genai#2186: Qwen3.5-MoE text-only model type and TRT-RTX swiglu_limit Jun 16, 2026
Copilot AI requested a review from xadupre June 16, 2026 19:11
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

📂 Impacted Files

4 file(s) changed in this pull request:

🔵 modelbuilder/builders/qwen.py (+54 / -4)
🔵 modelbuilder/ext_test_case.py (+16 / -4)
🔵 tests/fast/test_random_qwen2_5_omni.py (+5 / -2)
🔵 tests/fast/test_random_qwen3_5_moe.py (+27 / -1)

@github-actions github-actions Bot changed the title Propagate onnxruntime-genai#2186: Qwen3.5-MoE text-only model type and TRT-RTX swiglu_limit [qwen] Propagate onnxruntime-genai#2186: Qwen3.5-MoE text-only model type and TRT-RTX swiglu_limit Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.88%. Comparing base (f1a03b5) to head (52b4402).

Files with missing lines Patch % Lines
modelbuilder/builders/qwen.py 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #382      +/-   ##
==========================================
+ Coverage   78.87%   78.88%   +0.01%     
==========================================
  Files          27       27              
  Lines        8089     8113      +24     
==========================================
+ Hits         6380     6400      +20     
- Misses       1709     1713       +4     
Flag Coverage Δ
fast-tests 78.88% <92.59%> (+0.02%) ⬆️
fast-tests-ort-nightly 78.83% <92.59%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xadupre
xadupre marked this pull request as ready for review June 16, 2026 21:18
@xadupre

xadupre commented Jun 16, 2026

Copy link
Copy Markdown
Owner

@copilot fix build

@xadupre
xadupre merged commit 571940e into main Jun 17, 2026
11 checks passed
@xadupre
xadupre deleted the copilot/xadupre-372-propagate branch June 17, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants