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] [CK] [FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows - #8246
Adds fused split-K to the generic gfx1250 a8w8 GEMM (mx128 / mx32 / ptpc / batched): the K splits of a tile form one cluster along grid.z and are reduced in FP32 inside the same launch, with no reduce kernel. It also makes the kernel's cluster_m a launch argument, widens the mx128 tuner candidates, adds opt-in _qe / _nlb main-loop schedules, and retunes the Kimi-K3 and shared DSv4 mx128 rows. #7827, #7868, #7659, #8678, #8737 and #7449 are merged into main; this branch merges main up to 6afa7b412, so the diff holds only this PR's changes.
Motivation
Only the compute kernel had fused split-K; the generic kernel (all decode-size GEMMs) split K through a separate reduce kernel, an extra launch on small-M, large-weight GEMMs. The row-stripe epilogue also only fits 2/4/8 splits that divide K evenly, so most split counts small-M shapes want could not be fused. The K3 rows were not tuned with fused split-K, generic clusters or compute 1x1.
Changes
Fused split-K (_fsk), generic kernel. The shared row-stripe epilogue (split_k 2/4/8, K tiles split evenly, at least four waves) is used where it fits; otherwise rank0: every split stores its FP32 tile to scratch, a cluster barrier follows, and split 0 sums the splits in order and writes the output. rank0 takes split_k 2..16 and uneven K tiles (needs K % tile_k == 0 only; scratch must stay under 4 GiB, else the launch is unfused). cluster_m is a runtime argument and leaves the compile key and symbol name. A split_k 2 stripe of 4 GiB or more of Out (lean_stripe_fits) takes rank0 (generic) or the unfused reduction (compute, PTPC).
Lookahead schedule. Block-scaled kernels (mx128 / mx32 / batched) with one or two A rows issue the next K sub-step's LDS loads before the current WMMAs (32-scale ones from tile_k 512); every other kernel keeps main's order. With three or more A rows it spilled (mx32x32 t224x128x256: 626 VGPRs and 20 B of scratch, 1.31x slower); test_row_kernel_spills pins this. Opt-in suffixes: _qe, _nlb (1x1 clusters only), _cpN.
Tuner candidates (mx128). Fused twins, rank0 split counts, generic clusters, compute 1x1 / power-of-two clusters and four opt-in candidates, appended so existing kernelIds are unchanged. A fused twin takes the row-stripe epilogue only for an even K split and otherwise rank0 (in the launcher and in kernel_fits_shape).
Untuned-shape fallback: unchanged._flydsl_mxfp8_fallback_kernel keeps main's rule and iterates fallback_kernels(), the original kernels, so no widened candidate can be picked; picks equal origin/main on every sampled shape in the plain, A-preshuffle and mx32 modes (pinned by test_untuned_fallback_pick).
Tuned tables (kimik3_... and dsv4_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv): 1569 -> 1716 rows. K3: 136 rows change kernel, 147 added (303 -> 450). DSv4: 80 change kernel. 139 changed / added rows are fused. A row stays only where it beats main on the same box: over the measured points of its span the geomean of its time over main's is below 0.98 (every changed row is at 0.979 or less). Rows without that gain went back to main's line (9) or were dropped (8 added K3 rows). A row serves the Ms up to its own M; large M with no row walks (getPaddedM) to the 2048 / 4096 / 8192 / 16384 rows, so those rows were picked over their whole span. No exact-M guard rows.
Fixes found in review.fused_splitk_ok accepts only 2/4/8 splits, whole row passes and four waves (the shared epilogue wraps peer stripes with & (split_k - 1), stores whole row passes and sizes its load batch per 128 threads); other geometries take rank0. Uneven rank0 splits take equal numbers of loop cluster barriers. A row-stripe-capable geometry with an uneven K (t32x64x256 sk8 at K=7168) raised instead of taking rank0; fixed. The ptpc wrapper also checks N % (tile_n*cluster_n).
Performance (if applicable)
gfx1250 (256 CU), FlyDSL 0.5.5 (the version origin/main pins). Relative timings only (the CSV us are not comparable between machines and power states). Production entries with the merged tuned tables, cold weights (>= 1 GiB), CUDA graph, median over uncontended rounds; before = origin/mainecfa616d8, after = this branch. Every point was timed on all 4 GPUs and its value is the median (large-M cluster / compute kernels rank differently on GPU 0: K3 2304x1536 M=10241 is 0.924x there and 1.06x on the others). Measured at c4f8a6d2f; the commit after it changes no row's kernel or launch mode (see Validation). Point set: every gfx1250 row of every tuned table either tree loads, at its smallest M, the middle of its span and its tuned M: 6093 points, bitwise equal to main's output at 5845 (the rest take another kernel or split).
all 5663 rows of the 256-CU tables (0.962x; 1065 faster by > 3%)
221386 us
218538 us
-1.3%
gfx1250
mx128 M 1-64 (541 points, 0.84-0.86x)
6312 us
5752 us
-8.9%
gfx1250
mx128 M 65-640 (634, 0.88-0.89x)
9600 us
8789 us
-8.4%
gfx1250
mx128 M 641-2048 (210, 0.964x)
7558 us
7363 us
-2.6%
gfx1250
mx128 M > 2048 (503, 0.963x)
76350 us
75254 us
-1.4%
The 3 points above 1.03x: K3 2304x1536 M=10241 (1.060; an odd M-tile count demotes the cluster of the M=16384 catch-all row; its M=16384 row is 0.84x), DSv4 7168x3072 M=129 (1.037; the first M of a row that is 6-8% faster at its other Ms) and K3 67584x7168 M=32 (1.033; the same kernel on both sides, 0.98-1.08 over the GPUs).
Row level, same box: the 216 table rows that change a kernel are all at 0.979x or below (geomean 0.785x DSv4, 0.804x K3); the 147 added K3 rows are at 0.855x. A dense M scan (mx128, 37 K3 / DSv4 (N, K) shapes x 76 M from 1 to 640 = 2812 points) is 0.895x (-3.8% of the time; no shape's geomean over M above 1.00x), ragged / odd M (273 points) 0.929x, large M (315 points, M 660 to 32768) 0.930x. Main's DSv4.1 mx32 rows (#8047, 24 points): bitwise equal, 0.999x.
Untuned shapes (no table row; fallback = main's rule and kernels): 1384 fallback-served points (the kimik2_... table is 96-CU, so its 430 points run the fallback on this box; untuned K3 / DSv4 Ms; sampled shapes up to M=39033) are bitwise equal to main's at 1.000x, worst 1.025.
Lookahead: its first version, on for every row kernel, made 50 mx32x32 points up to 1.28x slower than main (33 kernels with three or more A rows spilled). The gate now covers block-scaled kernels with at most two A rows (32-scale ones only from tile_k 512 with four buffers, or at most two accumulator tiles per wave with three); PTPC keeps main's order. Result above: no mx32x32, PTPC or bmm32x32 point is above 1.03x. Known left: t32x64x1024 nb3 at 5120x15360 M 65-80 is about 1.5% slower with the lookahead (3 points).
The us recorded in the tables are not comparable with main's: main's rows were timed on another machine (main records 28.16 us for K3 4096x7168x1536, the same kernel measures 21.7 us on this box, and us moves about 10% with the GPU's power state), the rows this PR adds or changes carry the median of 6-8 runs on one GPU. So a changed row can record a higher us than the line it replaces and still be faster: 42 of the 216 changed rows record a us more than 5% above main's, and each is at 0.979x of main's time or less in the same-box pairing. The time ratios above are the measurement.
Testing
Unit tests added or updated
Performance benchmarks run
Tested on MI250X
Tested on MI300X
Tested on gfx1250 only; the changed kernels and tables are gfx1250 only.
Documentation
Docstrings updated
User guide updated
Performance guide updated
No documentation change is needed, with the reason stated below
No API change. Generic-kernel symbol names no longer contain _cm... because cluster_m is now a runtime argument, so existing FlyDSL AOT caches of that kernel must be rebuilt (the AOT cache keys on the changed sources, so a stale entry misses). Shapes without a tuned row keep main's fallback pick. The batched candidate enumeration is identical to origin/main.
The generic kernel gets cluster-based fused split-K and an M-independent cluster_m, so decode GEMMs drop the reduce-kernel launch and the per-cluster_m retrace; rank0 extends fusion to any split count up to 16 and to K the split count does not divide, which is where most small-M wins are. The widened candidates and retuned rows use them. The lookahead is limited to block-scaled kernels with one or two A rows, where it wins. The fallback is left alone on purpose: it keeps main's rule and picks, and only the tuner sees the widened candidates.
Validation and unverified scope
At gfx1250, FlyDSL 0.5.5:
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py as a script (all gfx1250 tuned rows, 17 fused cases x 5 M, direct, catalog and fallback tests): passes on the JIT path, from a prebuilt AOT cache, and with AITER_FLYDSL_AOT_CACHE=verify (every cache hit re-traced and its IR compared).
AOT: python3 -m aiter.aot.flydsl.gemm (all tables), then --check: 2704 replays ok, 0 failed, 20 refused by the runtime, 511 sizes inside rows' ranges, 0 failed (origin/mainecfa616d8: 2557 ok; the 147 added rows are the difference). All 126 generic fused rows (103 rank0, 23 row-stripe) hit the cache in verify mode, 0 misses.
Random fused configs (mx128 / mx32, split_k 2-16, clusters, random M / N / K; 2 seeds, 156 cases: 52 row-stripe, 104 rank0): zero mismatches against the FP32 reference, bitwise equal to the unfused twin where K divides evenly. Stress over the fused / N-cluster kernels the tables use, at every M each serves: ragged M (2066 runs), NaN canaries past M and N (2066), scratch canaries (1206), 18600 repeated launches compared bitwise: 0 failures.
Tuner --run_config through the production entry: K3 450/450 and DSv4 211/211 gfx1250 rows OK. test_config_shape_collision: 34 passed.
Untuned fallback = main's: picks equal origin/main on 19949 sampled shapes in each of the plain, A-preshuffle and mx32 modes (the PTPC fallback was checked on 6000 shapes at an earlier revision, its code is unchanged); 1384 untuned points through the production entry are bitwise equal to main's at 1.000x, worst 1.025.
Row-stripe K rule: over 12.6M tuner-catalog kernel x shape pairs the only change is 99825 pairs that newly fit through rank0, none stops fitting; none of the 149 fused table rows (26 row-stripe-capable on a generic kernel) has an uneven K, so no row changes launch mode. The t32x64x256 sk8 case at K=7168 (28 K tiles) now launches through rank0 and matches the FP32 reference.
Merge of [FlyDSL] [Perf] Let the consumer finish a gfx1250 PTPC split-K GEMM #7449: one textual conflict, run_preshuffle_gemm_a8_gfx1250 (both fused_splitk and partials kept; a launch with partials= runs unfused). One clean merge was wrong: _splitk_deferrable would have deferred a fused row whose output is already final, so it returns None for _fsk. Covered by run_ptpc_fused_splitk_ci_correctness and check_fused_row.
Existing suites: test_gemm_group32_interface.py + test_gemm_host_dispatch_cache.py 197 passed, 4 failed; the AOT tests (tests/test_flydsl_aot_{replay,launch,cache}.py, tests/test_aot_drivers.py) 97 passed, 7 failed: the same failing tests as on origin/mainecfa616d8 (same machine and toolchain). op_tests/test_gemm_a8w8.py (PTPC) stops in its hipBLASLt reference (0 valid solutions) on main and here alike, after run_ptpc_fused_splitk_ci_correctness has passed. test_batched_gemm_a8w8_mxscale_bpreshuffle.py, test_gemm_a8w8_bpreshuffle_pad_k.py (34 passed, 43 skipped) and op_tests/test_flydsl_batched_gemm.py pass. A hipBLASLt bf16 reference kernel in the tests' torch reference faults intermittently (seen on GPU 0 and 2; the batched script's fault reproduces on origin/main); the affected runs pass on rerun.
LDS-to-TDM flush ([FlyDSL] Work around gfx1250 LDS-to-TDM store corruption #8737) with the [FlyDSL] [Bugfix] gfx1250 FP8 GEMM: store C from registers / LDS read-back, not a TDM store from LDS #8486 two-stream reproducer (one CUDA graph, the PR kernel beside the routed MXFP4 MoE; mx32 N=1536 K=6144, M=32 and 64, 2 x 120 s per run): the row-stripe t32x64x256 nb3 sk4 _fsk kernel gave 293 and 204 bad replays with no flush, 142 and 140 with main's flush only, and 0 of 377600 and 0 of 429700 with both. An intermittent wrong-element error of generic kernels at M around 500 on origin/main4960107ee (8/800 runs at cm4_cn2) is gone (0 / 3000); it was the same LDS -> TDM hazard.
Known slower than main (measured, not fixed here; see Performance): K3 2304x1536 at odd M-tile counts (M=10241: 1.06x on 3 of 4 GPUs, 0.92x on GPU 0), DSv4 7168x3072 M=129 (1.037x) and three same-kernel points that spread 0.94-1.10 over the GPUs.
Remains unverified: MI250X / MI300X; full-model end-to-end at this revision (the decode graph at an earlier revision, ccc4270, gave GEMM time per step c32 -5.2%, c128 -21.5%, c256 -6.0%; batched T08 was about 10% slower in the c256 graph there, cause not found).
PR-specific question
Only gfx1250 reaches the changed paths (kernels and table rows are keyed gfx1250, cu_num 256), with FP8 A/B, E8M0 scales (mx128 / mx32) or per-token (ptpc), and bf16/fp16 output; the fallback runs only for shapes with no tuned row. The fused path is selected only by a _fsk kernel name (tuned row or tuner). Before launch the dispatcher raises RuntimeError unless N % (tile_n*cluster_n) == 0, K % tile_k == 0 with at least num_buffers K tiles per split (and K % (split_k*tile_k) == 0 unless the launch takes rank0), and cluster_m divides the M-tile count (otherwise shrunk to the largest power-of-two divisor). A _fsk name uses the row-stripe epilogue when fused_splitk_ok holds (at least four waves, split_k in 2/4/8, cm*cn*split_k <= 16, tile_m % split_k == 0, valid TDM output split, whole row passes), K tiles divide by split_k and, at split_k 2, the output stripe stays under 4 GiB; else, on a generic kernel, rank0 when rank0_splitk_ok holds (2 <= split_k <= 16, cm*cn*split_k <= 16, FP32 scratch under 4 GiB); else the unfused reduction. Compute kernels never take rank0. The tuner prunes the same conditions in kernel_fits_shape. _nlb is accepted only on generic kernels with a 1x1 cluster.
Changed op tests
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py: test_fused_splitk runs 17 mx128 / mx32 generic kernels with a _fsk name at M 1, 7, 33, 300, 640 (9 take the row-stripe epilogue, 8 take rank0: split_k 3/5/6/7/8, a two-wave tile, uneven K tiles, clustered ones, and a row-stripe-capable t32x64x256 sk8 at 28 K tiles): zero mismatches against an FP32 reference, no reduce kernel, same bytes under graph replay, bitwise equal to the unfused twin where K divides evenly. test_fused_splitk_whole_row_passes and test_fused_splitk_large_row_stride cover the whole-row and 2^29-stride cases; test_row_kernel_spills compiles every tuned generic row-path kernel with three or more A rows (COMPILE_ONLY) and requires no scratch; test_mx128_kernel_direct covers the sk1 _qe K3 kernels; test_untuned_fallback_pick pins four picks to main's; test_tuner_catalog checks rank0 / row-stripe fit rules (including the even / uneven K split) and every K3 row's kernelId.
op_tests/test_gemm_a8w8.py: run_ptpc_fused_splitk_ci_correctness (gfx1250) runs two PTPC _fsk kernels at M 1, 7, 33, 300 on a NaN-filled output: no NaN left, FP32 reference within the PTPC tolerance, no reduce kernel, bitwise equal to the unfused twin and under graph replay.
op_tests/test_gemm_a8w8_splitk_deferred.py: check_fused_row: a fused PTPC row is not deferred and gives its final output with no reduce launch and no partials.
A compute GEMM that runs right after another compute specialization is
1.2-1.7x slower: its code was evicted from the CU's instruction cache, and
s_prefetch_inst is a no-op while MODE.SCALAR_PREFETCH_EN is clear, which is
how waves start once the program was preloaded on the WGP.
Set the bit at kernel entry and prefetch the kernel's code (up to 56 KiB,
split across the waves). Output is unchanged. The new test runs two compute
kernels alternately and checks the cost stays within 10% of running them
back to back.
Two a4w4 compute kernels run alternately cost 1.5-2.2x of back to back,
for the same reason as the a8w8 ones: their code does not fit the
instruction cache together. Call prefetch_kernel_code at the entry of
kernel_gemm_a4w4_256x256.
A launch holds up to three kernels (tail_mode 2, 0, -1), so
prefetch_kernel_code takes the kernel's position in its module and uses
it for its label and .Lfunc_end. a8w8 keeps index 0 and its code objects
are unchanged.
Add test_compute_switch_penalty to test_gemm_a4w4.py. It runs only when
FlyDSL is installed, and checks each kernel's output against the
reference before timing. The a8w8 switch test in
test_flydsl_batched_gemm.py gets the same check, sharing its reference
with the compute cases.
…ill rows
- Key bounded_m only for fused split-K, its only reader.
- From 4 M-tiles per cluster row (split_k 1), pad grid.x to whole cluster
rows instead of falling back to a smaller cluster_m; padded workgroups
load and store zero rows. 1x32 and 128x128 rows keep the fallback.
- Restore the DSv4.1 Flash 32x32 M=16384 rows; add M=8192 compute rows for
O-B, shared gate/up and down, and Engram (it serves M in (4096, 16256]).
- Pass the cluster_m that fits M as a launch argument (i32_cm) to the
a8w8 and a4w4 compute kernels and the a4w4 general kernel, instead of
compiling one variant per fitted cluster_m. A launch of one workgroup
runs the plain kernel (use_cluster False). Kernel symbol names lose
_cm; tuned kernelNames are unchanged.
- Drop the a8w8 padded grid for the cluster_m fallback: the tuned
cluster_m if it tiles M, else the largest power of two that does
(cm=3 fits measured worse).
- Drop bounded_m: the fused split-K epilogue always stores through the
buffer descriptor.
- AOT: update the docs and comments for the above.
- test_flydsl_batched_gemm.py: use get_gfx_runtime in
test_compute_switch_penalty. test_gemm_a4w4.py: add off-grid shapes
for the shrunk clusters.
…luster_m
The generic a8w8 kernel (mx128, mx32, ptpc) reduced split-K through an FP32
plane per split and a separate reduce kernel. With fused_splitk the K splits
of a tile are one cluster along grid.z and reduce through the shared fused
epilogue, as the compute and a4w4 kernels already do; the sum stays in FP32
and in split order, so the output is bitwise equal to the unfused path.
- cluster_m is a launch argument (use_cluster + i32_cm) like the compute
kernel, so one binary serves every M; kernel symbols drop _cm and gain
_fsk / _plain.
- The epilogue helper handles tiles with fewer than one thread pass of
reduced rows (small tile_m / split_k); its other paths are unchanged.
- mx128/mx32, ptpc and the batched entries call the new signature; the ptpc
kernelName parser reads _fsk. fused_splitk_ok and fused_splitk_partial_shape
are shared by the entries.
…d ptpc
Every split_k > 1 candidate gets a fused twin (_fsk) appended at the end of
kernels_list, so existing kernelIds keep their kernels. The mx128 and ptpc
tuners keep split_k > 1 only as fused; the runtime fallback heuristics are
unaffected because ties still pick the earlier split_k 1 candidate.
…28 and mx32 GEMM
Each case runs the unfused kernelName and its _fsk twin on a NaN-filled
output: the bytes must match, the fused launch must skip the reduce kernel,
the result must match an FP32 reference, and a CUDA graph replay must give
the same bytes. Cases cover split_k 2/4/8, a one-row tile and clusters along
M and N, at ragged M.
github-actionsBot
changed the title
[FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows
[HIP] [CK] [FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows
Nov 19, 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 8246 --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.
PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers
Behavior and intent
The generic kernel gets cluster-based fused split-K and an M-independent `cluster_m`, so decode GEMMs drop the reduce-kernel launch and the per-`cluster_m` retrace; rank0 extends fusion to any split count up to 16 and to K the split count does not divide, which is where most small-M wins are. The widened candidates and retuned rows use them. The lookahead is limited to block-scaled kernels with one or two A rows, where it wins. The fallback is left alone on purpose: it keeps main's rule and picks, and only the tuner sees the widened candidates.
Validation and unverified scope
At gfx1250, FlyDSL 0.5.5:
- `op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py` as a script (all gfx1250 tuned rows, 17 fused cases x 5 M, direct, catalog and fallback tests): passes on the JIT path, from a prebuilt AOT cache, and with `AITER_FLYDSL_AOT_CACHE=verify` (every cache hit re-traced and its IR compared).
- AOT: `python3 -m aiter.aot.flydsl.gemm` (all tables), then `--check`: 2704 replays ok, 0 failed, 20 refused by the runtime, 511 sizes inside rows' ranges, 0 failed (`origin/main` `ecfa616d8`: 2557 ok; the 147 added rows are the difference). All 126 generic fused rows (103 rank0, 23 row-stripe) hit the cache in verify mode, 0 misses.
- Random fused configs (mx128 / mx32, split_k 2-16, clusters, random M / N / K; 2 seeds, 156 cases: 52 row-stripe, 104 rank0): zero mismatches against the FP32 reference, bitwise equal to the unfused twin where K divides evenly. Stress over the fused / N-cluster kernels the tables use, at every M each serves: ragged M (2066 runs), NaN canaries past M and N (2066), scratch canaries (1206), 18600 repeated launches compared bitwise: 0 failures.
- Tuner `--run_config` through the production entry: K3 450/450 and DSv4 211/211 gfx1250 rows OK. `test_config_shape_collision`: 34 passed.
- Untuned fallback = main's: picks equal `origin/main` on 19949 sampled shapes in each of the plain, A-preshuffle and mx32 modes (the PTPC fallback was checked on 6000 shapes at an earlier revision, its code is unchanged); 1384 untuned points through the production entry are bitwise equal to main's at 1.000x, worst 1.025.
- Row-stripe K rule: over 12.6M tuner-catalog kernel x shape pairs the only change is 99825 pairs that newly fit through rank0, none stops fitting; none of the 149 fused table rows (26 row-stripe-capable on a generic kernel) has an uneven K, so no row changes launch mode. The `t32x64x256 sk8` case at K=7168 (28 K tiles) now launches through rank0 and matches the FP32 reference.
- Merge of #7449: one textual conflict, `run_preshuffle_gemm_a8_gfx1250` (both `fused_splitk` and `partials` kept; a launch with `partials=` runs unfused). One clean merge was wrong: `_splitk_deferrable` would have deferred a fused row whose output is already final, so it returns None for `_fsk`. Covered by `run_ptpc_fused_splitk_ci_correctness` and `check_fused_row`.
- Existing suites: `test_gemm_group32_interface.py` + `test_gemm_host_dispatch_cache.py` 197 passed, 4 failed; the AOT tests (`tests/test_flydsl_aot_{replay,launch,cache}.py`, `tests/test_aot_drivers.py`) 97 passed, 7 failed: the same failing tests as on `origin/main` `ecfa616d8` (same machine and toolchain). `op_tests/test_gemm_a8w8.py` (PTPC) stops in its hipBLASLt reference (`0 valid solutions`) on main and here alike, after `run_ptpc_fused_splitk_ci_correctness` has passed. `test_batched_gemm_a8w8_mxscale_bpreshuffle.py`, `test_gemm_a8w8_bpreshuffle_pad_k.py` (34 passed, 43 skipped) and `op_tests/test_flydsl_batched_gemm.py` pass. A hipBLASLt bf16 reference kernel in the tests' torch reference faults intermittently (seen on GPU 0 and 2; the batched script's fault reproduces on `origin/main`); the affected runs pass on rerun.
- LDS-to-TDM flush (#8737) with the #8486 two-stream reproducer (one CUDA graph, the PR kernel beside the routed MXFP4 MoE; mx32 N=1536 K=6144, M=32 and 64, 2 x 120 s per run): the row-stripe `t32x64x256 nb3 sk4 _fsk` kernel gave 293 and 204 bad replays with no flush, 142 and 140 with main's flush only, and 0 of 377600 and 0 of 429700 with both. An intermittent wrong-element error of generic kernels at M around 500 on `origin/main` `4960107ee` (8/800 runs at cm4_cn2) is gone (0 / 3000); it was the same LDS -> TDM hazard.
- Known slower than main (measured, not fixed here; see Performance): K3 2304x1536 at odd M-tile counts (M=10241: 1.06x on 3 of 4 GPUs, 0.92x on GPU 0), DSv4 7168x3072 M=129 (1.037x) and three same-kernel points that spread 0.94-1.10 over the GPUs.
- Remains unverified: MI250X / MI300X; full-model end-to-end at this rev
[truncated in readiness report; see the PR description for the full answer]
PR-specific question
Only gfx1250 reaches the changed paths (kernels and table rows are keyed gfx1250, cu_num 256), with FP8 A/B, E8M0 scales (mx128 / mx32) or per-token (ptpc), and bf16/fp16 output; the fallback runs only for shapes with no tuned row. The fused path is selected only by a `_fsk` kernel name (tuned row or tuner). Before launch the dispatcher raises RuntimeError unless `N % (tile_n*cluster_n) == 0`, `K % tile_k == 0` with at least `num_buffers` K tiles per split (and `K % (split_k*tile_k) == 0` unless the launch takes rank0), and `cluster_m` divides the M-tile count (otherwise shrunk to the largest power-of-two divisor). A `_fsk` name uses the row-stripe epilogue when `fused_splitk_ok` holds (at least four waves, split_k in 2/4/8, `cm*cn*split_k <= 16`, `tile_m % split_k == 0`, valid TDM output split, whole row passes), K tiles divide by `split_k` and, at split_k 2, the output stripe stays under 4 GiB; else, on a generic kernel, rank0 when `rank0_splitk_ok` holds (`2 <= split_k <= 16`, `cm*cn*split_k <= 16`, FP32 scratch under 4 GiB); else the unfused reduction. Compute kernels never take rank0. The tuner prunes the same conditions in `kernel_fits_shape`. `_nlb` is accepted only on generic kernels with a 1x1 cluster.
Changed op tests
- `op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py`: `test_fused_splitk` runs 17 mx128 / mx32 generic kernels with a `_fsk` name at M 1, 7, 33, 300, 640 (9 take the row-stripe epilogue, 8 take rank0: split_k 3/5/6/7/8, a two-wave tile, uneven K tiles, clustered ones, and a row-stripe-capable `t32x64x256 sk8` at 28 K tiles): zero mismatches against an FP32 reference, no reduce kernel, same bytes under graph replay, bitwise equal to the unfused twin where K divides evenly. `test_fused_splitk_whole_row_passes` and `test_fused_splitk_large_row_stride` cover the whole-row and 2^29-stride cases; `test_row_kernel_spills` compiles every tuned generic row-path kernel with three or more A rows (`COMPILE_ONLY`) and requires no scratch; `test_mx128_kernel_direct` covers the sk1 `_qe` K3 kernels; `test_untuned_fallback_pick` pins four picks to main's; `test_tuner_catalog` checks rank0 / row-stripe fit rules (including the even / uneven K split) and every K3 row's kernelId.
- `op_tests/test_gemm_a8w8.py`: `run_ptpc_fused_splitk_ci_correctness` (gfx1250) runs two PTPC `_fsk` kernels at M 1, 7, 33, 300 on a NaN-filled output: no NaN left, FP32 reference within the PTPC tolerance, no reduce kernel, bitwise equal to the unfused twin and under graph replay.
- `op_tests/test_gemm_a8w8_splitk_deferred.py`: `check_fused_row`: a fused PTPC row is not deferred and gives its final output with no reduce launch and no partials.
PR state
PASS — pull request is marked ready for review
Copilot findings
FAIL — an active Copilot finding has no substantive reply from the PR author
FAIL — an active Copilot finding has no substantive reply from the PR author
FAIL — an active Copilot finding has no substantive reply from the PR author
FAIL — an active Copilot finding has no substantive reply from the PR author
Code and op-test hygiene
PASS — no committed artifact or conflict marker detected
Required CI
PASS — Black: passed
PASS — Ruff: passed
PASS — Repository dependency: passed
FAIL — Aiter Test Gate: failed
Required CI failed; fix it before requesting human review.
Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.
This PR extends gfx1250 FlyDSL GEMM support with fused split-K reduction, removing the separate reduction launch for eligible generic a8w8 kernels. It builds on #7827 and #7868 and retunes Kimi-K3 and shared model configurations.
Changes:
Add generic fused split-K support and runtime cluster sizing across kernels and wrappers.
Expand tuning candidates and update gfx1250 model tables.
Add correctness, table-consistency, and kernel-switching tests; update AOT documentation.
…ider cluster space
Widen the mx128 tuner candidates (fused split-K, generic clusters, compute 1x1 and
power-of-two clusters; appended so existing kernelIds are unchanged, and fused
clusters are capped at 16 workgroups) and retune the K3 a8w8 mxscale table: 64 rows
changed and 130 added. Shared DSv4 keys are updated where the new kernel is faster.
Rows that were slower in two independent sweeps stay on their old kernel.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Non-power-of-two fused split counts can cause incorrect reductions or unwritten scratch reads, and the FP32-reference comparison does not fail tests on numerical mismatches.
… reference in the fused test
The shared fused epilogue wraps peer stripes with `& (split_k - 1)`, which mixes
output rows for split counts that are not a power of two (e.g. 3 gave a wrong
result at M=48, N=128, K=1536). fused_splitk_ok now accepts only 2/4/8 splits, so
other counts take the unfused reduction. test_fused_splitk now fails on a mismatch
with the FP32 reference instead of only logging it.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The fused split-K path accepts a tile configuration whose epilogue leaves 32 rows per stripe unwritten, requiring matching divisibility guards in both paths and a regression test.
The generic fused path accepts a 192x256x128 tile with 2x2 waves, two buffers and split_k=2 for ptpc (M,N,K)=(192,256,1024), but the epilogue processes only 64 of each split's 96 rows, leaving 32 rows per stripe unwritten. Require divisibility by rows_per_iter * unroll, while retaining the predicated small-stripe case, so incomplete batches fall back to unfused reduction; mirror this check in kernels/gemm_a8w8_gfx1250.py:185–188. Add a regression for this configuration, following the complete-batch check in _splitk_epilogue_error for a4w4.
The fused epilogue stores whole passes of rows_per_iter * unroll rows, so a stripe that
is not a whole number of passes leaves its tail unwritten: a 192x256 tile with two
splits wrote 64 of 192 rows. fused_splitk_ok, and the matching check in the generic
kernel, now require a whole number of passes, so such configs take the unfused
reduction. None of the tuner candidates or tuned rows changes legality. Add a
regression for the 192x256 tile.
Conflict resolved (from #7449, PTPC split-K left to the consumer):
- bpreshuffle_gemm_gfx1250: keep both of run_preshuffle_gemm_a8_gfx1250's
fused_splitk and partials arguments. A caller's partials buffer is the
unfused (split_k, M, N) layout, so a launch with partials runs unfused
(the same fallback as an unsupported fused geometry) and skips the reduce;
the fused epilogue and the reduce launch keep their own guards.
Merged cleanly but needed a change:
- gemm_op_a8w8._splitk_deferrable: a fused split-K row (_fsk) reduces in the
kernel, its output is final, so it is not deferred and goes through
gemm_a8w8_bpreshuffle.
…plit-K hand-off (#7449)
- test_gemm_a8w8: a fused PTPC kernel name launched with partials= writes the
unfused (split_k, M, N) partials, launches no reduce and leaves Out alone;
reduce_splitk_partials_gfx1250 then gives the fused output's bytes.
- test_gemm_a8w8_splitk_deferred: a fused split-K row is not deferred (host
table check, and on gfx1250 the deferred call is the plain GEMM: no reduce
launch, no partials, same bytes).
…where it wins
The row schedule issued the next K sub-step's LDS loads before the current
WMMAs in every kernel, which keeps a second B and scale set live:
- with three or more A rows it spills (mx32x32 t224x128x256: 626 VGPRs and
20 B of scratch against 498 and none on main, 1.31x slower; t160x128x256
spills too);
- for PTPC, and for 32-scale kernels with two buffers or tile_k < 512, it is
neutral to slightly slower.
Keep it for block-scaled kernels with one or two A rows (32-scale ones from
tile_k 512 and three buffers); every other kernel keeps the previous schedule.
All 6069 points of every gfx1250 table row of main and this branch (cold
weights, CUDA graph, 6 rotated passes on 4 GPUs): the worst point against
main drops from 1.28 to 1.04 (mx32x32), 1.06 to 1.05 (ptpc) and 1.08 to
1.05 (bmm32x32); 1558 points are faster than main, 499 faster than the
schedule without the lookahead.
test_row_kernel_spills compiles the tuned row-path kernels with three or more
A rows and fails on any scratch use.
…and the 32-scale lookahead lose
Every gfx1250 table row of main and this branch (6069 points), a dense M scan
(2812) and ragged M (364), cold weights, CUDA graph, each point timed on all
4 GPUs and compared with origin/main:
- 32-scale kernels with tile_k 512, three buffers and more than two
accumulator tiles per wave (mx32x32 t64x64x512 nb3, 5120x15360 M 129-192)
were 1.5-2.5% slower than main on every GPU with the lookahead; they keep
main's schedule.
- K3 rows whose M block is slower than main take main's kernel:
6400x7168 M 80 / 96, 8448x7168 M 224 / 240 / 256, 12288x1536 M 320 / 512,
18432x1536 M 224 / 240, 7168x1536 M 4096 / 8192 (catch-all rows of the
ragged M above them; they lost up to 1.27x).
- DSv4 7168x768 M 8192 (catch-all of M 4097-8192): t256x256x128 nb2 cm2_cn4,
picked over its whole span.
Result: the 5639 cu256 rows take 2.7% less time than main (geomean 0.951);
7 points are > 1.03 (median of the 4 GPUs), the worst is K3 2304x1536
M 10241 (1.08 on GPUs 1-3, 0.93 on GPU 0: odd M-tile count demotes the
cluster of the M 16384 catch-all row).
_flydsl_mxfp8_fallback_kernel is main's rule again, over the original kernels
(fallback_kernels(), the head of kernels_list), so the widened tuner candidates
never reach it. Its picks equal main's on 39817 sampled shapes in each of the
plain, A-preshuffle and mx32 modes (the PTPC fallback on 6000).
1384 untuned points (kimik2 table on 256 CUs, the fallback-served M of the K3 /
DSv4 shapes, 683 sampled shapes; cold weights, CUDA graph, every point on all
4 GPUs) against origin/main: bit-equal outputs, 0.997x the time, worst 1.020.
test_untuned_fallback_pick pins main's picks and fails when a widened candidate
reaches the fallback.
… kernel gains under 2%
Seven rows (two DSv4, five K3) go back to main's line. Paired on one box, the time of
the retuned kernel over main's kernel is 0.98 or more (geomean over the row's points),
so the retune is within noise, and the recorded us of the new line sits on another
measuring scale than main's.
…in, keep main's line for two
Paired on one box at FlyDSL 0.5.5, these rows are not faster than main (geomean of the
time over main's >= 0.98). The eight added rows (M <= 2048) sit in front of a row whose
kernel is the one main serves the same M with, so every M of their span lands on main's
kernel without them; K3 18432x1536 M=160 was 1.05x slower than main on all four GPUs.
The two changed rows (1024x7168x4224 at M 1024, 3584x7168 at M 128) go back to main's line.
Update for the Dec 2 review (head 8f11bd4). New revision c4f8a6d (main merged up to ecfa616, FlyDSL 0.5.5 as pinned by main); the PR description is updated to match.
1. Shared default dispatch (gemm_op_a8w8.py). The change to that file is now two small edits against main (4 lines added, 3 removed): _splitk_deferrable returns None for a fused _fsk row (its output is already final, so #7449's deferred reduction must not take it), and _flydsl_mxfp8_fallback_kernel iterates fallback_kernels(), the original kernels at the head of the catalog, so an untuned shape gets the kernel main gives it: the picks equal main's on 19949 freshly sampled shapes in each of the plain, A-preshuffle and mx32 modes, pinned by test_untuned_fallback_pick. The retuned table rows are the only thing that changes which kernel a shape gets. Consumer validation on gfx1250 for the Kimi-K3 and DSv4 tables: --run_config through the production entry passes on every row (K3 450/450, DSv4 211/211); the op test runs every tuned gfx1250 row (JIT, AOT cache hit, AOT verify); all 6093 table points (every gfx1250 row of both trees' tables, at its smallest M, its middle and its tuned M, each timed on all 4 GPUs) are 0.962x of main's time, with outputs bitwise equal to main's at 5845 of them.
2. mx32 untuned ranking. Not changed by this PR any more: untuned mx32 calls keep main's ranking and main's kernels (point 1), so there is no mx32 ranking to validate. Paired production-entry data at this revision: mx32 table rows 108 points 0.990x (worst 1.011), mx32x32 2081 points 0.992x (worst 1.024), bmm32x32 298 points 0.992x; and 1384 untuned (fallback-served) points are bitwise equal to main's at 1.000x (worst 1.025).
3. The 3.71x over 758 shapes. Withdrawn together with the tile-cost fallback rule it measured; neither is in the PR or the description any more. The Performance section is now paired against origin/main on one box at FlyDSL 0.5.5 (relative timings only; the us in the CSVs of main and of this PR are not comparable), and states the point set and the method.
Other points. FlyDSL: every number is re-measured on 0.5.5 (main moved its pin from 0.5.3 in #8460). Data scope: K3 303 -> 450 rows (147 added, 136 changed), DSv4 1266 rows (80 changed), no duplicate keys; rows that did not beat main by 2% on the same box are not kept (9 changed rows went back to main's line, 8 added rows dropped). The 165-entry exact-M archive is unchanged.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Row-stripe selection can raise on a supported shape because it ignores K divisibility, and the new tuning CSV is not consumed by default dispatch or AOT prebuilding.
… evenly, else rank0
A _fsk kernel whose geometry fits the row-stripe epilogue took it whatever
K was, then raised when the K tiles did not divide by split_k, although
rank0 launches that shape (t32x64x256 sk8 at K=7168: 28 K tiles over 8).
The launcher and kernel_fits_shape now take the row-stripe epilogue only
for an even K split, and otherwise rank0 on a generic kernel. Adds that
case to the fused split-K sweep and the tuner catalog test. No tuned row
changes: none has a row-stripe geometry with an uneven K.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The gfx1250 cross-workgroup scratch exchange, uneven-split barriers, and LDS-to-TDM ordering need hardware-specialist review, with GPU correctness, concurrency, and performance results not independently reproduced.
Merges origin/main up to a0af09d. One textual conflict, in
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py: both sides edited the
aiter.test_common import (kept assertAllclose and run_perftest) and
appended an arch-gated block to the end of __main__ (kept the gfx1250
fused split-K block and main's gfx950 8-wave preshuffled-scale block).
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The gfx1250 cross-workgroup reduction and barrier/LDS ordering require specialist review and head-matched GPU validation beyond the available static checks.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The gfx1250 cluster synchronization, uneven split-K barriers, and LDS-to-TDM handoff require specialist review and head-matched GPU correctness and performance evidence unavailable in this source-only environment.
…15808c7, head 2026-11-19T10:14:52Z)
Applied as the diff ce334d0..15808c7 (26 files) onto the rebased 1116 tree; PR state: open, author aoli26, base main.
Squash-applied: #8246's branch merges main (ce334d0, this tree's base) and carries rebased copies of aoli26's
#7827 (head 9d38b5c, every added line present here) and #7868 (head 570805d; 3 of its added lines
are superseded by #8246's later edits), so this one diff applies the #7827 -> #7868 -> #8246 stack as #8246 has it.
(cherry picked from commit f58bb7e)
Rebase onto main 12-03: kept at the 15808c7 snapshot (the PR head is now c4f8a6d, see the rebase report). Main's #8678 (AOT launchers) and #7449 (deferred split-K partials) conflict with it in the two wrappers: bpreshuffle_gemm_gfx1250.py takes both fused_splitk and main's partials (a launch with partials runs unfused, main's _launch_splitk_reduce / reduce_splitk_partials_gfx1250 kept, skipped when fused); mxfp8_bpreshuffle_gemm_gfx1250.py keeps fused_splitk_ok (generic kernel included) and launches gemm_a8w8_launcher.lazy() with this PR's argument layout (arg_out, runtime cluster_m, fused_splitk). Same as the PR author's own merge of main, without the later lean_stripe_fits guard. aiter/aot/flydsl/sources.py: the gemm_a8w8_gfx1250 cache now also hashes kernels/splitk_fused_epilogue_gfx1250.py, which the kernel imports (as on the PR head).
Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce), as on the PR head.
#8978)
* K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows (#8778 @ ea7a5d8)
#8778 (aoli26; base main; open) applied to k3-455-dev as its net change on its 19 files at head
ea7a5d8 (2026-11-26T14:47:07Z), 3-way against the PR's main base adbb6ac. The 8 files k3-455-dev had
changed (all only by #8246 @ 15808c7) take the PR's version, so all 19 files equal the PR head. It
carries the newer #8246 (ccc4270), the table PRs #8579 / #8586 / #8601 and main's #8566 (its compute
guard, which #8778 replaces); no other main change rides in.
Validated in the K3 1P1D integration branch (aiter zejun/k3-455-dev 627e1eb) on 16 MI455X
(wuhuikx/LLM-Booster#578). The PR head has moved on since (204ce9d: merges of #8246 @ 0d6cf15 and of
main, which brings #8737); those can follow when #8778 lands.
Co-authored-by: zejunchen-zejun <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Update K3 FP8 kernels to c997 and add exact-M tuning
Preserve the existing dev wrappers and bucket tables. Add 162 accepted retuned exact configurations and 3 c997-default compatibility records, with CPU dispatch coverage for all 675 measured points. Backport the three kernel files from c99781c without merging main history. Integrated-head GPU validation remains outstanding.
---------
Co-authored-by: aoli26 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Zhang <[email protected]>
(cherry picked from commit 1cc9d02)
Rebase onto main 12-03: the 19 files keep this commit's content; only main's later changes are added: the AOT launcher factories of #8678 (mxfp8 / batched wrappers launch gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy(), splitk_reduce_launcher.lazy(); _lazy_import keeps _data_ptr), #7449's deferred split-K entry points and #8636's ragged-K fallback. gemm_a8w8_gfx1250.py: this commit's rank0 split-K epilogue and flush_addr (it already carries #8737's flush). gemm_op_a8w8.py: main's #8566 guard in get_mxscale_bpreshuffle_config (no padded row below a compute kernel's M tile) is removed, as on the #8778 head, because the c997 compute kernel serves underfilled tiles; test_gemm_host_dispatch_cache.py takes #8778's test_mxscale_compute_row_serves_underfilled_m_tile in place of main's two guard tests. kimik3 mxscale tuned CSV: this commit's rows (626 changed or added) replayed by key; the result equals this commit's table.
Rebase onto main 12-03: main #7449 moved the bpreshuffle row lookup into _bpreshuffle_config(XQ, WQ); this commit's Kimi-K3 exact-row lookup there needs x_scale, w_scale and Y, so _bpreshuffle_config takes them (the deferred split-K path passes a meta tensor of the output's shape and dtype, so it picks the same row as gemm_a8w8_bpreshuffle).
Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce).
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
Adds fused split-K to the generic gfx1250 a8w8 GEMM (mx128 / mx32 / ptpc / batched): the K splits of a tile form one cluster along grid.z and are reduced in FP32 inside the same launch, with no reduce kernel. It also makes the kernel's
cluster_ma launch argument, widens the mx128 tuner candidates, adds opt-in_qe/_nlbmain-loop schedules, and retunes the Kimi-K3 and shared DSv4 mx128 rows. #7827, #7868, #7659, #8678, #8737 and #7449 are merged into main; this branch merges main up to6afa7b412, so the diff holds only this PR's changes.Motivation
Only the compute kernel had fused split-K; the generic kernel (all decode-size GEMMs) split K through a separate reduce kernel, an extra launch on small-M, large-weight GEMMs. The row-stripe epilogue also only fits 2/4/8 splits that divide K evenly, so most split counts small-M shapes want could not be fused. The K3 rows were not tuned with fused split-K, generic clusters or compute 1x1.
Changes
_fsk), generic kernel. The shared row-stripe epilogue (split_k 2/4/8, K tiles split evenly, at least four waves) is used where it fits; otherwise rank0: every split stores its FP32 tile to scratch, a cluster barrier follows, and split 0 sums the splits in order and writes the output. rank0 takes split_k 2..16 and uneven K tiles (needsK % tile_k == 0only; scratch must stay under 4 GiB, else the launch is unfused).cluster_mis a runtime argument and leaves the compile key and symbol name. A split_k 2 stripe of 4 GiB or more ofOut(lean_stripe_fits) takes rank0 (generic) or the unfused reduction (compute, PTPC).tile_k512); every other kernel keeps main's order. With three or more A rows it spilled (mx32x32t224x128x256: 626 VGPRs and 20 B of scratch, 1.31x slower);test_row_kernel_spillspins this. Opt-in suffixes:_qe,_nlb(1x1 clusters only),_cpN._fskthrough main's AOT-cache launchers ([FlyDSL] [gfx1250] Launch the GEMM and grouped-MoE kernels through the AOT cache #8678). A PTPC_fskrow is never handed to [FlyDSL] [Perf] Let the consumer finish a gfx1250 PTPC split-K GEMM #7449's deferred reduction (_splitk_deferrablereturns None for it); a launch withpartials=runs unfused. The AOT cachegemm_a8w8_gfx1250also declaressplitk_fused_epilogue_gfx1250.pyas a source. The fused paths follow main's LDS flush before TDM stores ([FlyDSL] Work around gfx1250 LDS-to-TDM store corruption #8737).kernel_fits_shape)._flydsl_mxfp8_fallback_kernelkeeps main's rule and iteratesfallback_kernels(), the original kernels, so no widened candidate can be picked; picks equalorigin/mainon every sampled shape in the plain, A-preshuffle and mx32 modes (pinned bytest_untuned_fallback_pick).kimik3_...anddsv4_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv): 1569 -> 1716 rows. K3: 136 rows change kernel, 147 added (303 -> 450). DSv4: 80 change kernel. 139 changed / added rows are fused. A row stays only where it beats main on the same box: over the measured points of its span the geomean of its time over main's is below 0.98 (every changed row is at 0.979 or less). Rows without that gain went back to main's line (9) or were dropped (8 added K3 rows). A row serves the Ms up to its own M; large M with no row walks (getPaddedM) to the 2048 / 4096 / 8192 / 16384 rows, so those rows were picked over their whole span. No exact-M guard rows.aiter/configs/kimik3_fp8_exact_gemm.csv(165 entries, added by ZLkanyo009) is an inactive archive: nothing in dispatch or AOT reads it, and its entries need the exact-M dispatch integration ([K3][gfx1250] Bring c997 TP1 FP8 GEMM and exact-M tuning to k3-455-dev #8978; 14 also [HIP] [CK] [FlyDSL] [gfx1250] K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows #8778). It is not part of this PR's retuning.fused_splitk_okaccepts only 2/4/8 splits, whole row passes and four waves (the shared epilogue wraps peer stripes with& (split_k - 1), stores whole row passes and sizes its load batch per 128 threads); other geometries take rank0. Uneven rank0 splits take equal numbers of loop cluster barriers. A row-stripe-capable geometry with an uneven K (t32x64x256 sk8at K=7168) raised instead of taking rank0; fixed. The ptpc wrapper also checksN % (tile_n*cluster_n).Performance (if applicable)
gfx1250 (256 CU), FlyDSL 0.5.5 (the version
origin/mainpins). Relative timings only (the CSVusare not comparable between machines and power states). Production entries with the merged tuned tables, cold weights (>= 1 GiB), CUDA graph, median over uncontended rounds; before =origin/mainecfa616d8, after = this branch. Every point was timed on all 4 GPUs and its value is the median (large-M cluster / compute kernels rank differently on GPU 0: K3 2304x1536 M=10241 is 0.924x there and 1.06x on the others). Measured atc4f8a6d2f; the commit after it changes no row's kernel or launch mode (see Validation). Point set: every gfx1250 row of every tuned table either tree loads, at its smallest M, the middle of its span and its tuned M: 6093 points, bitwise equal to main's output at 5845 (the rest take another kernel or split).The 3 points above 1.03x: K3 2304x1536 M=10241 (1.060; an odd M-tile count demotes the cluster of the M=16384 catch-all row; its M=16384 row is 0.84x), DSv4 7168x3072 M=129 (1.037; the first M of a row that is 6-8% faster at its other Ms) and K3 67584x7168 M=32 (1.033; the same kernel on both sides, 0.98-1.08 over the GPUs).
Row level, same box: the 216 table rows that change a kernel are all at 0.979x or below (geomean 0.785x DSv4, 0.804x K3); the 147 added K3 rows are at 0.855x. A dense M scan (mx128, 37 K3 / DSv4 (N, K) shapes x 76 M from 1 to 640 = 2812 points) is 0.895x (-3.8% of the time; no shape's geomean over M above 1.00x), ragged / odd M (273 points) 0.929x, large M (315 points, M 660 to 32768) 0.930x. Main's DSv4.1 mx32 rows (#8047, 24 points): bitwise equal, 0.999x.
Untuned shapes (no table row; fallback = main's rule and kernels): 1384 fallback-served points (the
kimik2_...table is 96-CU, so its 430 points run the fallback on this box; untuned K3 / DSv4 Ms; sampled shapes up to M=39033) are bitwise equal to main's at 1.000x, worst 1.025.Lookahead: its first version, on for every row kernel, made 50 mx32x32 points up to 1.28x slower than main (33 kernels with three or more A rows spilled). The gate now covers block-scaled kernels with at most two A rows (32-scale ones only from
tile_k512 with four buffers, or at most two accumulator tiles per wave with three); PTPC keeps main's order. Result above: no mx32x32, PTPC or bmm32x32 point is above 1.03x. Known left:t32x64x1024 nb3at 5120x15360 M 65-80 is about 1.5% slower with the lookahead (3 points).The
usrecorded in the tables are not comparable with main's: main's rows were timed on another machine (main records 28.16 us for K3 4096x7168x1536, the same kernel measures 21.7 us on this box, andusmoves about 10% with the GPU's power state), the rows this PR adds or changes carry the median of 6-8 runs on one GPU. So a changed row can record a higherusthan the line it replaces and still be faster: 42 of the 216 changed rows record ausmore than 5% above main's, and each is at 0.979x of main's time or less in the same-box pairing. The time ratios above are the measurement.Testing
Tested on gfx1250 only; the changed kernels and tables are gfx1250 only.
Documentation
Dependencies
Depends on #7827, #7868, #7659, #8678, #8737 and #7449, all merged into main.
Breaking Changes
No API change. Generic-kernel symbol names no longer contain
_cm...becausecluster_mis now a runtime argument, so existing FlyDSL AOT caches of that kernel must be rebuilt (the AOT cache keys on the changed sources, so a stale entry misses). Shapes without a tuned row keep main's fallback pick. The batched candidate enumeration is identical toorigin/main.PR Self-Review
Reviewed revision
c0d4678
Behavior and intent
The generic kernel gets cluster-based fused split-K and an M-independent
cluster_m, so decode GEMMs drop the reduce-kernel launch and the per-cluster_mretrace; rank0 extends fusion to any split count up to 16 and to K the split count does not divide, which is where most small-M wins are. The widened candidates and retuned rows use them. The lookahead is limited to block-scaled kernels with one or two A rows, where it wins. The fallback is left alone on purpose: it keeps main's rule and picks, and only the tuner sees the widened candidates.Validation and unverified scope
At gfx1250, FlyDSL 0.5.5:
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.pyas a script (all gfx1250 tuned rows, 17 fused cases x 5 M, direct, catalog and fallback tests): passes on the JIT path, from a prebuilt AOT cache, and withAITER_FLYDSL_AOT_CACHE=verify(every cache hit re-traced and its IR compared).python3 -m aiter.aot.flydsl.gemm(all tables), then--check: 2704 replays ok, 0 failed, 20 refused by the runtime, 511 sizes inside rows' ranges, 0 failed (origin/mainecfa616d8: 2557 ok; the 147 added rows are the difference). All 126 generic fused rows (103 rank0, 23 row-stripe) hit the cache in verify mode, 0 misses.--run_configthrough the production entry: K3 450/450 and DSv4 211/211 gfx1250 rows OK.test_config_shape_collision: 34 passed.origin/mainon 19949 sampled shapes in each of the plain, A-preshuffle and mx32 modes (the PTPC fallback was checked on 6000 shapes at an earlier revision, its code is unchanged); 1384 untuned points through the production entry are bitwise equal to main's at 1.000x, worst 1.025.t32x64x256 sk8case at K=7168 (28 K tiles) now launches through rank0 and matches the FP32 reference.run_preshuffle_gemm_a8_gfx1250(bothfused_splitkandpartialskept; a launch withpartials=runs unfused). One clean merge was wrong:_splitk_deferrablewould have deferred a fused row whose output is already final, so it returns None for_fsk. Covered byrun_ptpc_fused_splitk_ci_correctnessandcheck_fused_row.test_gemm_group32_interface.py+test_gemm_host_dispatch_cache.py197 passed, 4 failed; the AOT tests (tests/test_flydsl_aot_{replay,launch,cache}.py,tests/test_aot_drivers.py) 97 passed, 7 failed: the same failing tests as onorigin/mainecfa616d8(same machine and toolchain).op_tests/test_gemm_a8w8.py(PTPC) stops in its hipBLASLt reference (0 valid solutions) on main and here alike, afterrun_ptpc_fused_splitk_ci_correctnesshas passed.test_batched_gemm_a8w8_mxscale_bpreshuffle.py,test_gemm_a8w8_bpreshuffle_pad_k.py(34 passed, 43 skipped) andop_tests/test_flydsl_batched_gemm.pypass. A hipBLASLt bf16 reference kernel in the tests' torch reference faults intermittently (seen on GPU 0 and 2; the batched script's fault reproduces onorigin/main); the affected runs pass on rerun.t32x64x256 nb3 sk4 _fskkernel gave 293 and 204 bad replays with no flush, 142 and 140 with main's flush only, and 0 of 377600 and 0 of 429700 with both. An intermittent wrong-element error of generic kernels at M around 500 onorigin/main4960107ee(8/800 runs at cm4_cn2) is gone (0 / 3000); it was the same LDS -> TDM hazard.ccc4270, gave GEMM time per step c32 -5.2%, c128 -21.5%, c256 -6.0%; batched T08 was about 10% slower in the c256 graph there, cause not found).PR-specific question
Only gfx1250 reaches the changed paths (kernels and table rows are keyed gfx1250, cu_num 256), with FP8 A/B, E8M0 scales (mx128 / mx32) or per-token (ptpc), and bf16/fp16 output; the fallback runs only for shapes with no tuned row. The fused path is selected only by a
_fskkernel name (tuned row or tuner). Before launch the dispatcher raises RuntimeError unlessN % (tile_n*cluster_n) == 0,K % tile_k == 0with at leastnum_buffersK tiles per split (andK % (split_k*tile_k) == 0unless the launch takes rank0), andcluster_mdivides the M-tile count (otherwise shrunk to the largest power-of-two divisor). A_fskname uses the row-stripe epilogue whenfused_splitk_okholds (at least four waves, split_k in 2/4/8,cm*cn*split_k <= 16,tile_m % split_k == 0, valid TDM output split, whole row passes), K tiles divide bysplit_kand, at split_k 2, the output stripe stays under 4 GiB; else, on a generic kernel, rank0 whenrank0_splitk_okholds (2 <= split_k <= 16,cm*cn*split_k <= 16, FP32 scratch under 4 GiB); else the unfused reduction. Compute kernels never take rank0. The tuner prunes the same conditions inkernel_fits_shape._nlbis accepted only on generic kernels with a 1x1 cluster.Changed op tests
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py:test_fused_splitkruns 17 mx128 / mx32 generic kernels with a_fskname at M 1, 7, 33, 300, 640 (9 take the row-stripe epilogue, 8 take rank0: split_k 3/5/6/7/8, a two-wave tile, uneven K tiles, clustered ones, and a row-stripe-capablet32x64x256 sk8at 28 K tiles): zero mismatches against an FP32 reference, no reduce kernel, same bytes under graph replay, bitwise equal to the unfused twin where K divides evenly.test_fused_splitk_whole_row_passesandtest_fused_splitk_large_row_stridecover the whole-row and 2^29-stride cases;test_row_kernel_spillscompiles every tuned generic row-path kernel with three or more A rows (COMPILE_ONLY) and requires no scratch;test_mx128_kernel_directcovers the sk1_qeK3 kernels;test_untuned_fallback_pickpins four picks to main's;test_tuner_catalogchecks rank0 / row-stripe fit rules (including the even / uneven K split) and every K3 row's kernelId.op_tests/test_gemm_a8w8.py:run_ptpc_fused_splitk_ci_correctness(gfx1250) runs two PTPC_fskkernels at M 1, 7, 33, 300 on a NaN-filled output: no NaN left, FP32 reference within the PTPC tolerance, no reduce kernel, bitwise equal to the unfused twin and under graph replay.op_tests/test_gemm_a8w8_splitk_deferred.py:check_fused_row: a fused PTPC row is not deferred and gives its final output with no reduce launch and no partials.