Skip to content

[FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning - #7659

Merged
aoli26 merged 12 commits into
mainfrom
gfx1250/dsv41-flydsl-fp8-gemm
Nov 17, 2026
Merged

aoli26 merged 12 commits into
mainfrom
gfx1250/dsv41-flydsl-fp8-gemm

Conversation

@aoli26

@aoli26 aoli26 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds 32x32 weight-scale, batched (bmm) and 1x1-cluster support to the gfx1250 FlyDSL mxfp8_32 compute GEMM, routes tuned compute kernelNames through the existing flydsl bmm path, and tunes the DSv4.1 Flash 32x32 GEMMs (Q-A/KV-A, Q-B, O-A, O-B, shared gate/up/down, Engram WKV) at decode M=768 and M=512..704 (C512), plus guard rows at M=288..448 so smaller M never fall back to a slower kernel. Prefill M=16384 keeps main's rows.

Motivation

On main, gfx1250 32x32 shapes can only use the generic batched mxfp8_32 kernel: the 256x256 compute kernel reads only the n32k4-shuffled 1x32 weight scale, has no batched mode, and needs cluster_m * cluster_n >= 2 at every M a row serves. Decode M in C512 varies between about 500 and 700, where most of these GEMMs had no tuned rows.

Changes

  • gemm_a8w8_256x256_gfx1250.py: constexprs b_scale_32x32 (row-major [N/32, K/32] B scale) and batched (grid.z = batch, per-batch offsets); a one-workgroup cluster launches without cluster dims, multicast masks or cluster barriers. Existing kernels compile to byte-identical ISA.
  • mxfp8_bpreshuffle_gemm_gfx1250.py: the dense mxfp8_32 runner takes w_scale_32x32 and batch; resolve_cluster_m may fall back to cluster_m = 1 for compute kernels. With batch > 1 it requires XQ.stride() == (batch*K, 1) and Out.stride() == (batch*N, 1).
  • batched_gemm_a8w8_gfx1250.py: compute kernelNames go to the dense runner's compute path (B=1 dense, B>1 batched); routing and heuristic are unchanged. A compute kernelName with y_scale_out raises (no fused quant epilogue).
  • dsv41 tuned CSVs (gfx1250, cu_num 256, 32x32): 6 rows at M=768, 34 at M=512..704, 19 guard rows at M=288..448 (keys below). M=16384 rows are identical to main. It also corrects 65 existing rows of the same shapes: 58 main rows with wrong latency/TFLOPS/BW (e.g. (1792, 5120) M=256 34.6 -> 7.1 us, M=1024 108.7 -> 10.6 us) and 7 of the rows above re-timed on the same footing ((5120, 8192) M=416..608, 704). 32 of the main rows also get a faster kernel (kernelName changed, 0.56-0.9x latency): (1792, 5120) M=1..224 (12 rows), 352, 416, 480, 800, 992; (25600, 6144) M=2..16, 672..736; (32768, 1280) M=288, 560; (4608, 5120) M=64; (5120, 2304) M=128; (5120, 8192) M=400, 480, 560, 672.
  • Tests: test_gemm_a8w8_blockscale.py gets a --w-scale-block 32x32 mode that asserts a mismatch ratio of at most 0.05; test_flydsl_batched_gemm.py gets test_batched_gemm_a8w8_compute (five explicit compute cases, per-batch reference check) and test_compute_operand_guards (host-side checks above).

Performance (if applicable)

gfx1250 (256 CU), repo UTs, only the tuned CSVs differ, median of 5 alternating samples, random init.

GEMM (B,N,K) decode M=768
Q-A/KV-A (1,1792,5120) 14.02 → 10.01 us (-28.6%)
Q-B (1,32768,1280) 21.00 → 20.55 us (-2.2%)
O-A (8,1024,4096) 16.15 → 16.16 us (row unchanged)
O-B (1,5120,8192) 21.78 → 20.00 us (-8.1%)
Shared gate/up (1,4608,5120) 14.92 → 14.30 us (-4.2%)
Shared down (1,5120,2304) 9.26 → 8.65 us (-6.6%)
Engram WKV (1,25600,6144) 69.48 → 59.68 us (-14.1%)

Decode M=512..704, latency change per M (a row serves M rounded up to a multiple of 32, so this covers M 481..704; "=" = row kept):

GEMM 512 544 576 608 640 672 704
Q-A/KV-A -9.9% -33.8% -21.0% = -7.3% -8.2% -32.9%
Q-B -7.3% -17.3% -8.4% -14.8% -5.6% -5.2% -12.0%
O-A (B=8) -9.0% -9.1% -9.5% -7.4% -7.1% -8.0% -7.7%
O-B -19.8% -15.3% -5.0% -10.5% = = -3.5%
Shared gate/up -18.3% -13.8% -3.4% -12.4% = -6.0% -11.8%
Shared down -3.1% -3.3% -2.6% = = = =

Guard rows: without them, M with no row of their own reach the new M=512 rows (next power of two), up to 26% slower than main for O-B and gate/up. With them, every M in 257..448 is at or below main (O-B and gate/up M 257..384 back at main's latency, within 1%; all other changed M 4-22% faster; 3 processes).

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

Dependencies

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

Overlaps #7668 on five dense keys, (576|672|768, 32768, 1280) and (576|768, 5120, 8192); whichever PR lands second re-times both kernels back to back and keeps the faster one.

Breaking Changes

None.

PR Self-Review

Reviewed revision

21a8b56

Behavior and intent

gfx1250 32x32 group32 GEMMs, dense and batched, can run the 256x256 compute kernel when a tuned row names it, including cluster_n = 1 configs on ragged M (the cluster falls back to one workgroup instead of raising). Shapes outside the listed keys keep their selection; within the keys' padded-M reach no M is slower than main. M >= 769, including prefill M=16384, keeps main's selection. The exception is the 32 main rows re-picked in Changes: each is at least 3% faster than main's kernel at its own M (5-process medians), but they were not swept across their padded-M range. The compute route rejects a dense XQ or Out at batch > 1 (per-batch offsets would go out of bounds) and y_scale_out.

The tuned O-A rows are read by batched_gemm_a8w8_mxscale_bpreshuffle. ATOM's fused wo_a entry (..._fused_quant) passes no kernel_name, does not read them, and is not changed here.

Validation and unverified scope

All on gfx1250 (256 CU):

  • Functional (NaN-poisoned output vs FP32 dequantized reference): every timed candidate passes (4855/4856, 15432/15432 M=512..704, 5624/5624 guard rows, 382/382 sweep pairs). The one failure is main's existing flydsl_bmm_mxfp8_32_wmma_t32x128x256_mw1_nw4_nb2_sk1_cm1_cn1 (inf at M=768, N=32768, K=1280), not selected. Repeated runs are bitwise identical and finite (200 per new M=768/512..704 pick, 20 per guard row).
  • Selection sweep vs main (runtime lookup of the 7 shapes, M 1..20000): selection changes in 60 runs of consecutive M, all within M 257..768; every M >= 769 keeps main's kernel. Each run was timed against main's kernel at its ends (up to 9 points): none is slower by more than 1.5% (worst +0.3%, 0.0% on a 3-process recheck). Timings predate dropping the M=16384 rows, which only changed picks at M 8193..16384, and the row refresh above (the 32 re-picked rows are not in this sweep).
  • Public entry picks the tuned kernel and passes: 14/14, 114/114, 57/57 (rows at M, M-15/M-31, plus M=300 and 450), also with FLYDSL_RUNTIME_RUN_ONLY=1 on a fresh AOT cache (before the row refresh). AOT (python -m aiter.aot.flydsl.gemm --csv ...), re-run after the row refresh on a fresh cache with FlyDSL 0.5.0: 684 replays, 94 scanned M, 0 failures, --check passes, an empty cache fails as expected.
  • Row refresh (65 rows): latency is the median of 5 processes (cold weights, rocprofv3 kernel trace, Tukey 1.5xIQR); the 32 re-picked kernels were chosen among 8-10 kernels already tuned for nearby M and pass the NaN-poisoned check against the FP32 reference at M, M-1 and M-15 (92/92).
  • ISA vs main: 11/11 existing compute kernels identical. Five batched compute cases pass (they fail with per-batch scales permuted). test_gemm_group32_interface.py + test_gemm_host_dispatch_cache.py: 188 passed; test_gemm_a8w8_mxfp8_bpreshuffle.py: 36 shapes; blockscale UT 128x128 and 32x32 pass; batched a8w8 defaults 50/50; ragged-M cluster fallback all pass; shape-collision guard passes; black and ruff==0.16.0 clean.
  • After merging main (edf58c67a4) and the review fixes (6c05f98beb, 1251a8d), fresh FlyDSL cache: the five compute cases pass (mismatch ratio 0); the dense memory path launched twice per w_scale layout is bitwise identical (so the [FlyDSL] [gfx1250] Pass arg_scale_out on every cached launch_gemm_a8w8 launch #7920 cached-handle launch works with w_scale_32x32, max error / max |ref| 2.2e-3); the operand guards pass. CPU: test_config_shape_collision 33 passed, -k "mx32 or mxscale" 15 passed. The timings above predate the merge; the kernel file has changed only in a comment since.
  • New 32x32 assert in the blockscale UT: the default sweep (54 runs, M 1..10240) has a mismatch ratio of at most 0.0014; with one K block in 16 of the weight scale one exponent too large it fails (0.74), while the previous script exits 0.

Unverified: e2e and CUDA-graph timing; the selection sweep and public-entry checks after the row refresh; MI250X/MI300X (gfx1250-only change); test_flydsl_batched_gemm.py main() (its fused-quant Triton reference does not compile on this box's Triton 3.6.0, so O-A was measured through the unfused entry and the compute cases and guards were called directly); gfx1250-strict (no hardware). The O-A gains do not apply to ATOM's fused wo_a entry.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

Keys, all gfx1250 / cu_num 256 / w_scale_block 32x32; dense in dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv as (N, K): M list, batched in dsv41_batched_gemm_a8w8_blockscale_mxscale_bpreshuffle_tuned.csv as (b, n, k): m list:

  • Q-A/KV-A (1792, 5120): 512, 544, 576, 640, 672, 704, 768
  • Q-B (32768, 1280): 320, 352, 448, 512..704 step 32, 768
  • O-B (5120, 8192): 288..448 step 32, 512, 544, 576, 608, 704, 768
  • Shared gate/up (4608, 5120): 288..448 step 32, 512, 544, 576, 608, 672, 704, 768
  • Shared down (5120, 2304): 352, 512, 544, 576, 768
  • Engram WKV (25600, 6144): 768
  • O-A batched (8, 1024, 4096): 352, 416, 448, 512..704 step 32

Evidence: the merged runtime tables differ from main only in these keys and in the 58 existing main rows listed in Changes (32 with a different kernel); routing and heuristic code are unchanged; the selection sweep lists every M whose kernel changes for the keys (60 runs, all M <= 768), each timed against main, and the 32 re-picked rows are timed separately (5-process medians).

Changed op tests

  • test_gemm_a8w8_blockscale.py: --w-scale-block 32x32 runs native E8M0 group32 operands (1x32 x_scale, 32x32 w_scale) through gemm_a8w8_blockscale_bpreshuffle. Arguments are validated before the arch skip, so an invalid combination fails on every arch. The mode asserts a mismatch ratio of at most 0.05, because checkAllclose only logs it and catastrophic_check misses a wrong but finite scale block. 128x128 is unchanged.
  • test_flydsl_batched_gemm.py: test_batched_gemm_a8w8_compute (run from main() on gfx1250) times five compute configs (ragged M, persistent and four-buffer tiles, the Q-B three-wide cluster, a cluster_n = 1 fallback) with distinct per-batch scales; the output starts as NaN, must end finite, and each batch must match its own dequantized reference. The existing test_batched_gemm reaches compute kernels only through tuned rows and does not assert, so it would miss wrong batch offsets, strides or the fallback. test_compute_operand_guards launches nothing and checks the rejection of a dense XQ or Out at batch > 1 and of y_scale_out. The compute cases follow get_gfx_runtime() and also run on gfx1250-strict.

@aoli26
aoli26 requested review from a team and a balanced review from Copilot November 9, 2026 13:50
@github-actions

github-actions Bot commented Nov 9, 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 7659 --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.

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.

🟡 Changes recommended

The 32×32 mode runs on incompatible gfx942 backends, and the new batched compute route lacks an asserting numerical regression to catch batch-offset or stride errors.

2 open issues
What changed in this PR

Extends the gfx1250 FlyDSL MXFP8 compute GEMM to support 32×32 weight scales and batched execution, enabling tuned compute kernels for DSv4.1 Flash workloads through existing dispatch paths.

Changes:

  • Adds scale-layout handling and per-batch addressing to the compute kernel and its wrappers.
  • Updates DSv4.1 tuning entries for selected Q-B, O-A and O-B shapes.
  • Adds a dense 32×32 E8M0 scale mode to the blockscale test.
File Description
op_tests/​test_gemm_a8w8_blockscale.py Adds the 32×32 scale test mode and matching reference calculation.
aiter/​ops/​flydsl/​mxfp8_bpreshuffle_gemm_gfx1250.py Passes scale-layout and batch parameters to kernel launches.
aiter/​ops/​flydsl/​kernels/​gemm_a8w8_256x256_gfx1250.py Implements 32×32 scale reads and batched addressing.
aiter/​ops/​flydsl/​batched_gemm_a8w8_gfx1250.py Routes compute kernel names through the dense runner.
aiter/​configs/​model_configs/​dsv41_batched_gemm_a8w8_blockscale_mxscale_bpreshuffle_tuned.csv Adds the batched O-A prefill compute configuration.
aiter/​configs/​model_configs/​dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv Updates O-B decode tuning and adds Q-B/O-B prefill configurations.

Review effort: Balanced

Comment thread op_tests/test_gemm_a8w8_blockscale.py Resolved
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:38
@aiter-bot

aiter-bot commented Nov 9, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 21a8b563de3a · 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

gfx1250 32x32 group32 GEMMs, dense and batched, can run the 256x256 compute kernel when a tuned row names it, including cluster_n = 1 configs on ragged M (the cluster falls back to one workgroup instead of raising). Shapes outside the listed keys keep their selection; within the keys' padded-M reach no M is slower than main. M >= 769, including prefill M=16384, keeps main's selection. The exception is the 32 main rows re-picked in Changes: each is at least 3% faster than main's kernel at its own M (5-process medians), but they were not swept across their padded-M range. The compute route rejects a dense XQ or Out at `batch > 1` (per-batch offsets would go out of bounds) and `y_scale_out`.

The tuned O-A rows are read by `batched_gemm_a8w8_mxscale_bpreshuffle`. ATOM's fused wo_a entry (`..._fused_quant`) passes no kernel_name, does not read them, and is not changed here.

Validation and unverified scope

All on gfx1250 (256 CU):

- Functional (NaN-poisoned output vs FP32 dequantized reference): every timed candidate passes (4855/4856, 15432/15432 M=512..704, 5624/5624 guard rows, 382/382 sweep pairs). The one failure is main's existing `flydsl_bmm_mxfp8_32_wmma_t32x128x256_mw1_nw4_nb2_sk1_cm1_cn1` (inf at M=768, N=32768, K=1280), not selected. Repeated runs are bitwise identical and finite (200 per new M=768/512..704 pick, 20 per guard row).
- Selection sweep vs main (runtime lookup of the 7 shapes, M 1..20000): selection changes in 60 runs of consecutive M, all within M 257..768; every M >= 769 keeps main's kernel. Each run was timed against main's kernel at its ends (up to 9 points): none is slower by more than 1.5% (worst +0.3%, 0.0% on a 3-process recheck). Timings predate dropping the M=16384 rows, which only changed picks at M 8193..16384, and the row refresh above (the 32 re-picked rows are not in this sweep).
- Public entry picks the tuned kernel and passes: 14/14, 114/114, 57/57 (rows at M, M-15/M-31, plus M=300 and 450), also with `FLYDSL_RUNTIME_RUN_ONLY=1` on a fresh AOT cache (before the row refresh). AOT (`python -m aiter.aot.flydsl.gemm --csv ...`), re-run after the row refresh on a fresh cache with FlyDSL 0.5.0: 684 replays, 94 scanned M, 0 failures, `--check` passes, an empty cache fails as expected.
- Row refresh (65 rows): latency is the median of 5 processes (cold weights, rocprofv3 kernel trace, Tukey 1.5xIQR); the 32 re-picked kernels were chosen among 8-10 kernels already tuned for nearby M and pass the NaN-poisoned check against the FP32 reference at M, M-1 and M-15 (92/92).
- ISA vs main: 11/11 existing compute kernels identical. Five batched compute cases pass (they fail with per-batch scales permuted). `test_gemm_group32_interface.py` + `test_gemm_host_dispatch_cache.py`: 188 passed; `test_gemm_a8w8_mxfp8_bpreshuffle.py`: 36 shapes; blockscale UT 128x128 and 32x32 pass; batched a8w8 defaults 50/50; ragged-M cluster fallback all pass; shape-collision guard passes; black and ruff==0.16.0 clean.
- After merging main (`edf58c67a4`) and the review fixes (`6c05f98beb`, `1251a8d`), fresh FlyDSL cache: the five compute cases pass (mismatch ratio 0); the dense memory path launched twice per w_scale layout is bitwise identical (so the #7920 cached-handle launch works with `w_scale_32x32`, max error / max |ref| 2.2e-3); the operand guards pass. CPU: `test_config_shape_collision` 33 passed, `-k "mx32 or mxscale"` 15 passed. The timings above predate the merge; the kernel file has changed only in a comment since.
- New 32x32 assert in the blockscale UT: the default sweep (54 runs, M 1..10240) has a mismatch ratio of at most 0.0014; with one K block in 16 of the weight scale one exponent too large it fails (0.74), while the previous script exits 0.

Unverified: e2e and CUDA-graph timing; the selection sweep and public-entry checks after the row refresh; MI250X/MI300X (gfx1250-only change); `test_flydsl_batched_gemm.py` `main()` (its fused-quant Triton reference does not compile on this box's Triton 3.6.0, so O-A was measured through the unfused entry and the compute cases and guards were called directly); `gfx1250-strict` (no hardware). The O-A gains do not apply to ATOM's fused wo_a entry.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

Keys, all gfx1250 / cu_num 256 / w_scale_block 32x32; dense in `dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv` as (N, K): M list, batched in `dsv41_batched_gemm_a8w8_blockscale_mxscale_bpreshuffle_tuned.csv` as (b, n, k): m list:

- Q-A/KV-A (1792, 5120): 512, 544, 576, 640, 672, 704, 768
- Q-B (32768, 1280): 320, 352, 448, 512..704 step 32, 768
- O-B (5120, 8192): 288..448 step 32, 512, 544, 576, 608, 704, 768
- Shared gate/up (4608, 5120): 288..448 step 32, 512, 544, 576, 608, 672, 704, 768
- Shared down (5120, 2304): 352, 512, 544, 576, 768
- Engram WKV (25600, 6144): 768
- O-A batched (8, 1024, 4096): 352, 416, 448, 512..704 step 32

Evidence: the merged runtime tables differ from main only in these keys and in the 58 existing main rows listed in Changes (32 with a different kernel); routing and heuristic code are unchanged; the selection sweep lists every M whose kernel changes for the keys (60 runs, all M <= 768), each timed against main, and the 32 re-picked rows are timed separately (5-process medians).

Changed op tests

- `test_gemm_a8w8_blockscale.py`: `--w-scale-block 32x32` runs native E8M0 group32 operands (1x32 x_scale, 32x32 w_scale) through `gemm_a8w8_blockscale_bpreshuffle`. Arguments are validated before the arch skip, so an invalid combination fails on every arch. The mode asserts a mismatch ratio of at most 0.05, because `checkAllclose` only logs it and `catastrophic_check` misses a wrong but finite scale block. 128x128 is unchanged.
- `test_flydsl_batched_gemm.py`: `test_batched_gemm_a8w8_compute` (run from `main()` on gfx1250) times five compute configs (ragged M, persistent and four-buffer tiles, the Q-B three-wide cluster, a cluster_n = 1 fallback) with distinct per-batch scales; the output starts as NaN, must end finite, and each batch must match its own dequantized reference. The existing `test_batched_gemm` reaches compute kernels only through tuned rows and does not assert, so it would miss wrong batch offsets, strides or the fallback. `test_compute_operand_guards` launches nothing and checks the rejection of a dense XQ or Out at `batch > 1` and of `y_scale_out`. The compute cases follow `get_gfx_runtime()` and also run on gfx1250-strict.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author

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.

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.

🟡 Changes recommended

The tests can accept unwritten NaN outputs and do not exercise the new persistent-prefetch offset, while the changed decode configuration lacks matching validation.

4 open issues
1 resolved since last review

Review effort: Balanced

Comment thread op_tests/test_flydsl_batched_gemm.py Resolved
Comment thread op_tests/test_flydsl_batched_gemm.py Resolved
Copilot AI balanced review requested due to automatic review settings November 9, 2026 15:01

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.

🟡 Changes recommended

The explicit compute-configuration tests check correctness but omit required timing and throughput metrics and a separate compute benchmark summary.

3 open issues
2 resolved since last review

Review effort: Balanced

Comment thread op_tests/test_flydsl_batched_gemm.py Resolved
Copilot AI balanced review requested due to automatic review settings November 9, 2026 15:23

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

The gfx1250 kernel changes affect synchronization, addressing, and scale prefetching, requiring target-hardware review because GPU validation is unavailable here, a GPU hang is reported, and graph/e2e validation remains incomplete.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:05

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.

🟡 Changes recommended

The tuning tables include M=512–704 workload changes outside the documented scope, requiring either reversion or updated key inventories and correctness/performance evidence covering exact and padded-M selection ranges.

1 open issue

Review effort: Balanced

Resolve the memory-path _launch_gemm_a8w8 call in the mxfp8 dense runner by
keeping main's k_tail and arg_scale_out (#7920) and passing w_scale_32x32 as
b_scale_32x32.
Require XQ/Out strides of batch*K / batch*N when batch > 1 and raise on
y_scale_out with a compute kernelName. Drop the unused
cluster_m_fallback_values and fix the grid.z comment.

Tests: run the compute cases on the runtime arch and on gfx1250-strict, add
test_compute_operand_guards, and validate --w-scale-block 32x32 arguments
before the arch skip.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 07:06
@aoli26

aoli26 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

All six are addressed in 6c05f98.

  1. The only conflict was the memory-path _launch_gemm_a8w8 call: kept [FlyDSL] [gfx1250] Pass arg_scale_out on every cached launch_gemm_a8w8 launch #7920's k_tail / arg_scale_out and pass w_scale_32x32 as b_scale_32x32.
  2. The description now says the O-A rows are reached only through batched_gemm_a8w8_mxscale_bpreshuffle; ATOM's fused wo_a entry passes no kernel_name, so it does not use them. This PR does not touch the fused path. Heads-up for [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667 (from reading the code, not run): once its fused entry passes the tuned kernelName through, the three compute O-A rows (M=416/448/512) reach a kernel with no fused epilogue, so it should skip compute names.
  3. Agreed that whichever lands second re-times back to back. The overlap with [FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668 is five dense keys, the four you listed plus (576, 5120, 8192).
  4. A compute kernelName with y_scale_out now raises ValueError up front.
  5. With batch > 1 the dense runner requires XQ.stride() == (batch*K, 1) and Out.stride() == (batch*N, 1).
  6. The compute test follows the runtime arch and includes gfx1250-strict; removed cluster_m_fallback_values; fixed the grid.z comment; --w-scale-block 32x32 args are validated before the arch skip; Reviewed revision updated.
    New test_compute_operand_guards covers 4 and 5. On gfx1250 I re-ran the five compute cases and the dense memory path launched twice per w_scale layout. gfx1250-strict was not run.

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.

🟡 Changes recommended

The new 32x32 test records comparison failures without asserting the normal mismatch tolerance, allowing finite scale or indexing regressions to pass.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread op_tests/test_gemm_a8w8_blockscale.py Resolved

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Action required before merge (3)

  1. Assert the mismatch tolerance in the new --w-scale-block 32x32 mode. In op_tests/test_gemm_a8w8_blockscale.py:165, err_ck is only recorded. catastrophic_check=True catches non-finite values and very large errors, but a wrong 32x32 scale block or index still gives finite errors and the script exits 0. Add assert err_ck <= 0.05 when w_scale_block == "32x32", and leave 128x128 unchanged. (Copilot, still open.)
  2. Fix the stale module docstring. aiter/ops/flydsl/mxfp8_bpreshuffle_gemm_gfx1250.py:10 still says "B scales are always 32x4 shuffled (N, K//32)". w_scale_32x32 now selects row-major (N//32, K//32).
  3. Import get_gfx_runtime under its own name. from aiter.jit.utils.chip_info import get_gfx_runtime as get_gfx (op_tests/test_flydsl_batched_gemm.py:55) makes every gate in the file read like the build-time get_gfx(), which AGENTS.md says not to use for test gates. Call get_gfx_runtime() directly.

Merge order with #7668 is agreed (whoever lands second re-times the 5 shared dense keys back to back). The two PRs still conflict in the dsv41 dense CSV, mxfp8_bpreshuffle_gemm_gfx1250.py and test_flydsl_batched_gemm.py. MI35X standard shards are still pending. No CI job runs these kernels on gfx1250, so the gfx1250 results in the description are the only hardware evidence; gfx1250-strict has not been run.


Re-reviewed at 6c05f98. Already fixed: merge of #7920 keeps k_tail/arg_scale_out and passes w_scale_32x32 (L452-454); description says the O-A rows do not reach ATOM's fused wo_a entry; y_scale_out + compute name raises ValueError (batched_gemm_a8w8_gfx1250.py:483); batch>1 XQ/Out stride guard (L346), which the in-tree caller satisfies through _check_bmm_operands; runtime arch gate + gfx1250-strict; cluster_m_fallback_values removed; grid.z comment; 32x32 args validated before the arch skip; Reviewed revision updated. Checked OK: per-batch A/B/scale/C offsets (Int64), 32x32 B-scale and c_relocate shift, use_cluster=False paths, cache keys include w_scale_32x32 and batch>1, no duplicate shapes (probe), M=16384 rows unchanged, no conflict with main.

… get_gfx_runtime

Assert the mismatch ratio of the --w-scale-block 32x32 mode of
test_gemm_a8w8_blockscale.py, so a wrong scale block or index fails
instead of only being logged. Describe the row-major w_scale_32x32 B scale
in the module docstring of mxfp8_bpreshuffle_gemm_gfx1250.py, and call
get_gfx_runtime() directly in test_flydsl_batched_gemm.py.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 16:27
@aoli26

aoli26 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

All three are addressed in 1251a8d.

  1. test_gemm_a8w8_blockscale.py: the 32x32 mode now asserts err_ck <= 0.05. The default sweep (54 runs, M 1..10240) stays at or below 0.0014. With one K block in 16 of the weight scale one exponent too large, the assert fails (0.74), while the old script exits 0 on the same error.
  2. The module docstring of mxfp8_bpreshuffle_gemm_gfx1250.py now describes the mxfp8_32 scale layouts: row-major or 32x4-shuffled A scales, and 32x4-shuffled or w_scale_32x32 row-major B scales.
  3. test_flydsl_batched_gemm.py calls get_gfx_runtime() directly, with no alias. The compute cases follow the runtime arch.
    Re-run on gfx1250 after the rename: the operand guards, the five compute cases and the dense memory path pass.

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

The gfx1250 pointer-offset, scale-layout, and synchronization changes require target-hardware validation because no head-matched report was supplied and GPU correctness and performance checks cannot run in this review environment.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Code done — waiting for CI

All three r18 asks are fixed at 1251a8d, and a full re-review of the whole diff found nothing new to change. This can merge once CI is green:

  • MI35X Standard Tests have not started yet. The py3.12 wheel build is still running, so no shard has run, and OPUS Tests (MI35X) is queued. Black, Ruff, Kernel Provider Interface and Triton pass.
  • No CI job runs these kernels on gfx1250. The only hardware evidence is the author's gfx1250 run at 1251a8d (five compute cases, operand guards, dense memory path). gfx1250-strict has not been run.
  • Merge order with #7668 is agreed: whichever PR lands second re-times the 5 shared dense keys back to back. The two PRs still conflict in the dsv41 dense CSV, mxfp8_bpreshuffle_gemm_gfx1250.py and test_flydsl_batched_gemm.py. The PR merges cleanly into main.

Re-reviewed at 1251a8d. Already fixed: the 32x32 mode now asserts err_ck <= 0.05 (test_gemm_a8w8_blockscale.py:166, which matches the checkAllclose default tol_err_ratio); the module docstring describes the w_scale_32x32 row-major (N//32, K//32) B scale (L9-11); test_flydsl_batched_gemm.py calls get_gfx_runtime() with no alias (no get_gfx left). Earlier fixes from r16/r18 still hold. Checked OK again: per-batch Int64 A/B/scale/C offsets, 32x32 B-scale LDS/TDM indexing and the sb_tile_shift, the use_cluster=False barrier/mask paths, cache keys, the batch>1 stride guard and the compute+fused ValueError. The duplicate-shape probe finds 0 duplicates (3814 dense keys, 740 batched).

amd-ruitang3
amd-ruitang3 previously approved these changes Nov 17, 2026
@aoli26
aoli26 requested a review from valarLip November 17, 2026 03:29
…small-M kernels

Re-measure the 32x32 dense rows whose recorded us/TFLOPS/BW were wrong
(e.g. 1792x5120 M=256 34.6 us -> 7.1 us), same cold-weight kernel-trace method as
the tuning runs. Re-pick the kernel of 32 small-M rows that were slower than
neighbouring M (1792x5120 M<=224, 25600x6144 M<=16 and 672..736, ...). Make
5120x8192 M=400..704 same-scale. AOT replay: 684 ok, 0 failed.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 05: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.

🔵 Needs a closer look

The gfx1250 kernel’s addressing, scale staging, and synchronization changes need human validation because no head-matched report was supplied and GPU correctness and paired performance checks cannot run here.

No open issues 🎉

Review effort: Balanced

@aoli26
aoli26 merged commit e9fbe77 into main Nov 17, 2026
@aoli26
aoli26 deleted the gfx1250/dsv41-flydsl-fp8-gemm branch November 17, 2026 08:28
ZLkanyo009 added a commit that referenced this pull request Nov 18, 2026
Conflict in aiter/ops/flydsl/mxfp8_bpreshuffle_gemm_gfx1250.py with #7659
(32x32 w_scale + bmm): both sides added independent parameters to
_run_mxfp8_bpreshuffle_gemm_a8_gfx1250 and to the 2-D launch specialization.
Kept both: main's w_scale_32x32 / batch in place with this branch's
a_scale_preload after them, main's stride_ascale_k = batch * k_blocks for
mxfp8_32 (which never reads a row-major A scale, a_scale_m_major = False),
and w_scale_32x32 followed by a_scale_m_major in the specialization key.

#6696 (OPUS mxfp8 bpreshuffle) needs no change here: its rows are gfx950
only, they run from _gemm_mxscale_bpreshuffle, which gets column-major
x_scale bytes (a row-major one is transposed first), and on gfx1250 the
mxfp8_128 config ignores any non-triton/flydsl row, so the row-major query
and the dispatch keep resolving the same FlyDSL kernel.

Co-authored-by: Cursor <[email protected]>
yhl-amd added a commit to yhl-amd/aiter that referenced this pull request Nov 23, 2026
…j at decode M 928..1536

Two DSv4.1 dense MXFP8 (32x32 weight scale) shapes at the high-concurrency
decode widths:

- engram wkv (N=25600, K=6144): M 928 / 960 / 992 / 1024 move from the
  batched kernel to the 2-D compute kernel t256x256x128 nb2 cm4 cn1; M 1216,
  1280, 1344, 1408, 1472, 1536 had no row (they used the M 2048 row) and get
  the same kernel.
- DSpark main_proj (N=5120, K=15360): M 928 / 960 / 992 / 1024 move to the
  compute kernel t128x256x128 nb3 cm2 cn2; M 1088..1536 (step 64) had no row
  and get the same kernel.

Rows were chosen from measurements inside the decode layer sequence (other
large GEMMs before and after), not back-to-back runs of one kernel. Outputs
are bit identical to the previous kernels. Prefill rows and other shapes are
unchanged.

The 32x32-scale compute kernel these rows name is already in main
(ROCm#7659, ROCm#7827).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yifehuan pushed a commit that referenced this pull request Nov 27, 2026
…j at decode M 928..1536 (#8048)

Two DSv4.1 dense MXFP8 (32x32 weight scale) shapes at the high-concurrency
decode widths:

- engram wkv (N=25600, K=6144): M 928 / 960 / 992 / 1024 move from the
  batched kernel to the 2-D compute kernel t256x256x128 nb2 cm4 cn1; M 1216,
  1280, 1344, 1408, 1472, 1536 had no row (they used the M 2048 row) and get
  the same kernel.
- DSpark main_proj (N=5120, K=15360): M 928 / 960 / 992 / 1024 move to the
  compute kernel t128x256x128 nb3 cm2 cn2; M 1088..1536 (step 64) had no row
  and get the same kernel.

Rows were chosen from measurements inside the decode layer sequence (other
large GEMMs before and after), not back-to-back runs of one kernel. Outputs
are bit identical to the previous kernels. Prefill rows and other shapes are
unchanged.

The 32x32-scale compute kernel these rows name is already in main
(#7659, #7827).

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.

6 participants