Repository navigation
Conversation
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 |
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
0dde638 to
d272f7d
Compare
|
Rebased onto the current #7668 head Rebase. The only conflict was Re-timing the
So the pipelined loop pays off for the 128-deep wq_b tile ( gfx1250 run at Description is updated with the PR Self-Review section (Reviewed revision |
dac9c3f to
091be1d
Compare
|
Rebased onto #7668's new head Nothing changes for 128-deep tiles: the default pick still needs tile_k >= 256, so such a tile runs the pipelined loop only when its name ends in gfx1250 at |
|
No activity for 15 days, so this is now labelled |
…ed entry runs the tuned row Fused MXFP8 epilogue: when the warp tile holds an even number of 16-column WMMA tiles (even wmma_n_rep), the group-32 quant reads the accumulators instead of staging the bf16 C tile in LDS and re-reading it per group. A lane holds 8 consecutive columns of one row per 16x16 tile, so a 32-column group is two adjacent tiles across lanes l and l^16 and its amax is one shuffle_xor(16). Values are rounded to the output dtype first, exactly as the bf16 path stores them, so the e4m3 codes and e8m0 scales are unchanged; the e4m3 and scale bytes still go through LDS for the TDM store. An odd wmma_n_rep keeps the LDS-staged quant. The epilogue has three peer branches (bf16 store, accumulator quant, LDS-staged quant) with the quant setup and the group-32 scale step shared by the two quant branches. batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant looks the shape up in the same preshuffle table as the bf16 entry and passes a flydsl row's kernelName to the runner, so both entries run the same tuned tile. No row, an opus row or a compute-kernel row leaves the tile to the runner; any other name is passed through, so a name the runner does not accept raises, as for the bf16 entry. Tests: op_tests/test_flydsl_batched_gemm.py checks the fused quant on tuned tiles that pin each epilogue branch (two LDS-staged, seven accumulator) at ragged M against quantize_fp8 of the bf16 GEMM on the same tile; op_tests/test_bmm_a8w8_fused_quant_tuned_row.py is a CPU test of the tuned-row lookup. Rebased onto main: the LDS-staged C tile follows ROCm#8737 (staged at C_OFF, LDS flush before the TDM store on the unfused path). Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the merge with main's gfx950 fused quant, one _fused_quant_tuned_kernel serves both arches. The CPU test now also checks a gfx950 flydsl row (passed through) and a gfx950 opus row or no row (runner's choice). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The batched mxfp8_32 kernel's accumulator quant and the 256x256 compute kernel's fused epilogue emitted the same per-group step (round to the output dtype, h0/h1 amax with one shuffle_xor(16), 1e-10 floor, RoundUp e8m0, scaled fp8 conversion, e4m3 and scale bytes into LDS) and the same scale-row store. Both now call emit_mxfp8_acc_pair_to_lds and emit_mxfp8_scale_rows_store in kernels/quant_utils.py, next to emit_mx_e8m0_scale; emit_mxfp8_group32_scale (floor + RoundUp scale) is also used by the batched kernel's LDS-staged quant. Each kernel keeps its own e4m3 TDM store. No change in the emitted code is intended. Co-Authored-By: Claude Opus 5.5 <[email protected]>
FUSED_QUANT_TILES adds t64x32x512 mw4 nw1 (one quant group per tile row) and t160x128x256 nw2 (more tile rows than threads, so the scale rows take a second pass), both shipped DSv4.1 rows on the accumulator branch that no test pinned. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The scale-row store loops ceil(tile_m / block) times, so a thread copies rows tid, tid + block, ...; say that in the helper docstring and at both kernel call sites instead of "one row per thread". In quant_utils, the native-scale helper no longer refers to a function that does not exist, and the module docstring names the dtypes _DTYPE_CFG actually defines. The gfx950 tuned-row test uses the DSv4 batched preshuffle table's row for its shape. Comments and test data only; no kernel change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
Two LDS-staged tiles (t16x64 nw4, t32x32 nw2) and seven accumulator tiles, as the tuple and the module docstring list them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fragments of k-step g+1 are read from LDS while the WMMAs of k-step g run, across K-tile boundaries too, so LDS reads, WMMAs and the TDM refill overlap. The fence before the next K-tile is split into signal/wait (the primitives the 256x256 compute kernel already uses) around the two halves of the last k-step's WMMAs, and the per-stage LDS read bases are formed a tile ahead. Every accumulator sees its k-steps in the same order with the same operands, so results are bit-identical to the single-fence loop. New pipelined constexpr, appended after fuse_quant_out: -1 (default) takes the pipelined loop for mxfp8_32, no scale preload, no cluster, split_k 1, tile_k >= 256 when the accumulators plus two in-flight fragment sets fit the register estimate; 1 forces it (batched kernel names may end in _pl; tile_k < 256 is rejected), 0 keeps the old loop. No new environment variable. The DSv4.1 mxscale table rows for N=5120, K=8192 at M 672/768 and for N=32768, K=1280 at M 576/672/768 are replaced in place with tiles that use the pipelined loop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pipelined constexpr now defaults to 0 and takes only 0 or 1; the automatic rule that moved every eligible mx32 tile onto the new loop is gone, so existing tuned rows keep the loop they were timed on. A trailing _pl in a batched or 2-D mxfp8_32 kernelName is the only way to select it, and check_pipelined_k_loop() is the single place that rejects it where the loop does not apply (it replaces the batched runner's tile_k check). The DSv4.1 rows validated with the pipelined loop now carry _pl: N=5120, K=8192 at M 576 / 672 / 768 (the latter two are the t192x128x256 rows that relied on the automatic rule); the N=32768, K=1280 rows already did. Also drop the unused pipelined argument of bmm_mx32_kernel_name, share the fragment join of load_a / load_b and the serpentine WMMA order with the pipelined loop, and fix the tail fence comment. Tests: CPU checks of the _pl name round trip (batched and 2-D) and of the rejections in op_tests/test_gemm_host_dispatch_cache.py; on gfx1250, op_tests/test_flydsl_batched_gemm.py compares _pl with the single-fence loop bit for bit on a ragged K and on a shipped _pl row, and runs the fused quant epilogue on a _pl tile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in's tile; test nb3/nb4 Re-timed the pipelined rows against the retuned tiles now on main for the six DSv4.1 2-D keys on one gfx1250 box. The pipelined t192x256x256 tile stays ahead at M 576 and 768 for N=32768, K=1280; the other four keys keep main's rows. PIPELINED_CASES also compares the pipelined and single-fence loops on a three-buffer and a four-buffer tile, where the tail fences differ from the steady loop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the fence wait the wave refills the stage tile kt held and then reads the first fragments of tile kt+1; the comment had the two steps swapped. Comment only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The us, tflops and bw of the two kept _pl rows (N=32768, K=1280 at M 576 and 768) were main's values scaled by a paired ratio. Replace them with values measured on gfx1250 through the MXFP8 GEMM tuner's harness (its data generation, B=1 batched run path, mp_tuner timing, error check and throughput formula), bw in the unit of the neighbouring gfx1250 rows. The kernelName of both rows is unchanged, so dispatch is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`_pl` stays the only switch of the software-pipelined K loop: a kernelName without it runs the single-fence loop it was tuned on, in the batched and the 2-D paths alike. CPU tests pin that: - untagged 2-D names on which the pipelined loop would apply (tile_k 256, split_k 1, before and after cluster_m is fitted to M) resolve to the single-fence loop, and their `_pl` names to the pipelined one; no other suffix parses; - every mxfp8_32 kernelName in the shipped tuned tables runs the pipelined loop exactly when it ends in `_pl`. Kernel comments: the early per-stage LDS bases are formed a tile ahead only when `early` holds, and the tail's max(..., 0) only touches the last tile's unused fence count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
check_pipelined_k_loop rejected a _pl kernelName with tile_k < 256 (one 128-deep k-step per K-tile). The pipelined loop does not need two k-steps: with one, the last-k-step branch is the only one taken, so the next tile's first fragments are read and its stage refilled during the second half of this tile's WMMAs, behind the same split fence. Every accumulator still sees its k-steps in the same order with the same operands, so the output is bit-identical to the single-fence loop. Only a kernelName that ends in _pl selects the loop, so nothing changes for existing rows. It lets 128-deep tiles that keep two workgroups per CU (for example t96x256x128 mw1 nw4) overlap their LDS reads with the WMMAs. Tests: test_gemm_host_dispatch_cache.py drops the tile_k rejection; test_flydsl_batched_gemm.py compares _pl with the single-fence loop bit for bit at tile_k = 128 (b = 8 and b = 1 decode shapes, and a ragged K). Depends on ROCm#7668 (the _pl loop, on ROCm#7667); this branch carries their commits until they merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
091be1d to
c4edcc4
Compare
|
Re-stacked on the current #7668 |
Update (12-04): re-stacked on the current #7668
dde80aaad(on main4052b38ae; it was on #7668's 11-17 head292a532f8); headc4edcc4fa, previous head091be1d9ekept asbak/8058-pre1204a. The only conflict was again thePIPELINED_CASEScomment: #7668 now compares a name without_pl(single-fence loop) with the same name plus_pl, so the_noplwording is gone and this PR'stile_k = 128cases are listed in that comment.Validation of the rebased heads, CPU only:
black --check,ruff checkandpy_compileon every changed file. The CPU op tests that import aiter's built modules were not rerun at these heads.Stacked on #7668 (which is on #7667); only the last commit is new here. Please merge #7667, then #7668; this PR will be rebased onto main after that.
Motivation
The software-pipelined K loop (
_plkernel names, #7668) was limited totile_k >= 256. Some 128-deep tiles are ahead of the current selection once they run the pipelined loop: at the DSv4.1 wq_b decode key(M, N, K) = (1344, 32768, 1280),t224x256x128 mw2 nw2 nb3 _plis ahead of main's tuned row (t128x256x128 mw1 nw4 nb3) and of the same tile without_pl(relative timings on gfx1250 in the PR comments). Not every 128-deep tile gains: at the batched wo_a key(b, M, N, K) = (8, 1344, 1024, 4096),t96x256x128 mw1 nw4 nb3 _plstays behind main's selection, so it is only a correctness case here.This PR adds no tuned rows; it only lets a tuned row name a 128-deep
_pltile.Technical Details
check_pipelined_k_loopno longer requirestile_k >= 256(thetile_kargument is dropped). With one 128-deep k-step per K-tile the loop only takes its last-k-step branch: the stage is refilled and the next tile's first fragments are read during the second half of the current tile's WMMAs, behind the same split fence. Every accumulator still sees its k-steps in the same order with the same operands, so the output is bit-identical to the single-fence loop._plselects the loop, so existing tuned rows and the default selection are unchanged. No new environment variables.Test Plan
op_tests/test_gemm_host_dispatch_cache.py: thetile_krejection test is removed; the remaining rejections (non-mx32, scale preload, cluster, split-K, values other than 0/1) are kept.op_tests/test_flydsl_batched_gemm.py(gfx1250):PIPELINED_CASESaddstile_k = 128cases compared bit for bit with the single-fence loop:b=8, M=1344, 1024 x 4096(t96x256x128 mw1 nw4 nb3),b=1, M=1344, 32768 x 1280(t224x256x128 nb3) and a ragged-K case (t64x128x128, K = 576).Test Result
PR Self-Review
Reviewed revision
c4edcc4
Behavior and intent
dde80aaad) plus one commit. Rebased from the previous [FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668 head; the only conflict was thePIPELINED_CASESlist and its comment inop_tests/test_flydsl_batched_gemm.py, where both sides were kept ([FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668's three- and four-buffer cases and this PR'stile_k = 128cases). Later rebased onto [FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668's head292a532f8; the only conflict was again thePIPELINED_CASEScomment, and the cases now compare_noplwith_pl. The default pick for names without a suffix still needs tile_k >= 256, so a 128-deep tile runs the pipelined loop only when its name ends in_pl._plkernelName withtile_k = 128raises incheck_pipelined_k_loop._pl. Nothing selects such a name today: no tuned row in the tree names a 128-deep_pltile, and the heuristics never append_pl.Validation and unverified scope
57628f0b1(same code as this head; the head differs only in [FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668's CSV-value commit underneath):python op_tests/test_flydsl_batched_gemm.pyexits 0. All sevenPIPELINED_CASES, including the threetile_k = 128ones, report 0 mismatches against the single-fence loop; the fused quant epilogue reports all bit-exact.python -m pytest op_tests/test_gemm_host_dispatch_cache.py op_tests/test_bmm_a8w8_fused_quant_tuned_row.py op_tests/test_bmm_a8w8_fused_quant_supported.pypasses.tile_k = 128_pltile, the same tile without_pl, and main's tile with_plwhere it is 128 deep),run_perftestwith the tuner's default warmup / iterations, several processes with alternating order; all candidates give the same output as main's selection. Relative results are in the PR comments._pltile, so no end-to-end run exercises it; gfx950 was not re-run at this head (the change is in the gfx1250 kernel only). CI has no gfx1250 runner for these FlyDSL op tests.PR-specific question
Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csvrowsgfx1250, cu_num 256, 32x32, (M, N, K)=(576, 32768, 1280)and(768, 32768, 1280), replaced in place with_plrows; see [FlyDSL] [gfx1250] mx32 GEMM: software-pipelined K loop; DSv4.1 rows use it #7668._plwithtile_k = 128. No row or heuristic produces such a name, so every shape keeps its selection; without_pl, the kernel compiles exactly as before.Changed op tests
op_tests/test_bmm_a8w8_fused_quant_tuned_row.py: comes from [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667 (CPU test of the fused entry's tuned-row lookup); unchanged here.op_tests/test_gemm_host_dispatch_cache.py(CPU): drops thetile_k < 256rejection case, which no longer holds; the other rejection cases stay. It is the CPU check of the_plvalidation that runs in CI.op_tests/test_flydsl_batched_gemm.py(gfx1250): threetile_k = 128entries inPIPELINED_CASES(a batched decode shape, a 2-D decode shape and a ragged K), each compared bit for bit with the single-fence loop. Not redundant: the existing cases all usetile_k = 256, where the loop also takes its middle-k-step branch; withtile_k = 128only the last-k-step branch runs, which no other case covers.🤖 Generated with Claude Code