You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HIP] [FlyDSL] [Perf] gfx950: 4-wave MXFP8 for DSv4.1 32x32 dense and batched wo_a GEMMs - #8975
Lets the gfx950 4-wave MXFP8 kernel (#8582) run DeepSeek-V4.1's 32x32-weight-scale dense GEMMs and batched wo_a (with fused MXFP8 output quant), adds an mxpsh XCD order _x1_, and switches the DSv4.1 gfx950 tuned rows to them. Prefill GEMMs at M=16384 gain 8-20% TFLOPS on MI355X.
Motivation
The 4-wave kernel is the fastest gfx950 MXFP8 GEMM at large M, but it only took 1x32 weight scales and had no batched entry, so these DSv4.1 GEMMs ran on the slower 8-wave, mxpsh or bmm kernels.
Changes
gfx950 only; used only where a tuned row names the kernel.
32x32 w_scale: read inside the kernel (switch b_scale_32x32, suffix _w32), no host expansion or cache.
Batched wo_a: switches batch / a_scale_rowmajor / fuse_quant (off by default); entry flydsl_mxfp8_4wave_bmm, routed from the bmm runner and the fused-quant op.
Fused quant: one helper shared with the bmm kernel; scale capped at 254 like per_1x32_mx_quant_hip (bmm output changes only on bf16 overflow).
Operand layouts: XQ is made contiguous on every path; an Out with a padded row stride runs into a contiguous scratch copied back, as the 8-wave backend does.
x_scale shuffle: one coalesced Triton kernel, same bytes, 1.2-9x faster.
mxpsh _x1_: M tiles sharing a weight tile stay on one XCD.
Tuners: can pick the 4-wave kernel and mxpsh XCD variants.
Tuned CSVs (gfx950 32x32 rows only): dsv41_..._tuned_gemm.csv 231 rows -> 4-wave (M >= 512), 14 new rows (M = 4224 / 8320), 30 rows at M <= 512 re-selected; dsv4_batched_..._tuned.csv 56 wo_a rows -> 4-wave, 2 new rows.
Performance (if applicable)
MI355X (gfx950, 256 CU), tuned-table kernel time, switched rows confirmed by interleaved A/B.
Hardware
Workload (N,K,M)
Before
After
Change (TFLOPS)
MI355X
wq_b 32768,1280,16384
1967 (mxpsh)
2362
+20.1%
MI355X
wo_b 5120,8192,16384
2713 (8-wave)
2936
+8.2%
MI355X
engram 25600,6144,16384
2665 (8-wave)
2982
+11.9%
MI355X
gate_up 4608,5120,16384
2383 (8-wave)
2679
+12.4%
MI355X
wo_a b=8, 1024,4096,2048
1850 (OPUS bmm)
2168
+17.2%
MI355X
wo_a b=8, 1024,4096,16384
2203 (FlyDSL bmm)
2458
+11.6%
M <= 512: 30 rows +2.6% to +7.9% TFLOPS; at M = 288, 7 non-main-path rows changed kernel, main-path rows unchanged. In-kernel 32x32 read: +0.44% median vs the host expansion the table was measured with.
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
Outputs bit-exact vs the 8-wave kernel (dense) and bmm + quantize_fp8 (batched); in-kernel 32x32 bit-exact vs host expansion.
Not verified: MI250X / MI300X (no changed path runs there), end-to-end model run; _x1_ has no CI test. 3 test_gemm_group32_interface.py failures also occur on base.
PR-specific question
gfx950, MXFP8 with 1x32 x_scale and 32x32 or 1x32 w_scale, only where a tuned row names the kernel; shapes it does not take (N, K multiples of 256, K >= 512, 32-bit sizes) fall back to the existing heuristic.
Changed op tests
op_tests/test_mxfp8_gemm_4wave_dispatch.py: dense 32x32 and batched 4-wave (incl. fused quant) bit-exact with a dispatch spy, batched with 1x32 and 32x32 w_scale (both gather paths), a padded-row-stride Out vs 8-wave, plus a bf16-overflow case for the 254 scale cap. Not covered elsewhere.
github-actionsBot
changed the title
[FlyDSL] [Perf] gfx950: 4-wave MXFP8 for DSv4.1 32x32 dense and batched wo_a GEMMs
[HIP] [FlyDSL] [Perf] gfx950: 4-wave MXFP8 for DSv4.1 32x32 dense and batched wo_a GEMMs
Dec 1, 2026
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 8975 --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.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical scale-cache, weight-size overflow, and assembly clobber defects remain unresolved, while tests can silently exercise fallback paths and lack an independent numerical reference.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The batched path can pass CPU or cross-device operands to a GPU launcher without validation, while the new launcher bypasses AOT export caching and the test runner may skip the added cases.
This return bypasses the existing _bound_launcher.lazy(...) export-to-C path, while compile_mxfp8_4wave_gemm has no AOT binding or source registration. The switched BMM rows therefore take ordinary JIT compilation instead of producing and loading export-cache entries through the GEMM prebuild. Register the 4-wave launcher with aot_factory and its source dependencies, and use its .lazy(...) handle for both prebuild and runtime execution.
Ensure the test runner executes the XCD-remapping cases
op_tests/test_gemm_group32_interface.py:831
The Aiter Test runner defaults to python3 "$file" (.github/scripts/aiter_test.sh:106), but this file has no pytest entry point and is not among its pytest exceptions. Its shard can therefore exit successfully without executing the new XCD-remapping cases. Add a pytest.main entry point or register this file in the runner's pytest cases.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Missing dtype and device validation can cause incorrect kernel inputs or invalid memory accesses, while overflow scale handling breaks quantization equivalence.
Reject multi-byte inputs before reinterpreting tensors as FP8
aiter/ops/flydsl/gemm_a8w8_mxfp8_4wave.py:429
Direct calls to this BMM entry accept multi-byte A/B tensors and reinterpret their bytes as FP8, producing incorrect inputs to the kernel. For example, contiguous float16 XQ shaped [256, 2, 512] occupies 524,288 bytes, but the kernel uses strides and bounds for 262,144 FP8 bytes. Reject non-1-byte XQ/WQ here, as the dense _check_operands does.
Reject non-CUDA inputs and enforce a shared device
aiter/ops/flydsl/gemm_a8w8_mxfp8_4wave.py:467
For M=64, B=2, N=256, K=512, XQ on cuda:0 and a contiguous BF16 Out on CPU or cuda:1 pass this wrapper's checks and reach a cuda:0 launch. These tensors are consumed as device-buffer addresses, so the mismatch can cause invalid memory accesses rather than an input error. Reject non-CUDA XQ and require WQ, both scales, and Out to share its device before shuffling or launching.
Cap E8M0 scale on overflow to match the HIP quantizer
When a BF16 output group contains Inf, emit_mx_e8m0_scale returns 0xFF (an E8M0 NaN), whereas the HIP quantizer caps the scale at 0xFE via mxfp8_cap_scale in csrc/include/mx_quant_utils.h:121. This breaks the promised quantization equivalence for overflow inputs, such as M=1, B=1, N=256, K=512 with A=W=1, x_scale=0xFE, and w_scale=0x7F. Cap the exponent before conversion and storage, and add an overflow regression case.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Missing input-storage and device validation can produce invalid GPU results, while overflow handling causes fused quantization to diverge from the standalone implementation.
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Action required before merge (9)
Thanks. Every switched tuned row is faster than the row it replaces. Dense and batched dispatch fall back cleanly when a 4-wave row does not fit the shape, and non-gfx950 paths are unchanged. Some items need fixing first:
Share the fused-quant epilogue, don't copy it.StoreCLds._quant_store in kernels/mxfp8_gemm_4wave.py (:751-790) repeats kernels/bmm_a8w8_mxscale_gfx950.py:1187-1218: the 1e-10 floor, emit_mx_e8m0_scale, and the cvt_scalef32_pk_fp8_bf16 pack. The copies already differ: only the 4-wave one caps E8M0 at 254 (:771). On bf16 overflow, the two gfx950 kernels behind batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant therefore write different y_scale bytes for the same input. Put one helper in kernels/quant_utils.py and call it from both kernels.
Read 32x32 w_scale in the kernel instead of expanding it on the host._w_scale_shuffled caches a 32x expansion to 1x32, N*K/32 bytes per weight (4.9 MB for 25600x6144, 2 MB for wo_a at b=16). Entries are never evicted, and past _W_SCALE_CACHE_MAX = 512 every call silently re-expands and reallocates. The 8-wave kernel already reads 32x32 scales (gemm_a8w8_mxfp8_8wave.py:353). If you keep the expansion, state the per-GPU memory and the weight count at the shipped TP.
Delete the dead _shuffle_scale_kernel (kernels/mxfp8_scale_shuffle_triton.py:12-34). Nothing calls it anymore. Move its layout docstring to _shuffle_scale_rm_kernel, whose docstring now only points at the old kernel (:41).
Test the 254 clamp, and close the Copilot threads. The test scale bytes are 110-139 at K ≤ 4096, so deleting _min(e8, 254) (mxfp8_gemm_4wave.py:771) still passes. Add a deterministic overflow case checked against per_1x32_mx_quant_hip. Fix or rebut the independent-fp32-reference thread (test_mxfp8_gemm_4wave_dispatch.py:376), then resolve both threads.
Correct the PR body.
The wq_b 32768,1280,16384 "before" kernel is mxpsh (flydsl_mxpsh_128x256x128_..._x4_sk1), not 8-wave.
The body gives both "29 decode rows" and "30 rows 2.6-7.9%". The CSV has 30 changed rows at M ≤ 512, gaining 2.5-7.3%.
Fix the stale comments. The comment above _W_SCALE_CACHE leaves out the new rows key field. kernels/gemm/mxscale_preshuffle.py:514 says "no-op when xcd_swizzle<=0", but the bound is now <=1. The batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant docstring does not mention the gfx950 4-wave path.
Handle _x1_ with fused split-K. The x1 remap runs only when bids is None. In the 1-D fused_l2 grid (mxscale_preshuffle.py:1683-1700), x1 therefore means no swizzle. mxpsh_xcd_candidates still generates x1 variants of _fsk seeds. Exclude that combination in the tuner; no shipped row uses it today.
Follow the aiter/ops/flydsl/AGENTS.md raw-API rule. The new raw calls carry no comment naming the missing stable API: create_buffer_resource/buffer_store in the quant store, _llvm.LoadOp/_rocdl.perm_b32 in _read_half_rowmajor, fx.arith.select/trunci, and the new inline asm in gather_soff. Use fx.copy/buffer tensors where they exist; otherwise add the comment.
Squash text. The commits include "refine code" three times, "fix conflict", and a malformed "FlyDSL] [Perf] ... restore the 128-bit quad reduce" whose change is not in the final diff. Use the PR title plus a corrected body as the squash message.
Checked OK: CSV rows (274 = 260 + 14, 58 = 56 + 2) are all gfx950 32x32 with no duplicates, including across the family merge; they are sorted by (N,K) then M, and untouched rows are identical. The cache key includes rows. The x1 tile map is bijective. The int32 bounds hold. The AOT sources are declared. The new op test is picked up by the MI35X shards; it covers dense 32x32, bmm, fused quant and both x_scale layouts, but not _x1_.
Root cause vs patch: right direction with patch-like parts. The kernel extension and the retune are real wins. Two parts are patches: 32x32 support is a host-side 32x scale expansion cached forever, where the root fix is the kernel reading 32x32 scales like the 8-wave one. The fused-quant epilogue is a drifting copy, where the root fix is one shared helper.
Reviewed at 99f66be (round 1, passA; size-split waived by the user).
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new 32x32 path can produce incorrect results for column-strided activations and rejects padded-row caller-owned outputs supported by the existing backend.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the added tests exercise a different kernel, leaving the new mxpsh XCD swizzle’s tile and split assignments without direct correctness coverage.
Thanks. Every switched tuned row is faster than the row it replaces. Dense and batched dispatch fall back cleanly when a 4-wave row does not fit the shape, and non-gfx950 paths are unchanged. Some items need fixing first:
Share the fused-quant epilogue, don't copy it.StoreCLds._quant_store in kernels/mxfp8_gemm_4wave.py (:751-790) repeats kernels/bmm_a8w8_mxscale_gfx950.py:1187-1218: the 1e-10 floor, emit_mx_e8m0_scale, and the cvt_scalef32_pk_fp8_bf16 pack. The copies already differ: only the 4-wave one caps E8M0 at 254 (:771). On bf16 overflow, the two gfx950 kernels behind batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant therefore write different y_scale bytes for the same input. Put one helper in kernels/quant_utils.py and call it from both kernels.
Read 32x32 w_scale in the kernel instead of expanding it on the host._w_scale_shuffled caches a 32x expansion to 1x32, N*K/32 bytes per weight (4.9 MB for 25600x6144, 2 MB for wo_a at b=16). Entries are never evicted, and past _W_SCALE_CACHE_MAX = 512 every call silently re-expands and reallocates. The 8-wave kernel already reads 32x32 scales (gemm_a8w8_mxfp8_8wave.py:353). If you keep the expansion, state the per-GPU memory and the weight count at the shipped TP.
Delete the dead _shuffle_scale_kernel (kernels/mxfp8_scale_shuffle_triton.py:12-34). Nothing calls it anymore. Move its layout docstring to _shuffle_scale_rm_kernel, whose docstring now only points at the old kernel (:41).
Test the 254 clamp, and close the Copilot threads. The test scale bytes are 110-139 at K ≤ 4096, so deleting _min(e8, 254) (mxfp8_gemm_4wave.py:771) still passes. Add a deterministic overflow case checked against per_1x32_mx_quant_hip. Fix or rebut the independent-fp32-reference thread (test_mxfp8_gemm_4wave_dispatch.py:376), then resolve both threads.
Correct the PR body.
The wq_b 32768,1280,16384 "before" kernel is mxpsh (flydsl_mxpsh_128x256x128_..._x4_sk1), not 8-wave.
The body gives both "29 decode rows" and "30 rows 2.6-7.9%". The CSV has 30 changed rows at M ≤ 512, gaining 2.5-7.3%.
Fix the stale comments. The comment above _W_SCALE_CACHE leaves out the new rows key field. kernels/gemm/mxscale_preshuffle.py:514 says "no-op when xcd_swizzle<=0", but the bound is now <=1. The batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant docstring does not mention the gfx950 4-wave path.
Handle _x1_ with fused split-K. The x1 remap runs only when bids is None. In the 1-D fused_l2 grid (mxscale_preshuffle.py:1683-1700), x1 therefore means no swizzle. mxpsh_xcd_candidates still generates x1 variants of _fsk seeds. Exclude that combination in the tuner; no shipped row uses it today.
Follow the aiter/ops/flydsl/AGENTS.md raw-API rule. The new raw calls carry no comment naming the missing stable API: create_buffer_resource/buffer_store in the quant store, _llvm.LoadOp/_rocdl.perm_b32 in _read_half_rowmajor, fx.arith.select/trunci, and the new inline asm in gather_soff. Use fx.copy/buffer tensors where they exist; otherwise add the comment.
Squash text. The commits include "refine code" three times, "fix conflict", and a malformed "FlyDSL] [Perf] ... restore the 128-bit quad reduce" whose change is not in the final diff. Use the PR title plus a corrected body as the squash message.
Checked OK: CSV rows (274 = 260 + 14, 58 = 56 + 2) are all gfx950 32x32 with no duplicates, including across the family merge; they are sorted by (N,K) then M, and untouched rows are identical. The cache key includes rows. The x1 tile map is bijective. The int32 bounds hold. The AOT sources are declared. The new op test is picked up by the MI35X shards; it covers dense 32x32, bmm, fused quant and both x_scale layouts, but not _x1_.
Root cause vs patch: right direction with patch-like parts. The kernel extension and the retune are real wins. Two parts are patches: 32x32 support is a host-side 32x scale expansion cached forever, where the root fix is the kernel reading 32x32 scales like the 8-wave one. The fused-quant epilogue is a drifting copy, where the root fix is one shared helper.
Reviewed at 99f66be (round 1, passA; size-split waived by the user).
Thanks for the second review.
Shared quant tail: 4-wave and bmm both call quant_utils.emit_mxfp8_quant_bf16_words; both cap the scale at 254, so the bmm output changes only on bf16 overflow.
32x32 w_scale: read in the kernel (switch b_scale_32x32, suffix _w32); no host expansion, no cache entry. Bit-identical to the old path; +0.44% median kernel time. ISA unchanged with the switch off.
_shuffle_scale_kernel removed; its layout notes moved to _shuffle_scale_rm_kernel.
Cap test added: test_bmm_fused_quant_caps_the_scale_on_bf16_overflow (4-wave and bmm, byte-exact vs per_1x32_mx_quant_hip; fails without the cap). FP32 reference: my earlier reply overstated it. test_4wave_vs_fp32_reference covers dense 1x32 only; the 32x32 and batched paths are covered through bit-equality with the bmm kernel, which test_flydsl_batched_gemm.py checks against FP32. Happy to add a direct FP32 check if you want it.
Description corrections (carried into the squash message): wq_b 32768,1280 and 4096,1280 were mxpsh, not 8-wave; 30 rows changed at M <= 512 (TFLOPS +2.6% to +7.9%); at M = 288, 7 non-main-path rows changed kernel, main-path rows unchanged; 4-wave rows start at M = 512; x_scale shuffle is 1.2-2.6x faster dense and 9x for batched wo_a.
Stale comments fixed (_W_SCALE_CACHE, xcd_swizzle, fused_quant docstring).
_x1_ + _fsk: the tuner no longer offers xcd 1 for fused split-K seeds.
Raw APIs: the row-major scale LDS read uses fx.copy; the remaining raw calls are commented with the missing API and evidence (fx.copy store: 4988 -> 5471 instructions).
Squash: PR title + description with the corrections in (5).
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Action required before merge (5)
Thanks. The kernel now reads 32x32 w_scales itself, and both gfx950 kernels share one fused-quant helper with the 254 cap. I emulated the new 32x32 gather and read on CPU against the old 1x32 shuffled layout, for both gather paths, and every byte matches. The cap test and all 8 _w32 dispatch cases ran in MI35X shard 5 (82 passed, 0 skipped). Prior asks 1, 2, 3, 6, 7, 8 and 9 are fixed. Ask 4 is partly done: the threads are still open. Ask 5 is partly done: the reviewed revision is stale. Small items left:
Stale text from removing the host expansion.gemm_tune/flydsl_gemm_mxscale_preshuffle_common.py:633 still says "The backend expands a 32x32 w_scale to 1x32 rows (cached per weight)". Change it to "the kernel reads a 32x32 w_scale as is". In gemm_a8w8_mxfp8_4wave.py:221-224, the _launch docstring says **batched holds only batch / n_per_batch / a_scale_rowmajor / fuse_quant. The dense 32x32 path now also passes b_scale_32x32 through it. Rename the kwargs and list b_scale_32x32.
Dead branches in ScaleGatherLDS (kernels/mxfp8_gemm_4wave.py). self.four (:428) is only an alias of a_rowmajor. _set_tile_voff_four runs only when a_rowmajor is set, so its else: va = (grp * row_i32 + L) * 4 (:502-503) and the A else soff_v in gather_soff (:533) never run. Drop the alias and both branches. _read_half_w32 and _read_half_rowmajor also build the same 8-byte LDS pointer type and UniversalCopy64b atom: share one ds_read_b64 helper.
Batched 1x32 w_scale lost its test. Before this round, every batched test ran the four-load gather with shuffled W scales, because 32x32 was expanded to 1x32. Now _bmm_operands and the cap test only build 32x32 scales. bmm_4wave_runs still accepts 1x32 (w_n in (1, 32)), but no test covers the four-load shuffled-W branch (:504-507). Parametrize test_bmm_bit_identical_to_bmm_kernel over 1x32 and 32x32. Include one row-major x_scale shape (300,8,1024,4096) and one shuffled shape (4224,8,1024,4096).
Close the three Copilot threads. The padded-stride fix (gemm_a8w8_mxfp8_4wave.py:407-420, scratch copied back as the 8-wave backend does) has no test. Add Copilot's case: M=300, N=1792, K=5120, with Out = backing[:, :1792], compared with 8-wave. Your FP32-reference rebuttal is sound: 32x32 and batched outputs are bit-equal to the bmm kernel, and test_flydsl_batched_gemm.py checks that kernel against FP32. Post it in the thread at test:376. Then resolve that thread, the clamp thread (now covered by test_bmm_fused_quant_caps_the_scale_on_bf16_overflow) and the stride thread.
PR body: "Reviewed revision 3d8d46d" is stale. eb7f388 changed the Out handling and the 32x32 XQ contiguity after that validation. Set it to eb7f388 and state the validation at that revision; this also clears the aiter-bot Self-Review SHA check.
Checked OK: CSVs are unchanged since round 1. Rerun against base: 14 + 2 new rows, all gfx950 / 256 CU / 32x32. There are no duplicates within a file or across the family merge. New rows are sorted by M within (N, K), and no switched row is slower. The body numbers match the CSV (231 rows switch to 4-wave from M=512; 30 decode rows gain +2.6% to +7.9% TFLOPS). Tuned names need no _w32 suffix, because the backend picks the 32x32 read from the w_scale shape. The tuner no longer offers x1 for _fsk seeds (mutant checked). New raw calls carry the AGENTS.md comment, and the row-major LDS read uses fx.copy. The +0.44% median for the in-kernel read is smaller than the smallest switched-row gain (2.1%).
Root cause vs patch: root fix. The 32x32 host expansion and the copied quant epilogue are replaced by the in-kernel 32x32 read and one shared helper. The items above are cleanup and coverage.
Reviewed at eb7f388 (round 2, passA; pass B not needed, verdict request_changes; size-split waived by the user). Already fixed: shared quant helper + cap, in-kernel 32x32 w_scale, dead shuffle kernel, stale comments, x1/fsk tuner filter, raw-API comments, body numbers. Merger: the repo squash default is COMMIT_MESSAGES ("refine code" x4, "fix conflict"), so squash with the PR title + body as agreed.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new _x1_ coordinate remap lacks explicit regression coverage against _x0_ for tile boundaries, eight-group rounds, and non-fused split-K, leaving tile coverage and batch/split indexing unverified.
Stale text: fixed. flydsl_gemm_mxscale_preshuffle_common.py:633 now says the kernel reads 32x32 as is, and the _launch docstring lists b_scale_32x32.
Dead branches: fixed. self.four is gone. _set_tile_voff_four and the four-load gather_soff are reachable only under a_rowmajor (set_tile_voff at :482; call sites :1273/:1325/:1484). _ds_read_b64 keeps the same pointer type, alignment, view and copy atom, at the same addresses.
Lost 1x32 coverage: fixed. test_bmm_bit_identical_to_bmm_kernel adds two 1x32 rows. On a 256-CU gfx950, M=300 takes the four-load gather (row-major x_scale) and M=4224 takes the dwordx4 gather. The spy also checks b_scale_32x32.
Padded-stride Out: fixed. test_dispatch_padded_row_stride_output (M=300, N=1792, K=5120, Out = backing[:, :1792]) asserts that the 4-wave kernel ran, that the output is bit-equal to the 8-wave output, and that the padding is untouched. All review threads are resolved.
Before merge: the new GPU tests (1 padded-stride + 8 bmm) have no CI run at this head yet. Only the wheel build is pending, and no MI35X op-test shard has run. Merge after a green MI35X op-test shard. Squash with the PR title + body as agreed: aiter's default squash uses the commit list ("refine code ×5", "fix conflict").
Root cause vs patch
Root fix. The kernel reads the 32x32 w_scale itself, and both gfx950 kernels share one fused-quant helper with the 254 cap. Nothing in this round is patch-like.
…red group-32 scale
_fused_quant_tuned_kernel imports the gfx1250 compute-kernel name check
only on gfx1250, after the table lookup; gfx950 returns the flydsl row's
name directly, as before the merge with the gfx1250 lookup. The gfx950 bmm
fused epilogue calls emit_mxfp8_group32_scale instead of its own copy of
the same steps (1e-10 floor, RoundUp e8m0, f32 scale). Two docstrings no
longer say the fused epilogue always quantizes the bf16 C tile.
Tests: FUSED_QUANT_TILES also pins the DSv4.1 wo_a tuned tiles the fused
entry runs (t192x128x256, t128x256x256 mw1 nw4, t96x128x256, and the
LDS-staged t32x32x512); the gfx1250 tuned-row fixture uses a CU count
other than the gfx950 one so the lookup must forward the caller's.
Rebased onto main: ROCm#8975 already moved the gfx950 bmm fused epilogue onto
quant_utils.emit_mxfp8_quant_bf16_words, so that file keeps main's version.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets the gfx950 4-wave MXFP8 kernel (#8582) run DeepSeek-V4.1's 32x32-weight-scale dense GEMMs and batched
wo_a(with fused MXFP8 output quant), adds an mxpsh XCD order_x1_, and switches the DSv4.1 gfx950 tuned rows to them. Prefill GEMMs at M=16384 gain 8-20% TFLOPS on MI355X.Motivation
The 4-wave kernel is the fastest gfx950 MXFP8 GEMM at large M, but it only took 1x32 weight scales and had no batched entry, so these DSv4.1 GEMMs ran on the slower 8-wave, mxpsh or bmm kernels.
Changes
gfx950 only; used only where a tuned row names the kernel.
b_scale_32x32, suffix_w32), no host expansion or cache.wo_a: switchesbatch/a_scale_rowmajor/fuse_quant(off by default); entryflydsl_mxfp8_4wave_bmm, routed from the bmm runner and the fused-quant op.per_1x32_mx_quant_hip(bmm output changes only on bf16 overflow)._x1_: M tiles sharing a weight tile stay on one XCD.dsv41_..._tuned_gemm.csv231 rows -> 4-wave (M >= 512), 14 new rows (M = 4224 / 8320), 30 rows at M <= 512 re-selected;dsv4_batched_..._tuned.csv56wo_arows -> 4-wave, 2 new rows.Performance (if applicable)
MI355X (gfx950, 256 CU), tuned-table kernel time, switched rows confirmed by interleaved A/B.
wq_b32768,1280,16384wo_b5120,8192,16384wo_ab=8, 1024,4096,2048wo_ab=8, 1024,4096,16384M <= 512: 30 rows +2.6% to +7.9% TFLOPS; at M = 288, 7 non-main-path rows changed kernel, main-path rows unchanged. In-kernel 32x32 read: +0.44% median vs the host expansion the table was measured with.
Testing
Documentation
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
2f9b5c1
Behavior and intent
DSv4.1's 32x32 dense GEMMs and batched
wo_arun the 4-wave kernel where tuned rows name it; before, the kernel rejected these shapes.Validation and unverified scope
MI355X, this revision:
test_flydsl_batched_gemm.pybit-exact.quantize_fp8(batched); in-kernel 32x32 bit-exact vs host expansion.Not verified: MI250X / MI300X (no changed path runs there), end-to-end model run;
_x1_has no CI test. 3test_gemm_group32_interface.pyfailures also occur on base.PR-specific question
gfx950, MXFP8 with 1x32 x_scale and 32x32 or 1x32 w_scale, only where a tuned row names the kernel; shapes it does not take (N, K multiples of 256, K >= 512, 32-bit sizes) fall back to the existing heuristic.
Changed op tests
op_tests/test_mxfp8_gemm_4wave_dispatch.py: dense 32x32 and batched 4-wave (incl. fused quant) bit-exact with a dispatch spy, batched with 1x32 and 32x32 w_scale (both gather paths), a padded-row-stride Out vs 8-wave, plus a bf16-overflow case for the 254 scale cap. Not covered elsewhere.