Skip to content

[FlyDSL] [gfx1250] Fall back to compiler allocation when a prefill tile exceeds the VGPR partition - #8540

Merged
zufayu merged 1 commit into
ROCm:mainfrom
andyluo7:fix/gfx1250-tdm-vgpr-partition-fit
Nov 25, 2026
Merged

zufayu merged 1 commit into
ROCm:mainfrom
andyluo7:fix/gfx1250-tdm-vgpr-partition-fit

Conversation

@andyluo7

@andyluo7 andyluo7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Builds 256x256x256 grouped MoE TDM tiles whose wave grid does not fit the explicit VGPR partition with compiler allocation, instead of asserting. This fixes the 36 gfx1250 FlyDSL MoE AOT replay failures first reported in #8133.

Motivation

When FlyDSL exposes sched_vgpr, every 256x256x256 tile pins each k128 prefetch slot to 128 VGPRs (v256-v511) and the accumulators to 512 (from v512). Some wave grids need more per slot: a4w4 1x4 needs 168 + 216 = 160, and a8w4 2x2 needs 816 + 88 = 192. Tuned rows from #7726 select them, so make_rmem_slot fails assert slot_width <= 128. The replay prints an empty AssertionError for 36 gfx1250 jobs, and run_aot() aborts. #8133 attributed these failures to the moe_sort_quant.cuh DPP build error; #8164 fixed that error, but these 36 jobs still fail at 162173e89c.

Changes

  • mxfp4_preshuffle_gfx1250_tdm.py: USE_EXPLICIT_VGPR_PARTITION also requires the slot (wmma_m_rep * ACT_NDW + wmma_n_rep * WMMA_N/2 <= 128) and the accumulators (n_acc * WMMA_N/2 <= 512) to fit. These are the same bounds the placement code asserts. Tiles that fit build exactly as before, including the _regpart kernel name and waves_per_eu=1.
  • test_flydsl_grouped_gemm.py: test_grouped_a4w4_prefill_tile_beyond_vgpr_partition forces a 256x256x256 tile with a 1x4 wave grid and checks a4w4 MoE against the PyTorch reference.

Testing

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

On gfx1250 hardware at 162173e89c:

Check Before After
FlyDSL MoE AOT replay (run_aot) 2690 ok, 36 failed 2726 ok, 0 failed
New test (a4w4, 256 tile, 1x4) AssertionError: slot_width <= 128 passes
Rest of test_flydsl_grouped_gemm.py 53 passed, 6 failed identical (same 6, failing before this change)

Documentation

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

The comment at the changed condition explains the fallback.

Dependencies

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

Breaking Changes

None.

PR Self-Review

Reviewed revision

e27f1e4

Behavior and intent

256x256x256 tiles that cannot fit the fixed VGPR placement now build with compiler allocation instead of failing an assertion. Tiles that fit are unchanged, so tuned rows that work today keep their kernel and name.

Validation and unverified scope

Validated on gfx1250 at 162173e. python3 -c "from aiter.aot.flydsl.common import run_aot; run_aot('/tmp/flydsl-cache')": MoE replay 2690 ok/36 failed before, 2726 ok/0 failed after. pytest op_tests/flydsl_tests/test_flydsl_grouped_gemm.py: the new a4w4 test fails before (AssertionError) and passes after; the other tests give 53 passed and 6 failed, identically before and after. Unverified: performance of the fallback tiles (they did not build before), and a8w4 numerics on 256x256x256 tiles. a8w4 2x2 builds with this change but gives wrong output on our hardware, and a8w4 grids that fit the partition (unchanged by this PR) also fail. That is tracked in #8539 for the kernel owners.

PR-specific question

The kernel source changes only the condition that selects the explicit VGPR partition; the placement code is unchanged. Compiled kernels that keep the partition are byte-identical in name and attributes. The only other change is one new op test.

Changed op tests

op_tests/flydsl_tests/test_flydsl_grouped_gemm.py: adds test_grouped_a4w4_prefill_tile_beyond_vgpr_partition. It covers a 256x256x256 tile whose 1x4 wave grid exceeds the 128-VGPR slot. Before this change that tile fails to build; no existing test selects it.

🤖 Generated with Claude Code

…le exceeds the VGPR partition

256x256x256 grouped MoE tiles pin each k128 prefetch slot to 128 VGPRs
(v256-v511) and the accumulators to 512 (from v512) whenever FlyDSL
exposes sched_vgpr. Wave grids that need more, such as a4w4 1x4 (160 per
slot) or a8w4 2x2 (192), hit `assert slot_width <= 128` in make_rmem_slot.
Tuned rows from ROCm#7726 select them, so 36 gfx1250 FlyDSL MoE AOT replay
jobs fail and run_aot() aborts.

Enable the explicit partition only when the tile fits, using the same
arithmetic as the assertion; otherwise keep compiler allocation, as every
non-prefill tile does. Tiles that fit build exactly as before.

Add an a4w4 1x4 regression test. a8w4 on these tiles is tracked in ROCm#8539.

Co-Authored-By: Claude <[email protected]>
@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 8540 --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.

@aiter-bot

aiter-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision e27f1e429c59 · 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

