[MCore] Add SiTU-GLU through Transformer Engine - #6674
Open
harryzhou2000 wants to merge 1 commit into
Open
Conversation
This was referenced Aug 19, 2026
harryzhou2000
force-pushed
the
hhanyu/situ-glu-te-main
branch
2 times, most recently
from
August 24, 2026 09:07
6c08179 to
f4d0954
Compare
harryzhou2000
marked this pull request as ready for review
August 24, 2026 09:22
harryzhou2000
force-pushed
the
hhanyu/situ-glu-te-main
branch
2 times, most recently
from
August 25, 2026 04:57
cb5c1d9 to
89b265c
Compare
6 tasks
Member
Author
|
Mirrored the SiTU-GLU review fixes from the paired dev PR #6673 in |
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
harryzhou2000
force-pushed
the
hhanyu/situ-glu-te-main
branch
from
August 26, 2026 02:54
89b265c to
c7a03fa
Compare
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 Kimi K3 SiTU-GLU as a global FFN activation on
main.Paired dev-target PR: #6673
Activation
For gate projection
G, up projectionU, and K3 defaultsbeta1=4,beta2=25:Reference: Kimi K3 technical report, Figure 4 and Equation 12.
Design
--situ-glu, with--moe-use-situ-gluas an alias, and apply it consistently to dense, routed-expert, and shared-expert FFNs.situ_glu_beta1=4andsitu_glu_beta2=25toTransformerConfig, with validation that SiTU-GLU is gated, unclamped, uses zero GLU linear offset, and has finite positive beta values.situluas the correct PyTorch pointwise reference and configuration marker. It serves non-TE/custom module paths until PyTorch provides a dedicatedtorch.nn.functional.situlu-style operation; unaryF.siluis not equivalent.transformer_engine.pytorch.ops.SiTUGLUfor ordinary dense, sequential-expert, and ordinary shared-expert paths.transformer_engine.pytorch.ops.ScaledSiTUGLUfor fused grouped dense, routed-expert, and shared-expert paths.The required TE interface is available in NVIDIA/TransformerEngine#3402.
With that TE interface, an older cuDNN frontend without SiTU parameters uses TE's unfused
GroupedLinear -> ScaledSiTUGLU -> GroupedLinearoperation sequence. A SiTU-capable cuDNN frontend enables fused grouped GEMM + SiTU-GLU without an MCore-side backend check.Test results
Validated on NVIDIA B300 with NVIDIA/TransformerEngine#3402 and cuDNN Frontend develop through NVIDIA/cudnn-frontend#670, using CuTe DSL 4.6.2:
ScaledSiTUGLU: passed;ScaledSiTUGLU, with the fused cuDNN/CuTe grouped-MLP operation asserted: passed;ScaledSiTUGLU, with the fused Hadamard forward operation asserted: passed;git diff --check, Python compilation, and Ruff on all changed source and test files: passed;--use-checkpoint-argsrestoration passed two parametrized SwiGLU/SiTU-GLU cases, including the SiTU selector and non-default beta values.Fused-shared NVFP4 currently reaches an existing TE FC1 weight-scale reshape failure that reproduces with an equivalent SwiGLU control, so this PR does not claim that combination. MXFP8 dSiTU validation used the cuDNN frontend correction included in NVIDIA/cudnn-frontend#670; the published cuDNN frontend 1.27.0 package tested here does not yet contain that correction.
Scope and dependencies
This PR depends on NVIDIA/TransformerEngine#3402 for TE-backed SiTU-GLU functionality. The cuDNN frontend support is optional for correctness and required only for fused block-scaled grouped execution. A functional test is deferred until that TE interface is available in Megatron-LM CI; the focused MCore unit and GPU suites cover the current integration boundary.
This PR is independent of Quantile Balancing and #6638.
Issue tracking
For PRs from open-source community contributors:
Linked issue: TODO — link a Megatron-LM feature-request issue before marking this draft ready for review.
Contribution process
Pre-checks
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.