Repository navigation
[Refactor] Leave decoder stacks through final_norm(skip_empty=True) - #41751
Merged
Merged
Conversation
This was referenced Sep 29, 2026
ch-wan
force-pushed
the
cheng/refactor/layer-boundary-naming
branch
from
September 29, 2026 20:00
876200b to
3bf8a5f
Compare
ch-wan
requested review from
1am9trash,
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
JustinTong0323,
YAMY1234,
Ying1123,
fzyzcjy,
hnyls2002,
hubertlu-tw,
iforgetmyname,
ispobock,
kkHuang-amd,
merrymercy,
ping1jing2,
rainj-me,
sogalin,
whybeyoung,
wisclmy0611 and
zijiexia
as code owners
September 29, 2026 20:00
ch-wan
force-pushed
the
cheng/refactor/final-norm-skip-empty
branch
2 times, most recently
from
September 29, 2026 20:29
d8faaaf to
7916f5b
Compare
ch-wan
force-pushed
the
cheng/refactor/layer-boundary-naming
branch
2 times, most recently
from
September 29, 2026 23:47
5ff6682 to
cb4fe23
Compare
ch-wan
force-pushed
the
cheng/refactor/final-norm-skip-empty
branch
from
September 29, 2026 23:47
7916f5b to
c1e1041
Compare
ch-wan
force-pushed
the
cheng/refactor/layer-boundary-naming
branch
from
September 29, 2026 23:56
cb4fe23 to
a6de83d
Compare
ch-wan
force-pushed
the
cheng/refactor/final-norm-skip-empty
branch
from
September 29, 2026 23:56
c1e1041 to
8d3cb4e
Compare
This was referenced Sep 29, 2026
ch-wan
force-pushed
the
cheng/refactor/layer-boundary-naming
branch
from
September 30, 2026 00:33
a6de83d to
661ceee
Compare
ch-wan
force-pushed
the
cheng/refactor/final-norm-skip-empty
branch
2 times, most recently
from
September 30, 2026 01:01
40f0308 to
ba89c53
Compare
ch-wan
force-pushed
the
cheng/refactor/layer-boundary-naming
branch
from
September 30, 2026 01:01
661ceee to
9a817ba
Compare
Base automatically changed from
cheng/refactor/layer-boundary-naming
to
main
September 30, 2026 04:05
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Twelve decoder stacks completed the last output with complete_output() and then called final_norm() only for a non-empty batch. final_norm() already completes owed work before the norm, and skip_empty=True skips only the norm kernel on a zero-row output, so the pair is the same computation. The old form also never released the batch's residual stream on an empty batch. Four split-prefill paths called complete_output() right before an unconditional final_norm(); drop the redundant call.
ch-wan
force-pushed
the
cheng/refactor/final-norm-skip-empty
branch
from
September 30, 2026 04:08
ba89c53 to
e0344fa
Compare
This was referenced Sep 30, 2026
This branch was successfully deployed
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
Twelve decoder stacks finished the last layer's output with
residual_batch.complete_output()and then calledfinal_norm()only for a non-empty batch.final_norm()already completes owed work before the norm, andskip_empty=Trueskips only the norm kernel on a zero-row output, so the pair did the same work as one call. On an empty batch the old form also left the batch's residual stream in place instead of releasing it. Four split-prefill paths calledcomplete_output()right before an unconditionalfinal_norm().Modifications
complete_output()followed by a non-empty-guardedfinal_norm()becomesfinal_norm(..., skip_empty=True)(GigaChat3.5, Intern-S2-Mobius, Laguna, MiniMax-M2, MiniMax-M3, Qwen2-MoE, Qwen3, Qwen3-VL, Qwen3-VL-MoE, Sarvam, Step3-VL, XLLM). Capture callbacks andpost_residual_additionare passed as before and, as before, not applied to an empty batch.complete_output()before an unconditionalfinal_norm()is removed (Qwen2-MoE, Qwen3-MoE, Sarvam ×2).forward_mode.is_idle()are unchanged: an idle DP batch can carry padded rows, so that guard is not equivalent. Stacks that capture the completed output before the norm are also unchanged.Accuracy Tests
B200,
--tp-size 2 --dp-size 2 --enable-dp-attention:one_batch --correctness-test(prefill logits and three generations) is identical to the parent commit for Qwen3-0.6B, Qwen1.5-MoE-A2.7B and Qwen3-VL-2B-Instruct.one_batchgives every DP rank the same prompts, so no rank is empty there.--disable-radix-cache --random-seed 42) received four single greedy requests one at a time, each served by one DP rank while the other stayed idle. Text, input and output logprobs and the top-5 logprobs are identical to the parent commit for Qwen1.5-MoE-A2.7B and Qwen3-VL-2B-Instruct, and a repeat run of the parent is identical too.H200, MiniMax-M3 cut to five layers (three dense, two MoE),
sglang.Enginewith--tp-size 2 --dp-size 2 --enable-dp-attentionand single requests alternating between the DP ranks: the output and the logits of every step are bitwise identical to the parent commit on both ranks. On the idle rank's zero-row forwards this PR's stack callsfinal_norm(skip_empty=True), so the empty path is exercised.97 affected unit test files (2,081 tests) pass.
Speed Tests and Profiling
Not applicable: the same kernels and collectives run.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⏳ Run #36667496735
Latest PR Test (Extra): ⏳ Run #36667496474
Latest PR Test (AMD ROCm 10): ⏳ Run #36667496688