[Bugfix] Support parameterized SwiGLU in SM90 FP8 MegaMoE - #87
Open
shiyang814-cpu wants to merge 1 commit into
Open
[Bugfix] Support parameterized SwiGLU in SM90 FP8 MegaMoE#87shiyang814-cpu wants to merge 1 commit into
shiyang814-cpu wants to merge 1 commit into
Conversation
Author
|
hi @Fridge003 , could you please review this SM90 FP8 MegaMoE correctness fix when you have a chance? Thanks! |
5 tasks
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.
Summary
This PR adds parameterized SwiGLU support to the SM90 FP8 MegaMoE kernel.
The existing implementation assumes standard SwiGLU:
Some MoE models use parameterized OAI-SwiGLU instead:
For example, MiniMax-M3 uses:
Without this change, the SM90 MegaMoE kernel silently applies the wrong activation semantics and produces corrupted model outputs.
Changes
activation_alphaandactivation_up_biasto the Python FP8 MegaMoE API.swigluoaiin the SM90 MegaMoE buffer and execution APIs.activation_alpha=1.0activation_up_bias=0.0Root Cause
The SM90 FP8 MegaMoE epilogues hardcoded standard SiLU:
Although an activation clamp was already configurable, the sigmoid alpha and up-projection bias were not represented by the public API or JIT template.
As a result, enabling MegaMoE for models using OAI-SwiGLU changed the model's mathematical semantics. The issue affected both epilogue implementations, including the optimized swapAB path.
Validation
The test was first run against an unmodified build from the latest
devbranch and failed with:After the fix, the SM90 MegaMoE output was compared against the PyTorch FP32/BF16 reference implementation on 8 Hopper GPUs.
Results:
The non-swapAB path was forced with:
The TVM FFI extension and the generated SM90 CUDA JIT kernels were rebuilt from the patched source before running the tests.
Compatibility
Existing callers are unaffected because the new parameters default to standard SwiGLU behavior:
No behavior changes are expected for existing DeepSeek MegaMoE workloads.