Repository navigation
Add RMSNorm latent up-projection - #6803
Open
harryzhou2000 wants to merge 1 commit into
Open
harryzhou2000 wants to merge 1 commit into
harryzhou2000 wants to merge 1 commit into
Conversation
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
harryzhou2000
force-pushed
the
hhanyu/k3-latent-rmsnorm-main
branch
from
August 26, 2026 02:54
d2bc54d to
90365f8
Compare
14 tasks
This branch has not been 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.
What does this PR do ?
Add an optional RMSNorm immediately before LatentMoE's duplicated latent up-projection. This matches the routed-expert aggregation in the Kimi K3 technical report, where the combined routed latent result is normalized before projecting back to model width.
Dev counterpart: #6804
Design
moe_latent_up_projection_rmsnorm, valid only whenmoe_latent_sizeis set.TERMSNormDuplicatedLinear, a thin MCore wrapper around TELayerNormLinearwithnormalization="RMSNorm"hard-coded.tp_size=1) because the latent up-projection is duplicated across TP ranks, while retaining the owning TP group for checkpoint metadata and MCore gradient-reduction/SP tags.Issue tracking
Linked issue: N/A
Contribution process
Pre-checks
Focused unit coverage includes BF16 numerical forward/backward checks, real TP2 with sequence parallelism, explicit checkpoint process-group metadata, Blackwell MXFP8 forward/backward with aligned dimensions, and real four-rank GTP execution with and without bias. No separate functional test was added because this is a module-local selection and wrapper change.
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.
Testing
Validated on NVIDIA B200 GPUs with PyTorch 2.12 nightly and Transformer Engine 2.20 development sources.
Checkpoint/rebase validation on the current tip also passed:
--use-checkpoint-argsrestores bothmoe_latent_sizeandmoe_latent_up_projection_rmsnorm.git diff --checkpass.The test suites exercise TP1 BF16, real TP2+SP BF16, MXFP8 forward/backward, and main-only GTP bias/no-bias behavior.
git diff --check, import sorting, and Python compilation also pass.