Repository navigation
[FlyDSL] [gfx1250] MegaMoE S1F: per-XCC GEMM1 queues on IOD-placed W1 at decode tiles - #8997
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
CI IN PROGRESSPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
…decode tiles _S1F_XCC_QUEUE_MAX_TILE_M = 0 turned the per-XCC queues off for every tile, placed W1 included, so a decode step with AITER_MOE_LOC=1 ran the global GEMM1 order (_locg) instead of the domain-aware per-XCC queues (_xq_loc). The 5-9 us loss that motivated the default was measured on unplaced weights. Auto now takes the per-XCC queues on placed W1 below _S1F_LOC_QUEUE_MIN_TILE_M (the per-domain queues already cover the wider tiles); unplaced weights keep the global order. AITER_MEGA_S1F_XCC_QUEUE=0/1 still overrides. DSV4.1 Flash EP4 a4w4, 4x gfx1250, 8 layers, S1F + fused stage 2, stage 1 / per layer (us), placed weights: tpr 192 (tile_m 32): _locg 90.3 / 184.9 -> _xq_loc 83.4 / 179.4 tpr 384 (tile_m 64): _locg 95.0 / 207.1 -> _xq_loc 90.1 / 201.8
a3dc7d4 to
2b8bf6d
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
An undeclared probe dependency can break cache validation, and placed weights can retain unsupported K-wave counts, with additional runtime correctness and test-coverage issues unresolved.
No open issues 🎉
What changed in this PR
This PR targets gfx1250 FlyDSL MoE performance regressions by adding optional I/O-die-local weight placement and adjusting grouped GEMM scheduling, quantization, and model tuning.
Changes:
- Add load-time weight placement, locality probing, and compatible-layout dispatch checks.
- Extend grouped GEMM and fused stage-1 scheduling, and distribute quantization work across more waves.
- Update DSV4.1 Flash tuning, test integration, and benchmark profiling.
| File | Description |
|---|---|
op_tests/tuning_tests/test_grouped_gemm_launch_abi.py |
Add the locality-table pointer to the expected launch interface. |
op_tests/multigpu_tests/bench_mega_moe.py |
Integrate optional placement and add a profiler flush delay. |
op_tests/flydsl_tests/test_flydsl_grouped_gemm.py |
Invoke placement during grouped-MoE test setup. |
aiter/ops/shuffle.py |
Expose the load-time weight-placement helper. |
aiter/ops/flydsl/kernels/mxfp4_preshuffle_gfx1250_tdm.py |
Read placed weights and schedule tiles by locality domain. |
aiter/ops/flydsl/kernels/moe_apreshuffled_quant_scatter.py |
Split quantization rows into parallel K-dimension runs. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/s1f_stage1.py |
Add locality-aware queues and scale-prologue support. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/s1f_ctl.py |
Configure new stage-1 variants and placement metadata. |
aiter/ops/flydsl/kernels/iod_loc_probe.py |
Probe memory locality and determine launch rotation. |
aiter/ops/flydsl/iod_locality.py |
Implement placement, registration, and layout lookup. |
aiter/ops/flydsl/grouped_moe_gfx1250.py |
Pin placed weights to compatible tile configurations. |
aiter/ops/flydsl/grouped_gemm_mxfp4.py |
Pass locality metadata and select persistent scheduling. |
aiter/fused_moe.py |
Reject placed weights on incompatible fallback paths. |
aiter/configs/model_configs/dsv41_flash_tuned_grouped_fmoe.csv |
Retune selected DSV4.1 Flash grouped-MoE workloads. |
Review effort: Balanced
… recv 32..1024, CSV GEMM1 TDM knobs in the S1F stage-1 kernel The other two parts of the DSV4.1 decode regression against the 1116 build, next to the per-XCC queues of the previous commit. Grouped MoE CSV, e96 a4w4 EP rows (topk -1) for the buckets c32-c256 decode lands in, back to the rows the 11-16 build ran: - 32: GEMM1 16x512x256, GEMM2 16x512x256, no A-scale prologue, no B TDM hint. - 64, 128: no prologue, no hint. - 256, 512, 1024: no prologue (B TDM hint 1 kept). S1F: the stage-1 kernel embeds the resolved row's B TDM hint and A-scale prologue again, as fused_moe passes them, instead of both off. 0fd0988 kept them off because the tile_m 32 row had both on (~1.5 us on the stage-1 kernel); with the rows above, the tile_m 16 buckets have both off, the tile_m 32 buckets (192..1024) run bth1 and 1536 up asprol + bth1, which is what the 11-16 build ran (_bth1 / _asprol_bth1). Each step bound's precompile key carries its own row's knobs (_compact_g1_tdm), so no bucket JIT-compiles in a graph capture. _compact_row factors out the row lookup _compact_gemm_tiles already did; the tiles it resolves are unchanged for every bucket. DSV4.1 Flash DEP4 c64 decode on gfx1250, 11-16 build vs the plain 11-27 main rebase: GEMM2 0.348 vs 0.429 ms/step, the stage-1 kernel 0.341 vs 0.454 ms/step (the latter with the per-XCC queues). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… recv 32..1024, CSV GEMM1 TDM knobs in the S1F stage-1 kernel The other two parts of the DSV4.1 decode regression against the 1116 build, next to the per-XCC queues of the previous commit. Grouped MoE CSV, e96 a4w4 EP rows (topk -1) for the buckets c32-c256 decode lands in, back to the rows the 11-16 build ran: - 32: GEMM1 16x512x256, GEMM2 16x512x256, no A-scale prologue, no B TDM hint. - 64, 128: no prologue, no hint. - 256, 512, 1024: no prologue (B TDM hint 1 kept). S1F: the stage-1 kernel embeds the resolved row's B TDM hint and A-scale prologue again, as fused_moe passes them, instead of both off. 0fd0988 kept them off because the tile_m 32 row had both on (~1.5 us on the stage-1 kernel); with the rows above, the tile_m 16 buckets have both off, the tile_m 32 buckets (192..1024) run bth1 and 1536 up asprol + bth1, which is what the 11-16 build ran (_bth1 / _asprol_bth1). Each step bound's precompile key carries its own row's knobs (_compact_g1_tdm), so no bucket JIT-compiles in a graph capture. _compact_row factors out the row lookup _compact_gemm_tiles already did; the tiles it resolves are unchanged for every bucket. DSV4.1 Flash DEP4 c64 decode on gfx1250, 11-16 build vs the plain 11-27 main rebase: GEMM2 0.348 vs 0.429 ms/step, the stage-1 kernel 0.341 vs 0.454 ms/step (the latter with the per-XCC queues). Cherry-picked from #8997 onto the main-based IOD branch: only the CSV rows apply. main already embeds each row's B TDM hint and A-scale prologue in the stage-1 kernel and keys every step bound's precompile by them (_compact_gemm_tiles, g1_tdm_b_th / g1_tdm_as_in_prologue). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Stacked on #7332 (base
zan/dsv41-decoding). With IOD-placed weights (AITER_MOE_LOC=1), the S1F stage-1 kernel now uses the domain-aware per-XCC GEMM1 queues (_xq_loc) at decode tile sizes instead of the global GEMM1 order (_locg). This fixes the stage-1 part of the DSV4.1 decode regression against the 1116 build.Motivation
Commit
0fd0988f5in #7332 set_S1F_XCC_QUEUE_MAX_TILE_M = 0. That turned the per-XCC queues off for every tile, placed W1 included. The per-domain queues start only attile_m >= 128, so a decode step (tile_m32 / 64) on placed W1 ran the global order (_locg). This is about as fast as running without placement, and slower than the 1116 build, which forcedxcc_queues = 1wheneveriod_locwas set. The 5-9 us loss given as the reason for the default was measured on unplaced weights.Changes
s1f_ctl._s1f_xcc_queues(tile_m, iod_loc): in auto mode, turns the per-XCC queues on for placed W1 below_S1F_LOC_QUEUE_MIN_TILE_M(128)._s1f_loc_queuesthen keeps them domain-aware. Wider tiles keep the per-domain queues, and unplaced weights keep the global order.AITER_MEGA_S1F_XCC_QUEUE=0/1still overrides.Second commit (
2b62874fd, the other two decode-side parts against the 1116 build):dsv41_flash_tuned_grouped_fmoe.csv: the e96 a4w4 EP rows (topk -1) at recv 32..1024, where c32-c256 decode lands, are back to the 11-16 rows. 32: GEMM1 / GEMM2 16x512x256, no A-scale prologue, no B TDM hint. 64, 128: no prologue, no hint. 256, 512, 1024: no prologue, B TDM hint 1 kept.tdm_b_th/tdm_as_in_prologueagain, as fused_moe passes them, instead of both off (0fd0988 turned them off because the tile_m 32 row had both on). With the rows above, the tile_m 16 buckets keep both off, tile_m 32 (recv 192..1024) runs_bth1, and 1536 up runs_asprol_bth1, as the 11-16 build did.dispatch_compact:_compact_rowfactors out the row lookup_compact_gemm_tilesalready did (resolved tiles unchanged for every bucket), and_compact_g1_tdmgives each step bound's precompile key its own row's knobs, so no bucket JIT-compiles in a graph capture.The stage-2 part of the regression is the 2048-token
ep_fused=1CSV row that #7921 added on main. It overrides the 1116 GEMM2 tile once #7332 meets main, so it lives on main, not on this base. That fix is on the separate branchzxe/fix_mega_s2_tile(one CSV line).Performance (if applicable)
_locg)_xq_loc)AITER_MOE_LOC=1Measured on #7332 (
ae63fb59f), withAITER_MEGA_S1F_XCC_QUEUE=1for the "after" column. At these tile sizes that is the configuration this PR makes the default.Testing
Documentation
The change is internal to the S1F default; the constants' comments in
s1f_ctl.pyare updated.Dependencies
Breaking Changes
None. The default changes only on IOD-placed W1 (
AITER_MOE_LOC=1, gfx1250), and the env override is unchanged.PR Self-Review
Reviewed revision
2b8bf6d
Behavior and intent
With IOD-placed W1 and GEMM1
tile_m < 128, the S1F stage-1 kernel now builds withxcc_queues=1(kernel name_xq_loc) instead of the global order (_locg). Before this change, a decode step on placed weights got no stage-1 benefit from the placement: stage 1 ran 5-7 us slower than the 1116 build, which always enabled the per-XCC queues withiod_loc. Unplaced weights and tiles >= 128 behave as before.Validation and unverified scope
Validated:
bench_mega_moe.pyon 4x gfx1250, withtorchrun --nproc_per_node=4 op_tests/multigpu_tests/bench_mega_moe.py -q a4w4_mxfp4 -e 384 -k 6 -hd 5120 -id 2304 -tpr {192,384} --layers 8 --stage1_fused true --stage2_fused true --dispatch_wire fp4 --combine_quant none --acc_verify 1andAITER_MEGA_S1F=1 AITER_MOE_LOC=1. This ran on [FlyDSL] [GFX1250] [MoE] Retune gfx1250 DSv4.1 EP4 a4w4 grouped MoE rows for d… #7332 withAITER_MEGA_S1F_XCC_QUEUE=1, which gives the same queue setting this PR picks in auto mode at tile_m 32 / 64. Numbers are in the table above, and accuracy passed in every run.On this revision:
ruff check(0.16.0),black --check,py_compile, andpytest op_tests/tuning_tests/test_grouped_gemm_launch_abi.py test_csv_validation.py test_grouped_ep_fused_lookup.py(46 passed).Second commit, CPU only: the three tuning tests above, 46 passed (same as the first commit);
black --check,py_compile; for the DSV4.1 Flash EP4 shape,_compact_gemm_tilesreturns the same tiles as before at recv 1..4096, and_compact_g1_tdmgives (bth, asprol) (0, 0) up to 128, (1, 0) at 192..1024 and (1, 1) from 1536 on.Unverified:
_xq_locin the stage-1 kernel name.PR-specific question
The main boundary is the switch at
tile_m < _S1F_LOC_QUEUE_MIN_TILE_M(128) on placed W1. Below it, the kernel uses the per-XCC queues, kept domain-aware. From 128 up, it keeps the per-domain queues, and unplaced W1 keeps the global order. The failure mode is a placed-W1 shape below 128 for which the per-XCC queues are slower or not buildable. The evidence covers only tile_m 32 and 64 on DSV4.1 Flash EP4 (table above, accuracy PASS).AITER_MEGA_S1F_XCC_QUEUE=0restores the previous behavior without a code change.xcc_queuesis already part of the launcher cache key, so the two settings never share a compiled kernel.Changed op tests
None.