[MCore] Add SiTU-GLU activation fallbacks - #6636
Closed
harryzhou2000 wants to merge 3 commits into
Closed
Conversation
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
6 tasks
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
6 tasks
Member
Author
|
Superseded by the smaller TE-only main-target PR: #6674. The previous implementation is preserved at branch |
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 SiTU-GLU as a global FFN activation on
main. MCore uses the public interface proposed by NVIDIA/TransformerEngine#3402 when the complete native interface is installed and otherwise falls back atomically to MCore-local CuTe DSL operations.Paired dev-target PR: #6635
Activation
The activation follows Kimi K3 Stable-LatentMoE:
K3 uses
beta1=4andbeta2=25. Forbeta1=4, the local implementation reusesa = tanh(G / 4)and evaluatessigmoid(G)exactly as0.5 + a / (1 + a^2), avoiding a separate exponential.Reference: Kimi K3 technical report, Figure 4 and Equation 12.
Implementation
--situ-glu, with--moe-use-situ-gluas a compatibility alias, and apply it to gated dense, routed-expert, and shared-expert FFNs.SiTUGLUandScaledSiTUGLUtogether from the public interface in [Common][PyTorch] Add SiTU-GLU activation TransformerEngine#3402:SwiGLUandScaledSwiGLUselection paths unchanged.BasicOperation; it is not aScaledSwiGLUsubclass and therefore cannot be mistaken for SwiGLU by TE's grouped-MLP matcher.Native block-scaled grouped SiTU-GLU fusion is supplied by NVIDIA/cudnn-frontend#645. MCore does not duplicate or patch those kernels.
Validation
Baseline B200 environment (TE
2.20.0.dev0, cuDNN frontend1.26.0, CuTe DSL4.5.2):GroupedMLP_CuTeGEMMGLU.Native-interface environment (NVIDIA/TransformerEngine#3402, NVIDIA/cudnn-frontend#645, CuTe DSL
4.6.2):GroupedMLP_CuTeGEMMGLU.vector.from_elementsBF16-to-FP32x2 verifier error inside the dependency implementation. No MCore or cuDNN frontend workaround is included here.The commits are SSH-signed and signed off.
git diff --checkand the repositorytools/autoformat.shpass; pylint rates the changed files 10/10 and Ruff reports no errors.Scope and dependencies
This PR owns the MCore configuration, selection logic, and local fallback. It does not change grouped-GEMM fusion policy or patch Transformer Engine/cuDNN frontend internals.
This PR does not depend on Quantile Balancing or #6638. The paired integration checkout was used only to verify that the independent features coexist.
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.