Repository navigation
[FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning - #7659
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
There was a problem hiding this comment.
🟡 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
NOT READY FOR HUMAN REVIEWPR 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 |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
🔵 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
There was a problem hiding this comment.
🟡 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.
|
All six are addressed in 6c05f98.
|
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (3)
- Assert the mismatch tolerance in the new
--w-scale-block 32x32mode. Inop_tests/test_gemm_a8w8_blockscale.py:165,err_ckis only recorded.catastrophic_check=Truecatches non-finite values and very large errors, but a wrong 32x32 scale block or index still gives finite errors and the script exits 0. Addassert err_ck <= 0.05whenw_scale_block == "32x32", and leave 128x128 unchanged. (Copilot, still open.) - Fix the stale module docstring.
aiter/ops/flydsl/mxfp8_bpreshuffle_gemm_gfx1250.py:10still says "B scales are always 32x4 shuffled(N, K//32)".w_scale_32x32now selects row-major(N//32, K//32). - Import
get_gfx_runtimeunder 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-timeget_gfx(), which AGENTS.md says not to use for test gates. Callget_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.
|
All three are addressed in 1251a8d.
|
There was a problem hiding this comment.
🔵 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
left a comment
There was a problem hiding this comment.
✅ 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-stricthas 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.pyandtest_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).
…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.
There was a problem hiding this comment.
🔵 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
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]>
…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]>
…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]>

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: constexprsb_scale_32x32(row-major[N/32, K/32]B scale) andbatched(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 takesw_scale_32x32andbatch;resolve_cluster_mmay fall back to cluster_m = 1 for compute kernels. Withbatch > 1it requiresXQ.stride() == (batch*K, 1)andOut.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 withy_scale_outraises (no fused quant epilogue).test_gemm_a8w8_blockscale.pygets a--w-scale-block 32x32mode that asserts a mismatch ratio of at most 0.05;test_flydsl_batched_gemm.pygetstest_batched_gemm_a8w8_compute(five explicit compute cases, per-batch reference check) andtest_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.
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):
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
Documentation
Dependencies
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) andy_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):
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).FLYDSL_RUNTIME_RUN_ONLY=1on 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,--checkpasses, an empty cache fails as expected.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.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 withw_scale_32x32, max error / max |ref| 2.2e-3); the operand guards pass. CPU:test_config_shape_collision33 passed,-k "mx32 or mxscale"15 passed. The timings above predate the merge; the kernel file has changed only in a comment since.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.pymain()(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.csvas (N, K): M list, batched indsv41_batched_gemm_a8w8_blockscale_mxscale_bpreshuffle_tuned.csvas (b, n, k): m list: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 32x32runs native E8M0 group32 operands (1x32 x_scale, 32x32 w_scale) throughgemm_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, becausecheckAllcloseonly logs it andcatastrophic_checkmisses a wrong but finite scale block. 128x128 is unchanged.test_flydsl_batched_gemm.py:test_batched_gemm_a8w8_compute(run frommain()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 existingtest_batched_gemmreaches compute kernels only through tuned rows and does not assert, so it would miss wrong batch offsets, strides or the fallback.test_compute_operand_guardslaunches nothing and checks the rejection of a dense XQ or Out atbatch > 1and ofy_scale_out. The compute cases followget_gfx_runtime()and also run on gfx1250-strict.