Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
15545b6 to
311c0a8
Compare
|
Rebased with #7667 onto the current head of #7178 ( |
311c0a8 to
52c4a81
Compare
52c4a81 to
96d2c64
Compare
|
Rebased onto the new #7667 (on #7178 @ 803a3cd). The K-loop commit cherry-picked without conflicts and is unchanged. The dsv41 mxscale csv row overlap with #7659 is still expected (whichever lands second gets a row-level rebase). Checked (no GPU): py_compile / black / ruff on the changed files, modules import from the branch tree, |
96d2c64 to
80eb895
Compare
|
Rebased onto the new #7667 (on the current #7178 head One fix folded into the K-loop commit: #7655 on main moved the kernel off |
80eb895 to
8a56033
Compare
|
CI note: the failing job (MI35X Standard Tests shard 7, https://github.com/ROCm/aiter/actions/runs/43052999770/job/130694496651) has a single failure, I also re-checked the |
…4-1536, 2048/3072 In the model a FlyDSL compute kernel runs 10-25 us slower after another compute specialization than it does alone, which the tuner cannot see. Pick kernels that do not have the penalty: - Q-B (1,32768,1280) M=576/672: compute -> bmm t192x256x256 nb2 _pl (needs the software-pipelined K loop from #7668, stacked on #7667) - O-A batched (8,1024,4096) M=1024..1536 step 64: compute -> bmm t256x256x256 nb2 (9 rows replaced; kernelName only; the fused-quant entry uses the tuned row only with #7667) - Shared down (5120,2304) M=2048/3072: new rows, bmm t256x256x256 nb2 - O-B (5120,8192) M=2048/3072: new rows, compute t256x256x128 nb2 cm1_cn1
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (4)
- Make the pipelined loop one explicit switch instead of a silent default flip.
pipelined=-1(kernels/gemm_a8w8_gfx1250.py:180-185) moves every existing mx32 row with tile_k>=256 that fits the VGPR estimate onto the new loop: 425 rows ofdsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv, 29 ofdsv41_batched_...tuned.csvand 9 dense rows ofdsv4_a8w8_mxfp8_bpreshuffle_tuned_gemm.csv, not just the 5 rows in the description. Their timings were measured on the old loop, and no kernelName can select the old loop again (no suffix maps to0), so a regression on one shape can't be rolled back in the CSV. Default to0, keep_plas the only switch (add it to the dense name regex too), and mark the rows you validated, starting with the two t192x128x256 rows that currently rely on the auto rule. - Add tests for the new path.
op_tests/test_gemm_host_dispatch_cache.py:_plname round-trip (cfg["pipelined"]1 / -1) and the tile_k<256 rejection, CPU-only.op_tests/test_flydsl_batched_gemm.py(gfx1250): forced_plvs old loop bit-identical on one ragged-K shape and one shipped_plrow. Today the bit-identity claim rests only on out-of-tree scripts. - Drop speculative/duplicate code.
bmm_mx32_kernel_name(..., pipelined=False)has no caller that passes it (batched_gemm_a8w8_gfx1250.py:164). The runner'stile_k < 256check (:496) repeats the kernel'spipelined == 1 and not pipe_okcheck (kernels/gemm_a8w8_gfx1250.py:161)._join4copies the shuffle inload_a/load_b(:597,:607), so hoist it and use it in all three._MMA_ORDERrepeats_mma_rows' serpentine order. - Small fixes. Reject
pipelinedvalues outside {-1, 0, 1}:2currently becomesTruewithout thepipe_okcheck. The tail comment "their fences wait for fewer outstanding TDM tiles" isn't true for j=0, which waits num_buffers-2 like the steady loop. Fill in the aiter-bot PR Self-Review sections.
Not blocking: merge #7667 first (this branch carries its two commits). Expect a row-level conflict with #7659 in the dsv41 mxscale CSV. CPU probes found no bugs in the new loop: the early LDS bases give the same addresses as load_a/b/sa/sb (564k cases), and for nb 2-4 the tile-level issue/fence/refill order has no read-before-land or refill-before-read hazard.
Reviewed at 8a56033 (own commit only; base #7667 @ 5aa2e85).
8a56033 to
098f005
Compare
A shared expert with an MXFP8 down projection runs the gate_up GEMM (bf16 [M, 2*I]), silu_and_mul (bf16 [M, I]) and quantize_fp8 (e4m3 [M, I] plus e8m0 [M, I/32]) as three launches with two round trips through HBM. launch_gemm_a8w8 gains fuse_act_mul / act_limit (batched mxfp8_32 with a 32x32 B scale, fuse_quant_out, no K tail, 64-column multiples per tile and per wave): - B is the unmodified [gate; up] weight. Each CTA gathers its tile_n rows as tile_n/64 blocks of [32 gate rows, the matching 32 up rows] through one nested TDM view (and the same for the 32x32 scale rows), so a wave's 64-column block holds gate and up of the same 32 outputs in the same lanes. No weight reorder is needed. - The epilogue rounds the accumulators to bf16, forms bf16(silu(min(g, L)) * clamp(u, -L, L)) like aiter silu_and_mul, and quantizes each 32-column group to e4m3 + e8m0 (amax floor 1e-10, ceil pow2 of amax/448) like the existing fused-quant epilogue. The e4m3 tile goes out with one TDM store, the scales one row per thread. batched_gemm_a8w8_gfx1250 adds run_gate_up_silu_mxfp8_32_gfx1250(XQ, WQ, x_scale, w_scale, Out, y_scale_out, swiglu_limit, kernel_name=None) and gate_up_silu_kernel_for(m, n2, k), which returns the tuned tile for M up to 4096 at shapes the tiles divide, or None (the caller keeps the unfused path, as for larger M or other archs). Scales match the unfused chain exactly; an e4m3 code can differ by one step where the epilogue's exp/rcp and silu_and_mul's land on either side of an e4m3 rounding midpoint. Tests: op_tests/test_flydsl_batched_gemm.py runs the fused entry against GEMM + silu_and_mul + quantize_fp8 for every tile bucket, with clamped, tiny and zero rows. Depends on ROCm#7668 (and ROCm#7667); this branch carries their commits until they merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @valarLip. Both items, at 1. Merge order. Agreed: #7667 goes in first. This branch still sits on #7667's head 2. Split-fence comment order. Fixed in CSV values of the two kept In each process the first candidate timed is slowed by the GPU ramping up, so the comparison is position-matched (gfx1250, at
In the balanced batch every The earlier batch of 7 processes gives the same sign at both positions (-3.2% to -4.9%). So gfx1250 run at The previous head is kept on the fork as |
valarLip
left a comment
There was a problem hiding this comment.
✅ LGTM — code done; waiting on #7667 and CI (2)
- Merge #7667 first, then rebase this onto main. #7667 (
68071323b) is still open with changes requested, and this branch still carries its eight commits. Only1b0cc342e..96c03e69abelong to this PR. Against current mainfe40b01fc,git merge-treeis clean, and main has not touched any of the changed files since0d894387b. - Tighten two kernel comments (optional, can go in the rebase). In
aiter/ops/flydsl/kernels/gemm_a8w8_gfx1250.py::1027-1029says the per-stage LDS read bases are formed a whole tile ahead. That is only true whenearlyholds. Witha_preshuffle,a_scale_preshuffledorwarp_tile_n % 32 != 0,_stage_basesforms them inline. Start the sentence with "Whenearly,".:1195-1198says tail tile j waits formax(num_buffers - 2 - j, 0)tiles. The last tail tile (j = nb-1,last=True) has no fence, so themax(..., 0)clamp never applies. Say that, or drop the clamp.
I found nothing else. The full review at this head re-checked the DS (_NLD) and tensor wait counts, the split fence for nb 2/3/4, the stage refill vs next-stage reads, the fragment carry across K tiles, ragged K, and the early LDS bases. All of these check out. pipelined=0 leaves the old loop unchanged, pipelined is in both specialization keys, and check_pipelined_k_loop is the single gate. A CPU probe shows that both CSV rows parse to pipelined=1 and pass the check. Their errRatio of 0.0027 is under the tuner's 0.05 threshold, and 19 other gfx1250 rows in the table also have a nonzero errRatio. CI: everything that has reported passes. The py3.12 wheel build is pending and the MI35X standard tests have not reported yet.
Re-reviewed at 96c03e6 (own commits 1b0cc34..96c03e6; base #7667 @ 6807132). Already fixed: the split-fence comment at :1011-1016 now follows the code order (refill, then _load_frags(nbuf, 0), at :1177-1178). The two _pl rows now carry us / tflops / bw measured through the tuner's harness instead of scaled values.
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]>
A shared expert with an MXFP8 down projection runs the gate_up GEMM (bf16 [M, 2*I]), silu_and_mul (bf16 [M, I]) and quantize_fp8 (e4m3 [M, I] plus e8m0 [M, I/32]) as three launches with two round trips through HBM. launch_gemm_a8w8 gains fuse_act_mul / act_limit (batched mxfp8_32 with a 32x32 B scale, fuse_quant_out, no K tail, 64-column multiples per tile and per wave): - B is the unmodified [gate; up] weight. Each CTA gathers its tile_n rows as tile_n/64 blocks of [32 gate rows, the matching 32 up rows] through one nested TDM view (and the same for the 32x32 scale rows), so a wave's 64-column block holds gate and up of the same 32 outputs in the same lanes. No weight reorder is needed. - The epilogue rounds the accumulators to bf16, forms bf16(silu(min(g, L)) * clamp(u, -L, L)) like aiter silu_and_mul, and quantizes each 32-column group to e4m3 + e8m0 (amax floor 1e-10, ceil pow2 of amax/448) like the existing fused-quant epilogue. The e4m3 tile goes out with one TDM store, the scales one row per thread. batched_gemm_a8w8_gfx1250 adds run_gate_up_silu_mxfp8_32_gfx1250(XQ, WQ, x_scale, w_scale, Out, y_scale_out, swiglu_limit, kernel_name=None) and gate_up_silu_kernel_for(m, n2, k), which returns the tuned tile for M up to 4096 at shapes the tiles divide, or None (the caller keeps the unfused path, as for larger M or other archs). Scales match the unfused chain exactly; an e4m3 code can differ by one step where the epilogue's exp/rcp and silu_and_mul's land on either side of an e4m3 rounding midpoint. Tests: op_tests/test_flydsl_batched_gemm.py runs the fused entry against GEMM + silu_and_mul + quantize_fp8 for every tile bucket, with clamped, tiny and zero rows. Depends on ROCm#7668 (and ROCm#7667); this branch carries their commits until they merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shared expert with an MXFP8 down projection runs the gate_up GEMM (bf16 [M, 2*I]), silu_and_mul (bf16 [M, I]) and quantize_fp8 (e4m3 [M, I] plus e8m0 [M, I/32]) as three launches with two round trips through HBM. launch_gemm_a8w8 gains fuse_act_mul / act_limit (batched mxfp8_32 with a 32x32 B scale, fuse_quant_out, no K tail, 64-column multiples per tile and per wave): - B is the unmodified [gate; up] weight. Each CTA gathers its tile_n rows as tile_n/64 blocks of [32 gate rows, the matching 32 up rows] through one nested TDM view (and the same for the 32x32 scale rows), so a wave's 64-column block holds gate and up of the same 32 outputs in the same lanes. No weight reorder is needed. - The epilogue rounds the accumulators to bf16, forms bf16(silu(min(g, L)) * clamp(u, -L, L)) like aiter silu_and_mul, and quantizes each 32-column group to e4m3 + e8m0 (amax floor 1e-10, ceil pow2 of amax/448) like the existing fused-quant epilogue. The e4m3 tile goes out with one TDM store, the scales one row per thread. batched_gemm_a8w8_gfx1250 adds run_gate_up_silu_mxfp8_32_gfx1250(XQ, WQ, x_scale, w_scale, Out, y_scale_out, swiglu_limit, kernel_name=None) and gate_up_silu_kernel_for(m, n2, k), which returns the tuned tile for M up to 4096 at shapes the tiles divide, or None (the caller keeps the unfused path, as for larger M or other archs). Scales match the unfused chain exactly; an e4m3 code can differ by one step where the epilogue's exp/rcp and silu_and_mul's land on either side of an e4m3 rounding midpoint. Tests: op_tests/test_flydsl_batched_gemm.py runs the fused entry against GEMM + silu_and_mul + quantize_fp8 for every tile bucket, with clamped, tiny and zero rows. Depends on ROCm#7668 (and ROCm#7667); this branch carries their commits until they merge. 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]>
|
Pushed Why the automatic pick comes back. With What changed, and how it keeps the earlier review points.
Tests.
The previous head is kept on the fork as |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
- Drop the default pick again: a kernelName without
_plmust run the single-fence loop.1b573ced8brings back the silent flip that round 1 asked you to remove.default_pipelined_k_loop()is applied inbatched_gemm_a8w8_gfx1250.py:115-128andmxfp8_bpreshuffle_gemm_gfx1250.py:630-641. It moves 487 untagged rows on main onto the new loop: 442 indsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv, 36 indsv41_batched_..._tuned.csvand 9 indsv4_a8w8_mxfp8_bpreshuffle_tuned_gemm.csv. These rows were not "tuned with the automatic rule". Main has no pipelined loop, so every one of them was timed on the single-fence loop. On 11-14 you agreed that "every existing row keeps the loop it was timed on" and that only a few rows had been validated at serving shapes. Your own 11-17 re-pick also shows the loop is not a free win. At M576 N5120 K8192, plaint128x128x256 nb4beat its_plversion, and 30 rows of that tile in the dsv41 table now flip._pllost or tied on 4 of 6 keys. The 11-18 "CPU check" only compares against this PR's own earlier rule, not against main. The fix: - Merge #7667 first, then rebase onto main. #7667 (
68071323b) is still open with changes requested. This branch still carries its eight commits, and only1b0cc342e..292a532f8belong here.
Optional, still open from last round: in kernels/gemm_a8w8_gfx1250.py, :1028 should start with "When early,". At :1196-1206 the last tail tile has no fence, so the max(..., 0) clamp never applies; drop it or say so.
Nothing else blocks. The kernel code is unchanged since 96c03e69a (only the docstring at :52-53 changed). -1 never reaches the kernel or a cache key. CI: 18 checks pass; the 8 MI35X standard shards and OPUS are still pending.
Re-reviewed at 292a532 (own commits 1b0cc34..292a532 on #7667 @ 6807132; the head moved by two new commits on top of 96c03e6, not a rebase). Already fixed: nothing new since 96c03e6; the earlier rounds' items are still fixed.
292a532 to
e9476df
Compare
|
@valarLip Thanks for the review. Rebased onto #7667's current head ( 1. Default pick dropped. A kernelName without
2. Rebase. The branch is #7667
Optional items (both in
Validation at
|
|
Merged main into the branch to clear a new conflict with #8291 (head |
…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. 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. Co-Authored-By: Claude Opus 5.5 <[email protected]>
c9ce4ea to
b21a4a9
Compare
|
Re-stacked on the rebased #7667 ( |
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]>
b21a4a9 to
1683901
Compare
|
Re-stacked on #7667 |
Stacked on #7667; only the commits after #7667's head are new here. Please merge #7667 first; this PR will be rebased onto main after that.
Summary
Software-pipelined K loop for the gfx1250 FlyDSL mx32 GEMM kernel (
gemm_a8w8_gfx1250.py, batched and 2-D), the LDS reads of the next k-step and the TDM refill overlap the current k-step's WMMAs. Results are bit-identical to the existing loop. A tuned row opts in with the kernelName suffix_pl; every name without it, including all existing tuned rows and heuristic picks, keeps the single-fence loop it was timed on.Motivation
Instrumenting the production kernels showed the TDM refill already runs ahead and the tile barrier is not the main serial point. The time goes inside the compute phase: each k-step's
ds_loads wait for the WMMA queue to drain (the new fragments reuse registers still read by in-flight WMMAs, and the address VALU sits right before the loads), and the next K-tile's first fragments can only be read after the tile-top barrier. So "LDS read + WMMA" behaves like the sum of the two instead of overlapping.Changes
kernels/gemm_a8w8_gfx1250.py, newpipelinedconstexpr (afterfuse_quant_out, default0):pipeline_fence_signal/pipeline_fence_waitprimitives the 256x256 compute kernel already uses: signal after this tile's LDS reads and this wave's TDM of tile kt+1 have landed, issue half of the last k-step's WMMAs, wait, refill the stage with tile kt+num_buffers and read tile kt+1's first fragments, issue the other half.warp_tile_n % 32 == 0), per-stage LDS read bases are formed a tile ahead, so no address VALU sits right before the boundary reads; otherwise they are formed inline.check_pipelined_k_loop()is the one place that validates it: only 0 or 1; 1 needs mxfp8_32, no scale preload, no cluster, split_k 1 and tile_k >= 256. The fragment join ofload_a/load_band the serpentine WMMA order are shared with the new loop._plon a batched mxfp8_32 kernelName (batched_gemm_a8w8_gfx1250.py) or a generic 2-D mxfp8_32 kernelName (mxfp8_bpreshuffle_gemm_gfx1250.py) is the only switch. A name without it runs the single-fence loop; there is no default pick. Compute-bound and mxfp8_128 names do not accept_pl. Moving other tuned rows to_plis left to follow-up PRs that re-time them.dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv: after [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659 retuned the same DSv4.1 keys, the pipelined rows were re-timed against main's tiles on one gfx1250 box and kept only where_plis ahead: N=32768, K=1280 at M 576 and 768 (t192x256x256 nb2 _pl, replacing main's compute-kernel rows in place). The other four keys (N=5120, K=8192 at M 576 / 672 / 768; N=32768, K=1280 at M 672) keep main's rows. Theus/tflops/bw/errRatioof the two rows are measured on gfx1250 through the MXFP8 GEMM tuner's harness (see Validation).PR Self-Review
Reviewed revision
1683901
Behavior and intent
d4016d527, on main3fd42598c) plus this PR's own commits: the K-loop commit, the review commit that makes_plthe only switch, the re-pick of the DSv4.1 rows against [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659's retune with three- and four-bufferPIPELINED_CASES, the split-fence comment in code order, the measuredus/tflops/bwof the two_plrows, ande9476df89(CPU tests that untagged names run the single-fence loop; two kernel comments). The merge of main from the previous head is gone: [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667 is now on current main and this PR's six commits are replayed onto it (71ec00293..1683901ce); the only conflicts were test-file docstrings and a test helper next to main's_fused_quant_k(). The CSV diff against main is still only the two_plrows. The default pick for names without a suffix and the_noplsuffix from the previous head (1b573ced8,292a532f8) are dropped. The rebase onto [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's new head kept both [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667'sy_scale_outand this PR'spipelinedin the 2-D runner's arguments, and added the_pltile to [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's longerFUSED_QUANT_TILES._plrun the software-pipelined loop; every other row, including heuristic picks, runs the single-fence loop as before. The two tuned DSv4.1 rows listed above carry_pl. An unsupported_plconfig, or apipelinedvalue other than 0 / 1 reaching the kernel, raises.Validation and unverified scope
098f00596(same K-loop code as this head), offline gfx1250 compile oflaunch_gemm_a8w8(flydsl 0.5.0, null pointers, no GPU), final ISA compared:_plconfigs (batched 32x32t128x128x256 nb4,t192x128x256 nb3,t192x256x256 nb2, ragged-Kt64x128x256 nb2, 2-Dt64x128x256 nb3, fused quant witht128x128x256andt192x128x256) give ISA identical to the previous head with the loop forced on. No VGPR spill, no scratch._pl, all batched / 2-D / mxfp8_128 / ptpc / fused configs checked give ISA identical to main (bf16) or to [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667 (fused); an explicitpipelined=0is the same kernel as the default. (A name without_plmeant 0 at that revision, as it does at this head; the K-loop kernel code is unchanged since.)1683901ce(this head): CPUop_tests/test_gemm_host_dispatch_cache.py+test_bmm_a8w8_fused_quant_tuned_row.py28 passed; the 10 failures are CUDA-only cases that fail the same way on main. black / ruff clean. No idle gfx950 GPU for a rerun. The kernel files of [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667 under it give the same gfx1250 ISA asdfc62154e(see [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667). The lines below are ate9476df89; this PR's own commits are unchanged since.e9476df89, CPU (GPU-less container,GPU_ARCHS=gfx950):python -m pytest op_tests/test_gemm_host_dispatch_cache.py19 passed, 16 skipped; [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's head gives 15 passed, and the same pre-existing case (test_mxscale_config_precheck_matches_padded_walk, needs CUDA) fails on both. black 26.10.1 and ruff clean on the changed files; the CSV keeps its column count.e9476df89, gfx950:python op_tests/test_flydsl_batched_gemm.py(GPU_ARCHS=gfx950) exits 0 and prints the same correctness columns as [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's headdfc62154erun on the same box (45 fused-quant lines, all 0 mismatches). This is a regression check of the shared files only; the pipelined loop is gfx1250-only and its cases do not run on gfx950.96c03e69a; the rebase onto [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's new head is not yet run on gfx1250). It will be posted before merge.138091409:python op_tests/test_flydsl_batched_gemm.pyexits 0: the pipelined K loop cases (ragged Kt64x128x256 nb2, shippedt192x256x256 nb2,t192x128x256 nb3,t128x128x256 nb4) are bit-exact against the single-fence loop, the fused-quant pinned tiles including the_plone have 0 mismatches at M = 48 and M = 200, the fused epilogue reports all bit-exact, and main's compute kernelName cases pass.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 on the same box. Row choice: main's row and the_plrow timed back to back on one gfx1250 box for each of the six keys, several rounds in alternating / shuffled order; the two kept keys were ahead in most paired rounds, the other four were behind or within noise. All candidates gave the same output. Log and relative timings in the PR comments.0c2745d1a(same K-loop code, on [FlyDSL] [gfx1250] Batched mxfp8 GEMM fused-quant epilogue: quantize from the accumulators, use the tuned row #7667's previous head; a name without_plmeant 0 there, as it does now):python op_tests/test_flydsl_batched_gemm.pyexits 0 (pipelined K loop all bit-exact for the fourPIPELINED_CASES, fused quant epilogue all bit-exact, compute kernelName cases pass) and the three pytest files above pass._plrows:csrc/gemm_a8w8_mxfp8_bpreshuffle/gemm_a8w8_mxfp8_bpreshuffle_tune.pyonly takes 128x128 shapes on gfx1250, so a thin subclass replaces only itstune()candidate list (main's row and the_plrow for each key) and keeps everything else:generate_datawith the 32x32 scale,run_bmm_flydsl(B = 1, the path a kernelIdbmmrow runs), themp_tunertask, the default warmup / iterations, the error check and the throughput formula. Eight processes with the candidate order alternated:_plis ahead of main's row for both keys at either position. The writtenusis the median for the candidate timed second in its process (the first one in each process is slowed by the GPU ramping up);bwis in the unit of the neighbouring gfx1250 rows;errRatiois the tuner's (main's kernel gives the same value). Main's other gfx1250 rows of this table were not produced by this tuner ([FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659 used kernel traces), so absolute values are not directly comparable across rows; the relative result is in the PR comments.ci:gfx1250-ffm-tritonruns only for branches in ROCm/aiter and only the Triton suite plus two FlyDSL tests), so gfx1250 coverage of the op test is the manual run above.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.csvwithgfx1250, cu_num 256, w_scale_block 32x32, libtype flydsl:(M, N, K)=(576, 32768, 1280)and(768, 32768, 1280)(DSv4.1 wq_b), reached through the table's padded-M lookup._pla name runs the single-fence loop.test_mx32_shipped_rows_take_the_k_loop_their_name_askschecks this over every kernelName inaiter/configs. mxfp8_128, ptpc, compute-bound, split-K and cluster configs keep exactly the previous kernel.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):test_mx32_pl_suffix_round_trip(batched and 2-D mxfp8_32 names parse_plto 1 and the plain name to 0, nothing else in the config changes; compute-bound and mxfp8_128 names reject_pl),test_mx32_name_without_pl_runs_single_fence_loop(2-D names on which the pipelined loop would apply resolve to 0 without_pland to 1 with it, also aftercluster_mis fitted to M;_nopland other suffixes do not parse),test_mx32_shipped_rows_take_the_k_loop_their_name_asks(every mxfp8_32 kernelName in the shipped tables runs the pipelined loop exactly when it ends in_pl) andtest_pipelined_k_loop_check(tile_k < 256, no mx32, preload, cluster, split_k > 1 and values other than 0 / 1 are rejected). These are the parts that run in CI; no existing test parses_plor reaches the check.op_tests/test_flydsl_batched_gemm.py(gfx1250):PIPELINED_CASEScomparenamewithname + "_pl"bit for bit on a ragged K (k_tail), on the shippedt192x256x256 nb2row, and on a three-buffer (t192x128x256 nb3) and a four-buffer (t128x128x256 nb4) tile, where the tail fences wait on fewer outstanding tiles than the steady loop;FUSED_QUANT_TILESruns t128x128 without and with_pl, so the fused epilogue runs after both loops. Not redundant: before this, bit-identity with the old loop rested only on out-of-tree scripts.🤖 Generated with Claude Code