256x256x256 tiles that cannot fit the fixed VGPR placement now build with compiler allocation instead of failing an assertion. Tiles that fit are unchanged, so tuned rows that work today keep their kernel and name.

Validation and unverified scope

Validated on gfx1250 at 162173e89c. `python3 -c "from aiter.aot.flydsl.common import run_aot; run_aot('/tmp/flydsl-cache')"`: MoE replay 2690 ok/36 failed before, 2726 ok/0 failed after. `pytest op_tests/flydsl_tests/test_flydsl_grouped_gemm.py`: the new a4w4 test fails before (AssertionError) and passes after; the other tests give 53 passed and 6 failed, identically before and after. Unverified: performance of the fallback tiles (they did not build before), and a8w4 numerics on 256x256x256 tiles. a8w4 2x2 builds with this change but gives wrong output on our hardware, and a8w4 grids that fit the partition (unchanged by this PR) also fail. That is tracked in #8539 for the kernel owners.

PR-specific question

The kernel source changes only the condition that selects the explicit VGPR partition; the placement code is unchanged. Compiled kernels that keep the partition are byte-identical in name and attributes. The only other change is one new op test.

Changed op tests

`op_tests/flydsl_tests/test_flydsl_grouped_gemm.py`: adds `test_grouped_a4w4_prefill_tile_beyond_vgpr_partition`. It covers a 256x256x256 tile whose 1x4 wave grid exceeds the 128-VGPR slot. Before this change that tile fails to build; no existing test selects it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

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

Verified on gfx1250 (flydsl 0.5.0, base 162173e89c vs head e27f1e429c).

The fallback condition matches the placement asserts exactly. slot_vgprs is wmma_m_rep * ACT_NDW + wmma_n_rep * WMMA_VECTOR_DWORDS: A and B are placed back to back from 256 + slot_idx * 128, with no padding. n_acc * (WMMA_N // 2) <= 512 is the accumulator assert. Run over the tuned gfx1250 grouped CSVs, the condition selects exactly the 36 failing replay jobs:

  • gptoss_gfx1250 row 12: a4w4 1x4, 12 jobs
  • minimax_m3_gfx1250 row 29: a8w4 2x2 GEMM2, 12 jobs
  • tuned_grouped_fmoe.csv rows 20, 67 and 68: a8w4 1x4 and 2x2, 4 jobs each

On hardware:

  • New test: at base it fails with the empty assert slot_width <= 128. At head it passes (logits_diff 3.8e-06). The overrides also apply to GEMM2, so both kernels take the fallback: they are ..._w1x4_... with no _regpart. This test is skipped on CI (MI35X), so the green CI does not cover it.
  • Fallback kernels: 866 and 874 VGPRs, no spills, no scratch. Without waves_per_eu=1 the compiler still fits them.
  • Fitting tiles are unchanged: the a4w4 2x2 kernels keep _regpart, and their ISA is byte-identical between base and head.

The a8w4 problem is in the harness, not the kernel. On gfx1250, resolve_activation_dtype() returns fp4x2 unless AITER_FORCE_A8W4=1 is set (fused_moe.py:1189). run_moe() does not set it; only the CLI's set_data_format() does. So run_moe("a8w4", ...) runs the a4w4 kernel (mxfp4_tdm_fp4_*) and compares it against the a8w4 reference. That gives logits_diff 0.109 / rel_l2 0.506, the #8539 numbers, for every tile, including the default 64-row tile.

With AITER_FORCE_A8W4=1, the real a8w4 kernels (mxfp4_tdm_fp8_*) pass at the same shape (logits_diff 4.6e-06) with the default tile and with 256x256x256 at both 2x2 and 1x4. So the 24 a8w4 jobs this PR unblocks run correctly. The existing test_grouped_a8w4_situv2_matches_torch_ref has the same gap: 0.064 without the variable, 8.6e-06 with it. That is probably one of the 6 failures that were already there. Could you update the a8w4 notes in the description and in #8539? Making run_moe() call set_data_format() would fix the harness (separate PR).

Suggestion: also require at most 4 waves. The partition always puts the accumulators at v512 and above, and it only works with one wave per SIMD. 2x4, 4x2 and 4x4 pass both checks but cannot run. For 4x2, the build produces 768-VGPR _regpart kernels for a 256-thread workgroup, and dispatch fails with hipErrorLaunchOutOfResources. This happens for both a4w4 and a8w4; the a8w4 kernel also spills 60–69 VGPRs. That is the 4x2 row of #8539, which was actually an a4w4 kernel, and probably the cause of the 4x4 hang as well (not run here). With compiler allocation, a4w4 4x2 runs and passes: 476 VGPRs, 4 spilled.

No tuned row uses these grids today, but an AITER_TDM_M_WARP/N_WARP sweep can reach them, and at 4x4 that hangs the GPU. Adding and m_warp * n_warp * k_waves <= 4 to fits_vgpr_partition would send them to compiler allocation too.

Nit: (8 if a_is_fp4 else 16) duplicates ACT_NDW. Defining ACT_NDW before this check and reusing it would keep the condition and the asserts from drifting apart.

@zufayu
zufayu merged commit 924a3c6 into ROCm:main Nov 25, 2026
100 of 105 checks passed
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