Repository navigation
refactor(sm10x): MegaMoE arch policy + SM107 FP4 K=128 mainloop - #165
Merged
Merged
Conversation
zcnrex
added a commit
that referenced
this pull request
Nov 24, 2026
- Add SM10xArch, MegaMoEMainloop, is_mega_moe_mainloop_valid (including num_stages >= 3 for SM103UltraK96), and uses_packed_fp4_weights in types.cuh; keep get_compiled_sm10x_arch() device-only. - Select the host SM10x arch from the JIT target (get_sm10x_arch()) and remove unused SM103ArchSpec. - Consolidate per-arch MegaMoE mainloop, store-tile override, SIMT/TMA dispatch pull, and SMEM budget into get_mega_moe_arch_policy(), and fall back to Default if the resulting pipeline has too few stages. - Add 5- or 6-int DG_MEGA_MOE_TILES support and include fp4_weights, gran_k, and mainloop in the DG_PRINT_CONFIGS dedup key. - Add constexpr make_mega_moe_mainloop_plan() and remove unreachable SM103 BM=240 compact K=96 ring. - Add SM107 FP4 (NVFP4/MXFP4) K=128 mainloop (2 MMAs per BLOCK_K=256 stage, no Default tail), SM100_MMA_MXF4NVF4_BLOCK32_2x1SM_SS, and 576-col Allocator2SmExclusive for BM=240. - Drop redundant RowShuffled/K64 asserts already implied by RowShuffled requiring NVFP4 (avoiding unnecessary conflict with #166).
zcnrex
force-pushed
the
chunan/sm103-decode-megamoe-1d1d-opt
branch
from
November 27, 2026 07:54
fd0f49c to
65167ac
Compare
This was referenced Nov 27, 2026
Collaborator
Author
Post-split verification (
|
zcnrex
added a commit
that referenced
this pull request
Nov 27, 2026
Use block_m=128 as the decode floor for NVFP4 on SM103 and SM107 (monotonic in the multi-block loop) and enable SIMT dispatch pull by default on SM103 NVFP4 decode (block_m <= 128). Split out from #165 so it can be gated on Muse replay-routing benchmarks independently of the arch-policy refactor and SM107 K=128.
aryatsc
added a commit
to aryatsc/DeepGEMM
that referenced
this pull request
Nov 28, 2026
Brings in sgl-project#170, sgl-project#165, sgl-project#169, sgl-project#178 and sgl-project#171. Conflicts: - csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp: the K=64 switch is now `uses_packed_fp4_weights(config.mainloop)` (sgl-project#165); the row-shuffled FP8 x FP4 layout asserts that mainloop instead of `config.use_sm107_k64`. The kernel template takes the mainloop in place of the two K=64 / K=96 flags, followed by this branch's four parameters. - deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh: sgl-project#165's mainloop plan and validity check replace the K=64 static assert; the base MMA loop is taken from dev (now under `run_base_loop`) with this branch's SFB word order for row-shuffled packed FP4 weights re-applied in it.
zcnrex
added a commit
that referenced
this pull request
Dec 1, 2026
…174) * perf(sm10x): NVFP4 MegaMoE decode block_m=128 + SM103 SIMT dispatch pull Use block_m=128 as the decode floor for NVFP4 on SM103 and SM107 (monotonic in the multi-block loop) and enable SIMT dispatch pull by default on SM103 NVFP4 decode (block_m <= 128). Split out from #165 so it can be gated on Muse replay-routing benchmarks independently of the arch-policy refactor and SM107 K=128. * Drop the NVFP4 decode block_m=128 floor; keep the SM103 SIMT pull A 4-round decode sweep (expected 1..64 tokens per expert, uniform / zipf / biased routing) found the BM128 floor 1-5% slower than BM64 on SM103 and SM107 for uniform and moderately skewed routing; it wins only under heavy skew at 16+ expected tokens per expert. The SM103 SIMT pull alone is 0.2-1.8% faster in every cell, including BM16. 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.
Summary
Architecture & MegaMoE mainloop refactor (
types.cuh,sm100.hpp,mega_moe.hpp,sm100_fp8_fp4_mega_moe.{hpp,cuh})SM10xArch { SM100, SM103, SM107 }, device-onlyget_compiled_sm10x_arch(),MegaMoEMainloop { Default, SM107PackedK64, SM103UltraK96, SM107K128 },is_mega_moe_mainloop_valid()(includingnum_stages >= 3forSM103UltraK96), anduses_packed_fp4_weights()indeep_gemm/include/deep_gemm/common/types.cuh.get_sm10x_arch(), i.e.103a/107a/100fmatching__CUDA_ARCH__) and remove unusedSM103ArchSpec.BLOCK_M = 192), SIMT/TMA dispatch pull, and SMEM budget intoget_mega_moe_arch_policy()(csrc/jit_kernels/heuristics/mega_moe.hpp). Afterget_pipeline_config_for_mega_moe()computesnum_stages, re-checkis_mega_moe_mainloop_valid(..., num_stages)and fall back toDefaultif the pipeline has too few stages (e.g.DG_MEGA_MOE_TILESoverrides on SM103).DG_MEGA_MOE_SM107_K64,DG_MEGA_MOE_SM103_K96,DG_MEGA_MOE_SIMT_PULL, 5- or 6-intDG_MEGA_MOE_TILES), addDG_MEGA_MOE_SM107_K128(default1), and includefp4_weights,gran_k, andmainloopin theDG_PRINT_CONFIGSdedup key.Default-loop tail requirement once inconstexpr make_mega_moe_mainloop_plan(). Remove the unreachable compact 32-col K=96 ring forBLOCK_M = 240.not use_k64 or not use_shuffled_weightshost/device asserts (still implied ondevbyRowShuffledrequiringNVFP4, avoiding unnecessary conflict with [SM100] Mega MoE: one-rank FP8xFP4 fast paths for die-local weights, with opt-in bitwise parity with trtllm-gen #166).SM107 FP4 (
NVFP4/MXFP4)K=128MegaMoE mainloop & 576-col exclusive TMEM (sm100_fp8_fp4_mega_moe.cuh,tcgen05.cuh)K=128instruction descriptor encoding ({k_size_upper_=bit3, k_size_lower_=bit31} = {1, 0}), issuing 2 MMAs perBLOCK_K=256stage (a_desc.lo = base + k_sub * 4,block16for NVFP4 with 2 SF chunks/MMA,block32viaSM100_MMA_MXF4NVF4_BLOCK32_2x1SM_SSfor MXFP4 with 1 SF chunk/MMA) with no cross-stage grouping and no remainder tail.Allocator2Sm(<= 512cols) forBM <= 192, andAllocator2SmExclusive(<= 576cols: 576 for NVFP4, 544 for MXFP4) atBM = 240, withsfa_chunk_stride = (umma_n > 128) ? 8 : 4.Verification & Relative Performance
SM107 (4× CC 10.7, 212 SMs, EP4, CUDA 13.4)
SM107K128vsDefault, deterministic mode):NVFP4(gate_up_interleaved):BM=16, 64, 128, 192 (umma_n>128), 240 (T=256 & T=2048, 576-col exclusive)→calc_diff = 0.00e+00,max_abs = 0.0000e+00(bit-exact)NVFP4(gate_up_block8):BM=128→calc_diff = 0.00e+00,max_abs = 0.0000e+00MXFP4(gate_up_block8):BM=64, 128, 192andBM=240 (T=2048, 544-col exclusive)→calc_diff = 0.00e+00,max_abs = 0.0000e+00FP8×FP4(SM107PackedK64vsDefaultregression):BM=64→calc_diff = 0.00e+00BM=192prefill (Muse shape, uniform routing):SM107K128beatsDefaultby 0.9% (T=2048, 266.6 vs 269.2 us), 0.9% (T=4096, 402.2 vs 405.8 us), and 1.3% (T=8192, 757.7 vs 768.6 us) against 0.0–0.2% A/A.BM=240prefill (T=2048, 544-col exclusive): 1.09x speedup (242.4 → 222.3 us).SM103 (4× B300 SXM6, 148 SMs, EP4, CUDA 13.0)
SM103UltraK96vsDefault, deterministic mode):NVFP4(gate_up_interleaved&gate_up_block8):BM=16, 128, 192→calc_diff = 0.000e+00,max_abs = 0.0000e+00(bit-exact);BM=240underDG_MEGA_MOE_TILESrunsDefault(bitwise match).nvfp4_trtllm,situ,l1_fp4_accuracy,l1_sentinel,nvfp4_alphas,global_tokens,pre_dispatch, andtest_mega_moe_sglon SM103) passed on the pre-split build; please re-run a quick SM103/SM107 build & smoke test after the latest review fixes (num_stagesvalidation +get_compiled_sm10x_archdevice-only).