Repository navigation
[SM100] Mega MoE: fix FP4 full-pool TMA pull, cache ready peers in combine, and vectorize L1 FP4 epilogue - #160
Merged
zcnrex merged 1 commit intoNov 23, 2026
Conversation
Collaborator
|
Looks very solid overall — the
|
…mbine, and vectorize L1 FP4 epilogue
Denji-kk
force-pushed
the
perf/sm100-mega-moe-fp4-dispatch-combine-epilogue
branch
from
November 23, 2026 08:44
b5ba377 to
357f34b
Compare
Author
|
Thanks for the review! Rebased onto latest |
zcnrex
approved these changes
Nov 23, 2026
trevor-m
added a commit
to trevor-m/DeepGEMM
that referenced
this pull request
Nov 23, 2026
…ebased dev Re-measured after rebasing onto dev a96d065 (sgl-project#160, sgl-project#162), same Vera Rubin setup: - L1-first with decode tiles (BLOCK_M <= 64) now allows at most 4 extra L1 waves after the warmup (was 8). 4 extra waves still gain 0.7-1.4%; 5 were 0-0.6% slower than dev and 7 up to 1.2% slower, worst without a shared expert (sgl-project#162's swizzled order). - Shared L2 keeps its early slot for every BLOCK_M < 192, on every part (was: decode tiles, or 128-row tiles below 100 CTA pairs). With 128-row tiles the tail no longer gains on Vera Rubin either: alone it was 0-0.8% slower, and with L1-first the early slot is 1.3% faster. This drops the CTA-pair term from the gate. Outputs stay bitwise identical to dev. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zcnrex
pushed a commit
that referenced
this pull request
Nov 23, 2026
…ed L2 at the tail for large tiles (#157) * [SM100] Mega MoE: all L1 tasks first for decode-sized loads, shared L2 at the tail above BLOCK_M 64 - Routed tasks: issue every L1 task before the first L2 task when the L1 work is decode-sized (`BLOCK_M <= 64`, or at most one L1 wave left after the warmup waves) and every pool block has its own ring slot. The last M blocks start their L1 earlier, and their L1 -> L2 chain sets the tail. Larger loads keep the interleaved order. - Fused shared expert: the shared L2 tasks keep the early slot (before the routed tasks) only with decode tiles (`BLOCK_M <= 64`); with larger tiles they go after the routed tasks. Only the task order changes, so outputs are bitwise identical. Measured on Vera Rubin (CC 10.7), fp8xfp4 with a fused FP8 shared expert, DeepSeek-V4.1- Flash shapes, EP4: -2.3% to -7.2% per call at 32-rank decode loads and -2.1% to -6.9% at 16-rank loads. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [SM100] Mega MoE: bound L1-first by extra L1 waves, keep shared L2 early for 128-row tiles below 100 CTA pairs Review follow-up: - L1-first now needs at most 8 extra L1 waves after the warmup with decode tiles (BLOCK_M <= 64), and at most 1 with larger tiles. Unbounded, it was slightly slower with many local experts and few tokens each (104 experts per rank at EP4: up to +0.9%), while 13 experts per rank still gain through 7 extra waves. - With 128-row tiles the shared L2 keeps its early slot below 100 CTA pairs (B300 / GB300), where the tail was ~1% slower. BLOCK_M >= 192, and 128 on Vera Rubin's 106 pairs, keep the tail. Outputs stay bitwise identical to dev. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [SM100] Mega MoE: retune the L1-first cap and shared L2 gate on the rebased dev Re-measured after rebasing onto dev a96d065 (#160, #162), same Vera Rubin setup: - L1-first with decode tiles (BLOCK_M <= 64) now allows at most 4 extra L1 waves after the warmup (was 8). 4 extra waves still gain 0.7-1.4%; 5 were 0-0.6% slower than dev and 7 up to 1.2% slower, worst without a shared expert (#162's swizzled order). - Shared L2 keeps its early slot for every BLOCK_M < 192, on every part (was: decode tiles, or 128-row tiles below 100 CTA pairs). With 128-row tiles the tail no longer gains on Vera Rubin either: alone it was 0-0.8% slower, and with L1-first the early slot is 1.3% faster. This drops the CTA-pair term from the gate. Outputs stay bitwise identical to dev. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Dec 3, 2026
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.
This PR bundles four targeted, layout-preserving fixes and optimizations for the SM100 FP8/FP4 MegaMoE kernel (
sm100_fp8_fp4_mega_moe.cuhandcommon/math.cuh):kUseFullPoolFP8FP4Pathfor packed FP4 activations (NVFP4/MXFP4):sm100_fp8_fp4_mega_moe.cuh,kUseFullPoolFP8FP4PathrequiredBLOCK_K == BLOCK_N and kNumHiddenTokenBytes == kNumBytesPerPull. BecauseBLOCK_K = 256andBLOCK_N = 128for all 4-bit MMA kinds (MmaKind::NVFP4andMmaKind::MXFP4),BLOCK_K == BLOCK_Nwas unconditionallyfalsefor every FP4-activation kernel, forcing multi-descriptor TMA pulls even when an entire token fits in one pull (hidden <= 16384).BLOCK_K == BLOCK_Ncheck sokUseFullPoolFP8FP4Path = (kNumHiddenTokenBytes == kNumBytesPerPull)activates for single-pull FP4 tokens, and use__stcgon stridedlocal_sf_ptrDispatch writes to avoid L1 write-allocate cache line thrashing.known_ready_ranks):uint64_t known_ready_ranksbitmask across the Combine token loop (__reduce_or_sync(0xffffffff, lane_bit)) avoids re-issuingld_acq_syspolling over NVLink once a peer rank has already been observed ready.nvfp4_sf_inv_lutSMEM table and vectorize the L1 FP4 epilogue:nvfp4_sf_inv_lutshared-memory lookup +__frcp_rnfallback with a branchless 1-step Newton-Raphson reciprocal (rcp.approx.ftz.f32+ 2fma.rn.f32refinements), which is 0-ULP bit-identical to1.0f / decode(code)across all 127 finite non-negative UE4M3 codes, freeing1,024 Bof shared memory per CTA and removing LUT bank conflicts.L1_OUT_BLOCK_N_BYTES == 32FP4 epilogue path with warp-shuffled bank-conflict-freeuint32_t(STS.32) writes, and coalesce the 4 warps' NVFP4 L1UE4M3scale bytes viaamax_reductionSMEM into a singleuint32_tglobal store per row instead of 4 strided byte stores.UTCCPwhenvalid_m <= 128:128-row SFAUTCCPtranspose (i == 1whenSF_BLOCK_M == 256) oni * kNumUTCCPAlignedElems < task_info.valid_mso partially filledBLOCK_M = 192 / 240tiles with<= 128valid tokens skip redundant TMEM scale copies.Outputs across all tested workloads are 100% bitwise identical (
max_abs_diff = 0.0,100.00%exact element match) todev.Tests
Passed the Blackwell MegaMoE test suite on 8x B300 (
test_mega_moe_pre_dispatch,test_mega_moe_nvfp4_trtllm,test_mega_moe_nvfp4_alphas,test_mega_moe_l1_fp4_accuracy,test_mega_moe_l1_sentinel,test_mega_moe_situ,test_mega_moe_global_tokensacross 8-rank NVFP4, 2-rank MXFP4 ring wrap, and 2-rankx_scales) and verified thesetup.pypybind build.Microbenchmark & NCU
8x B300 (
EP = 8) standalonenvfp4_mega_moemicrobenchmark (fast_math=True, use_x_scales=True, median of 60 iterations across slowest rank after 15 warmup calls;M= tokens per rank):H, I, E, top_k)M/rank, routing)BLOCK_Mdev(us)devH=7168, I=5120, E=384, K=4M=16, uniformH=7168, I=5120, E=384, K=4M=2048, uniformH=7168, I=5120, E=384, K=4M=2048, skewedH=7168, I=5120, E=384, K=4M=8192, skewedH=7168, I=2048, E=256, K=8M=8, uniformH=7168, I=2048, E=256, K=8M=2048, uniformH=7168, I=2048, E=256, K=8M=4096, skewedNsight Compute (
2026.3.0) 1-GPU (EP = 1,H=7168, I=5120, E_local=48, top_k=4) hardware counters confirming the SMEM and L1/L2 sector reductions:devM=4096, uniformlaunch__shared_mem_per_blockM=4096, uniforml1tex__t_sectors_pipe_lsu_mem_global_op_st.sumM=4096, uniforml1tex__data_bank_conflicts_pipe_lsu_mem_shared_op_st.sumM=2048, skewedl1tex__t_sectors_pipe_lsu_mem_global_op_st.sumM=2048, skewedl1tex__data_bank_conflicts_pipe_lsu_mem_shared_op_st.sum