Repository navigation
Conversation
DSR1 prefill past a 4096-token receive bound stayed on dispatch plus GEMM1, and the EP fused lookup missed the existing grouped rows. Drop the default cap and add the gfx1250 tiles measured on 4x gfx1250. Co-authored-by: Cursor <cursoragent@cursor.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Fused shared experts look up experts=65, so the expert-64 rows never matched. Point the EP rows at the tiles measured on that key.
The EP4 tpr 8192 step still used 128x256x256 with 2 buffers. On S1F, 256x256x256 with 2x2 waves is faster.
Keep the expert-65 ep_fused rows only where this branch is faster or the other PR has no row.
Summary
Remove the default MegaMoE stage-1 fusion receive cap, and retune the gfx1250 grouped-MoE rows for DeepSeek-R1 with fused shared experts. That path looks up
experts=65,topk=-1,ep_fused=1, so the earlier expert-64 rows never matched.On 4× gfx1250, DSR1 EP4 with one fused shared expert, the rows kept here are 13–21% faster than main with S1F off at tpr 128–1024. Overlapping buckets where #8002 is as fast or faster are left to that PR.
Motivation
AITER_MEGA_S1Fdefaults on, but a step whose receive bound was above 4096 took the whole S1F-off path (dispatch plus GEMM1). For this shapemax_recv = world_size * tokens_per_rank, so tpr 1536 (6144), 2048 (8192), and 4096 (16384) all stepped off.With
--fused_shared_experts 1the bench still prints 64 routed experts per rank, and MegaMoE sees 260 experts, top-9, 65 experts per rank. The grouped lookup isexperts=65 topk=-1 ep_fused=1. The expert-64ep_fused=1rows miss that key. Most expert-65 rows at these tokens areep_fused=0or a blank wildcard, so the fused path fell back totile_m=64. The expert-65ep_fused=1row at token 1024 was128×256×256with 2 buffers and was slower than the measured64×256×256row.Changes
_S1F_MAX_RECVis1 << 30, so every width runs the stage-1 kernel.AITER_S1F_MAX_RECVstill imposes a cap;0leaves it uncapped.ep_fused=1rows this branch added. They do not match the fused-shared lookup. The pre-existing expert-64 token-4096 row stays.experts=65,topk=-1,ep_fused=1rows indsr1_tuned_grouped_fmoe.csvfor the buckets [gfx1250] [MoE] DeepSeek-R1 EP4 MegaMoE grouped FMoE rows: ep_fused=1 buckets, tuned 8192 and 32768 #8002 does not tune, plus token 512, where this tile is faster than [gfx1250] [MoE] DeepSeek-R1 EP4 MegaMoE grouped FMoE rows: ep_fused=1 buckets, tuned 8192 and 32768 #8002's row. The token key is the padded receive countnext_pow2(4 * tpr). GEMM1 N is 256.usis the per-layer time of the 10-iter S1F-on run, used only to rank duplicate keys.ep_fused=1rowRows for tokens 32, 64, 128, 256, 8192, 16384, and the token-32768 retune were measured and then removed. #8002 already has those keys. On the same 8-layer bench its row was faster, or the two ranges overlapped, so this PR no longer carries them. Token 512 is the exception: #8002's
16×256×256 / 16×512×128row is 1668.4 µs (1654.7–1683.4) and the row above is 1501.8 µs (1494.6–1508.2). Token 8192 is shared by tpr 1536 and 2048. #8002 is faster at tpr 1536 (3330.1 vs 3394.0 µs) and this branch was faster at tpr 2048 (3963.6 vs 4141.5 µs); one key cannot keep both, so the row goes to #8002.Tiles were chosen by the lowest S1F-on 8-layer median with
--fused_shared_experts 1. The S1F kernel's own K tile stays 256; CSVtile_kstill selects the unfused GEMM and GEMM2. Token 2048's buffer change was checked again at 10 iters: buffers 3 is 2055.3 µs (2044.1–2083.3) and buffers 2 is 2092.7 µs (2082.5–2103.7).Performance (if applicable)
Hardware is 4× gfx1250. Workload is DeepSeek-R1, EP4, 256 routed experts plus 1 fused shared expert per rank, top-8, hidden 7168, intermediate 2048, A4W4 MXFP4, fp4 dispatch, stage-1 and stage-2 fused, uniform routing,
AITER_MEGA_QUANT_FUSE=128,AITER_MEGA_PLAN_PREFETCH=0. Bench isop_tests/multigpu_tests/bench_mega_moe.py --layers 8 --warmup 5 --iters 10 --profile_table 0 --acc_verify 0 --fused_shared_experts 1. The number is the median host time of one CUDA-graph replay of the 8-layer chain, averaged across the 4 ranks. Before is main403b24d8bbwithAITER_MEGA_S1F=0and the stock CSV. After is this branch with S1F on (the default) and the rows above. The earlier table on this PR was expert 64 with fused shared experts off, and it does not apply to this path.Min and max of the 10 iters do not overlap on these four points. tpr 128 had no
ep_fused=1row on main and used the default tile. tpr 256–1024 already had anep_fused=1row; the change is the tile above, except token 4096, which was already128×256×256with 3 buffers.Testing
No new unit test. The bench above is the validation, with
acc_verifyleft off. No MI250X or MI300X run; the schedule and the rows are gfx1250. Routing other than uniform, EP sizes other than 4, and top-k other than 8 were not swept.Documentation
s1f_max_recvdocuments the removed cap and theAITER_S1F_MAX_RECVoverride. No user-guide change.Dependencies
Breaking Changes
None.
AITER_S1F_MAX_RECVcan still restore a cap. Wide prefill steps that used to run dispatch plus GEMM1 now run the stage-1 kernel, and they compile a few more plan widths.The only expert-65
ep_fused=1key still shared with #8002 is token 512. This PR keeps it because that tile is faster on the fused-shared bench. The other shared keys were removed.PR Self-Review
Reviewed revision
4cd3f6c
Behavior and intent
S1F stays on for every receive width unless
AITER_S1F_MAX_RECVsays otherwise. DSR1 with fused shared experts takes the expert-65ep_fused=1tiles instead of the default or theep_fused=0rows.Validation and unverified scope
Command shape:
torchrun --standalone --nproc_per_node=4 op_tests/multigpu_tests/bench_mega_moe.py -tpr <tpr> --layers 8 -e 256 -k 8 -hd 7168 -id 2048 --fused_shared_experts 1 --routing uniform -q a4w4_mxfp4 --dispatch_wire fp4 --stage1_fused true --stage2_fused true --profile_table 0 --acc_verify 0 --warmup 5 --iters 10, withAITER_MEGA_QUANT_FUSE=128andAITER_MEGA_PLAN_PREFETCH=0. Before usesAITER_MEGA_S1F=0on main's CSV. After usesAITER_MEGA_S1F=1on this branch. Accuracy was not checked in this pass.PR-specific question
The wide-prefill fallback existed so a new width would not JIT a stage-1 plan on the serving path, and so a wide plan would not slow the other steps. Those widths are compiled up front. The grouped rows for the wide buckets stay with #8002.
Changed op tests
None.
Made with Cursor