Repository navigation
[Fix] MoE: require TopK layer_id to ensure routed expert captures - #40980
Conversation
652b47b to
5cd6b5c
Compare
|
/rerun-test test/registered/moe/test_triton_fused_moe.py test/registered/moe/test_fused_moe.py test/registered/moe/test_topk_padded_region.py test/registered/moe/test_topk_renormalize_degenerate.py test/registered/rl/test_return_routed_experts.py test/registered/e2e/models/test_mimo_v2_flash.py test/registered/basic_perf/test_moe_throughput.py test/registered/e2e/models/test_kimi_linear_models.py test/registered/dllm/test_dllm_batching_fdfo.py test/registered/e2e/models/test_minimax_m25_basic.py test/registered/unit/models/test_granitemoe_split_expert_loading.py test/registered/unit/models/test_shared_experts_fusion_gates.py test/registered/unit/models/test_nemotron_h_mtp_reduction.py |
|
Results for 🚀 🚀 🚀 🚀 🚀 |
|
/rerun-test test/registered/e2e/models/test_kimi_linear_models.py |
|
/rerun-test test/registered/basic_perf/test_moe_throughput.py |
|
Results for 🚀 |
|
Results for 🚀 |
|
/tag-run-ci-label |
5cd6b5c to
3bd28b7
Compare
MiMoV2MoE built its TopK without layer_id, so with
--enable-return-routed-experts the routed-experts capture could not index
its per-layer buffer and the decode CUDA-graph capture failed with a shape
mismatch ("Target sizes: [8, 1, 4, 8]"). Pass the layer id like the other
MoE models do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cherry-picked from #38718 (merged into sglang-miles).
TopK defaulted layer_id to None, so a model that forgot it still built and only failed once routed-experts capture was on: the capturer indexes buffer[:, None, :], which inserts an axis and breaks CUDA-graph capture with a shape mismatch. The same one-line fix has been made model by model (#30363, #38718, and the MiMo-V2 commit above). Make layer_id a required keyword and pass it in the remaining MoE models. The DBRX, DeepSeek, Xverse and AFMoE MoE blocks now take layer_id from their decoder layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3bd28b7 to
56c23fb
Compare
… graph registration (sgl-project#40648, sgl-project#40978, sgl-project#40979, sgl-project#40980, sgl-project#40977, sgl-project#41972) Retain colocated training fixes above the release MiMo implementation, including address-stable Marlin reload and mandatory TopK layer IDs. Disable NCCL graph registration for TP LM-head all-to-all and pausable graph pools. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Summary
TopKnow requireslayer_id, so no MoE model can omit it and break routed-experts capture.Symptom & Reproduction
--enable-return-routed-experts, MiMo-V2 fails decode CUDA-graph capture with a shape mismatch,Target sizes: [8, 1, 4, 8]; 20 otherTopKcalls onmain(Nemotron-H, Mixtral, Llama 4, DeepSeek, Kimi, ...) omitlayer_idthe same way.python -m sglang.launch_server --model-path <MiMo-V2 checkpoint> --trust-remote-code --tp 4 --enable-return-routed-experts; expected: graphs capture; observed: the error above.Root Cause
TopK.__init__defaultslayer_idtoNone, so omitting it is silent.capture_routed_experts_if_allowedforwardslayer_id=Noneto the capturer.self.buffer[:batch, layer_id, :](state_capturer/base.py:50) inserts an axis forNone.[batch, 1, num_layers, top_k], so the copy fails.Fix
TopK.__init__takeslayer_id: intwith no default, so a model that omits it fails at construction withTypeErrorinstead of at capture time. Past fixes went model by model ([Fix] Support mimo state_capturer routing replay #30363, [sglang-miles] Pass Nemotron-H layer ID to routing replay #38718) and did not stop the next model from repeating the mistake.layer_idparameter fed by their decoder layer.layer_id=0.layer_id,HashTopK, andselect_experts.Verification
pre-commit run --files <changed files>at this head: passed (isort, ruff, ruff-format, codespell, registered-test checks).TopK(...)calls passlayer_id(deepseek_v2.pythroughtopk_kwargs), and each passed name is a parameter or an earlier-assigned attribute of the enclosing__init__.--enable-return-routed-expertscaptured CUDA graphs. The Nemotron-H line ([sglang-miles] Pass Nemotron-H layer ID to routing replay #38718): NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 started with routing replay on 8 H200 GPUs.Review Focus
TopK.__init__: dropping the default makes out-of-tree models that buildTopKwithoutlayer_idfail at init withTypeError; that is the intended guard.dbrx.py/deepseek.py/xverse_moe.py/afmoe.py: the new MoE-blocklayer_idparameter has exactly one caller each.🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #36065710223
Latest PR Test (Extra): ❌ Run #36065709688
Latest PR Test (AMD ROCm 10): ❌ Run #36065710061