Repository navigation
[SM100] Mega MoE: use block_m 64 for decode-sized loads - #130
Merged
Merged
Conversation
Root cause: up to 24 expected tokens per expert the heuristic picks block_m 16 (<= 10) or 32 from the uniform-routing mean. Real decode routing concentrates on a few hot experts per rank, which those tiles split into several M blocks, and every extra block re-streams the expert's weights. Fix: pick 64 between 2 and 24 expected tokens; keep 16 at <= 2, where 64 rows lose under any routing. Loads above 24 are unchanged. Same rule as sgl-project#121. Validation (GB300, CUDA 13.0, DSv4.1 shapes 384 experts / top-6 / hidden 5120 / intermediate 2304, EP4, fused shared expert): - sgl_deep_gemm/tests/test_mega_moe.py against the DeepEP baseline passes for fp8xfp4, fp8xfp8 and bf16xbf16 at 32/198/342 tokens per rank (20 iterations each); test_mega_moe_global_tokens.py passes. - fp8_fp4_mega_moe outputs are bitwise identical to the old tiles at 2-342 tokens per rank, uniform and one-hot-expert-per-rank (~6x) routing. - Kernel time with synthetic routing: -0.9% to +2.8% (largest loss at 3-4 expected tokens). The decode gains come from real routing skew: SGLang DSv4.1 decode step -2% to -10% without EPLB and -1% to -3% with dynamic EPLB in sgl-project/sglang#46593, which applied this mapping through DG_MEGA_MOE_TILES.
This was referenced Nov 7, 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.
Motivation
SM100 Mega MoE sizes
block_mfrom the mean tokens per expert plus one sigma, which assumes near-uniform routing. Decode routing is skewed: a few hot experts per rank take a large share of the rank's tokens. With 16- or 32-row tiles, a hot expert's tokens split into several M blocks, and each extra block streams that expert's weights again. Decode Mega MoE is bound by weight streaming, so the extra blocks cost real time.sgl-project/sglang#46593 raised these tiles from the SGLang side through
DG_MEGA_MOE_TILES(16/32 -> 64 in decode CUDA graphs) for DeepSeek-V4.1-Flash on GB300, with DSpark speculative decoding:Change
Between 2 and 24 expected tokens per expert,
get_block_config_for_mega_moepicksblock_m = 64instead of 16 (up to 10) or 32 (up to 24). At 2 or fewer expected tokens it keeps 16, where 64 rows lose under any routing. Loads above 24 expected tokens are unchanged. This is the rule from #121.get_block_m_for_mega_moegoes through the same heuristic, so callers that lay out shared-expert scale factors from it stay consistent without a change.Validation
GB300 (
sm_103a), CUDA 13.0. DeepSeek-V4.1-Flash shapes: 384 experts, top-6, hidden 5120, intermediate 2304, EP4, one fused shared expert.sgl_deep_gemm/tests/test_mega_moe.py, checked against the DeepEP baseline, passes forfp8xfp4,fp8xfp8andbf16xbf16at 32, 198 and 342 tokens per rank, 20 iterations each. 32 tokens stays at 16; 198 and 342 move from 32 to 64.sgl_deep_gemm/tests/test_mega_moe_global_tokens.pypasses.fp8_fp4_mega_moeoutputs are bitwise identical to the old tiles at 2-342 tokens per rank. Routing was uniform, and a synthetic skew with one hot expert per rank at about 6x the local mean (the hottest-expert skew measured after dynamic EPLB settles in sglang#46593).Kernel time with synthetic routing, slowest rank, old -> new:
block_mWith one moderately hot expert per rank, the kernel is within -1% to +3% of the old tiles; it loses most at 3-4 expected tokens. The end-to-end gains below, and the faster kernel times #121 reported when replaying captured serving routing, come from the heavier skew of real routing.
End to end
DeepSeek-V4.1-Flash on GB300, SGLang nightly 2026-10-30, disaggregated serving with DSpark speculative decoding (real acceptance), InferenceX AgentX trace, 1200 s per run. Stock is
sgl_deep_gemm0.2.3.post2; patched is the same release with this commit, installed as a wheel. Both arms ran at the same time on the same trace. NoDG_MEGA_MOE_TILESand no SGLang change. Decode step is per DP rank, binned by running requests per rank.DEP4 decode (one node, 96 local experts per rank), 6x DEP2 prefill, no EPLB:
c600 is past this topology's capacity on both arms (TPOT about 40 ms with 16-18 ms steps), so read it as a relative comparison only.
DEP16 decode (four nodes) with dynamic EPLB (16 redundant experts, rebalance every 15000 iterations), 5x DEP2 prefill, c1400:
After EPLB settles (480-1200 s, 6-7 rebalances), decode step p50 is within -0.4% to +1.0% in every bin from 4 to 27 requests per rank, and within 0.4% in the busy 8-23 bins. Before the first rebalance, bins 0-15 are 1.3-2.1% faster. So the gain comes from expert imbalance: large without EPLB, small once dynamic EPLB has evened out the ranks, and no regression in either case.
GSM8K (sgl-eval 0.1.3, 1319 questions) with the patched build, DEP16 with EPLB: 96.89%, vs 96.82% on stock.
Related
DG_MEGA_MOE_TILES; with this PR, SGLang needs no remap.sm_107aandsm_103awith replayed serving routing. This PR carries it todev.