Skip to content

[FlyDSL] DSR1 EP4 fused-shared: uncap S1F at top-9 and retune four grouped rows - #8092

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

XingerZhu wants to merge 14 commits into
mainfrom
zxe/tune_dsr1_s1f

Conversation

@XingerZhu

@XingerZhu XingerZhu commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

DeepSeek-R1 on EP4 fuses its shared expert, so the MegaMoE grouped lookup is experts=65 topk=-1 ep_fused=1 and the S1F cap check sees top-9. This PR does two things for that path:

  • S1F no longer steps off for receive widths above 4096 on DSR1 EP4 top-9 ((4, 9) joins the uncapped shapes).
  • Four ep_fused=1 grouped rows are retuned for tokens 512, 1024, 2048 and 4096. [gfx1250] [MoE] DeepSeek-R1 EP4 MegaMoE grouped FMoE rows: ep_fused=1 buckets, tuned 8192 and 32768 #8002 is already on main and owns the other buckets.
  • Packed-A S1F (tile 256) no longer fails to build for hidden >= 7168: the storecnt waits are capped at 63 instead of raising ValueError. Single-tray EP4 s1f_s2f on hidden 7168 (DSV4-Pro style, top-6/7) now runs at tpr 8192 and 16384 (see "Packed-A storecnt cap" below).
  • With AITER_MEGA_S1F_FALLBACK=mori, S1F is faster than the mori dispatch path at every tpr from 64 to 16384 (−1.4% to −13.7% per layer). Commit 8a9752a ports the pinned EP4 prefill path from [FlyDSL] perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F #7410, turns it on by default, and keeps the mori and small-tile paths at their previous speed (see "vs mori dispatch" below).

The s1f_ctl.py change is exactly the hunk #7332 also carries, so the two PRs merge in either order and AITER_MOE_LOC=1 keeps its placed-weight launch arguments.

Motivation

For this shape max_recv = world_size * tokens_per_rank, so tpr 1536 (6144), 2048 (8192) and 4096 (16384) all stepped off S1F and ran dispatch plus GEMM1. DSV4.1 top-6/7 was already uncapped; DSR1 top-9 was not.

With #8002 merged, tokens 8–256, 8192, 16384 and 32768 have ep_fused=1 rows. Token 512 is a copy of the ep_fused=0 row (16×256×256 / 16×512×128). Tokens 1024 and 2048 are 128×256×256 with 2 buffers, and 4096 had no 10-iter measurement. The S1F kernel runs its own 256×256 n/k tile; CSV tile_k only affects the unfused GEMM and GEMM2.

