fix(sm90): sanitize pruned FP8 MegaMoE weight blocks - #68
Open
ercaoeatting wants to merge 1 commit into
Open
Conversation
ercaoeatting
marked this pull request as ready for review
August 1, 2026 09:39
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
SM90 MegaMoE can produce incorrect output when a pruned 128x128 FP8 weight block retains arbitrary FP8 bytes while its weight scale is tiny but nonzero.
This change sanitizes those blocks during
transform_weights_for_mega_moe_sm90:abs(scale) < 1e-12as pruned.The same handling is applied to both W13 and W2 weights.
Root cause
The SM90 MegaMoE split-MN path rescales partial results with reciprocals of the weight scales. A tiny nonzero scale can therefore amplify residual FP8 bytes in a block into a large incorrect result. A truly pruned block must be represented as zero data with a safe finite scale.
Validation
On an H20D (SM90) in the container:
test_mega_moe_sm90_weight_transform.py --num-processes 1— PASStest_mega_moe_pre_dispatch_sm90.py --num-processes 1— 8 cases PASStokens=1,experts=1,topk=1) — kernel launched successfully (52.5 us, non-fatal symmetric-memory multicast warning)max_abs=1870659584.0with the unsanitized tiny-scale block andmax_abs=0.0after sanitization.The SGLang-side workaround can be removed once this fix is available in a released DeepGEMM package.