[qwen] Add Qwen3_5MoeForCausalLM (flat text-only MoE) support - #384
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix issue related to PR 2146 for xadupre/mbext
Add Qwen3_5MoeForCausalLM (flat text-only MoE) support
Jun 17, 2026
xadupre
marked this pull request as ready for review
June 17, 2026 10:09
📂 Impacted Files3 file(s) changed in this pull request: 🔵 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #384 +/- ##
==========================================
+ Coverage 78.88% 78.91% +0.02%
==========================================
Files 27 27
Lines 8113 8123 +10
==========================================
+ Hits 6400 6410 +10
Misses 1713 1713
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Propagates onnxruntime-genai#2146 (Qwen3.5‑MoE). The MoE
*ForConditionalGenerationbuilder from #2146 was already present and faithful to upstream; the gap was the flat text-onlyQwen3_5MoeForCausalLMvariant, which mbext provides for the dense model (Qwen35CausalLMModel/Qwen3_5ForCausalLM) but not for MoE.Changes
builders/qwen.pyQwen35MoeTextModel.__init__so the MoE config mapping (num_experts → num_local_experts,moe_intermediate_size → intermediate_size) applies to both the nested (text_config) and the flatQwen3_5MoeTextConfig:Qwen35MoeCausalLMModel(Qwen35MoeTextModel), mirroring the denseQwen35CausalLMModel: defaultsexclude_embeds=False(keeps the embedding layer so the graph takesinput_ids) and loads weights viaQwen3_5MoeForCausalLM.builder.py— dispatchQwen3_5MoeForCausalLM → Qwen35MoeCausalLMModel.tests/fast/test_random_qwen3_5_moe.py— flat-config helper +test_qwen3_5_moe_causallm_fp32_cpu_full_attention_buildassertinginput_idsinput, an MoE/QMoE op, andmodel_type == "qwen3_5_moe_text".Notes for reviewers
Qwen3_5MoeForCausalLMis an mbext-side extension (not in #2146 upstream), added for parity with the existing denseForCausalLMpath. The text-onlymodel_type(qwen3_5_moe_text) aligns with themodel_type.hentry from onnxruntime-genai#2186.