Repository navigation
[Fix] Stop deferring the last layer's FFN all-reduce in five models - #40868
Merged
Merged
Conversation
Merged
4 of 5 tasks
ch-wan
marked this pull request as ready for review
September 23, 2026 07:28
This was referenced Sep 23, 2026
Merged
ch-wan
force-pushed
the
cheng/refactor/nemotron-dp-attn-communicator
branch
from
September 23, 2026 09:32
4e928dd to
199cc84
Compare
ch-wan
requested review from
Fridge003,
Ying1123,
hanming-lu,
hebiao064,
hnyls2002,
ispobock,
merrymercy,
yizhang2077 and
yuan-luo
as code owners
September 23, 2026 09:32
ch-wan
force-pushed
the
cheng/hot-fix/qwen3-next-last-layer-allreduce
branch
from
September 23, 2026 09:32
4f446bf to
713aa75
Compare
ch-wan
force-pushed
the
cheng/refactor/nemotron-dp-attn-communicator
branch
from
September 23, 2026 21:40
199cc84 to
90c040e
Compare
Base automatically changed from
cheng/refactor/nemotron-dp-attn-communicator
to
main
September 23, 2026 21:40
With FlashInfer all-reduce fusion enabled, LayerCommunicator leaves a layer's FFN all-reduce to be fused into the next layer's residual add + norm unless the layer is marked as the model's last one. Five decoder layers did not mark it, so their final norm ran on TP-partial sums: - Qwen3-Next (both decoder layer types) and MiniMax-M3 never passed is_last_layer. Qwen3-Next is on the auto-enable list for this fusion (SM90 / SM100, TP > 1, no DP attention), so the default configuration is affected; its MTP draft model is covered by the same change. - Bailing-MoE-linear never passed it either, including for its hybrid NextN draft layer. - Bailing-MoE's and Step-3.5's draft layers are built with a layer id that is not num_hidden_layers - 1 (0 and num_hidden_layers respectively), so the existing check marked them as not last. Both decoder layers now take is_nextn, as the DeepSeek, GLM and Dots3 ones already do, and their NextN / MTP models pass it.
ch-wan
force-pushed
the
cheng/hot-fix/qwen3-next-last-layer-allreduce
branch
from
September 23, 2026 21:40
713aa75 to
2b45b0e
Compare
4 of 5 tasks
ch-wan
added a commit
that referenced
this pull request
Sep 25, 2026
MiniMax-M3's decoder layers decided by hand whether to leave their FFN all-reduce to the next layer, passed the decisions to the MLP, and then wrapped the output or ran postprocess. For sparse layers at TP > 1 they also forced the all-reduce to run in the layer, to avoid a runaway without EOS once the sum was deferred. That came from the last layer's deferred sum reaching the final norm unreduced: the layer was not marked as the last one, which #40868 fixed, and the layer-stack exit now completes any sum the last layer leaves. Use ffn_exit instead, like the other layer-communicator models, and pass its decisions to the MLP. Sparse layers now leave the sum to the next layer's input as the dense ones do, wherever the next layer runs the same all-reduce (fused or not, and under attention DP with the scatter back to this rank's tokens).
ch-wan
added a commit
that referenced
this pull request
Sep 25, 2026
MiniMax-M3's decoder layers decided by hand whether to leave their FFN all-reduce to the next layer, passed the decisions to the MLP, and then wrapped the output or ran postprocess. For sparse layers at TP > 1 they also forced the all-reduce to run in the layer, to avoid a runaway without EOS once the sum was deferred. That came from the last layer's deferred sum reaching the final norm unreduced: the layer was not marked as the last one, which #40868 fixed, and the layer-stack exit now completes any sum the last layer leaves. Use ffn_exit instead, like the other layer-communicator models, and pass its decisions to the MLP. Sparse layers now leave the sum to the next layer's input as the dense ones do, wherever the next layer runs the same all-reduce (fused or not, and under attention DP with the scatter back to this rank's tokens).
kevin-mii
pushed a commit
to zcnrex/sglang
that referenced
this pull request
Sep 25, 2026
main moved MiniMax-M3 onto LayerCommunicator.ffn_exit (sgl-project#41198) and takes a layer's last-layer fact from its scatter-mode plan (sgl-project#41199). Resolution in minimax_m3.py: - forward: take main's ffn_exit block. It drops the ROCm-only gate this branch kept on the sparse-MoE all-reduce deferral: sgl-project#41198 removes the forced in-layer all-reduce on every platform, since sgl-project#40868 fixed the no-EOS runaway it guarded. - LayerCommunicator: drop is_last_layer, keep enable_fused_ar_quant_per_token. The per-token fused AR + RMSNorm + quant branch in _reduce_output_and_update_and_read_residual merged cleanly: prepare_attn hands it the UnreducedOutput's partial tensor, as for the per-group path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
This PR is part of a stack (oldest at bottom):
Motivation
With FlashInfer all-reduce fusion enabled,
LayerCommunicatorleaves a layer's FFN all-reduce to be fused into the next layer's residual add + RMSNorm, unless the layer is marked as the model's last one (is_last_layer). Five decoder layers were not marked, so their last layer handed its reduction to a layer that does not exist, and the final norm ran on TP-partial sums.Qwen3-Next is on the list of architectures that auto-enable this fusion (SM90 / SM100, TP > 1, no DP attention), so its default configuration is affected. Outputs stay fluent, which hides the problem; the error only shows up numerically (see Accuracy Tests).
Modifications
qwen3_next.py: both decoder layer types passis_last_layer. The MTP draft model builds a single layer withnum_hidden_layers = 1, so it is covered by the same expression.minimax_m3.py: passesis_last_layer.bailing_moe_linear.py: passesis_last_layer=(is_nextn or layer_id == num_hidden_layers - 1), which also covers the hybrid NextN draft layer (built withlayer_id=0).bailing_moe.py/bailing_moe_nextn.pyandstep3p5.py/step3p5_mtp.py: the draft layers are built withlayer_id0 andnum_hidden_layersrespectively, so the existinglayer_id == num_hidden_layers - 1check marked them as not last. Both decoder layers now takeis_nextn, as the DeepSeek, GLM and Dots3 layers already do, and their NextN / MTP models pass it.test/registered/unit/models/test_last_layer_communicator.py: builds each affected decoder layer class through its real__init__(submodules stubbed) and checks theis_last_layerhanded toLayerCommunicator, for every layer id and for the draft layer. On current main, exactly the 9 affected cases fail (last layer of Qwen3-Next ×2, Bailing-MoE-linear, MiniMax-M3; draft layer of Qwen3-Next ×2, Bailing-MoE-linear, Bailing-MoE, Step-3.5); all 29 pass with this change.is_last_layeralso keeps the last layer from reduce-scattering in input-scattered mode, so that path is corrected for these models as well.Accuracy Tests
Qwen3-Next-80B-A3B-Instruct-FP8, TP2 on H200, default fusion (auto-enabled). Four greedy prompts, 32 new tokens, top-5 logprobs, requests submitted one at a time. Reference: the same model at TP1.
SGLANG_ENABLE_JIT_DEEPGEMM=0for every arm, because DeepGEMM's FP8 GEMM hits an unrelated CUDA-graph-capture assert in this environment on both main and this branch.--enforce-disable-flashinfer-allreduce-fusion)Step 0 depends on prefill only. With this change, fusion-on accuracy matches fusion-off. A per-rank decision log shows the last layer now decides not to fuse, which it never did on main.
The other four models are not on the fusion auto-enable list, so their default outputs are unchanged; the fix matters only when fusion is enabled explicitly.
Speed Tests and Profiling
No kernel change. The last layer now completes the all-reduce it used to drop.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): 🚫 Run #35923940045
Latest PR Test (Extra): 🚫 Run #35923939765
Latest PR Test (AMD ROCm 10): ❌ Run #35923940048