Skip to content

[FlyDSL] Uncap MegaMoE S1F and tune DSR1 fused-shared EP4 rows - #8092

Open
XingerZhu wants to merge 4 commits into
mainfrom
zxe/tune_dsr1_s1f
Open

XingerZhu wants to merge 4 commits into
mainfrom
zxe/tune_dsr1_s1f

Conversation

@XingerZhu

@XingerZhu XingerZhu commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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_S1F defaults on, but a step whose receive bound was above 4096 took the whole S1F-off path (dispatch plus GEMM1). For this shape max_recv = world_size * tokens_per_rank, so tpr 1536 (6144), 2048 (8192), and 4096 (16384) all stepped off.

With --fused_shared_experts 1 the bench still prints 64 routed experts per rank, and MegaMoE sees 260 experts, top-9, 65 experts per rank. The grouped lookup is experts=65 topk=-1 ep_fused=1. The expert-64 ep_fused=1 rows miss that key. Most expert-65 rows at these tokens are ep_fused=0 or a blank wildcard, so the fused path fell back to tile_m=64. The expert-65 ep_fused=1 row at token 1024 was 128×256×256 with 2 buffers and was slower than the measured 64×256×256 row.

Changes

recv token tpr GEMM1 GEMM2 buffers vs the previous expert-65 ep_fused=1 row
512 128 32×256×128 32×256×128 3 new
1024 256 64×256×256 64×256×256 3 was 128×256×256, buffers 2
2048 512 128×256×256 128×256×256 3 same tile, buffers 2 → 3
4096 1024 128×256×256 128×256×256 3 unchanged

Rows 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×128 row 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; CSV tile_k still 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 is op_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 main 403b24d8bb with AITER_MEGA_S1F=0 and 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.

Hardware Workload/configuration Before After Change
4× gfx1250 tpr 128, 8-layer 1810.4 µs 1501.8 µs −17.0%
4× gfx1250 tpr 256, 8-layer 2085.0 µs 1645.9 µs −21.1%
4× gfx1250 tpr 512, 8-layer 2431.6 µs 2055.3 µs −15.5%
4× gfx1250 tpr 1024, 8-layer 3134.8 µs 2734.6 µs −12.8%

Min and max of the 10 iters do not overlap on these four points. tpr 128 had no ep_fused=1 row on main and used the default tile. tpr 256–1024 already had an ep_fused=1 row; the change is the tile above, except token 4096, which was already 128×256×256 with 3 buffers.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

No new unit test. The bench above is the validation, with acc_verify left 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

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

s1f_max_recv documents the removed cap and the AITER_S1F_MAX_RECV override. No user-guide change.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. AITER_S1F_MAX_RECV can 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=1 key 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_RECV says otherwise. DSR1 with fused shared experts takes the expert-65 ep_fused=1 tiles instead of the default or the ep_fused=0 rows.

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, with AITER_MEGA_QUANT_FUSE=128 and AITER_MEGA_PLAN_PREFETCH=0. Before uses AITER_MEGA_S1F=0 on main's CSV. After uses AITER_MEGA_S1F=1 on 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

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>
@XingerZhu
XingerZhu requested review from a team and a balanced review from Copilot November 17, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8092 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title [FlyDSL] [Config] Uncap MegaMoE S1F and tune DSR1 EP4 grouped rows [FlyDSL] Uncap MegaMoE S1F and tune DSR1 EP4 grouped rows Nov 17, 2026
@aiter-bot

aiter-bot commented Nov 17, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 4cd3f6c60375 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — validation answer must explicitly state what remains unverified (or say none with a reason)

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

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.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XingerZhu XingerZhu changed the title [FlyDSL] Uncap MegaMoE S1F and tune DSR1 EP4 grouped rows [FlyDSL] Uncap MegaMoE S1F and tune DSR1 fused-shared EP4 rows Nov 17, 2026
The EP4 tpr 8192 step still used 128x256x256 with 2 buffers. On S1F, 256x256x256 with 2x2 waves is faster.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Keep the expert-65 ep_fused rows only where this branch is faster or the other PR has no row.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants