Skip to content

[FlyDSL] [gfx1250] MegaMoE S1F: per-XCC GEMM1 queues on IOD-placed W1 at decode tiles - #8997

Merged
yhl-amd merged 2 commits into
zan/dsv41-decodingfrom
zxe/fix_mega_regression
Dec 2, 2026
Merged

yhl-amd merged 2 commits into
zan/dsv41-decodingfrom
zxe/fix_mega_regression

Conversation

@XingerZhu

@XingerZhu XingerZhu commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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 0fd0988f5 in #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 at tile_m >= 128, so a decode step (tile_m 32 / 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 forced xcc_queues = 1 whenever iod_loc was 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_queues then keeps them domain-aware. Wider tiles keep the per-domain queues, and unplaced weights keep the global order.
  • AITER_MEGA_S1F_XCC_QUEUE=0/1 still 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.
  • S1F stage-1 kernel: it embeds the resolved row's tdm_b_th / tdm_as_in_prologue again, 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_row factors out the row lookup _compact_gemm_tiles already did (resolved tiles unchanged for every bucket), and _compact_g1_tdm gives each step bound's precompile key its own row's knobs, so no bucket JIT-compiles in a graph capture.
  • 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, stage-1 kernel 0.341 vs 0.454 ms/step (the latter with the per-XCC queues of the first commit).

The stage-2 part of the regression is the 2048-token ep_fused=1 CSV 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 branch zxe/fix_mega_s2_tile (one CSV line).

Performance (if applicable)

Hardware Workload/configuration Before (_locg) After (_xq_loc) Change
4x gfx1250 (256 CU) DSV4.1 Flash EP4 a4w4, tpr 192 (tile_m 32), 8 layers, S1F + fused stage 2, AITER_MOE_LOC=1 stage 1 90.3 us, 184.9 us/layer stage 1 83.4 us, 179.4 us/layer -6.9 / -5.5 us
4x gfx1250 (256 CU) same, tpr 384 (tile_m 64) stage 1 95.0 us, 207.1 us/layer stage 1 90.1 us, 201.8 us/layer -4.9 / -5.3 us

Measured on #7332 (ae63fb59f), with AITER_MEGA_S1F_XCC_QUEUE=1 for the "after" column. At these tile sizes that is the configuration this PR makes the default.

Testing

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

Documentation

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

The change is internal to the S1F default; the constants' comments in s1f_ctl.py are updated.

Dependencies

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

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 with xcc_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 with iod_loc. Unplaced weights and tiles >= 128 behave as before.

Validation and unverified scope

Validated:

  • bench_mega_moe.py on 4x gfx1250, with torchrun --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 1 and AITER_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 with AITER_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, and pytest 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_tiles returns the same tiles as before at recv 1..4096, and _compact_g1_tdm gives (bth, asprol) (0, 0) up to 128, (1, 0) at 192..1024 and (1, 1) from 1536 on.

Unverified:

  • This exact revision has not been run on GPU, because the local machine was busy. Re-running the bench above should show _xq_loc in the stage-1 kernel name.
  • tile_m 16 and 96 with placed W1, other models (DSR1), and EP8/EP16 have not been measured with the per-XCC queues.
  • End-to-end in ATOM also needs ATOM Fusion allreduce old add rmsnorm #3144.
  • The second commit has not been run on GPU on this branch; its rows and stage-1 knobs are the ones the 11-16 build ran.

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=0 restores the previous behavior without a code change. xcc_queues is already part of the launcher cache key, so the two settings never share a compiled kernel.

Changed op tests

None.

@XingerZhu
XingerZhu requested review from a team and a balanced review from Copilot December 1, 2026 09:13
@github-actions

github-actions Bot commented Dec 1, 2026

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 8997 --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 Zxe/fix mega regression [FlyDSL] Zxe/fix mega regression Dec 1, 2026
@github-actions github-actions Bot added the FlyDSL label Dec 1, 2026
@aiter-bot

aiter-bot commented Dec 1, 2026 •

Copy link
Copy Markdown

CI IN PROGRESS

PR Self-Review

Revision 2b8bf6d47276 · 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

With IOD-placed W1 and GEMM1 `tile_m < 128`, the S1F stage-1 kernel now builds with `xcc_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 with `iod_loc`. Unplaced weights and tiles >= 128 behave as before.

Validation and unverified scope

Validated:
- `bench_mega_moe.py` on 4x gfx1250, with `torchrun --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 1` and `AITER_MEGA_S1F=1 AITER_MOE_LOC=1`. This ran on #7332 with `AITER_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`, and `pytest op_tests/tuning_tests/test_grouped_gemm_launch_abi.py test_csv_validation.py test_grouped_ep_fused_lookup.py` (46 passed).

Unverified:
- This exact revision has not been run on GPU, because the local machine was busy. Re-running the bench above should show `_xq_loc` in the stage-1 kernel name.
- tile_m 16 and 96 with placed W1, other models (DSR1), and EP8/EP16 have not been measured with the per-XCC queues.
- End-to-end in ATOM also needs ATOM #3144.

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=0` restores the previous behavior without a code change. `xcc_queues` is already part of the launcher cache key, so the two settings never share a compiled kernel.

Changed op tests

None.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • WAIT — Black: missing
  • WAIT — Ruff: missing
  • WAIT — Repository dependency: missing
  • WAIT — Aiter Test Gate: missing
  • Required CI is incomplete; the CI verdict appears once it completes.

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

…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
@XingerZhu
XingerZhu force-pushed the zxe/fix_mega_regression branch from a3dc7d4 to 2b8bf6d Compare December 1, 2026 09:21
@XingerZhu
XingerZhu changed the base branch from main to zan/dsv41-decoding December 1, 2026 09:21

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.

🔵 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

@XingerZhu XingerZhu changed the title [FlyDSL] Zxe/fix mega regression [FlyDSL] [gfx1250] MegaMoE S1F: per-XCC GEMM1 queues on IOD-placed W1 at decode tiles Dec 1, 2026
… 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]>
@yhl-amd
yhl-amd merged commit 46916fe into zan/dsv41-decoding Dec 2, 2026
@yhl-amd
yhl-amd deleted the zxe/fix_mega_regression branch December 2, 2026 07:51
Boss2002n pushed a commit that referenced this pull request Dec 2, 2026
… 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]>
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