[https://nvbugs/6412108][fix] AutoDeploy:Shard shared Qwen3.5 experts#16286
[https://nvbugs/6412108][fix] AutoDeploy:Shard shared Qwen3.5 experts#16286greg-kwasniewski1 wants to merge 1 commit into
Conversation
|
/bot run |
📝 WalkthroughWalkthroughChangesQwen3.5 MoE sharding
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/bot run |
|
/bot run |
|
PR_Github #58811 [ run ] triggered by Bot. Commit: |
|
PR_Github #58811 [ run ] completed with state |
|
PR_Github #58813 [ run ] triggered by Bot. Commit: |
|
PR_Github #58813 [ run ] completed with state |
|
PR_Github #58815 [ run ] triggered by Bot. Commit: |
|
PR_Github #58815 [ run ] completed with state |
|
/bot run |
|
PR_Github #58830 [ run ] triggered by Bot. Commit: |
|
PR_Github #58830 [ run ] completed with state
|
|
/bot run |
The Qwen3.5 MoE shared expert was force-replicated via the qwen3.5_moe_400b.yaml `shard_layers` whitelist (its linears were left untagged so the whitelist excluded them). Because the routed experts are sharded, the single merge-point `expert_output + shared_expert_output` then `all_reduce` scaled the replicated shared output by world_size (8x), collapsing MMLU from ~85 to ~0.05. Instead of special-casing the reduction order to accommodate a replicated shared expert (which couples modeling-code correctness to an optional yaml), shard the shared expert too: tag its gate/up (colwise) and down (rowwise) linears with `layer_type="mlp"` and remove the `shard_layers` whitelist so both routed and shared experts emit per-rank partials. The existing add-then-all_reduce merge point is then correct. Benchmarks show replicating the shared expert yields no throughput benefit over sharding it (within ~1-2% across concurrency 1/16/32/64 on 8xB200), so sharding both paths is the simpler, self-consistent fix. Unwaives accuracy/test_llm_api_autodeploy.py::TestQwen3_5_397B_MoE::test_nvfp4[8]. Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
7578296 to
de481d3
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #59159 [ run ] triggered by Bot. Commit: |
Summary
Fix the Qwen3.5-397B MoE NVFP4 accuracy regression (nvbugs/6412108) by sharding the shared expert instead of keeping it replicated.
Root cause
The shared expert (
Qwen3_5MoeMLP) had itstorch_linear_simpleops left untagged, andqwen3.5_moe_400b.yamlsetapply_sharding_hints.shard_layers: ["moe","delta","mha"], which excludes untagged ("unknown") nodes. So the shared expert stayed replicated (full output on every rank) while the routed experts were sharded. The single merge-pointexpert_output + shared_expert_outputfollowed byall_reducethen scaled the replicated shared output byworld_size(8x), dropping MMLU from ~85 to ~0.05.Fix
Shard the shared expert like the routed experts rather than special-casing the reduction order:
colwise) and down (rowwise) linears withlayer_type="mlp"inmodeling_qwen3_5_moe.py.shard_layerswhitelist fromqwen3.5_moe_400b.yamlso all tagged nodes shard.all_reducemerge point: both routed and shared branches now emit per-rank partials, so one reduction on the sum lifts both to full.This decouples modeling-code numerical correctness from an optional YAML knob (the whitelist).
Relation to #15922
This supersedes the alternative fix in #15922, which instead reordered the collective (
all_reducethe routed partial first, then add the replicated shared output). That approach keeps the shared expert replicated and leaves correctness dependent on the yaml whitelist. Local benchmarking (Qwen3.5-397B-A17B-NVFP4, 8xB200, ISL/OSL 1024, concurrency 1/16/32/64) shows replicating vs sharding the shared expert is within ~1-2% throughput (run-to-run noise, no consistent winner), so there is no perf reason to keep it replicated; sharding both paths is the simpler, self-consistent fix.Test plan
TestQwen3_5_397B_MoE::test_nvfp4[8]accuracy: MMLU ~86.8 (was ~0.05), passes threshold; unwaived here.test_sharding_num_correctness.pyformodeling_qwen3_5_moeacross tp-only / ep-only / tep / attn-dp (normal pass +SHARDING_IR_SABOTAGE=1true-negative).tests/unittest/auto_deploy/multigpu/suite.Risk
library-visible (AutoDeploy sharding / modeling).
Summary by CodeRabbit