Repository navigation
[SM100] Mega MoE on CC 10.7: K=64 packed-FP4 MMA and SIMT dispatch pull - #126
Merged
Merged
Conversation
On CC 10.7, `kind::mxf8f6f4` has a K=64 shape that reads E2M1 operands packed. FP8 x FP4 Mega MoE now uses it: - Routed FP4 weights stay packed in shared memory (64B swizzle). The host builds packed TMA maps with `fp4_unpacked_smem=false`. This halves each weight stage and the number of UMMAs. - Each 128-wide K block issues two K=64 UMMAs, each taking its two per-32 scale factors by id. - The FP8 shared expert splits each K block into two 64-wide halves, with 64B-swizzled activation and weight maps. - The stage heuristic counts packed weight stages. The dispatch pull can also run on SIMT lanes: each lane loads its 16-byte slices of the token, its scale factors and its top-k weight from the peer, then stores them locally. A token then costs one remote round trip instead of chunked TMA copies through the shared-memory send buffers. With the SIMT pull: - Dispatch warps keep 96 registers, since each lane holds its whole token slice. The epilogue gets 184 at <= 64 experts per rank. - Expert counts are pushed with `red.sys.add` instead of `atom.sys.add`. - The shared-memory budget stays at the normal 232448 bytes. Oversized mode (sgl-project#120) shrinks L1, which the pull's in-flight remote loads need; with it, the SIMT pull is slower than the TMA pull. Hardening: - `red_add_rel` (u32) gets a "memory" clobber, so the elected lane's weight and metadata stores cannot be sunk past the release. - `fence.proxy.async.global` after the ring-slot empty wait, before SIMT stores overwrite a slot that TMA read in the previous wave. - The K=64 MMA issue is an `if constexpr`/`else`, so no instantiation has an unreachable loop. Both features are template switches set per launch: - K=64 is on by default for CC 10.7 FP8 x FP4 with packed FP4 weights, BLOCK_K 128 and per-32 scale factors. `DG_MEGA_MOE_SM107_K64=0` disables it. - The SIMT pull follows K=64. `DG_MEGA_MOE_SIMT_PULL=0/1` forces it. - With both off, the generated kernel is unchanged, oversized shared memory included. SM100, SM103 and the other MMA kinds are unaffected. Performance, on Rubin at EP4 with hidden 5120 and intermediate 2304: - Shapes: 48, 24 or 16 experts per rank; top-6, top-6 or top-3; one shared expert; 330-960 tokens per rank; localization on. - 8-16% faster per call than before (6-15% with localization off). - Output is bitwise equal to vLLM's SM107 DeepGEMM build. - K=64 changes the MMA accumulation order, so the output differs from the K=32 path by about 3e-5 relative L2. Tested on 4 Rubin GPUs, against the K=32 path on identical inputs: - Balanced, masked, hot-expert and empty-rank routing; 1-1920 tokens. - BLOCK_M 16-240, including ring wrap. - 96 experts per rank with 2 shared experts. - Per-32-block scale-factor stress. - Localization on and off, CUDA-graph replay and determinism. - Expert-receive stats are bitwise equal to the K=32 path; the SIMT-only output is bitwise equal too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zcnrex
pushed a commit
that referenced
this pull request
Oct 29, 2026
…ll (#126) On CC 10.7, `kind::mxf8f6f4` has a K=64 shape that reads E2M1 operands packed. FP8 x FP4 Mega MoE now uses it: - Routed FP4 weights stay packed in shared memory (64B swizzle). The host builds packed TMA maps with `fp4_unpacked_smem=false`. This halves each weight stage and the number of UMMAs. - Each 128-wide K block issues two K=64 UMMAs, each taking its two per-32 scale factors by id. - The FP8 shared expert splits each K block into two 64-wide halves, with 64B-swizzled activation and weight maps. - The stage heuristic counts packed weight stages. The dispatch pull can also run on SIMT lanes: each lane loads its 16-byte slices of the token, its scale factors and its top-k weight from the peer, then stores them locally. A token then costs one remote round trip instead of chunked TMA copies through the shared-memory send buffers. With the SIMT pull: - Dispatch warps keep 96 registers, since each lane holds its whole token slice. The epilogue gets 184 at <= 64 experts per rank. - Expert counts are pushed with `red.sys.add` instead of `atom.sys.add`. - The shared-memory budget stays at the normal 232448 bytes. Oversized mode (#120) shrinks L1, which the pull's in-flight remote loads need; with it, the SIMT pull is slower than the TMA pull. Hardening: - `red_add_rel` (u32) gets a "memory" clobber, so the elected lane's weight and metadata stores cannot be sunk past the release. - `fence.proxy.async.global` after the ring-slot empty wait, before SIMT stores overwrite a slot that TMA read in the previous wave. - The K=64 MMA issue is an `if constexpr`/`else`, so no instantiation has an unreachable loop. Both features are template switches set per launch: - K=64 is on by default for CC 10.7 FP8 x FP4 with packed FP4 weights, BLOCK_K 128 and per-32 scale factors. `DG_MEGA_MOE_SM107_K64=0` disables it. - The SIMT pull follows K=64. `DG_MEGA_MOE_SIMT_PULL=0/1` forces it. - With both off, the generated kernel is unchanged, oversized shared memory included. SM100, SM103 and the other MMA kinds are unaffected. Performance, on Rubin at EP4 with hidden 5120 and intermediate 2304: - Shapes: 48, 24 or 16 experts per rank; top-6, top-6 or top-3; one shared expert; 330-960 tokens per rank; localization on. - 8-16% faster per call than before (6-15% with localization off). - Output is bitwise equal to vLLM's SM107 DeepGEMM build. - K=64 changes the MMA accumulation order, so the output differs from the K=32 path by about 3e-5 relative L2. Tested on 4 Rubin GPUs, against the K=32 path on identical inputs: - Balanced, masked, hot-expert and empty-rank routing; 1-1920 tokens. - BLOCK_M 16-240, including ring wrap. - 96 experts per rank with 2 shared experts. - Per-32-block scale-factor stress. - Localization on and off, CUDA-graph replay and determinism. - Expert-receive stats are bitwise equal to the K=32 path; the SIMT-only output is bitwise equal too. Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 5430b49)
zcnrex
added a commit
that referenced
this pull request
Nov 4, 2026
* [SM100] Mega MoE: SIMT dispatch pull for FP4 activations Let NVFP4 and MXFP4 take the SIMT dispatch pull (#126), which was gated to FP8 x FP4. It is on by default for FP4 activations on CC 10.7 and opt-in elsewhere through DG_MEGA_MOE_SIMT_PULL=1. The DG_PRINT_CONFIGS key now includes the MMA kind and the resolved pull, so a forced pull or a second MMA kind at the same shape still prints. test_mega_moe_simt_pull.py checks SIMT == TMA pull bitwise (y and receive counts) for NVFP4, NVFP4 with x-scales, and MXFP4, including a ring-wrapping load, and that the env var resolves to the requested pull. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fold the SIMT pull check into test_mega_moe_global_tokens Each load pattern now also forces DG_MEGA_MOE_SIMT_PULL=0/1 and checks the resolved pull and bitwise-equal y and receive counts. --mma-type mxf4xmxf4 and --x-scales cover the other FP4 pulls; run_tests.sh runs MXFP4 at a ring-wrapping shape and NVFP4 with x-scales. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Simplify the SIMT pull gate; add SM107ArchSpec::is_current Same decisions as before: reuse is_mma_with_sf and the token byte count, and name the default condition (CC 10.7 with packed FP4 weight stages). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
On CC 10.7,
kind::mxf8f6f4has a K=64 shape that reads E2M1 operands packed. FP8 x FP4 Mega MoE now uses it:fp4_unpacked_smem=false. This halves each weight stage and the number of UMMAs.The dispatch pull can also run on SIMT lanes: each lane loads its 16-byte slices of the token, its scale factors and its top-k weight from the peer, then stores them locally. A token then costs one remote round trip instead of chunked TMA copies through the shared-memory send buffers. With the SIMT pull:
red.sys.addinstead ofatom.sys.add.Hardening:
red_add_rel(u32) gets a "memory" clobber, so the elected lane's weight and metadata stores cannot be sunk past the release.fence.proxy.async.globalafter the ring-slot empty wait, before SIMT stores overwrite a slot that TMA read in the previous wave.if constexpr/else, so no instantiation has an unreachable loop.Both features are template switches set per launch:
DG_MEGA_MOE_SM107_K64=0disables it.DG_MEGA_MOE_SIMT_PULL=0/1forces it.Performance, on Rubin at EP4 with hidden 5120 and intermediate 2304:
Tested on 4 Rubin GPUs, against the K=32 path on identical inputs:
Credits to @zihaok and @nvzhihanj