Changes

  • s1f_ctl.py: add (4, 9): 1 << 30 to _S1F_MAX_RECV_BY_SHAPE, with the same comment lines as [FlyDSL] [GFX1250] [MoE] Retune gfx1250 DSv4.1 EP4 a4w4 grouped MoE rows for d… #7332. Nothing else in the file changes.
  • s1f_stage1.py: remove the OP_STORES + 3 > 63 check ("an op's stores overflow the storecnt wait field") and cap the WAIT_STEPS counts at 63 (min(_STORECNT_MAX, OP_STORES + p)). Nothing else in the file changes. Why it is safe:
    • A packed-A op issues PAY_ITERS + SC_ITERS + 1 VMEM stores. For hidden 7168 fp4 that is 56 payload + 4 scale + 1 rowmap = 61, so OP_STORES + 3 reached 64, one past what the 6-bit s_wait_storecnt immediate can encode. Hidden 5120 and 4096 need 44 and 32 and were never affected.
    • retire() waits for the largest listed count <= d (d = stores the wave issued after the retiring op's last store); a smaller count only over-waits.
    • A wave never has more than 63 stores outstanding, because the 64th issue stalls until the oldest retires. So when d >= 63, the retiring op is already complete and wait(63) holds either way.
  • Merge of origin/main ([FlyDSL] [gfx1250] MegaMoE S1F: packed A only where its stores fit storecnt #8889) into this branch, and later of origin/main at 2d62557a8 (one conflict in mxfp4_preshuffle_gfx1250_tdm.py: this branch's VGPR-partition setup kept with main's split_f4_wmma from [FlyDSL] [gfx1250] Split 32x16x128 f4 WMMA into two 16x16x128 on gfx1250-strict #9058). Its s1f_packed_a_fits required op_stores + 3 <= 63, which turns packed A off for hidden 7168 (61 stores per op). This branch uses op_stores <= 63 instead, with the same WAIT_STEPS cap, so hidden 7168 keeps packed A. Measured on the merged code (tpr 8192, hidden 7168, 2 layers, 10 iters, two rounds): packed A 2914–2935 µs, the [FlyDSL] [gfx1250] MegaMoE S1F: packed A only where its stores fit storecnt #8889 gate 2969–2975 µs.
  • s1f_ctl.py: s1f_ring_fits(tile_m, wire_row). The producer's slot ring (4 slots × 8 rows × wire row + 5248 B) aliases the GEMM1 LDS arena. For hidden 7680/8192 fp4 (4096/4352 B rows, 136320/144512 B of producer LDS) tile 64 (arena 133632 B) did not fit, and the build raised producer LDS ... exceeds the GEMM arena. Such a tile is no longer offered, so a step that aligns to it takes the existing separate dispatch + GEMM1 path. Hidden 5120 and 7168 fit every tile, so their paths do not change.
  • dsr1_tuned_grouped_fmoe.csv, experts=65, model_dim=7168, inter_dim=2048. The token key is the padded receive count next_pow2(4 * tpr). Of the 72 rows, 13 change (ep_fused=1 rows for topk=-1, tokens 512–4096; cluster_m on rows with topk=9 for non-fused calls at tokens 4096–32768, and on topk=-1 rows at 16384 and 32768). The other 59 rows, including every experts=64 row, are byte-identical to origin/main. cluster_m 2/4 → 1 on the topk=9 rows is the DSR1 (4, 9) non-fused path, which the fused S1F path does not read; see Performance.
recv token tpr GEMM1 GEMM2 buffers previous row on main
512 128 32×256×128 32×256×128 3 16×256×256 / 16×512×128 (#8002)
1024 256 64×256×256 64×256×256 3 128×256×256, buffers 2
2048 512 128×256×256 128×256×256 3 same tile, buffers 2
4096 1024 128×256×256 128×256×256 3 same tile, us filled in

Rows for the other buckets were measured and dropped. On the same bench #8002's rows were as fast or faster there, or the ranges overlapped, so tokens 8–256, 8192, 16384 and 32768 stay as #8002 has them.

Performance (if applicable)

4× gfx1250, 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, AITER_MOE_LOC=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 current main (with #8002), After is this branch.

Workload main S1F on (default) main S1F off this branch, S1F on vs S1F on vs S1F off
tpr 128 1662.3 µs 1932.3 µs 1498.1 µs −9.9% −22.5%
tpr 256 1805.0 µs 2090.3 µs 1645.9 µs −8.8% −21.3%
tpr 512 2088.2 µs 2436.5 µs 2062.3 µs −1.2% −15.4%
tpr 1024 2761.2 µs 3152.3 µs 2745.3 µs −0.6% −12.9%

At tpr 128 and 256 the ranges do not overlap. At tpr 512 the ranges touch (2042–2069 vs 2070–2104 µs) and at tpr 1024 they overlap, so those two are within noise against main with S1F on.

AITER_MOE_LOC=1 was also run on this branch merged with #7332 (S1F on, fused shared expert, uniform routing, 8 iters, single run per point):

tpr 32 128 512 1024 1536 2048 8192 16384
µs 1371.4 1490.0 2047.8 2739.4 3302.8 4000.0 11875.9 22710.7

Every point runs and acc_verify 1 passes at tpr 128 and 1536 (logits diff 0.112 against tolerance 0.216 at 1536).

Packed-A storecnt cap (hidden 7168, tile 256)

Cause: the grouped CSV picks the 256-row GEMM1 tile once the padded receive count reaches 32768 (EP4 tpr 8192), and S1F forces packed A (a_preshuffled=1) at tile 256. On hidden 7168 that built an op with 61 stores, which the old check rejected. The error was not turned into a fallback, so the whole s1f_s2f configuration failed (err=9, fb=0) while none, s2f and s1f_off passed. Before this change, EP4 top-6, hidden 7168, tpr 8192 reproduced the ValueError on all 4 ranks.

4× gfx1250, DEP4, A4W4 MXFP4, fp4 dispatch, stage-2 fused, uniform routing, -e 384 -hd 7168 -id 3072 --layers 2 --iters 3 --warmup 5 --profile_table 0, --stage1_fused both (mori dispatch vs S1F in one process). The number is the median host time of one CUDA-graph replay of the 2-layer chain, averaged across the 4 ranks. Accuracy is the bench's fp32-reference logits_diff, tolerance 0.063559, and it passes in every row.

shape (world, topk) tpr mori S1F S1F vs mori logits_diff mori / S1F
(4, 6) -k 6 8192 3209.1 µs 2922.3 µs −8.9% 0.042081 / 0.042083
(4, 6) -k 6 16384 5515.6 µs 5036.3 µs −8.7% 0.042090 / 0.042088
(4, 7) -k 6 --fused_shared_experts 1 8192 4269.9 µs 4045.5 µs −5.3% 0.042020 / 0.042023

At (4, 6) tpr 16384 the S1F replays spread from 5011 to 5460 µs (min to max), more than the other rows; only 3 iterations were run, so this was not investigated. The DSR1 (4, 9) shape takes the pinned #7410 path, not packed A, and is unaffected by this change.

vs mori dispatch (commit 8a9752a)

Per-layer unit bench, not the CUDA-graph chain above: op_tests/multigpu_tests/bench_mega_moe.py -q a4w4_mxfp4 -e 256 -k 8 -hd 7168 -id 2048 --fused_shared_experts 1 --layers 58 -tpr <tpr> --stage1_fused both --stage2_fused true --dispatch_wire fp4 --combine_quant none --warmup 5 --iters 20 on 4× gfx1250, with AITER_MEGA_S1F_FALLBACK=mori and the default AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1. Each cell is us per layer, mean over 20 iters, one run per point. The mori column is the same run with S1F off. Accuracy passes at every point, and logits_diff matches commit 9caaca3 bit for bit.

tpr mori S1F S1F vs mori S1F vs mori at 9caaca3 / 0a458ea
64 204.2 184.5 −9.6% −10.3%
128 207.6 186.7 −10.0% −9.9%
256 231.1 205.5 −11.1% −10.5%
512 291.6 251.6 −13.7% −13.2%
1024 376.2 338.1 −10.1% −10.7%
1536 425.7 419.6 −1.4% −4.1%
2048 513.8 492.2 −4.2% −5.2%
4096 845.3 777.5 −8.0% −1.8%
8192 1493.5 1384.4 −7.3% −0.7%
16384 2778.7 2665.9 −4.1% −0.1% (ran mori)

Up to tpr 2048 the S1F numbers are the same as before this commit, within about 1%. The 1536 and 2048 margins are smaller because the mori path got faster there, while S1F moved by 4–5 us, which is close to run-to-run noise. At tpr 4096 and above the pinned prefill path takes over:

tpr 4096, us before after
S1F stage-1 kernel (dispatch + GEMM1) 324.7 292.5
S1F GEMM2 294.1 275.4
S1F combine reduce 41.8 37.5

What the commit carries:

  • From [FlyDSL] perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F #7410: s1f_prefill_config() (M256/N256/K256 2x2, GEMM1 3 buffers, GEMM2 4 buffers, A preshuffle, for recv ≥ 16384 on the DSR1 and Flash EP4 shapes). The stage-1 kernel gets row-major MMA reuse, paired CTAs with A multicast, an 8-slot ring, and an APRE payload for GEMM2. GEMM2 uses a 4096-worker fixed-N EP scatter. Combine uses a dense BF16 slot pitch and a 128-thread reduce, and masks dropped routes using the source topk IDs.
  • AITER_FLYDSL_EXPLICIT_VGPR_PARTITION now defaults to 1 and only gates those pinned specializations. M256 4-wave tiles always take the fixed VGPR partition, as on main, and small tiles no longer take it. With the [FlyDSL] perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F #7410 global flag, tpr 256 S1F was 241 us/layer; it is 205.5 now.
  • Clustered 1x4/2x2 APRE GEMMs (the mori path) keep main's grouped DS schedule and ksl0_fence_mma tail, and compact M variants are limited to cluster_n <= 2. Mori GEMM2 at tpr 4096 went from 300.7 to 291.5 us.
  • The direct BF16 combine reduce picks a block size that divides one token's lanes (448 threads at hidden 7168), so it loads route IDs from a uniform address. Mori combine at tpr 4096 went from 57.1 to 44.9 us.
  • DSR1 tile-256 grouped rows use cluster_m=1. Clustered kernels now form under graph capture, and at tpr 16384 the automatic 4x4 GEMM1 took 980 us vs 780 us at 1x4. This also makes mori faster than before at 8192 (1516 → 1494) and 16384 (2879 → 2779).
  • Tpr 16384 (recv 65536) runs S1F under the mori fallback when the pinned prefill is on. 3 of 3 runs passed with no fault. The earlier fault at this width was intermittent, came from the bench's timing phase, and also showed up with S1F off, so it was not specific to S1F.

AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=0 turns the pinned path off. Then tpr 4096 S1F is 820.4 (−2.9% vs mori), 8192 is 1491.2 (tie), and 16384 runs mori again. Tpr 64–2048 and every mori number stay within 0.6% of the pinned-on run.

No end-to-end serving run has been done on this commit yet.

CSV cluster_m change, DSR1 (4, 9) (A/B against origin/main's CSV)

Only aiter/configs/model_configs/dsr1_tuned_grouped_fmoe.csv was swapped; everything else is this branch. Command: run_watch.sh with -e 256 -k 8 --fused_shared_experts 1 -hd 7168 -id 2048 --layers 2 --iters 3 --profile_table 0 --dispatch_wire fp4 --stage1_fused both --stage2_fused true -tpr {4096,8192}, one run per side, 4× gfx1250. MEGA-CHECK PASS in all four runs.

tpr (token key) path origin/main CSV this branch diff
4096 (16384) non-fused 1693 µs 1673 µs −1.2%
4096 (16384) S1F 1644 µs 1659 µs +0.9%
8192 (32768) non-fused 3065 µs 3041 µs −0.8%
8192 (32768) S1F 2984 µs 2930 µs −1.8%

One run per side, so this shows no regression beyond about 2%, not a speedup. The _find_grouped_config lookups before and after confirm the selected cluster_m is 1 instead of 2 or 4 on those keys.

Testing

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

CPU tests: test_grouped_ep_fused_lookup.py, test_grouped_gemm_launch_abi.py, test_flydsl_aot_launch.py: 72 passed, 2 skipped. test_grouped_ep_fused_lookup.py's fake compact config gains topk, world_size, stage1_fused and the fp4 dispatch_token_nbytes / dispatch_scale_nbytes that _compact_gemm_tiles now reads; without them test_compact_plan_uses_ep_fused_tile failed on origin/main too.

Post-merge GPU runs (fp4 wire, stage1_fused true, stage2_fused true, MEGA-CHECK PASS in every row): DSR1 (4, 9) pinned at tpr 4096 and 8192 (repeated 3 times at 8192, 2749–2756 µs; origin/main 3464 µs on the same config); (4, 6) hidden 7168 at tpr 8192 and 16384; hidden 7680 and 8192 at tpr 1024, 8192 and 16384; Flash (5120, 2304) at tpr 4096, 8192 and 16384; fp8 wire at hidden 8192 tpr 8192. The bf16 wire is rejected by the compact dispatch (recipe.py) on origin/main too. The Flash hang seen earlier is in --stage1_fused false (mori dispatch) at tpr 4096, on origin/main as well; the S1F run of the same shape passes.

In the CUDA-graph chain benchmark, accuracy was checked only in the AITER_MOE_LOC=1 run above, at two points; the unit-bench table checks it at every tpr. No MI250X or MI300X run. Routing other than uniform, EP sizes other than 4 and top-k other than 9 (with the fused shared expert) were not swept.

Documentation

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

The cap table is documented in s1f_ctl.py; AITER_S1F_MAX_RECV still overrides it.

Dependencies

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

Breaking Changes

None. DSR1 EP4 top-9 steps wider than 4096 received tokens now run the stage-1 kernel instead of dispatch plus GEMM1, and they compile a few more plan widths. AITER_S1F_MAX_RECV can still impose a cap.

AITER_FLYDSL_EXPLICIT_VGPR_PARTITION now defaults to 1, so the pinned #7410 prefill path is on for the DSR1 (7168, 2048, 65, 9, 4) and Flash (5120, 2304, 96, 6, 4) EP4 shapes once recv ≥ 16384. Set it to 0 to get the previous behaviour. Flash was not re-benchmarked on this branch.

Merging with #7332: s1f_ctl.py is identical in the cap hunk. The only overlap is the token-512 row, which #7332 carries from #8002; keep this PR's row there.

PR Self-Review

Reviewed revision

85e3b90

Behavior and intent

For DSR1 EP4 with the fused shared expert, the S1F stage-1 kernel now runs at every receive width ((4, 9) cap 1 << 30). It was failing with an op's stores overflow the storecnt wait field at tpr 8192 and 16384, and that is what this PR removes. The packed-A check now allows one storer op up to 63 stores, which keeps packed A for hidden 7168, where #8889's op_stores + 3 <= 63 turned it off and made S1F slower than mori. The producer ring is checked against the GEMM arena, so hidden 7680/8192 fp4 falls back to separate dispatch + GEMM1 at tile 64 instead of raising at build time. The grouped CSV retunes 13 DSR1 rows (see Changes). Why the existing behavior is insufficient: on origin/main the S1F build raises for these widths, so the fused path cannot be used at all for them.

Validation and unverified scope

Commands and results. CPU: pytest op_tests/tuning_tests/test_grouped_ep_fused_lookup.py op_tests/tuning_tests/test_grouped_gemm_launch_abi.py tests/test_flydsl_aot_launch.py: 72 passed, 2 skipped. Lint with the CI-pinned black 26.10.1 and ruff 0.16.0 over tracked files: clean. GPU (4× gfx1250, fp4 wire, stage1_fused true, stage2_fused true, MEGA-CHECK PASS in every run): DSR1 (4, 9) pinned at tpr 4096 (1585 µs) and 8192 (2741 µs, repeated 3×, 2749–2756 µs); (4, 6) hidden 7168 at tpr 8192 (2916 µs) and 16384 (5032 µs); hidden 7680 at tpr 8192 (4036 µs) and 16384 (12111 µs, on the separate dispatch + GEMM1 fallback); hidden 8192 at tpr 8192 and 16384; Flash 5120/2304 at tpr 4096 (1051 µs), 8192 and 16384. origin/main on the DSR1 tpr 8192 config: 3464 µs. The CSV A/B is in Performance above.

Unverified (not run): two-node setups (the two-node failure from the original report was not reproduced); tpr ≥ 32768 (except the 32768 token key in the CSV A/B); hidden > 8192; MI250X and MI300X; routing other than uniform; more than 3 iterations per point. The retuned fused rows for tokens 512, 1024 and 2048 were measured before the merge with #8889, not re-measured after it. The Flash 5120/2304 hang in --stage1_fused false (mori dispatch, tpr 4096) also reproduces on origin/main; it is out of scope here and the S1F run of the same shape passes.

PR-specific question

The cap was there so a wide step would not JIT a new stage-1 plan on the serving path. Those plans are compiled up front.

Changed op tests

op_tests/tuning_tests/test_grouped_ep_fused_lookup.py (the only changed op test). (1) test_ep_fused_rows_selected now expects the retuned fused rows: 512 → tile 32, 1024 → tile 64, 2048 → tile 128 (buffers 3). These are the CSV rows this PR changes, so the old expectations would fail on them. (2) New test_compact_rows_override_only_compact checks that compact and mori resolve the same row for DSR1 8192 and 16384 when no compact-only row exists, which covers the compact/mori split in _find_grouped_config that no other test exercises. (3) test_compact_plan_uses_ep_fused_tile fake config gains the fp4 wire sizes, topk, world_size and stage1_fused, which _compact_gemm_tiles reads since #8889; without them the test failed on origin/main as well. Not redundant: none of these three cases are covered by the other tests in the directory.

Made with Cursor

@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

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 85e3b90103d2 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

For DSR1 EP4 with the fused shared expert, the S1F stage-1 kernel now runs at every receive width (`(4, 9)` cap `1 << 30`). It was failing with `an op's stores overflow the storecnt wait field` at tpr 8192 and 16384, and that is what this PR removes. The packed-A check now allows one storer op up to 63 stores, which keeps packed A for hidden 7168, where #8889's `op_stores + 3 <= 63` turned it off and made S1F slower than mori. The producer ring is checked against the GEMM arena, so hidden 7680/8192 fp4 falls back to separate dispatch + GEMM1 at tile 64 instead of raising at build time. The grouped CSV retunes 13 DSR1 rows (see Changes). Why the existing behavior is insufficient: on `origin/main` the S1F build raises for these widths, so the fused path cannot be used at all for them.

Validation and unverified scope

Commands and results. CPU: `pytest op_tests/tuning_tests/test_grouped_ep_fused_lookup.py op_tests/tuning_tests/test_grouped_gemm_launch_abi.py tests/test_flydsl_aot_launch.py`: 72 passed, 2 skipped. Lint with the CI-pinned black 26.10.1 and ruff 0.16.0 over tracked files: clean. GPU (4× gfx1250, fp4 wire, `stage1_fused true`, `stage2_fused true`, MEGA-CHECK PASS in every run): DSR1 (4, 9) pinned at tpr 4096 (1585 µs) and 8192 (2741 µs, repeated 3×, 2749–2756 µs); (4, 6) hidden 7168 at tpr 8192 (2916 µs) and 16384 (5032 µs); hidden 7680 at tpr 8192 (4036 µs) and 16384 (12111 µs, on the separate dispatch + GEMM1 fallback); hidden 8192 at tpr 8192 and 16384; Flash 5120/2304 at tpr 4096 (1051 µs), 8192 and 16384. `origin/main` on the DSR1 tpr 8192 config: 3464 µs. The CSV A/B is in Performance above.

Unverified (not run): two-node setups (the two-node failure from the original report was not reproduced); tpr ≥ 32768 (except the 32768 token key in the CSV A/B); hidden > 8192; MI250X and MI300X; routing other than uniform; more than 3 iterations per point. The retuned fused rows for tokens 512, 1024 and 2048 were measured before the merge with #8889, not re-measured after it. The Flash 5120/2304 hang in `--stage1_fused false` (mori dispatch, tpr 4096) also reproduces on `origin/main`; it is out of scope here and the S1F run of the same shape passes.

PR-specific question

The cap was there so a wide step would not JIT a new stage-1 plan on the serving path. Those plans are compiled up front.

Changed op tests

`op_tests/tuning_tests/test_grouped_ep_fused_lookup.py` (the only changed op test). (1) `test_ep_fused_rows_selected` now expects the retuned fused rows: 512 → tile 32, 1024 → tile 64, 2048 → tile 128 (buffers 3). These are the CSV rows this PR changes, so the old expectations would fail on them. (2) New `test_compact_rows_override_only_compact` checks that compact and mori resolve the same row for DSR1 8192 and 16384 when no compact-only row exists, which covers the compact/mori split in `_find_grouped_config` that no other test exercises. (3) `test_compact_plan_uses_ep_fused_tile` fake config gains the fp4 wire sizes, `topk`, `world_size` and `stage1_fused`, which `_compact_gemm_tiles` reads since #8889; without them the test failed on `origin/main` as well. Not redundant: none of these three cases are covered by the other tests in the directory.

Made with [Cursor](https://cursor.com)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

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
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.

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.

@XingerZhu XingerZhu changed the title [FlyDSL] Uncap MegaMoE S1F and tune DSR1 fused-shared EP4 rows [FlyDSL] DSR1 EP4 fused-shared: uncap S1F at top-9 and retune four grouped rows Nov 23, 2026
Copilot AI balanced review requested due to automatic review settings November 23, 2026 08:15

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.

@zufayu
zufayu requested a review from GwilliamHu November 23, 2026 10:19
@zufayu zufayu assigned GwilliamHu and unassigned yadaish Nov 23, 2026
Copilot AI balanced review requested due to automatic review settings November 24, 2026 12:30

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.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:15

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.

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.

The only compact ep_fused=2 row (token 8192, tile 128) covers recv bounds
4096-8192, i.e. tpr 1025-2048 under the bench's max_recv = 4 * tpr.
Dropping it sends the compact path to the ep_fused=1 row (tile 256, APRE),
the tile mori already runs there.

Unit bench, S1F us/layer with the row -> without the row (same worktree):
  tpr 1280  410.6 -> 382.0  (-7.0%)
  tpr 1536  419.6 -> 401.7  (-4.3%)
  tpr 2048  491.4 -> 498.0  (+1.3%)
MEGA-CHECK accuracy PASS at all three. Not yet measured end to end.

test_compact_rows_override_only_compact now asserts that the compact lookup
at token 8192 resolves to the same ep_fused=1 row as mori.
88480c1 retuned the DSR1 EP4 ep_fused=1 rows for the fused-shared-expert
key (experts=65), but test_grouped_ep_fused_lookup kept the old values and
failed on four checks:

  token  row now          test expected
  512    32/32, 3/3       16/16, 3/3
  1024   64/64, 3/3       128/128, 2/2
  2048   128/128, 3/3     128/128, 2/2
  compact plan align at 512: 32, expected 16

Point the expectations at the current rows; the CSV is unchanged.
All 13 tests in the file pass.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 08: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.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 08:42

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.

Boss2002n pushed a commit that referenced this pull request Nov 26, 2026
…-mask selects

A select on a raw ArithValue condition takes the constant type from the
other operand, so two Python ints fail to build ('int' object has no
attribute '_CAPIPtr') on some FlyDSL 0.5.3 builds. Main wraps them; #8092
had unwrapped the cluster-mask pair.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 12:39

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.

…tile 256

OP_STORES + 3 reached 64 for hidden 7168 (56 payload + 4 scale + 1 rowmap
stores per op), which tripped the "stores overflow the storecnt wait field"
ValueError once a step picked the 256-row tile (EP4 tpr >= 8192). The wait
immediate is 6 bits, but retire() only needs a count <= d, and a wave never has
more than 63 stores outstanding, so capping the listed waits at 63 is safe.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 13:13

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.

Resolve conflicts with #8889 (s1f_ctl.py, s1f_stage1.py, dispatch_compact.py):
keep the config-based S1F helpers, and redefine s1f_packed_a_fits as
"one storer op's stores <= the 63 a wave can have outstanding" so hidden
7168 (61 stores/op) keeps packed A through the capped WAIT_STEPS.
Fix test_compact_plan_uses_ep_fused_tile config (dispatch_token_nbytes /
dispatch_scale_nbytes), broken on origin/main by #8889.
…arena

Wide wire rows (hidden 7680/8192 fp4) made the stage-1 kernel raise
"producer LDS 136320 B exceeds the GEMM arena 133632 B" at tile 64, on
origin/main too. Record each variant's GEMM1 arena and drop a tile whose
arena is smaller than the producer ring from the offered tiles, so a step
that aligns to it keeps dispatch and GEMM1 separate (the existing S1F
fallback) instead of failing in the JIT. Hidden 5120/7168 fit every tile,
so their paths are unchanged.

Add test_s1f_ring_fits.py for the packed-A store limit and the ring gate.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 11:40

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.

Drop the unit test added with the producer-ring gate; the gate itself is unchanged.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 11:43

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.

Resolve the conflict in mxfp4_preshuffle_gfx1250_tdm.py: keep this branch's
VGPR-partition / preshuffled-output setup and main's split_f4_wmma
(gfx1250-strict, #9058); both sit in the same prologue and are independent.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 11:55

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 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 85e3b90103d2 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

For DSR1 EP4 with the fused shared expert, the S1F stage-1 kernel now runs at every receive width (`(4, 9)` cap `1 << 30`). It was failing with `an op's stores overflow the storecnt wait field` at tpr 8192 and 16384, and that is what this PR removes. The packed-A check now allows one storer op up to 63 stores, which keeps packed A for hidden 7168, where #8889's `op_stores + 3 <= 63` turned it off and made S1F slower than mori. The producer ring is checked against the GEMM arena, so hidden 7680/8192 fp4 falls back to separate dispatch + GEMM1 at tile 64 instead of raising at build time. The grouped CSV retunes 13 DSR1 rows (see Changes). Why the existing behavior is insufficient: on `origin/main` the S1F build raises for these widths, so the fused path cannot be used at all for them.

Validation and unverified scope

Commands and results. CPU: `pytest op_tests/tuning_tests/test_grouped_ep_fused_lookup.py op_tests/tuning_tests/test_grouped_gemm_launch_abi.py tests/test_flydsl_aot_launch.py`: 72 passed, 2 skipped. Lint with the CI-pinned black 26.10.1 and ruff 0.16.0 over tracked files: clean. GPU (4× gfx1250, fp4 wire, `stage1_fused true`, `stage2_fused true`, MEGA-CHECK PASS in every run): DSR1 (4, 9) pinned at tpr 4096 (1585 µs) and 8192 (2741 µs, repeated 3×, 2749–2756 µs); (4, 6) hidden 7168 at tpr 8192 (2916 µs) and 16384 (5032 µs); hidden 7680 at tpr 8192 (4036 µs) and 16384 (12111 µs, on the separate dispatch + GEMM1 fallback); hidden 8192 at tpr 8192 and 16384; Flash 5120/2304 at tpr 4096 (1051 µs), 8192 and 16384. `origin/main` on the DSR1 tpr 8192 config: 3464 µs. The CSV A/B is in Performance above.

Unverified (not run): two-node setups (the two-node failure from the original report was not reproduced); tpr ≥ 32768 (except the 32768 token key in the CSV A/B); hidden > 8192; MI250X and MI300X; routing other than uniform; more than 3 iterations per point. The retuned fused rows for tokens 512, 1024 and 2048 were measured before the merge with #8889, not re-measured after it. The Flash 5120/2304 hang in `--stage1_fused false` (mori dispatch, tpr 4096) also reproduces on `origin/main`; it is out of scope here and the S1F run of the same shape passes.

PR-specific question

The cap was there so a wide step would not JIT a new stage-1 plan on the serving path. Those plans are compiled up front.

Changed op tests

`op_tests/tuning_tests/test_grouped_ep_fused_lookup.py` (the only changed op test). (1) `test_ep_fused_rows_selected` now expects the retuned fused rows: 512 → tile 32, 1024 → tile 64, 2048 → tile 128 (buffers 3). These are the CSV rows this PR changes, so the old expectations would fail on them. (2) New `test_compact_rows_override_only_compact` checks that compact and mori resolve the same row for DSR1 8192 and 16384 when no compact-only row exists, which covers the compact/mori split in `_find_grouped_config` that no other test exercises. (3) `test_compact_plan_uses_ep_fused_tile` fake config gains the fp4 wire sizes, `topk`, `world_size` and `stage1_fused`, which `_compact_gemm_tiles` reads since #8889; without them the test failed on `origin/main` as well. Not redundant: none of these three cases are covered by the other tests in the directory.

Made with [Cursor](https://cursor.com)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

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.

5 participants