Skip to content

[FlyDSL] [Bugfix] gfx950 A16W16: reduce split-K and slice-K partials in fp32, deterministically - #7053

Open
AndreasKaratzas wants to merge 24 commits into
ROCm:mainfrom
AndreasKaratzas:akaratza_hgemm_fp32_partials
Open

AndreasKaratzas wants to merge 24 commits into
ROCm:mainfrom
AndreasKaratzas:akaratza_hgemm_fp32_partials

Conversation

@AndreasKaratzas

@AndreasKaratzas AndreasKaratzas commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
  • Slice-K: every k-wave writes its fp32 accumulator tile to LDS once, and the whole workgroup adds the k-waves in order while it stores C (or the split's partial). C is rounded once.
  • Split-K: every split stores its fp32 partial to a workspace and counts itself in on the tile's counter. Partials are added in split order and C is written once. No zero-init of C, no atomics on C, no cache-wide fences (sc1 accesses only).
  • Split-K reduction, picked by the host per launch:
    • Shared, when the whole grid fits on the CUs, split_k <= 16, the tile has at least 4096 elements and, for k_waves=1, split_k * tile >= 16384 (not for half-tile-interleaved configs): each split promises to reduce one range of the tile, polls at most 64 times until every split has arrived, then adds every split's share of that range and writes it to C. A split whose polls run out stores its range and withdraws the promise with a CAS. The last split to arrive reduces every range that has no promise. No wait is unbounded.
    • Otherwise the last split to arrive reduces the whole tile: from the MMA fragments for k_waves=1, through LDS for k_waves>1. With fragments and tiles of at least 1024 elements, it adds its own partial from registers (one copy of the sum per split index, picked by a scalar branch), and when the tiles cross M, partial stores and loads of 4-row groups past M point past the bounds-checked workspace, so nothing is written or read for them.
  • Every kernel argument the kernels use (A, B, C, semaphore, workspace and bias addresses, M, N, K, working K) is loaded through one empty asm at entry, so the scalar loads share one wait instead of two serialized round trips before the first weight load.
  • With group_m == 0, the grid is (n tiles, m tiles, splits): the same dispatch order as the linear tile id, without dividing it by num_pid_n.
  • Each tile's counter is one int32 on its own 128-byte line, and the last arrival resets it for the next launch. get_split_k_buffers() loses its split_k argument, and op_tests/test_graph_alloc.py now calls it as get_split_k_buffers(s, dev).
  • split_k no longer has to divide K: each split takes whole block_k tiles and the last split takes the remainder. Configs that were valid before get the same partition. The gfx950 tuner tries split_k 1..16, 20, 24, 28, 32 and k_waves 1, 2, 4, 8.
  • Kernel names gain fp32/f32, plus c (one-pass slice-K combine), s (shared reduction) and m (row-masked partials), so stale disk-cache binaries are not reused. split_k is a constexpr of the param, so the reduction is unrolled.
  • Retuned the 824 gfx950 bf16 rows with M <= 128 that use split-K or slice-K. A row only changes if the new config is exact on integer inputs, bitwise deterministic, and faster in separate processes and in interleaved runs. 43 of them now go to torch (hipBLASLt) or Triton, which were faster there than the exact FlyDSL configs tried.
  • The fp32 split-K workspace is cached per stream and size bucket (982be6a). Eager host time per split-K call drops from about +7 us to about +2 us vs main. A launch inside a graph capture on a stream without a cached buffer still takes its workspace from the graph's pool. graph_alloc.is_capturing() is added for this.
  • 39 of the 68 256-CU bf16 rows on the asm split-K kernels with 3 or more splits (not repeatable) move to repeatable, faster configs (49de840).
  • Two more retunes for the fp32 reduction: 123 split-K rows (b155ae8), then 317 rows from a staged screen of the tuner catalog (98615f7, fb04752). Exact, repeatable configs only.
  • minimax_m3_mxfp4 128x12288x6144 uses the exact FlyDSL config t128x96x64x5 ks2 w4x1x1 stg3 bnt from aca9344. 491a3ab had moved this row to hipBLASLt solution 17403. 1f8a4e5 removes that row again, because main removed all shipped hipBLASLt BF16 rows in [Config] [Bugfix] Remove all shipped hipBLASLt BF16 tuned rows #8490 ([Config] Check hipBLASLt solution indexes in tuned BF16 CSVs against the hipBLASLt they are used with #8406). This PR adds no hipBLASLt rows.
  • aiter/aot/flydsl/gemm.py is unchanged: main's replay-based AOT build ([FlyDSL] [JIT] Build the GEMM, conv, chunk_gdn_h and FP8 FMHA AOT caches by replaying the runtime #6956) launches each tuned row through gemm_a16w16, so it builds the kernels with the workspace and the counter buffer without HGEMM-specific arguments.
  • test_flydsl_hgemm.py: with integer inputs every fp32 partial is exact, so split-K and slice-K outputs must equal the exact product rounded once, and repeated runs must be bitwise identical. Adds one uneven split (4x1536x7168 ks5) and more split-K and slice-K cases.

The gfx950 FlyDSL HGEMM rounded every split-K partial to bf16 and added it to C with packed bf16 atomics. It also summed slice-K wave partials through an LDS tile typed as the bf16 output. So each output went through several bf16 roundings instead of one rounding of the fp32 sum, and split-K results with 3 or more splits changed from run to run with the atomic order. This is #5976. The tuner accepts these kernels because it checks at 5e-2. We hit it in vLLM with bf16 linears and VLLM_ROCM_USE_AITER=1: on the Kimi-K3 decode rows below, 37-50% of outputs are wrong (hipBLASLt: under 0.1%).

An exact reduction has to store fp32 partials and read them back, which the bf16 atomics skipped. Sharing that reduction across the splits where they are all resident, doing the slice-K combine in one pass and loading the kernel arguments in one round trip bring the 1733 affected rows to 5.0% (cold) / 5.7% (warm) below main in geomean. 257 of them stay more than 2% slower than main (none above 15%); see Performance.

Outputs vs the correctly rounded fp64 product. Gaussian inputs, 20 runs, dispatched through aiter.tuned_gemm with each version's own tables:

M x N x K kernel before -> after before: != RN / >1 ulp after: != RN / >1 ulp hipBLASLt: != RN / >1 ulp runs differing before -> after
8x1536x7168 t16x32x128x8 ks4 -> t16x32x64x8 ks5 (Kimi-K3) 6100 / 1720 of 12288 4 / 0 5 / 0 19/19 -> 0/19
8x3584x7168 t16x16x256x4 kw2 -> stages 5 (Kimi-K3) 10592 / 2116 of 28672 6 / 0 11 / 0 0/19 -> 0/19
4x1536x7168 t16x64x128x4 ks7 -> t16x32x64x8 ks5 3494 / 1177 of 6144 2 / 0 1 / 0 19/19 -> 0/19
32x384x7168 t32x32x64x9 ks8 -> t32x16x64x8 ks9 7256 / 2621 of 12288 2 / 0 3 / 0 19/19 -> 0/19
64x2304x6144 t64x64x64x6 ks6 -> t64x64x128x3 ks7 (MiniMax) 82070 / 26740 of 147456 30 / 2 41 / 2 19/19 -> 0/19
66x6144x6144 t96x96x64x5 ks4 -> t96x96x128x3 ks4 kw2 (MiniMax) 202739 / 57984 of 405504 69 / 4 137 / 8 15/19 -> 0/19
64x6144x12288 t96x64x128x2 ks4 kw2 -> t64x96x128x3 ks4 223373 / 76923 of 393216 151 / 13 111 / 11 19/19 -> 0/19
256x8192x7168 t128x128x128x2 ks2 hti 786220 / 157807 of 2097152 781 / 45 594 / 43 0/19 -> 0/19
999x6144x24576 t256x256x64x2 ks2 hti, bias 2547922 / 568207 of 6137856 3089 / 207 3086 / 206 19/19 -> 0/19

The remaining >1 ulp outputs are near-zero sums, where fp32 accumulation error is bigger than a bf16 ulp; hipBLASLt shows the same. Before this change, 656 of the 663 distinct gfx950 tuned FlyDSL split-K/slice-K configs gave inexact integer products and 424 were not reproducible. After it, all 663 and all 645 configs in the new tables are exact and reproducible. In a scan of every M from 1 to 128 over the 137 tuned (N, K) groups, every FlyDSL dispatch is exact.

What the old kernel loses

At the kernel level, compared with the exact fp64 product rounded once to bf16 (134M outputs, Gaussian inputs plus real activations and weights from Qwen3-8B and Llama-3.2-1B layers):

original reduction != RN >1 ulp from RN rel. error vs hipBLASLt outputs changed between 2 launches
ks1 kw2 36.4% 6.9% 1.45x 0%
ks2 37.4% 7.5% 1.47x 0%
ks4 48.5% 13.1% 1.84x 18.2%
ks4 kw2 56.8% 19.6% 2.22x 12.0%
ks8 59.3% 20.9% 2.42x 50.5%
ks16 67.5% 29.1% 3.20x 67.9%
after, any config / hipBLASLt 0.01-0.08% as hipBLASLt 1.00x 0
  • One correct rounding gives a relative error of 1.66e-3. The old kernel gives 2.45e-3 at ks2 or kw2, 3.15e-3 at ks4 and 5.3e-3 at ks16. That is about 0.55-1.7 bits of the 8-bit bf16 significand lost at the output of the affected linears. It grows with split_k and k_waves (roughly sqrt(ks/2)) and is flat in K from 1024 to 32768.
  • It is not truncation. The CDNA4 ISA says float atomic adds round to nearest-even, and a probe of buffer_atomic_pk_add_bf16 on MI350X matched round-to-nearest-even on all 2,097,152 adds, including every tie. The pooled bias toward zero is about 1% of the RMS error; truncating atomics would make it 100-1000x larger. A bit-level emulator of the old rounding sequence reproduces 99.86% of 4.15M sampled outputs bit for bit.
  • Split-K 2 and slice-K are wrongly rounded but deterministic. With 3 or more splits the result depends on atomic order: two sessions on the same GPU disagreed on 1.86M of 99.8M outputs. After this change the FlyDSL kernels disagree on 0, as with hipBLASLt.
  • Results also depend on batch size. Rows 0-7 computed at M=8 vs at larger M change in 26.7% of outputs, by up to 64 ulps of the row RMS. After: 0.015%, up to 4 (hipBLASLt: 0.020%, up to 4). So the fix is not batch-invariant either, just at hipBLASLt level.
  • After this change the output matches hipBLASLt accuracy, but it is not bitwise identical to it (0.024% of outputs differ, by at most 4 row-ulps).

In vLLM with VLLM_ROCM_USE_AITER=1, the affected kernels are hit in Qwen3-8B o_proj at M 6-128 and qkv at M 33-112, Llama-3.2-1B o_proj at M 6-8 and gate_up at M 33-128, and MiniMax-M3 qkv at TP4/TP8 for most M from 6-9 to 128. In gsm8k serving of Qwen3-8B at concurrency 32, 76% of forward steps had 17-32 tokens, where the old o_proj runs ks4.

Model level, with ORIGINAL (old tree and tables), FIXED (this PR) and a reference arm with AITER linears off (VLLM_ROCM_USE_AITER_LINEAR=0, hipBLASLt):

  • Logits: with max_num_batched_tokens=48 so that every step is decode-sized, Qwen3-8B over 108k teacher-forced positions moves slightly further from an fp32 run of the same model. KL to fp32 rises 12.6% (+6.3e-5, 95% CI [+4.8e-5, +8.0e-5]) and mean |delta target logprob| rises 5.5% (+1.41e-3, CI [+1.18e-3, +1.65e-3]). Llama-1B: +11% KL, +3.0% logprob. FIXED and the reference are indistinguishable. Top-1 agreement and NLL do not move (CIs include 0). With default batching prefill never reaches these kernels and ORIGINAL equals FIXED bitwise.
  • lm_eval: no detectable change. Qwen3-8B gsm8k 5-shot (1319 questions, 8 runs per arm): ORIGINAL 0.8770, FIXED 0.8775, reference 0.8784; FIXED - ORIGINAL +0.05 pt, CI [-0.23, +0.32], run-permutation p=0.71. Llama-1B gsm8k (10 runs per arm): +0.09 pt, CI [-0.29, +0.47], p=0.66. Qwen arc_challenge, hellaswag and wikitext (2 runs each, same decode-sized setting): no significant difference; wikitext word perplexity 12.7438/12.7435 vs 12.7439. These designs could detect about 0.4 pt on Qwen gsm8k and 0.55 pt on Llama, so smaller effects are not ruled out. A custom gsm8k client on MiniMax-M3 also shows nothing (-0.34 pt, CI [-1.6, +0.9]).
  • Determinism: 100 prompts x 256 greedy tokens on Qwen3-8B at decode batch 48 (old ks4), the same batch run twice gave identical text for 40/100 and 38/100 prompts, diverging as early as token 3. FIXED and the reference gave 100/100 in both sessions and across processes. At batch 104, where the old kernel only uses ks2/kw2, all arms are 100/100. Changing the batch composition makes every bf16 arm diverge, so this PR does not make serving deterministic. In gsm8k serving all arms flip 15-19 questions between their own runs.

So the loss is real and easy to measure at the GEMM output, small but measurable in the logits under decode-sized batches, and below what gsm8k, arc, hellaswag and wikitext can resolve on these models. The clear model-level effect is that identical requests stop diverging.

Is it a speed/accuracy trade-off? Nothing in the old kernel selects it: there is no flag, it is not documented, and the error is set only by how many bf16 roundings a config does, so it changes with split_k, k_waves, run order and batch size. The same tiles reduced in fp32 are as accurate as hipBLASLt. The tuner only kept these configs because it checks at 5e-2. On speed, the retuned exact kernels are 5.0% / 5.7% faster in geomean over the 1733 affected rows (table below), but not on every row: where storing and re-reading fp32 partials costs more than bf16 atomics, as at 64x2304x6144, the exact version is slower.

Performance

Time through aiter.tuned_gemm, main (dd6beb9; its gfx950 bf16 rows and gfx950 A16W16 kernel files are the same at 5bb98ce) against this PR, each with its own tables. MI355X, HIP-graph replay, weights rotated past 400 MB, one worker process per build on the same GPU plus a second main worker as a control, 9 interleaved rounds. "Cold" also rotates the activations, "warm" reuses one activation buffer. A row's ratio is the median of the per-round ratios; two passes with fresh processes are combined by their geometric mean. A row counts as slower only when it is slower than both main workers.

Rows: every 256-CU gfx950 bf16 row that uses split-K or slice-K on either side, or whose pick this PR changes: 1733 rows. Cells with three numbers are cold / warm / either mode.

Table Rows >2% slower than main >5% / >10% Geomean vs main, cold / warm Worst row
All affected rows 1733 234 / 170 / 257 102 / 14 -5.0% / -5.7% +14.3%
DeepSeek-V4 407 80 / 55 / 86 41 / 9 -2.9% / -4.1% +14.3%
Kimi-K3 294 38 / 33 / 45 13 / 3 -3.2% / -3.5% +11.9%
Qwen3.8-Flash-Next 131 19 / 16 / 20 8 / 0 -6.9% / -7.0% +9.6%
GLM-5 123 15 / 13 / 15 6 / 0 -7.2% / -8.1% +8.4%
MiniMax-M3 121 8 / 10 / 14 2 / 0 -4.6% / -4.5% +6.4%
Kimi-K2 90 23 / 11 / 23 15 / 0 -1.3% / -4.1% +9.8%
DeepSeek-V4.1 89 11 / 4 / 11 4 / 1 -5.5% / -6.9% +10.0%
MiniMax-M3 EAGLE 73 4 / 4 / 5 1 / 0 -6.2% / -6.3% +6.4%
gpt-oss 65 4 / 0 / 4 1 / 0 -6.3% / -7.3% +8.1%
Qwen3.5-397B 61 8 / 4 / 8 3 / 1 -4.3% / -4.7% +10.7%
Qwen 32B 51 3 / 3 / 3 2 / 0 -6.1% / -7.1% +6.6%
Llama 70B 45 0 / 0 / 0 0 / 0 -10.6% / -10.5% +1.3%
Llama 405B 44 0 / 0 / 0 0 / 0 -13.7% / -13.4% -0.3%
Gemma-4-26B-A4B 39 9 / 7 / 10 2 / 0 -5.7% / -5.7% +5.9%
GLM-5.3-Flash 35 1 / 0 / 1 0 / 0 -5.7% / -6.1% +3.9%
DeepSeek-V3 29 7 / 6 / 7 3 / 0 -9.9% / -10.0% +8.4%
Mistral Large 4 23 2 / 1 / 2 1 / 0 -5.0% / -5.8% +5.4%
Kimi 5 2 / 2 / 2 0 / 0 -0.5% / +1.1% +4.9%
bf16_tuned_gemm 1 0 / 1 / 1 0 / 0 +1.9% / +2.3% +2.2%
4 other tables 7 0 / 0 / 0 0 / 0 -26.8% / -28.5% -2.9%

838 rows are more than 2% faster than main in both modes, and the summed cold time of the 1733 rows is 5.9% below main. The two main workers differ by 0.27% at the median, 1.1% at the 90th percentile and 3.2% at the 99th, so single rows near the 2% line do not carry signal; the single passes give 250 and 255 rows above 2%. Of 90 control rows this PR does not touch, two are above 2% (worst +4.5%).

257 rows are more than 2% slower than main (190 above 3%, 102 above 5%, 14 above 10%, none above 15%). 236 of them use 3 or more splits on main, and main's kernel takes under 12 us on 193 of them. They cost 0.40 us per call more than main at the median (0.84 us at the 90th percentile). The tables come from a staged screen of the tuner catalog: every tile, split and wave class with 1 to 8 splits, 3.0 M of the catalog's 34.1 M (row, config) pairs timed. The screen is not exhaustive (more than 8 splits and 96 rows were not screened), and it found no faster repeatable config for these rows. Their K loop is as fast as main's or faster; the reduction is not. Kernel time (cold, us) with parts of the reduction switched off:

M x N x K main (bf16 atomics) K loop only + fp32 partial stores whole kernel (this PR)
1664x64x7168 8.20 7.17 7.88 9.32
928x64x7168 7.16 5.61 5.97 7.76
160x768x7168 9.03 7.89 8.12 9.92
1088x64x4096 6.17 4.54 5.18 6.54
80x1280x2560 5.96 4.88 5.03 6.42

On 11 such rows the K loop alone is 0.9 to 1.6 us faster than main's whole kernel, which puts main's atomics at about that cost, and the fp32 reduction costs 1.5 to 2.2 us: after its stores, a split has to learn that every other split has stored and then read the partials back, two memory round trips that the atomics do not have. Where fewer splits are enough the cost goes away: 288x2272x7168 with 3 splits and two k-waves (instead of 7 splits) runs at -0.8% / +1.6% against main.

Some rows are bimodal on this machine with both kernels (see the 99th percentile of the control above); the two passes and the per-round ratios absorb most of it.

End to end in vLLM, Llama-3.1-70B on one MI355X, VLLM_ROCM_USE_AITER=1, prefix caching off, 32 prompts x 128 tokens, median of 7 runs: 1190, 1187 and 1167 tok/s on main (three processes), 1185, 1187, 1182 and 1186 tok/s with this PR (four processes). With 8 prompts at temperature 0, main returns 6 different outputs in 6 identical calls and this PR 1. MiniMax-M3-MXFP4, TP4, input 512, output 128 (vllm bench latency, earlier revision of this PR): batch 16 is 0.3% slower and batch 32 0.2% faster, both within the run-to-run spread.

Merge with main and retune of M > 128 rows (42c04b5)

  • Merged origin/main (581579a). Conflicts: the kernel keeps the fp32 workspace and the one-counter get_split_k_buffers(stream, device), and takes main's capture_scoped_cache, kernarg preload, k_stagger and b_non_temporal. aot/flydsl/gemm.py takes main's replay-based AOT build ([FlyDSL] [JIT] Build the GEMM, conv, chunk_gdn_h and FP8 FMHA AOT caches by replaying the runtime #6956), which launches through the runtime and needs no HGEMM arguments. test_graph_alloc.py calls get_split_k_buffers(s, dev).
  • Tables are merged row by row. Where both sides changed a row, main's row is kept: glm5 2624x6144 M=1-8 use the skinny kernel ([FlyDSL] Glm5 2 qkv proj opt for gfx950 #6427) and kimik3 64x20480x7168 uses the band-stream kernel ([HIP] [FlyDSL] [CI] Add tunable HGEMM K-stagger and B streaming loads #7546). Neither uses split-K, and both are exact and repeatable.
  • Retuned the M > 128 split-K/slice-K rows that the exact reduction made slower. These rows were tuned for the bf16 atomics. 162 rows were slower than main by more than 2% in all rounds. The gfx950 tuner (gemm_a16w16_tune.py, flydsl/torch/triton) ran on them with a narrowed FlyDSL catalog, in two passes. Pass 1 used the row's tile and the tiles the tables use for the same N,K, with split_k up to the current one (about 60 candidates). Pass 2 used 300 seeded random catalog configs with split_k <= 16, plus the current tile. glm5 2624x6144 M=192/256 used 1200 random catalog configs. A new row is kept only if it is faster than the merged row by more than 1% in interleaved runs. 119 rows in 14 tables change (107 to other FlyDSL configs, 12 to torch). glm5 2624x6144 gets a new M=192 row (t128x128x64x3 ks6) and M=256 moves to t128x128x64x3 ks6 kw2. No row with M <= 128 changes.

Timing as in the Performance section (aiter.tuned_gemm, HIP-graph replay, weights rotated past the LLC, each version in its own process, interleaved rounds), on MI350X with FlyDSL 0.4.2. All 672 gfx950 rows with M > 128 that use split-K or slice-K in the tables this PR touches, 3 rounds:

merged, before retune after retune
geomean vs main 1.012 0.984
rows more than 2% / 5% / 10% slower than main 196 / 130 / 41 125 / 55 / 12
rows more than 2% faster than main 218 288
summed time vs main +6.3% -1.8%

The rows that stay slower are mostly small-N split-K rows of 8-12 us (N = 64-768, K = 5120-7168, ks 5-8), where storing and reading back fp32 partials costs more than the bf16 atomics. hipBLASLt is not faster on them either: of the 88 retuned rows that stayed above +2%, it beat the FlyDSL pick on 1.

GLM-5.2 fused_qkv_a (2624x6144), 9 rounds. Before the retune, M=192 and M=256 were 6.3% and 5.8% slower than main:

M main config this PR config main (us) this PR (us) delta
1 t4x16x128x3 ks1 kw4 skinny same 8.09 7.95 -1.8%
2 t4x16x128x4 ks1 kw4 skinny same 8.28 8.18 -1.5%
4 t4x16x128x4 ks1 kw4 skinny same 8.80 8.81 -0.5%
6 t8x16x128x3 ks1 kw8 skinny same 9.07 8.97 -0.9%
8 t8x16x128x2 ks1 kw4 skinny same 9.66 9.50 -2.4%
12 t16x64x128x3 ks6 same 9.66 9.73 +1.0%
16 t16x64x128x3 ks6 same 9.83 9.85 -0.1%
24 t32x64x128x4 ks6 t32x64x128x4 ks6 kw2 9.91 10.11 +2.3%
32 t32x64x64x9 ks6 t32x64x128x4 ks6 kw2 10.10 10.38 +2.9%
48 t64x64x64x5 ks6 t64x64x128x3 ks6 10.67 11.36 +6.8%
60 t64x64x64x6 ks6 t64x64x64x8 ks6 11.35 11.90 +3.8%
64 t64x64x64x6 ks6 t64x64x64x8 ks6 11.48 12.14 +7.5%
84 t96x64x64x5 ks6 same 13.19 13.51 +2.2%
100 t64x64x64x6 ks3 t128x64x128x3 ks6 15.00 14.40 -4.0%
128 t64x64x64x6 ks3 t128x64x128x3 ks6 16.15 15.02 -6.9%
192 t64x96x64x4 ks4 t128x128x64x3 ks6 24.28 19.10 -21.8%
256 t64x96x64x4 ks4 t128x128x64x3 ks6 kw2 22.69 20.85 -8.2%

M=24-84 stay 2-8% slower. A tuner rerun on M=24-84 (800 candidates each) reported no config faster than the times in the table, so these rows are unchanged. At 2624x6144, every M from 1 to 256 through aiter.tuned_gemm is exact on integer inputs, and 20 runs on Gaussian inputs give bitwise identical outputs (0/19 differ from the first). Outputs that are not the correctly rounded fp64 product: 129 of 671744 at M=256 (hipBLASLt: 161), 118 of 503808 at M=192 (hipBLASLt: 118).

One note on the tuner catalog: configs where (block_m / m_waves) x (block_n / n_waves) x split_k is large compile very slowly. One tuner shard finished no candidate for 50 minutes while it compiled t32x256x64x2 ks28 w1x4x1, and t64x128x64x4 ks14 w1x1x1 was among the compiles that did not finish in 10 minutes. The retune above capped split_k at 16 for this reason. The stock catalog still includes these configs.

Retune of M <= 128 rows that stayed slower than main (aca9344)

After the merge, 89 gfx950 rows with M <= 128 were still more than 2% slower than main. This commit searches them again with a wider candidate set. It changes only tables.

  • GLM-5 2624x6144, M = 24, 32, 48, 60, 64, 84: every config in the gfx950 FlyDSL tuner catalog, 74,013 configs (8,729 to 14,689 for each M). Then the k_stagger and b_non_temporal variants of the 40 best configs for each M (1,200 configs).
  • The other 83 rows: every config with the tile of the main row or of the PR row and with split_k within 3 of it, plus 600 random configs from the catalog for each row (122,261 configs). Then the k_stagger and b_non_temporal variants of the 15 best configs for each row (4,600 configs).
  • hipBLASLt: all solutions for each row, timed in the same harness and checked for bitwise repeatability.
  • Each config is compiled ahead of time on the CPU with a limit of 600 s. 65 configs did not compile in 600 s. All of them have split_k 20 to 32 and (block_m / m_waves) x (block_n / n_waves) x split_k of 28,672 or more. They are not used.
  • Selection: a screen of every config against the current row, then 11 or 15 interleaved rounds of up to 22 finalists for each row (kernels only, one process), then interleaved runs through aiter.tuned_gemm (main, the previous head 42c04b5, and this commit, each in its own process). A row changes only if the new config is exact on integer inputs, gives bitwise identical outputs in 20 runs, and is more than 1% faster than the previous row in both timing modes below.
  • Rows near the 1% limit got 15 more interleaved rounds in both modes on other GPUs. Two rows did not stay more than 1% faster in both modes, so they keep the row of 42c04b5: kimik3 96x2272x7168 and minimax_m3_mxfp4 48x1280x6144.

58 rows in 12 tables change, all to other FlyDSL configs (dsv4, glm5, glm53_flash, gptoss, kimi, kimik3, minimax_m3_eagle, minimax_m3_mxfp4, mistral_large4, qwen32B, qwen38_flash_next, qwen3_5_397b). 6 of them (M = 1 and 2) use the skinny kernel, 5 of them instead of split-K. In this commit, no row moves to hipBLASLt, torch or Triton. 491a3ab moved 128x12288x6144 to hipBLASLt, and 1f8a4e5 removes that row again (see below).

The us column of the 58 changed rows is the median kernel time from the interleaved kernel-only rounds of the selection (HIP-graph replay, weights rotated past the LLC). It is not the tuner's time, so it does not compare directly with the us of rows that the tuner wrote. On 25 of the 58 rows the new us is larger than the old us, but the new config is faster in the interleaved runs below.

Timing as in the Performance section (MI350X, HIP-graph replay, weights rotated past the LLC, each version in its own process, interleaved rounds). The harness of the Performance section calls torch.cuda.empty_cache() between rows, so weights and workspace get new addresses for each row. This moves both kernels by up to 0.7 us on some rows. So the 89 rows were timed in both modes, 7 rounds on each of two GPUs for each mode (GPUs 2 and 4 with empty_cache, GPUs 3 and 5 without). The ratios below are the median of the 14 per-round ratios for each row:

89 rows, vs main 42c04b5, empty_cache this commit, empty_cache 42c04b5, no empty_cache this commit, no empty_cache
geomean 1.048 1.003 1.038 0.990
rows more than 2% / 5% / 10% slower 71 / 39 / 6 41 / 13 / 0 62 / 26 / 5 31 / 6 / 0
rows more than 2% faster 0 24 3 29
summed time +4.2% +0.4% +3.3% -0.9%

On the 58 changed rows, this commit is 6.6% faster than 42c04b5 in geomean with empty_cache and 7.2% faster without it. Over the four GPUs, each changed row is 0.9% to 19.4% faster than 42c04b5 (median of 28 per-round ratios for each row). In a single 7-round run on one GPU, a changed row can show up to 4% slower. The 15-round rechecks were on 64x2560x2560 and 2x4480x7168, in both modes on four other GPUs: 64x2560x2560 was 4.4% to 5.6% faster than 42c04b5, and 2x4480x7168 was 1.4% to 4.9% faster. The largest changes are 8x4x10240 (-19.4%), 48x768x7168 (-17.7%), 1x2560x6144 (-14.3%), 112x768x7168 (-13.4%) and 1x2304x6144 (-13.1%). The M = 1 rows use the skinny kernel.

Over all 914 gfx950 rows with M <= 128 that use split-K or slice-K or changed in this PR (3 rounds, empty_cache, one GPU), the geomean vs main is 0.926 for 42c04b5 and 0.929 for this commit. This run used the first version of this commit with 60 changed rows. On the 854 rows that did not change, the two versions run the same kernel and differ by 0.6% in geomean. That is the noise of this run, and it is larger than the effect of the changed rows on the geomean of 914.

GLM-5.2 fused_qkv_a (2624x6144), 9 rounds, empty_cache, measured on one GPU:

M main config this PR config main (us) 42c04b5 (us) this PR (us) delta vs main
1 t4x16x128x3 ks1 kw4 skinny same 8.18 8.20 8.24 +0.9%
2 t4x16x128x4 ks1 kw4 skinny same 8.45 8.35 8.40 -0.6%
4 t4x16x128x4 ks1 kw4 skinny same 8.71 8.63 8.73 +1.1%
6 t8x16x128x3 ks1 kw8 skinny same 9.21 9.13 9.20 +1.2%
8 t8x16x128x2 ks1 kw4 skinny same 9.55 9.57 9.79 +1.8%
12 t16x64x128x3 ks6 same 9.66 9.90 9.92 +2.2%
16 t16x64x128x3 ks6 same 9.89 9.97 9.97 +1.0%
24 t32x64x128x4 ks6 t32x32x128x4 ks3 stg1 bnt 10.00 10.38 10.04 +0.9%
32 t32x64x64x9 ks6 t32x64x128x4 ks6 kw2 10.03 10.63 10.57 +5.1%
48 t64x64x64x5 ks6 t64x64x128x3 ks6 10.61 11.39 11.40 +7.5%
60 t64x64x64x6 ks6 t64x64x64x8 ks6 11.33 11.93 12.04 +6.3%
64 t64x64x64x6 ks6 t64x64x64x8 ks6 11.35 12.28 12.29 +8.1%
84 t96x64x64x5 ks6 same 13.07 13.59 13.36 +1.7%
100 t64x64x64x6 ks3 t128x64x128x3 ks6 15.00 14.39 14.50 -3.3%
128 t64x64x64x6 ks3 t128x64x128x3 ks6 16.25 15.11 15.14 -6.6%
192 t64x96x64x4 ks4 t128x128x64x3 ks6 24.25 19.33 19.14 -21.1%
256 t64x96x64x4 ks4 t128x128x64x3 ks6 kw2 22.61 21.07 21.05 -7.1%

Only M=24 changes. It is 3.4% faster than 42c04b5 in this run and 2.9% to 3.4% faster in the four-GPU runs above (both modes). M=32, 48 and 84 had configs that were 2-4% faster in the screen and in the interleaved rounds of the kernels alone, but through aiter.tuned_gemm in separate processes the gain was 1% or less in at least one mode, so those rows did not change.

GLM-5 2624x6144 at M=32 to 64 is still 5-8% slower than main. The cause is the exact fp32 reduction: each split stores its fp32 partial and the reduction reads it back, and the bf16 atomics of main did not. The full-catalog search found no config that is more than 1% faster than the current rows. Main's own configs with the exact reduction are 1-2% slower than the current rows (kernels only, M=60: +1.2%, M=64: +1.8%). hipBLASLt is slower on all six rows: its best solution takes 12.6-15.9 us against 10.0-13.4 us for FlyDSL.

On 6 of the other rows, the best hipBLASLt solution was faster than the previous row in the screen. Through aiter.tuned_gemm it is faster than the new FlyDSL row by more than 1% on one of them: 128x12288x6144 with solution 17403. 491a3ab used it, and 1f8a4e5 removes it again (see below). torch (default hipBLASLt heuristic) was 8-33% slower than the new FlyDSL rows on the six rows where hipBLASLt looked close.

Correctness through aiter.tuned_gemm with the final tables: all 58 changed rows and the 2 rows put back are exact on integer inputs, and 0/19 runs on Gaussian inputs differ from the first. For GLM-5 2624x6144, every M from 1 to 256 is exact on integer inputs and 0/19 runs differ from the first. op_tests/tuning_tests/test_config_shape_collision.py: 32 passed.

minimax_m3_mxfp4 128x12288x6144: hipBLASLt row removed (491a3ab, 1f8a4e5)

491a3ab moved this row to hipBLASLt solution 17403. Through aiter.tuned_gemm it was 5-12% faster than the FlyDSL row on MI350X with hipBLASLt 1.4.1. A hipBLASLt solution index belongs to one hipBLASLt build, and with another build it can be invalid or point to another kernel. Main removed all shipped hipBLASLt BF16 rows for this reason in #8490 (wrong output after a hipBLASLt upgrade, #8406). So 1f8a4e5 puts back the exact FlyDSL row of aca9344: t128x96x64x5 ks2 w4x1x1 stg3 bnt, 41.81 us. Main still has its own row for this shape from #6235 (t128x96x64x4 ks2 w2x2x1, 43.58 us, err_ratio 0.0057). That row was tuned for the bf16 atomics, and aca9344 replaced it with a faster exact config, so the merge does not take it. After 1f8a4e5, git diff origin/main -- aiter/configs has no hipBLASLt row.

Merge with main after #7624 (e438aae)

Merged origin/main (ef0a5a2). #7624 retuned the gfx950 router GEMM row 128x384x5120 in dsv41_bf16_tuned_gemm.csv to t32x32x128x4 ks5 w2x2x1. This PR also changed that row (t32x32x64x8 ks5 w2x2x1). No other row conflicts. Main's tile is split-K, so it was timed with the fp32 reduction of this PR against the row of this PR. Main's tile is faster, so the merge keeps main's row. The row is now the same as on main.

Timing through aiter.tuned_gemm (MI350X, HIP-graph replay, interleaved, 15 rounds on each of two GPUs, median us):

GPU main (bf16 atomics) PR row main's tile, fp32 reduction (merged) merged vs PR row merged vs main
0 6.351 6.255 6.174 -1.3% (15/15 faster) -3.0%
1 6.341 6.275 6.254 -0.5% (12/15 faster) -1.6%

Correctness of the merged row through aiter.tuned_gemm: exact on integer inputs (0/49152 differ), 0/19 Gaussian runs differ from the first. Main gives 25848/49152 inexact and 19/19 runs differ. test_config_shape_collision.py, test_csv_validation.py and test_a16w16_tuned_config_lookup.py: 61 passed. op_tests/test_flydsl_hgemm.py: passed.

Merge with main (48106c6, 2f25095)

  • 48106c6 merged origin/main (13a7499). The kernel keeps this PR's whole-tile split partition and validator, and takes main's bpreshuffle shape check. The kimik3, qwen38_flash_next and qwen3_5_397b tables are merged row by row. For the five gfx950 kimik3 896x3584 rows (M 8-64) that both sides changed, the merge keeps this PR's exact rows.
  • 2f25095 merged origin/main (c86d490). The kernel takes main's AOT-cache launch ([FlyDSL] [CI] [AOT_TO_C] Fix/flydsl aot key guards hgemm #8565, [FlyDSL] Launch the planner, GDN, conv3d, FP8 attention and MegaMoE launchers through the AOT cache #8600): bind_aot, and _run_compiled with the param items and the device as the specialization key. It keeps this PR's fp32 workspace argument. The param items include split_k_resident and m_tail, so the AOT key covers the reduction that the host picks for each launch.
  • llama70B and minimax_m3_eagle tables are merged row by row. One row changed on both sides: minimax_m3_eagle 128x50016x6144. The merge keeps main's row ([Config] [Perf] MiniMax-M3.1 TP4 lm_head BF16 (N50016 K6144) gfx950: exact-M rows for verify row counts and M 192-512 #8598, FlyDSL t128x256x64x3 ks1 w4x4x1, 119.9 us; this PR had torch at 135.0 us). It has no split-K and no slice-K, so this PR's reduction does not apply. This is the same rule as the merge in 42c04b5.
  • Main adds or changes one gfx950 row with slice-K: minimax_m3_eagle 112x50016x6144 (ks1 kw2, [Config] [Perf] MiniMax-M3.1 TP4 lm_head BF16 (N50016 K6144) gfx950: exact-M rows for verify row counts and M 192-512 #8598). It now runs with the fp32 combine of this PR. It was not timed again (no gfx950 here).
  • Checks on 8x MI300X (gfx942). The gfx950 kernels do not run here. A CPU check calls make_gemm_a16w16_param_and_validate for every gfx950 FlyDSL row in all tables: 2891 valid, 0 invalid (main: 2945 valid, 0 invalid). 10 of 10 runs: python op_tests/test_gemm_a16w16.py and python op_tests/test_flydsl_hgemm.py exit 0, pytest tests/test_flydsl_aot_launch.py tests/test_flydsl_aot_cache.py gives 32 passed and 3 skipped, and pytest op_tests/test_graph_alloc.py op_tests/test_flydsl_hgemm.py op_tests/tuning_tests/{test_a16w16_tuned_config_lookup,test_asm_splitk_guard,test_config_shape_collision,test_csv_validation}.py gives the same 17 failures as main (script-style test_flydsl_hgemm.py functions that pytest calls without arguments) plus the setup error of test_hgemm_partial_sums for the same reason.

Merge with main and hipBLASLt row removal (cdcb1aa, 1f8a4e5)

  • cdcb1aa merged origin/main (dd6beb9). No conflicts. None of the 7 new main commits changes a gfx950 bf16 tuned table.
  • 1f8a4e5 replaces the hipBLASLt row of minimax_m3_mxfp4 128x12288x6144 with the FlyDSL row of aca9344 (see above).
  • Checks on MI300X (gfx942), CPU only. A CPU check calls make_gemm_a16w16_param_and_validate (arch gfx950, 256 CUs) for every gfx950 FlyDSL row in all bf16 tables: 2913 valid, 0 invalid, plus 38 skinny rows (main: 2966 valid, 0 invalid). pytest op_tests/tuning_tests/{test_config_shape_collision,test_csv_validation,test_a16w16_tuned_config_lookup}.py: 68 passed, 8 failed. The same 8 subtests of test_gfx1250_legacy_wrapper_routing fail on main on this host. black 26.10.1 and ruff 0.16.0: clean.

Merge with main after #8929 and #8915 (d6e4fd4)

Merged origin/main (2f019ba). Two files conflicted.

  • gemm_a16w16_gfx950.py vs [FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow #8929: [FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow #8929 makes the C offset int64, because a contiguous C can have more than 2^31 elements. The merge keeps this PR's 4-argument write_cshuffle_vec_to_global(out, offset, vec, is_fp32). Main's out_buf and is_split_k arguments are not new in [FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow #8929. They exist only for the bf16/fp32 atomic split-K store that this PR removes, so the merge does not bring them back. The int64 offset fx.Int64(global_row) * n + global_col goes to all three C stores of this PR: the full-tile store, the half-tile-interleaved store, and store_c_vec, which the one-pass slice-K combine and the split-K reducers use. store_c_vec is not in main, so a plain merge leaves it on int32. With an int32 offset there, a slice-K launch with a C of more than 2^31 elements stops with an illegal memory access.
  • test_flydsl_hgemm.py adds one case next to [FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow #8929's: 31777x67712x512, ft, k_waves=2. It goes through store_c_vec. test_hgemm_partial_sums also runs it and checks every element of C, so it covers the rows past element 2^31. It fails with an illegal memory access when store_c_vec uses an int32 offset, and passes with the merge.
  • Split-K cannot write such a C: the validator allows at most 2048 tiles and a workspace below 2^31 bytes, so a split-K C has fewer than 2^28 elements. On a 31777x67712 C, split_k 2, 4 and 8 are rejected.
  • kimik3_bf16_tuned_gemm.csv vs [Config] [Perf] Use non-temporal B loads in twelve Kimi-K3 decode BF16 GEMM rows on gfx950 #8915: [Config] [Perf] Use non-temporal B loads in twelve Kimi-K3 decode BF16 GEMM rows on gfx950 #8915 moves 12 rows (6016x7168 and 6288x7168, M = 1, 2, 4, 8, 16, 32) to the _bnt names. The rule of the earlier merges applies. 8 keys changed only on main and have no split-K and no slice-K, so they take main's row. 4 keys were timed on the merged tree (MI350X, FlyDSL 0.5.3, two sessions of 2 and 5 interleaved passes) among the merge-base, branch and main configs: 1x6016 and 8x6016 (both sides changed; main's is slice-K), 32x6016 (main only, ks4) and 32x6288 (both sides changed, split-K). Every candidate is exact on integer inputs and gives the same bits in 20 calls. 8x6016 and 32x6016 take main's row (2% to 4% faster, tuner method, in both sessions). For 1x6016 and 32x6288 the tuner time is a tie in the 5-pass session (within 0.2%). The 2-pass session puts them 1% to 2% apart, in opposite directions, and the cold-graph order changes between sessions. Warm-graph time decides: 1x6016 takes main's row (13.9 us vs 15.1 us), 32x6288 keeps this PR's ks4 row (17.1 us vs 18.6 us). So 11 rows take main's row as it is, and 1 keeps this PR's row. The us, tflops and bw columns are copied from the row that is kept, not measured again.
  • Main also adds 14 new gfx950 FlyDSL rows that use split-K or slice-K: 9 in minimax_m3_mxfp4 and 5 (128 CUs) in qwen38_flash_next. They merge without conflict and now run with the fp32 reduction. All 14 are exact on integer inputs and repeatable in 20 calls. With the tuner method, 13 are faster than torch and one (1024x1024x4096 with bias) is a tie (21.8 us vs 21.6 us). The merge keeps main's rows. The 128-CU rows were timed on a 256-CU MI350X, so their times do not show 128-CU performance.

Merge with main after #8460 and #8862 (ec803d3)

Merged origin/main (f90c562). One file conflicted, and main's CK pin moves to 39483cc9.

  • gemm_a16w16_gfx950_utils.py vs [FlyDSL] [CI] [Build] Pin FlyDSL to v0.5.5 #8460: [FlyDSL] [CI] [Build] Pin FlyDSL to v0.5.5 #8460 pins FlyDSL 0.5.5 and adds s_nop 1 after the inline-asm global_store_dwordx4 in store_global_f32_vec and SplitKProtocol.zero_c. The hazard recognizer cannot see into inline asm, and gfx950 needs two wait states before a VALU overwrites the data VGPRs of a wide store. This PR removes both functions (no zero-init of C, no atomic split-K store), so the merge keeps this PR's file. The fp32 workspace stores (BufferCopy128b, sc1) and the C stores are emitted by LLVM, which handles the hazard itself. The only inline asm left in the kernel is the empty kernarg-preload asm. In the final ISA of four split-K kernels (fp32 output, half-tile interleaved, bias, k_waves=2 shared reduction), the ASMSTART/ASMEND pair is empty and every wide store is compiler-emitted.
  • gptoss_bf16_tuned_gemm.csv vs [OPUS][Config] gfx1250 96cu bf16 GEMM: GPT-OSS TP2 LM head, M 33..256 #8862: merges cleanly. It keeps this PR's gfx950 rows and adds main's 14 gfx1250 rows, with no duplicate keys.
  • FlyDSL 0.5.5 vs 0.5.3 on the merged tree (the A16W16 kernel source is the same in both): 10 tuned split-K rows (ks2-16, k_waves 1/2/4, bias, fp32 output, half-tile interleaved, bnt), called through tuned_gemm.flydsl_gemm. Every row is exact on integer inputs, and 0 of 19 eager calls and 0 of 20 graph replays differ from the first output. Graph-replay time per call is within the round-to-round spread on the shared GPU, or slightly faster on 0.5.5. 5-round medians: 56x896x7168 fp32 out 7.03 vs 7.07 us, 32x64x7168 ks14 3.62 vs 3.73 us, 64x16384x26624 ks4 183.5 vs 182.7 us.

PR Self-Review

Reviewed revision

ec803d3d1e0f076cefb5255226eff9250942057e

Behavior and intent

The gfx950 FlyDSL A16W16 GEMM rounded every split-K partial to bf16 and added it to C with packed bf16 atomics, and summed slice-K wave partials through a bf16 LDS tile. Outputs went through several bf16 roundings instead of one (37-68% not correctly rounded, 1.45-3.2x hipBLASLt's error), and with 3 or more splits they changed from run to run with the atomic order (#5976). This PR keeps every partial in fp32 and adds them once in split order, so outputs are as accurate as hipBLASLt and bitwise repeatable. The reduction is picked per launch on the host (shared across splits when the grid is resident, otherwise by the last split to arrive). The fp32 workspace is cached per stream, so eager calls do not allocate it each time. The affected rows are retuned for the exact reduction, and 39 asm split-K rows that were not repeatable move to repeatable configs. Over the 1733 affected rows this is 5.0% (cold) / 5.7% (warm) faster than main in geomean; 257 rows stay more than 2% slower (median +0.4 us per call, none above 15%), and I accept that cost for repeatability. Rows outside gfx950 bf16 are untouched.

Validation and unverified scope

On this head (ec803d3), MI350X (gfx950), FlyDSL 0.5.5:

  • python op_tests/test_flydsl_hgemm.py: exit 0 in 10 of 10 runs, 31 exact-and-deterministic cases each. pytest op_tests/test_graph_alloc.py: 7 passed, 1 skipped.
  • pytest op_tests/tuning_tests/{test_csv_validation,test_config_shape_collision,test_a16w16_tuned_config_lookup,test_asm_splitk_guard}.py: 94 passed, 5244 subtests passed.
  • black 26.10.1 and ruff 0.16.0: clean.

On d6e4fd4, MI350X (gfx950), FlyDSL 0.5.3:

  • python op_tests/test_flydsl_hgemm.py: exit 0 in 10 of 10 runs, 31 exact-and-deterministic cases (the new 31777x67712x512 slice-K case included). python op_tests/test_gemm_a16w16.py: exit 0. pytest op_tests/test_graph_alloc.py: 7 passed, 1 skipped.
  • pytest op_tests/tuning_tests/{test_csv_validation,test_config_shape_collision,test_a16w16_tuned_config_lookup}.py: 91 passed.
  • C with more than 2^31 elements (31777x67712x512): the full-tile, slice-K and half-tile-interleaved stores give the exact product on both sides of element 2^31, and leave no element unwritten.

On fb04752 (tables of 98615f7 + fb04752, kernel of 982be6a), MI355X (gfx950):

  • python op_tests/test_flydsl_hgemm.py: exit 0, 30 exact-and-deterministic cases. python op_tests/test_gemm_a16w16.py and python op_tests/test_gemm_a16w16.py -t normal out compile -d bf16: exit 0. python op_tests/test_gemm_codegen.py: 74 passed.
  • pytest op_tests/test_graph_alloc.py: 7 passed, 1 skipped. The new workspace test fails without 982be6a, and fails when the cache is made to serve a capturing stream or to share one buffer between streams.
  • pytest op_tests/tuning_tests/{test_a16w16_tuned_config_lookup,test_csv_validation,test_config_shape_collision,test_asm_splitk_guard}.py: 71 passed, 8 failed. The 8 are test_gfx1250_legacy_wrapper_routing subtests that also fail at 1f8a4e5 and pass after a local merge with main (9da5928).
  • Repeatability under load through aiter.tuned_gemm (two other GEMM processes on the same GPU; 32 outputs per case from eager, synced, interleaved and graph-replayed calls): all 2819 FlyDSL rows plus 312 changed rows at two more M (3337 cases) and all 1038 torch, Triton and skinny-default rows: 0 differ. In 8 identical calls, 0 of the 1733 affected rows differ (main: 1215).
  • Accuracy vs fp64: relative L2 error of the FlyDSL rows 0.00166 median, 0.00171 p99 (torch/hipBLASLt rows: 0.00166 / 0.00169).
  • Timing: all 1733 affected rows, aiter.tuned_gemm, HIP-graph replay, weights rotated past 400 MB, 9 interleaved rounds against main and a second main worker, cold and warm activations, two full passes (see Performance).
  • End to end: Llama-3.1-70B in vLLM on one MI355X, temperature 0: 6 different outputs in 6 identical calls on main, 1 on this head. Throughput at 32 prompts x 128 tokens: 1167-1190 tok/s on main, 1182-1187 tok/s here.

Earlier revisions (MI350X, FlyDSL 0.4.1 / 0.4.2), kept for the kernel history:

  • python op_tests/test_flydsl_hgemm.py: 10/10 runs. python op_tests/test_gemm_a16w16.py -t normal out compile -d bf16 on 6 split-K shapes and the defaults: 10/10.
  • Every split-K/slice-K config in the original tables (663) and in the tables then (645): exact on integer inputs and bitwise repeatable. Every M from 1 to 128 over the 137 tuned (N, K) groups: every FlyDSL dispatch exact.
  • Every gfx950 bf16 FlyDSL row that uses split-K, slice-K, the skinny or band-stream kernel, or k_stagger/b_non_temporal (1530 rows, at 42c04b5): exact on integer inputs, repeatable over 5 runs.
  • lm_eval and logit studies on Qwen3-8B, Llama-3.2-1B and MiniMax-M3, and vLLM MiniMax-M3-MXFP4 TP4 latency (see the accuracy section). These ran on an earlier revision, not on this head.

Unverified:

  • gfx942 and gfx1250: no tables or kernels change there, and they were not run.
  • fp16 inputs and the 128-CU gfx950 tables.
  • The catalog screen is not exhaustive: 3.0 M of 34.1 M (row, config) pairs, nothing above 8 splits, 96 rows had no screening pass. Faster exact configs may exist for the 257 slower rows.
  • The asm split-K rows this PR does not move are still not repeatable (29 with bf16 output, 55 with fp32 output). The opus backend was not among the screened backends.
  • lm_eval was not rerun on this head; only the Llama-3.1-70B repeatability and throughput check was.
  • Main merge (dc5802f): main is merged in. Two tables conflicted, because main retuned rows on the old atomic split-K kernel. llama405B_bf16_tuned_gemm.csv: 26 rows were re-timed under this PR's kernel (9 main-only split-K rows and 17 rows changed on both sides); 11 keep this PR's config and 15 take main's. minimax_m3_eagle_bf16_tuned_gemm.csv: main's 9 new split-K rows were re-timed; 7 keep main's config, and 480x9216x6144 and 496x9216x6144 move to torch (about 28% faster than main's ks3 config under the fp32 reduction). All 35 re-timed rows give the same bits in 5 calls, with rel. L2 0.00165 to 0.00168 vs fp32 torch. The GPU was shared during this timing. After the merge: tests/test_moe_dispatch_snapshot.py 3 passed (it failed on fb04752 because [MoE] Refresh the legacy dispatch golden for #7611's intermediate_pad #8790 was missing); test_csv_validation.py, test_config_shape_collision.py and test_a16w16_tuned_config_lookup.py 91 passed; test_graph_alloc.py 7 passed, 1 skipped; python op_tests/test_flydsl_hgemm.py exit 0.
  • test_gemm_a16w16.py prints checkAllclose ... failed! for the two asm variants at 64x256x5120, as it did at b155ae8 and does on d6e4fd4; not checked on main.
  • On FlyDSL 0.5.5, only the 10 split-K rows above were checked for repeatability and timing. test_gemm_a16w16.py and the full-table sweeps were not rerun.

PR-specific question

The changed rows are gfx950 bf16 rows in 22 aiter/configs/model_configs/*_bf16_tuned_gemm.csv tables: DeepSeek-V3/V4/V4.1, Gemma-4-26B-A4B, GLM-5, GLM-5.3-Flash, gpt-oss, inkling, Kimi, Kimi-K2, Kimi-K3, Llama 70B/405B, MiniMax-M3 and its EAGLE draft, Mistral Large 4, Qwen3-VL (q3vl), Qwen 32B, Qwen3.8-Flash-Next, Qwen3.5-397B, Qwen3.8-27B and Qwen3.8-2.4T-A95B. Against main (dd6beb9, the last main merge), 1181 of the 4192 gfx950 rows in these tables change their pick (libtype, solidx, splitK or kernelName): 1068 FlyDSL to FlyDSL, 61 FlyDSL to torch, 10 FlyDSL to Triton, 1 FlyDSL to skinny, 2 Triton to FlyDSL, and 39 asm to FlyDSL (37), torch (1) or Triton (1). 4 rows are added and none is removed. No row uses hipBLASLt. Every other row, and every non-gfx950 row, is byte-identical to main, so other shapes keep their selection. Largest per-table changes: DeepSeek-V4 237 rows, Kimi-K3 207, GLM-5 92, Qwen3.8-Flash-Next 87, MiniMax-M3 84. A pick changes only if the new config is exact on integer inputs, bitwise repeatable, and faster in the interleaved harness. aiter/tuned_gemm.py is unchanged. gemm_a16w16_policy.py only widens the tuner's candidate catalog (split_k 1..16, 20-32, k_waves 1/2/4/8, fp32 LDS sizing). graph_alloc.py adds is_capturing() for the workspace cache. Neither changes how tuned rows are looked up.

Changed op tests

op_tests/test_flydsl_hgemm.py: adds test_hgemm_partial_sums. Small-integer inputs keep every fp32 partial exact in any order, so split-K and slice-K outputs must equal the exact product rounded once, bit for bit, and repeated Gaussian runs must be bitwise identical. The existing tests compare against torch with a tolerance (5e-2 scale), which is why the bf16-partial kernels passed; nothing else in op_tests checks exactness or run-to-run determinism of these kernels. The cases cover k_waves 2/4/8, split_k up to 32, an uneven split, bias, fp32 output and half-tile-interleaved configs. It also adds 31777x67712x512 with k_waves=2, next to the two int64-offset cases of #8929. That C has more than 2^31 elements and goes through the slice-K store, which is not in main. It fails with an illegal memory access if that store uses an int32 offset.

op_tests/test_graph_alloc.py:

  • test_every_cached_scratch_comes_from_the_private_pool calls get_split_k_buffers(s, dev) (new signature) and adds the cached fp32 workspace as a site, so the workspace must also come from the private pool.
  • New test_gfx950_split_k_workspace_is_cached_per_stream_and_size (gfx950 only). It checks that one buffer serves each stream and size bucket, that two streams never share a buffer, and that a capture on a stream without a buffer caches nothing. It fills the workspace with NaN before each call and requires the exact product on integer inputs, eager and under graph replay, so stale partials can never reach C. No other test covers this cache; it fails without 982be6a.

AI assistance (Claude Code) was used to draft this change. Every line was reviewed by the submitter.

…in fp32, deterministically

The gfx950 FlyDSL HGEMM rounded every split-K partial to the output dtype
and added it to C with packed bf16/fp16 atomics, and summed slice-K wave
partials from an LDS tile typed as the output dtype. With bf16 output each
partial is rounded to 8 bits and every add rounds again, instead of one
rounding of the fp32 sum, and the atomics make the result depend on
arrival order (fp32 output used fp32 atomics: order-dependent too).
Issue ROCm#5976.

- Slice-K: k-waves hand their fp32 accumulators to k-wave 0 through LDS,
  one k-wave at a time; C is rounded once. Same LDS for k_waves=2.
- Split-K: every split stores its fp32 partial to a workspace (sc1, agent
  coherent); the tile's last split to start waits until the others have
  counted themselves done and adds all partials in split order, then
  writes C once. No zero-init of C, no atomics on C, no cache-wide fence.
  The semaphore holds a ticket and a done word per tile, both monotonic.
- split_k is now a constexpr of the param (unrolled reduction); kernel
  names gain "f32" so stale disk-cache binaries are not reused.
- op_tests/test_flydsl_hgemm.py: small-integer inputs keep every fp32
  partial exact, so split-K/slice-K outputs must equal the exact product
  rounded once, and Gaussian inputs must be bitwise reproducible.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full 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 7053 --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.

AndreasKaratzas and others added 3 commits October 28, 2026 15:37
The fp32 split-K reduction made small-M split-K rows 1.5-2.3 us slower
(+7..+40%): the tile's last split to start spin-waited on a done counter
until the other splits had stored their partials. This gets that time back
and retunes the affected rows. Outputs stay exact and bitwise
deterministic.

- Reduction: every split stores its fp32 partial, waits for its own sc1
  stores, then increments the tile's counter (atomic inc with wrap at
  split_k - 1, so the last arrival also resets it). The split that reads
  split_k - 1 is the last to arrive: it adds all partials in split order
  and writes C once. No workgroup waits for another.
- Each tile's counter sits on its own 128-byte line. Packed counters put
  every split of every tile on one or two lines, where the agent-scope
  atomics serialized. One int32 counter per tile replaces the int64
  ticket/done pair, so get_split_k_buffers() drops its split_k argument
  (op_tests/test_graph_alloc.py already calls it that way). Kernel names
  use "_ksNfp32" so binaries of the previous protocol are not reused from
  the disk cache.
- split_k no longer has to divide K: each split takes whole block_k tiles
  and the last split takes the remainder. Configs that were valid before
  get the same partition. The gfx950 tuner tries split_k 1..16; its pruner
  no longer counts per-split K padding and allows 3 grid rounds.
- Tables: the 824 gfx950 rows with M <= 128 that use split-K or slice-K
  were re-searched under this kernel; 587 rows change (new picks: 535
  FlyDSL, 43 torch, 8 triton, 1 skinny). A row changes only
  if the new config is exact on integer inputs, bitwise deterministic and
  faster in three separate runs.
- op_tests/test_flydsl_hgemm.py gains an uneven split (4x1536x7168 ks5).

Through aiter.tuned_gemm, HIP-graph replay, weights rotated past the LLC,
median of 7 interleaved rounds, MI350X, 824 rows, vs the kernel and tables
before the fp32 fix:

                          geomean   rows <= before   summed us
  fp32 fix alone           1.215          52            15727
  with this change         0.968         490            13454

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Conflicts: SPLIT_K_SEMAPHORE_MAX_LEN takes main's 2048 next to the per-tile
counter stride. Tuned CSVs merged row by row: main's rows win where only main
changed them or where main moved a row off split-K; this branch's exactness-
gated retunes win where both changed a split-K/slice-K row.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: root <[email protected]>
…duction, retune

The exact fp32 split-K reduction left 237 of the 824 gfx950 M <= 128 rows slower
than the bf16-atomic kernel. Its tail (store the partial, wait for it, count in,
reload every partial) costs about 1 us more than the old fire-and-forget atomics,
and big tiles with many splits move S x tile x 4 bytes of partials at the end.
Outputs stay bitwise identical to the previous commit.

- Load every kernel argument the kernels use (A, B, C, semaphore, workspace and
  bias base addresses, M, N, K, working K) through one empty asm at entry, so the
  scalar loads share one wait instead of two serialized round trips before the
  first weight load, and the tail no longer reloads the semaphore pointer.
- With group_m == 0, launch a (n tiles, m tiles, splits) grid: same dispatch
  order as the linear tile id, without dividing it by num_pid_n.
- Split-K tiles of at least 1024 elements: the reducer adds its own partial from
  registers (one copy of the sum per split index, chosen by a scalar branch), and
  partial stores and loads skip groups entirely past M by pointing them past the
  bounds-checked workspace.
- Tables: 222 gfx950 bf16 rows re-picked among FlyDSL configs near the current
  and pre-fp32 picks, timed with HIP-graph replay and weights rotated past the
  LLC. A row changes only if the new config is faster by >= 1% and >= 0.05 us in
  at least 4 of 5 interleaved rounds (3 of 3 for 16 rows), and it is exact on
  integer inputs and bitwise deterministic. Rows retuned on main keep main's pick.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude <[email protected]>
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision ec803d3d1e0f · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

The gfx950 FlyDSL A16W16 GEMM rounded every split-K partial to bf16 and added it to C with packed bf16 atomics, and summed slice-K wave partials through a bf16 LDS tile. Outputs went through several bf16 roundings instead of one (37-68% not correctly rounded, 1.45-3.2x hipBLASLt's error), and with 3 or more splits they changed from run to run with the atomic order (#5976). This PR keeps every partial in fp32 and adds them once in split order, so outputs are as accurate as hipBLASLt and bitwise repeatable. The reduction is picked per launch on the host (shared across splits when the grid is resident, otherwise by the last split to arrive). The fp32 workspace is cached per stream, so eager calls do not allocate it each time. The affected rows are retuned for the exact reduction, and 39 asm split-K rows that were not repeatable move to repeatable configs. Over the 1733 affected rows this is 5.0% (cold) / 5.7% (warm) faster than main in geomean; 257 rows stay more than 2% slower (median +0.4 us per call, none above 15%), and I accept that cost for repeatability. Rows outside gfx950 bf16 are untouched.

Validation and unverified scope

On this head (ec803d3d1e), MI350X (gfx950), FlyDSL 0.5.5:
- `python op_tests/test_flydsl_hgemm.py`: exit 0 in 10 of 10 runs, 31 exact-and-deterministic cases each. `pytest op_tests/test_graph_alloc.py`: 7 passed, 1 skipped.
- `pytest op_tests/tuning_tests/{test_csv_validation,test_config_shape_collision,test_a16w16_tuned_config_lookup,test_asm_splitk_guard}.py`: 94 passed, 5244 subtests passed.
- black 26.10.1 and ruff 0.16.0: clean.

On d6e4fd4231, MI350X (gfx950), FlyDSL 0.5.3:
- `python op_tests/test_flydsl_hgemm.py`: exit 0 in 10 of 10 runs, 31 exact-and-deterministic cases (the new 31777x67712x512 slice-K case included). `python op_tests/test_gemm_a16w16.py`: exit 0. `pytest op_tests/test_graph_alloc.py`: 7 passed, 1 skipped.
- `pytest op_tests/tuning_tests/{test_csv_validation,test_config_shape_collision,test_a16w16_tuned_config_lookup}.py`: 91 passed.
- C with more than 2^31 elements (31777x67712x512): the full-tile, slice-K and half-tile-interleaved stores give the exact product on both sides of element 2^31, and leave no element unwritten.

On fb047529d (tables of 98615f7 + fb04752, kernel of 982be6a), MI355X (gfx950):
- `python op_tests/test_flydsl_hgemm.py`: exit 0, 30 exact-and-deterministic cases. `python op_tests/test_gemm_a16w16.py` and `python op_tests/test_gemm_a16w16.py -t normal out compile -d bf16`: exit 0. `python op_tests/test_gemm_codegen.py`: 74 passed.
- `pytest op_tests/test_graph_alloc.py`: 7 passed, 1 skipped. The new workspace test fails without 982be6a, and fails when the cache is made to serve a capturing stream or to share one buffer between streams.
- `pytest op_tests/tuning_tests/{test_a16w16_tuned_config_lookup,test_csv_validation,test_config_shape_collision,test_asm_splitk_guard}.py`: 71 passed, 8 failed. The 8 are `test_gfx1250_legacy_wrapper_routing` subtests that also fail at 1f8a4e5f6 and pass after a local merge with main (9da592818).
- Repeatability under load through `aiter.tuned_gemm` (two other GEMM processes on the same GPU; 32 outputs per case from eager, synced, interleaved and graph-replayed calls): all 2819 FlyDSL rows plus 312 changed rows at two more M (3337 cases) and all 1038 torch, Triton and skinny-default rows: 0 differ. In 8 identical calls, 0 of the 1733 affected rows differ (main: 1215).
- Accuracy vs fp64: relative L2 error of the FlyDSL rows 0.00166 median, 0.00171 p99 (torch/hipBLASLt rows: 0.00166 / 0.00169).
- Timing: all 1733 affected rows, `aiter.tuned_gemm`, HIP-graph replay, weights rotated past 400 MB, 9 interleaved rounds against main and a second main worker, cold and warm activations, two full passes (see Performance).
- End to end: Llama-3.1-70B in vLLM on one MI355X, temperature 0: 6 different outputs in 6 identical calls on main, 1 on this head. Throughput at 32 prompts x 128 tokens: 1167-1190 tok/s on main, 1182-1187 tok/s here.

Earlier revisions (MI350X, FlyDSL 0.4.1 / 0.4.2), kept for the kernel history:
- `python op_tests/test_flydsl_hgemm.py`: 10/10 runs. `python op_tests/test_gemm_a16w16.py -t normal out compile -d bf16` on 6 split-K shapes and the defaults: 10/10.
- Every split-K/slice-K config in the original tables (663) and in the tables then (645): exact on integer inputs and bitwise repeatable. Every M from 1 to 128 over the 137 tuned (N, K) groups: every FlyDSL dispatch exact.
- Every gfx950 bf16 FlyDSL row that uses split-K, slice-K, the skinny or band-stream kernel, or k_stagger/b_non_temporal (1530 rows, at 42c04b532): exact on integer inputs, repeatable over 5 runs.
- lm_eval and logit studies on Qwen3-8B, Llama-3.2-1B and MiniMax-M3, and vLLM MiniMax-M3-MXFP4 TP4 latency (see the accuracy section). These ran on an earlier revision, not on this head.

Unverified:
- gfx942 and gfx1250: no tables or kernels change there, and they were not run.
- fp16 inputs and the 128-CU gfx950 tables.
- The catalog screen is not exhaustive: 3.0 M of 34.1 M (row, config) pairs, nothing above 8 splits, 96 rows had no screening pass. Faster exact configs

[truncated in readiness report; see the PR description for the full answer]

PR-specific question

The changed rows are gfx950 bf16 rows in 22 `aiter/configs/model_configs/*_bf16_tuned_gemm.csv` tables: DeepSeek-V3/V4/V4.1, Gemma-4-26B-A4B, GLM-5, GLM-5.3-Flash, gpt-oss, inkling, Kimi, Kimi-K2, Kimi-K3, Llama 70B/405B, MiniMax-M3 and its EAGLE draft, Mistral Large 4, Qwen3-VL (q3vl), Qwen 32B, Qwen3.8-Flash-Next, Qwen3.5-397B, Qwen3.8-27B and Qwen3.8-2.4T-A95B. Against main (dd6beb98d, the last main merge), 1181 of the 4192 gfx950 rows in these tables change their pick (libtype, solidx, splitK or kernelName): 1068 FlyDSL to FlyDSL, 61 FlyDSL to torch, 10 FlyDSL to Triton, 1 FlyDSL to skinny, 2 Triton to FlyDSL, and 39 asm to FlyDSL (37), torch (1) or Triton (1). 4 rows are added and none is removed. No row uses hipBLASLt. Every other row, and every non-gfx950 row, is byte-identical to main, so other shapes keep their selection. Largest per-table changes: DeepSeek-V4 237 rows, Kimi-K3 207, GLM-5 92, Qwen3.8-Flash-Next 87, MiniMax-M3 84. A pick changes only if the new config is exact on integer inputs, bitwise repeatable, and faster in the interleaved harness. `aiter/tuned_gemm.py` is unchanged. `gemm_a16w16_policy.py` only widens the tuner's candidate catalog (split_k 1..16, 20-32, k_waves 1/2/4/8, fp32 LDS sizing). `graph_alloc.py` adds `is_capturing()` for the workspace cache. Neither changes how tuned rows are looked up.

Changed op tests

`op_tests/test_flydsl_hgemm.py`: adds `test_hgemm_partial_sums`. Small-integer inputs keep every fp32 partial exact in any order, so split-K and slice-K outputs must equal the exact product rounded once, bit for bit, and repeated Gaussian runs must be bitwise identical. The existing tests compare against torch with a tolerance (5e-2 scale), which is why the bf16-partial kernels passed; nothing else in op_tests checks exactness or run-to-run determinism of these kernels. The cases cover k_waves 2/4/8, split_k up to 32, an uneven split, bias, fp32 output and half-tile-interleaved configs. It also adds 31777x67712x512 with k_waves=2, next to the two int64-offset cases of #8929. That C has more than 2^31 elements and goes through the slice-K store, which is not in main. It fails with an illegal memory access if that store uses an int32 offset.

`op_tests/test_graph_alloc.py`:
- `test_every_cached_scratch_comes_from_the_private_pool` calls `get_split_k_buffers(s, dev)` (new signature) and adds the cached fp32 workspace as a site, so the workspace must also come from the private pool.
- New `test_gfx950_split_k_workspace_is_cached_per_stream_and_size` (gfx950 only). It checks that one buffer serves each stream and size bucket, that two streams never share a buffer, and that a capture on a stream without a buffer caches nothing. It fills the workspace with NaN before each call and requires the exact product on integer inputs, eager and under graph replay, so stale partials can never reach C. No other test covers this cache; it fails without 982be6a.

AI assistance (Claude Code) was used to draft this change. Every line was reviewed by the submitter.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

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.

…slice-K combine

The fp32 split-K reduction is slowest where the last split of a tile has
to read every split's partial alone. Spread that work over the splits
where the whole grid is resident, and keep the fragment-store reduction
everywhere else.

- Shared reduction: every split arrives on the tile's word with a promise
  to reduce one range of the tile, polls (at most 64 times) until every
  split has arrived, then adds bias + every split's share of its range in
  split order and writes that part of C. A split whose polls run out
  stores its range and withdraws the promise with a CAS, which fails once
  the last split has arrived; the last arrival reduces every range whose
  promise is missing. Every wait is bounded.
- The host picks the reduction per launch: shared only when
  num_pid_m * num_pid_n * split_k <= CUs, the tile has at least 4096
  elements and, for k_waves=1, split_k * tile >= 16384. Otherwise
  k_waves=1 stores partials straight from the MMA fragments (row-masked
  only when M is not a multiple of block_m, so full tiles compile to the
  previous ISA) and k_waves>1 uses the last-arrival reduction through LDS.
- One-pass slice-K combine: every k-wave writes its fp32 tile to LDS once
  and the whole workgroup adds the k-waves in order while storing C or the
  split's row-major partial.
- The tuner catalog adds k_waves 4 and 8 and split_k 20, 24, 28 and 32.
- Kernel names gain "c" (one-pass combine), "s" (shared reduction) and
  "m" (row-masked partials), so older binaries are not reused from the
  disk cache.
- Retuned the 824 small-M (M <= 128) gfx950 rows. A row only changes if
  the new config is exact on small-integer inputs, bitwise repeatable and
  faster in separate processes and in lockstep runs against the previous
  tables.

Every per-element sum keeps its order (bias, then splits 0..S-1, k-waves
in order), so outputs are bitwise identical to the previous kernel on all
42 compared configs. The 663 tuned configs of the original tables, the
552 of the previous tables and the 620 of these run exact and
deterministic on this kernel.

All 824 rows through aiter.tuned_gemm on MI355X, HIP-graph replay over
weights rotated past the LLC, 7 lockstep rounds, against main:
geomean 0.948 (previous tables 0.969), 631 rows at or below main,
31 more than 5% slower; summed 13183 us vs 14153 us.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Conflict: op_tests/test_flydsl_hgemm.py keeps both main's HTI concurrent-copy
test (ROCm#7042) and this branch's partial-sum exactness test.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
…tza_hgemm_fp32_partials

Combines the PR branch's f301498 with the shared split-K reduction and the
one-pass slice-K combine of this branch.

Kernel:
- Taken from f301498: the kernarg loads through one empty asm at entry in
  both kernels, the (n tiles, m tiles, splits) grid for group_m == 0 (the
  split-K counters and partial slots follow its tile index), the bounds-checked
  workspace for every split-K path, and the fragment-partial reducer adding
  its own partial from registers for tiles of at least 1024 elements.
- Fragment partials skip groups past M through an offset beyond the
  workspace (f301498's mechanism) instead of a branch and a reload of group
  0, but only when the tiles cross M (this branch's host flag) and the tile
  has at least 1024 elements: on 16x16 tiles the mask cost 2-3% and saved
  nothing.
- The shared reduction no longer loads another split's slot in place of its
  own; the own split's load reads past the workspace.
- Tried and dropped: the last-arrival LDS reduction adding its own partial
  from registers (per-split selects made split_k >= 20 tiles up to 14%
  slower).

Tables: rows changed on both sides (162) take whichever of this branch's,
f301498's or an earlier pick of the PR is fastest on the combined kernel
(101 this branch, 57 f301498, 4 earlier picks); rows changed on one side
keep that side's pick unless another one is faster by > 1% in >= 5 of 7
lockstep rounds (23 of 303 switched). Three rows (16x24x2560, 80x512x2560,
32x2560x2880 with bias) then take f301498's config, which was faster by > 1%
in >= 14 of 21 rounds. Every config is exact on small-integer inputs and
bitwise repeatable on the combined kernel.

824 gfx950 M <= 128 rows through aiter.tuned_gemm, HIP-graph replay, weights
rotated past the LLC, 7 lockstep rounds against the original tables:
geomean 0.922 (this branch 0.948, f301498 0.941), 694 rows at or below,
15 more than 5% slower; vs the faster of the two parents per row 0.993.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
AndreasKaratzas and others added 2 commits November 8, 2026 02:12
Conflicts:
- gemm_a16w16_gfx950.py: keep the fp32 split-K workspace, the one-counter
  get_split_k_buffers(stream, device) and the up-front kernarg loads; take
  main's capture_scoped_cache, kernarg preload hints, k_stagger and
  b_non_temporal.
- aot/flydsl/gemm.py: take main's replay-based AOT build (ROCm#6956), which
  launches through the runtime and so needs no HGEMM-specific arguments.
- glm5/kimik3/minimax_m3_eagle tables: rows are merged one by one. Where both
  sides changed a row, main's row is kept: glm5 2624x6144 M=1/2/4/6/8 use
  the skinny kernel (ROCm#6427), and kimik3 64x20480x7168 uses the band-stream
  kernel (ROCm#7546). Neither uses split-K; both are exact and repeatable.
- test_graph_alloc.py: call get_split_k_buffers(s, dev), which no longer
  takes split_k.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
… reduction

The exact fp32 reduction made some M > 128 split-K and slice-K rows slower
than main, because these rows were tuned for the bf16 atomic reduction.
Retune them with the gfx950 tuner (csrc/gemm_a16w16/gemm_a16w16_tune.py,
flydsl/torch/triton candidates). Keep a new row only when it is faster
than the merged row in interleaved runs with weights rotated past the LLC.

- 119 rows in 14 tables change (107 FlyDSL to FlyDSL, 12 FlyDSL to torch).
- glm5 2624x6144: M=256 moves to t128x128x64x3 ks6 kw2, and a new M=192
  row uses t128x128x64x3 ks6.
- No row with M <= 128 changes.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
AndreasKaratzas and others added 2 commits November 8, 2026 07:15
89 gfx950 rows with M <= 128 were more than 2% slower than main with the
exact fp32 split-K reduction. This retunes them with a wider search.

- FlyDSL: every config of the tuner catalog for the 6 GLM-5 2624x6144
  rows (8.7k-14.7k per row), and for the other 83 rows the configs with
  the row's tile and split_k +-3 plus 600 random configs. Then the
  k_stagger and b_non_temporal variants of the best configs.
- hipBLASLt: every solution was timed. It was not faster on GLM-5.
- A row changes only if the new config is exact on integer inputs, gives
  bitwise identical outputs in 20 runs, and is more than 1% faster than
  the current row in interleaved runs through aiter.tuned_gemm, with and
  without torch.cuda.empty_cache() between rows.

58 rows in 12 tables change, all to other FlyDSL configs. On the 89
rows, the geomean vs main goes from 1.048 to 1.003 with empty_cache and
from 1.038 to 0.990 without it (7 rounds on each of 2 GPUs per mode).

The `us` column of the changed rows is the median kernel time from the
interleaved selection runs (HIP-graph replay, weights rotated past the
LLC). It is not the tuner's time, so it does not compare directly with
the `us` of the old rows.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
…6144

hipBLASLt solution 17403 is exact on integer inputs, bitwise repeatable
and 5-12% faster than the FlyDSL split-K row through aiter.tuned_gemm
(15 interleaved rounds on 2 GPUs, with and without empty_cache). The
index is valid for hipBLASLt 1.4.1 (ROCm 10.0.0).

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
Resolve aiter/configs/model_configs/dsv41_bf16_tuned_gemm.csv after ROCm#7624.
The gfx950 128x384x5120 row changed on both sides. Take the row from main.
With the fp32 partial reduction of this branch, its tile is exact and
deterministic, and it is faster than the row of this branch.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
@eppaneamd

Copy link
Copy Markdown
Contributor

I measured this PR on gfx950 (MI355X) with split-K bf16 rows we tune for GLM-5.3-Flash and Qwen3.8-Flash-Next, and with this PR's own retuned rows for those two models.

Setup:

  • amd-aiter 0.1.28.post1 with [Triton/Gluon] [FlyDSL] [CI] [Bugfix] Never share scratch buffers whose zero fill was recorded into a graph #7126 backported, then e438aae59f on top, including its glm53_flash_bf16_tuned_gemm.csv and qwen38_flash_next_bf16_tuned_gemm.csv changes. Every hunk applies except the import hunk of gemm_a16w16_gfx950.py, applied by hand. Both arms' FlyDSL kernels were prebuilt, so no timed call compiles.
  • Per (M, N, K) through tuned_gemm.gemm_a16w16; get_GEMM_A16W16_tuned_config must return the row under test.
  • GPU time per call: events around 20 eager calls queued behind a torch.cuda._sleep that outlasts the host's enqueue (checked for every measurement), so the GPU never waits for the host; median of 3. Host time per call: wall time of the same 20 calls.
  • Error: relative L2 against fp32 torch. A key is reproducible when 5 calls on the same inputs are bitwise equal.
rows keys GPU time with / without, geomean (range) > 1.03 < 0.97 host time per call without, median host time added, median
our split-K rows (19 also slice K), the same config in both arms 133 1.005 (0.79–1.19) 51 38 37.9 µs +7.0 µs
qwen38_flash_next_bf16_tuned_gemm.csv: this PR's rows against 0.1.28.post1's at the same keys 103 0.935 (0.65–1.08) 6 57 37.5 µs +7.0 µs
glm53_flash_bf16_tuned_gemm.csv: the same 12 1.005 (0.83–1.12) 7 4 37.5 µs +8.3 µs

Error and reproducibility come from a separate run, in which the lookup also missed 4 more Qwen keys (not reproduced since); they are left out here:

rows keys max rel L2, without → with keys not reproducible, without → with
ours 133 0.0046 → 0.0017 118 → 0
Qwen table 99 0.0045 → 0.0018 69 → 0
GLM table 12 0.0041 → 0.0017 6 → 0
  • On our rows, the 118 keys that were not reproducible without this PR are exactly those with ks ≥ 3.
  • GPU time is neutral on our rows and lower on the retuned Qwen rows. Repeating the baseline gives geomeans of 1.000, 0.999 and 1.008 but single keys from 0.95 to 1.23, so only the geomeans carry signal.
  • Host time: these calls are host-bound when run eagerly (median GPU time 4.7–10.8 µs per table against ~38 µs of host time per call). With this PR each split-K call allocates its fp32 workspace with torch.empty (1.6 µs on its own) and passes one more tensor through from_dlpack, which accounts for part of the +7 µs. CUDA graph replay does not run this host code.
  • 6 of this PR's keys in those two tables are not in the tables above: 0.1.28.post1's lookup does not return this PR's row for them (5 name bnt kernels its catalog does not recognize).

Not measured: a main build, end-to-end serving, other GPUs.

The semaphore comes from get_split_k_buffers (capture_scoped_cache), while the fp32 workspace is a torch.empty on every call. Would a cached workspace per stream (kept at the largest size seen) work with the inter-partition protocol, so that eager callers do not pay the allocation?

@AndreasKaratzas

Copy link
Copy Markdown
Contributor Author

@eppaneamd thanks for measuring this. Yes, a cached per-stream workspace works with the protocol, and I'll switch to one.

Why it is safe: the workspace needs no initial value. Each split writes its own fp32 slots before it takes its ticket, and the reducer reads them only after the counter shows every split has arrived. The counter (from get_split_k_buffers) is what has to start at zero, and the last arrival resets it. On one stream the next launch starts only after the previous one has finished, so reusing the slots is fine. Two streams running at the same time would race on a shared buffer, so the key includes the stream, as it already does for the counter. A buffer bigger than one launch needs is also fine. The kernel indexes slots by tile_idx * split_k * tile_elems, and only the out-of-M groups use the SKIP offset, which sits past 2**31 - 16 bytes, so the extra length is never touched.

Two constraints decide the shape of the change:

  1. A CUDA graph records the buffer's address. So a buffer can never be freed and replaced by a larger one while a graph may still hold it. If the replaced buffer went back to the persistent pool, a later cached buffer, for example a semaphore, could get that address. So it can't be a single buffer that grows and replaces itself. I'd key it by power-of-two size buckets and never free a bucket, the same way the top-k workspace is cached (_get_topk_mb_workspace_keyed(device, stream_id, size)).
  2. It has to come from persistent_alloc. Otherwise its first allocation inside a capture comes from the graph's private pool and can share an address with an intermediate tensor.

Sketch (cached with capture_scoped_cache, like the counter):

@capture_scoped_cache
def _split_k_workspace(device, stream_handle, numel):
    with persistent_alloc(device):
        ws = torch.empty((numel,), dtype=torch.float32, device=device)
    return ws, _dynamic_tensor_arg(ws, 0)

# in gemm_a16w16, split_k > 1:
needed = split_k * tiles * param.block_m * param.block_n
bucket = 1 << (needed - 1).bit_length()
if bucket * 4 > 2**30:  # keep the SKIP offset outside the buffer
    bucket = needed
_, workspace_arg = _split_k_workspace(device, stream.cuda_stream, bucket)

I cache the wrapped from_dlpack(...).mark_layout_dynamic(0) argument along with the tensor. FlyDSL reads the data pointer and the shape from the wrapped tensor at each launch, so the wrapper can be reused. That removes both host costs you saw. On MI355X (host loop, 20k iterations, best of 5), torch.empty costs 1.4 us, from_dlpack + mark_layout_dynamic costs 3.1 us (4.5 us together), and a dict lookup returning a cached pair costs 0.15 us. So about 4.4 us of the +7 us should go away. I expect the rest to come from the extra kernel argument and the per-launch host-side choice of reduction. I haven't measured that part yet.

Cost: one bucket per (device, stream, size) is kept for the life of the process. With the tables in this PR, the largest single workspace is 56 MiB (llama70B 256x8192x28672, t128x256 ks7). Every other table needs at most 48 MiB, and most need 8-16 MiB. Power-of-two buckets cap the total per stream at about twice the largest bucket. A cached buffer first allocated after vLLM's memory profiling (for example during graph capture at a larger M) isn't counted in the profile. Today the per-call torch.empty is counted at its peak. I'll note that in the PR.

I'll add a test that two eager calls on one stream reuse the same workspace, that two streams get different ones, and that the exact-and-deterministic cases still pass under graph replay. I'll also rerun your host-time comparison.

Conflicts:
- gemm_a16w16_gfx950.py: keep this branch's whole-tile split partition
  (last split takes the remainder) and its validator. Drop main's FT
  balanced-split branch in the kernel body, because the host now always
  passes a block_k-aligned working_k, so that branch cannot run. Keep
  this branch's kernel names (they already differ from main's
  _kst4/_kst5 names). Keep main's bpreshuffle shape check.
- gemm_a16w16_policy.py: keep both the whole_tile_splits field and
  main's tdm/b_k_contiguous fields. Keep this branch's split_k
  candidates, which are a superset of main's 1..9 for K >= 9.
- kimik3, qwen38_flash_next, qwen3_5_397b tables: key-based 3-way
  merge. Take main's change where this branch did not touch a row
  (incl. the hipBLASLt row removal from ROCm#8490). For the five gfx950
  kimik3 896x3584 rows (M 8-64) that both sides retuned, keep this
  branch's exact fp32-partial rows.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
AndreasKaratzas and others added 3 commits November 26, 2026 21:16
Conflicts:
- gemm_a16w16_gfx950.py: take main's AOT-cache launch (ROCm#8565, ROCm#8600):
  bind_aot, _PARAM_ITEMS and _run_compiled with the sorted param items
  and the device as the specialization key. Keep this branch's fp32
  workspace argument, its one-counter get_split_k_buffers(stream,
  device) and its get_cu_num/buf_base_i64 imports. The param items now
  include this branch's split_k_resident and m_tail, so the AOT key
  covers the per-launch reduction choice.
- llama70B, minimax_m3_eagle tables: key-based 3-way merge. Take main's
  change where this branch did not touch a row. For minimax_m3_eagle
  128x50016x6144, which both sides changed, keep main's row (ROCm#8598,
  FlyDSL t128x256x64x3 ks1 w4x4x1, 119.9 us vs this branch's torch row
  at 135.0 us). It has no split-K and no slice-K, so this PR's
  reduction does not apply and it is exact. This follows the earlier
  merges, which kept main's row where main's non-split-K pick is faster.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
…28x12288x6144

Main removed every shipped hipBLASLt BF16 row in ROCm#8490, because a saved
solution index can map to another kernel with a different hipBLASLt
build (ROCm#8406). This row goes back to the exact FlyDSL config from
aca9344 (t128x96x64x5 ks2 w4x1x1 stg3 bnt, 41.81 us).

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
AndreasKaratzas and others added 3 commits November 27, 2026 22:44
…tream

Eager launches reuse one fp32 workspace per (stream, device, power-of-two
size) instead of a torch.empty and a from_dlpack per call: on MI355X the
host time of a split-K call goes from +8.0 us to +2.0 us against main.
A launch on a capturing stream that has no eager buffer still takes its
workspace from the graph's pool, so captures keep no extra memory.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
…tic kernels

The asm split-K kernels return different bits from run to run with 3 or
more splits. 39 gfx950 bf16 rows move to FlyDSL (37), torch (1) and Triton
(1) configs that are repeatable and 1.4% to 33% faster with cold
activations on MI355X; 29 bf16 rows stay on the asm kernel.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
…eduction

123 gfx950 bf16 rows in 16 tables (11 of them in the Gemma-4-26B-A4B table,
which was never retuned) move to exact configs: 111 FlyDSL, 12 torch. Each is
1.0% to 35.5% (median 5.7%) faster than the row it replaces with cold and with
warm activations on MI355X. 107 of the rows were more than 2% slower than
main; 73 of those are now within 2%.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
@AndreasKaratzas

Copy link
Copy Markdown
Contributor Author

I timed every affected gfx950 row on MI355X against main, with cold and with warm activations, and pushed three follow-up commits. Short version: they take about 70 rows out of the "more than 2% slower than main" set (472 before, 401 after) and make 39 asm split-K rows repeatable. 401 of 1733 rows are still more than 2% slower than main (165 above 5%, 37 above 10%), and I did not find a way to close those with the fp32 reduction.

Commits

  1. [FlyDSL] [Perf] gfx950 A16W16: cache the split-K fp32 workspace per stream. The cached workspace from the discussion above. Eager host time per split-K call goes from about +7 us to about +2 us against main (median of 18 split-K rows: +7.2 us before, +1.7 us after; FlyDSL rows without split-K carry about +1 us with and without the cache). A launch inside a graph capture still takes its workspace from the graph's pool.
  2. [Config] [Perf] gfx950 A16W16: move 39 asm split-K rows to deterministic kernels. The asm split-K kernels with 3 or more splits return different bits from run to run, and this PR did not touch them. 39 of the 68 256-CU bf16 rows on them move to repeatable configs that are also faster (37 FlyDSL, 1 torch, 1 Triton; 1.9% to 32% faster with cold activations). 29 stay; the 55 asm split-K rows with fp32 output were not looked at.
  3. [Config] [Perf] gfx950 A16W16: retune 123 split-K rows for the fp32 reduction. Exact configs only (111 FlyDSL, 12 torch). 11 of the rows are in gemma4_26b_a4b_bf16_tuned_gemm.csv, which main added after the earlier retunes.

Every FlyDSL split-K and slice-K row keeps the fp32 reduction. I also built a two-split policy that keeps main's packed atomics (two additions onto zero commute, so it is repeatable): it brings 26 more rows within 2% of main, at main's accuracy on 38 rows (12.9% of outputs more than 1 ulp off instead of 0.01%). It is not in this push, because it gives up the accuracy this PR is about and #8031 has just removed the same reduction on gfx1250. I can open it as a separate PR if that trade is wanted.

Timing

aiter.tuned_gemm with each build's own tables, HIP-graph replay, one worker process per build on the same GPU (main dd6beb9, the branch, a second main worker as a control), 9 interleaved rounds with rotating order, at least 240 calls per sample, weights rotated past 400 MB. "Cold" also rotates the activations; "warm" reuses one activation buffer. dd6beb9 is the main commit this branch last merged; main's gfx950 bf16 rows and gfx950 A16W16 kernel files are the same there and at 9da5928.

A row counts as slower only when the median of its per-round ratios is above the threshold against both main workers. The control differs from main by 0.29% (median) and 1.40% (90th percentile). Counting a row when the geometric mean of the two ratios is above 2% gives 429 rows instead of 401.

Rows: every 256-CU gfx950 bf16 row that uses split-K or slice-K on either side or whose pick this PR changes, 1733 rows. "Before" is 1f8a4e5 with commits 1 and 2; "after" is all three commits. Each cell with three numbers is cold / warm / either mode.

Table Rows >2% slower, cold / warm / either: before after >5% / >10% (either): before after Geomean vs main, cold / warm: before after Worst row: before after
All affected rows 1733 431 / 350 / 472 356 / 278 / 401 218 / 56 165 / 37 -2.6% / -3.3% -3.2% / -4.0% +24.6% +18.8%
Gemma-4-26B-A4B 39 32 / 31 / 33 24 / 22 / 26 16 / 6 8 / 1 +4.6% / +4.6% +1.8% / +1.6% +14.1% +11.1%
Per table
Table Rows >2% slower, cold / warm / either: before after >5% / >10% (either): before after Geomean vs main, cold / warm: before after Worst row: before after
DeepSeek-V4 407 131 / 97 / 141 117 / 77 / 127 64 / 21 57 / 16 -1.2% / -2.3% -1.6% / -2.9% +24.6% +14.8%
Kimi-K3 294 85 / 77 / 92 62 / 61 / 72 49 / 10 33 / 7 -0.6% / -0.9% -1.7% / -2.1% +19.3% +18.8%
Qwen3.8-Flash-Next 131 31 / 33 / 37 25 / 26 / 30 17 / 6 12 / 5 -4.0% / -3.9% -4.5% / -4.4% +17.7% +18.5%
GLM-5 123 19 / 14 / 19 16 / 15 / 18 11 / 0 9 / 0 -3.8% / -4.7% -4.0% / -5.0% +10.0% +9.5%
MiniMax-M3 121 19 / 18 / 24 18 / 14 / 21 8 / 0 5 / 0 -2.9% / -3.1% -3.0% / -3.4% +8.4% +9.3%
Kimi-K2 90 35 / 26 / 42 34 / 19 / 41 19 / 6 15 / 1 +0.8% / -1.5% +0.3% / -2.3% +16.8% +10.5%
DeepSeek-V4.1 89 22 / 10 / 22 15 / 8 / 16 10 / 4 9 / 3 -4.1% / -5.6% -4.4% / -6.0% +22.1% +16.6%
MiniMax-M3 EAGLE 73 9 / 6 / 10 6 / 5 / 8 3 / 0 1 / 0 -3.3% / -3.6% -4.1% / -4.5% +6.3% +5.3%
gpt-oss 65 5 / 1 / 5 2 / 0 / 2 2 / 0 2 / 1 -6.0% / -6.7% -6.0% / -6.8% +9.6% +10.1%
Qwen3.5-397B 61 10 / 7 / 11 10 / 6 / 10 5 / 2 4 / 2 -2.7% / -3.1% -3.0% / -3.4% +21.1% +15.7%
Qwen 32B 51 9 / 8 / 9 8 / 7 / 8 6 / 0 4 / 0 -3.8% / -4.6% -3.7% / -4.6% +7.8% +8.1%
Llama 70B 45 1 / 2 / 2 0 / 1 / 1 0 / 0 0 / 0 -8.3% / -8.3% -8.8% / -8.7% +3.2% +2.5%
Llama 405B 44 1 / 0 / 1 1 / 1 / 1 0 / 0 1 / 0 -10.4% / -10.4% -11.8% / -11.4% +4.4% +6.3%
GLM-5.3-Flash 35 2 / 4 / 4 2 / 2 / 3 1 / 0 0 / 0 -3.1% / -3.4% -4.1% / -4.5% +7.9% +3.6%
DeepSeek-V3 29 11 / 8 / 11 9 / 7 / 9 4 / 1 3 / 1 -6.5% / -7.1% -6.9% / -7.1% +10.8% +11.0%
Mistral Large 4 23 7 / 6 / 7 5 / 4 / 5 2 / 0 1 / 0 -0.5% / -1.0% -1.5% / -2.1% +6.7% +5.3%
Kimi 5 2 / 2 / 2 2 / 2 / 2 1 / 0 1 / 0 +0.4% / +1.9% -0.9% / +0.5% +5.8% +5.3%
bf16_tuned_gemm 1 0 / 0 / 0 0 / 1 / 1 0 / 0 0 / 0 +1.7% / +1.8% +1.9% / +2.5% +1.5% +2.4%
4 other tables 7 0 / 0 / 0 0 / 0 / 0 0 / 0 0 / 0 -26.4% / -28.2% -26.6% / -28.3% -2.8% -2.4%

"Before" was measured earlier the same day with the same harness. On the 1610 rows that commit 3 does not change, 356 were above 2% then and 362 are now (325 in both runs). Of the 123 changed rows, 116 were above 2% before and 39 are after. 699 rows are more than 2% faster than main in both modes. Summed over the 1733 rows, the cold time is 4.1% below main (3.4% before). In 8 identical calls per row, 0 of the 1733 rows return different bits; on main 1213 do.

How far the count moves between runs: on the 1695 rows that a second full run a few hours earlier shares with this one, it gave 363 rows above 2% and this one 374; 346 rows are above 2% in both and 391 in at least one. One row can sit 6% apart between two runs with the same kernel (Llama 405B 256x9216x16384: +6.3% here, -0.7% there), so single rows near the threshold do not carry signal; the count does.

Why the remaining rows are slower

369 of the 401 use 3 or more splits on main (146 with 4, 103 with 8, 65 with 7); 30 use 2. Their K loop is as fast as on main; the reduction is not. Kernel time (cold, us) with parts of the reduction switched off:

M x N x K (config) main, bf16 atomics no reduction at all + fp32 partial stores + arrival count + read back and add (this PR)
1216x64x7168 (t48x64 ks8) 7.75 6.32 6.78 7.57 8.76
368x384x7168 (t32x96 ks8) 11.18 9.76 10.38 11.47 12.42
64x2816x2112 (t64x64 ks3) 7.22 6.45 6.77 7.56 8.07
288x2272x7168 (t96x96 ks7) 21.28 18.68 21.11 22.68 25.14

The packed atomics cost 0.8 to 2.6 us on these rows and the fp32 reduction 1.6 to 6.5 us. The partial stores are cheaper than the atomics. The cost is in what follows: the last split has to learn that every other split has stored (wait for its own stores, a barrier, one atomic that returns a value: 0.8 to 1.6 us) and then read the partials back (0.5 to 2.5 us). Those are two more memory round trips after the K loop, on kernels of 6 to 12 us.

What I tried on these rows:

  • Retune: 96,933 (row, config) pairs on the 500 slowest rows. FlyDSL catalog configs with 1 to 16 splits and slice-K, the asm kernels with 1 and 2 splits, torch and Triton, each checked for repeatability and accuracy before it was timed. The three fastest per row went into the interleaved harness; a row changes only if the new config is more than 1% faster than the current one in both modes. That is commit 3.
  • Two splits with packed atomics, each split rounded before it is added: within 2% of main on the 38 rows described above and, as the best such config, on 14 of 51 rows that use 3 or more splits on main. Not in this push.
  • Kernel variants of the reduction on 12 to 20 slow rows: the shared reduction for every tile size, a look at the counter while the stores are in flight, partials read without an arrival count and checked against a sentinel, a pairwise tree with exchange atomics. None beat the current reduction on more than 3 rows; the last two were 8% to 245% slower than main.

Ways forward for these rows: a tuner run over the full catalog (the second screening pass, 15,507 new pairs on the 120 slowest rows, still gave 34 of the 123 changes, so the catalog is not exhausted); a cheaper ordered reduction in the kernel; or accepting them. A per-row switch back to the atomics for 3 or more splits would make them as fast as main and non-repeatable again. I have not added one.

Checks on MI355X

  • python op_tests/test_flydsl_hgemm.py: exit 0 in 3 of 3 runs, with 30 exact-and-deterministic cases each. pytest op_tests/test_graph_alloc.py: 7 passed, 1 skipped, 3 of 3 runs. The new workspace test fails without commit 1, and fails when the cache is made to serve a capturing stream or to share one buffer between streams.
  • pytest op_tests/tuning_tests/{test_a16w16_tuned_config_lookup,test_csv_validation,test_config_shape_collision,test_asm_splitk_guard}.py: 71 passed, 4762 subtests passed, 8 failed. The 8 are the test_gfx1250_legacy_wrapper_routing subtests, which fail the same way at 1f8a4e5 and pass after a merge with main.
  • Repeatability under load, through aiter.tuned_gemm, while two other processes run GEMMs on the same GPU, 8 eager calls and a 4-call graph replayed 4 times per row: 0 of 2764 FlyDSL and skinny rows differ (every 256-CU gfx950 bf16 row of those two kinds with M <= 8192 and N x K <= 2^29, without preshuffle), 0 of 980 cases at M and M-1 on 500 random rows, 0 of the 857 torch and Triton rows. The 85 larger rows outside that filter, at M and M-1 with 16 eager calls and the same graph replay (169 cases): 0 differ. The 22 preshuffle rows were not swept.
  • Llama-3.1-70B in vLLM on one MI355X, 8 prompts, temperature 0, prefix caching off: main returns 6 different outputs in 6 identical calls (in each of two processes), the branch 1. Throughput at 32 prompts x 128 tokens: 1192 and 1186 tok/s on main, 1192 tok/s on the branch.

Merge with main

1f8a4e5 and the three commits merge cleanly into main (9da5928). On the merged tree the four tuning test files give 80 passed and 0 failed, test_graph_alloc.py 7 passed and 1 skipped, and test_flydsl_hgemm.py exits 0.

AI assistance (Claude Code) was used for the measurements and for these commits.

AndreasKaratzas and others added 2 commits November 28, 2026 15:47
…talog screen

319 gfx950 bf16 rows in 17 tables move to other repeatable configs: 246
FlyDSL to FlyDSL, 65 to the FlyDSL skinny kernel (M <= 128), 4 to torch,
3 to Triton, 1 torch to FlyDSL. The configs come from a screen of the
tuner catalog for the 1733 rows this PR affects: the (tile, block_k,
split_k, waves) classes with up to 8 splits, then every stage count and
the k_stagger / b_non_temporal variants of the best classes, 3.0 M (row,
config) pairs timed with HIP-graph replay over cold weights. A row
changes only if the new config is repeatable in 8 calls, as accurate as
the current one, and not more than 1% slower than the current row with
cold or with warm activations in separate runs.

On MI355X against main (dd6beb9 rows and kernels), two interleaved
passes over the 1733 rows: rows more than 2% slower than main go from
381 to 255 and above 5% from 148 to 108 in these passes; geomean
vs main from -3.4% / -4.1% (cold / warm activations) to -4.9% / -5.7%.
288x2272x7168, the slowest row, moves from t96x96x64x5 ks7 to
t96x96x128x3 ks3 with two k-waves and is within 2% of main.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
…onfig

Three reruns on the committed tables (two interleaved passes over the
1733 affected rows with 9 rounds each, and a 15-round run of the rows in
question) found no gain on two of the 319 rows of the previous commit:

- dsv4 1920x64x4096: t32x64x128x4 ks4 with waves 2x4x1 reads 1.2% to
  2.1% slower with warm activations than with waves 2x2x1, and within
  0.7% with cold ones.
- qwen32B 16x5120x25600: t16x128x128x4 ks5 with waves 1x2x1 reads 0.6%
  to 0.9% slower than with waves 1x4x1 in both modes. Its stored time
  (56.6 us) does not reproduce; the kernel takes 46.7 us.

Two workers that run the same kernel differ by up to 0.8% on these rows,
so the first is a small loss at most and the second is no change.
Neither is a gain, so both rows go back to their b155ae8 line and the
retune covers 317 rows.

The same reruns against main (dd6beb9 rows and kernels) with these
tables: rows more than 2% slower than main go from 377 at b155ae8 to
257, above 5% from 142 to 102, above 10% from 30 to 14, none above 15%;
geomean vs main from -3.4% / -4.1% (cold / warm activations) to -5.0% /
-5.7%. The screen behind the previous commit timed 3.0 M of the 34.1 M
(row, config) pairs in the tuner catalog of these rows; it is not an
exhaustive run.

Signed-off-by: Andreas Karatzas <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
@AndreasKaratzas

AndreasKaratzas commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

I screened the tuner catalog for all 1733 affected gfx950 rows and pushed two more commits with the result. Short version: it helps, and it does not bring every row within 2% of main.

  • Rows more than 2% slower than main: 377 before, 257 after. Above 5%: 142 to 102. Above 10%: 30 to 14. Above 15%: 7 to 0.
  • Geomean against main: -3.4% / -4.1% (cold / warm activations) before, -5.0% / -5.7% after.
  • 288x2272x7168, the slowest row so far (+16% / +19%), is now at -0.8% / +1.6%. The slowest row is now 1664x64x7168 at +14%.
  • All 1733 rows return the same bits in 8 calls. On main 1215 of them do not.
  • The screen is not exhaustive: 3.0 M of the 34.1 M (row, config) pairs in the catalog were timed. What was and was not covered is listed below.

Commits

  • [Config] [Perf] gfx950 A16W16: retune 319 rows from a staged tuner-catalog screen. Tables only.
  • [Config] gfx950 A16W16: put two retuned rows back on their previous config. Reruns on the committed tables found no gain on two of the 319 rows: 1920x64x4096 in the DeepSeek-V4 table read 1.2% to 2.1% slower than the row it replaced with warm activations and the same with cold ones, and 16x5120x25600 in the Qwen 32B table read 0.6% to 0.9% slower in both modes. Two workers with the same kernel differ by up to 0.8% on these rows, so this is a small loss at most; neither was a gain.

Together: 317 rows in 17 tables. 244 go from one FlyDSL config to another, 65 to the FlyDSL skinny kernel (rows with M from 1 to 48), 4 to torch, 3 to Triton, 1 from torch to FlyDSL. Every new FlyDSL name is in the tuner's default catalog for its shape, at the solidx the row stores. The us column of the changed rows holds the cold time from the harness below, so it does not compare with the us of rows written by the tuner: 60 changed rows carry a higher us than the row they replace and are faster side by side.

Timing

Same harness and statistic as in my last comment: aiter.tuned_gemm with each build's own tables, HIP-graph replay, weights rotated past 400 MB, one worker process per build on the same GPU (main dd6beb9, b155ae8 as "before", this push as "after", a second main worker as a control), 9 interleaved rounds, "cold" rotating the activations too. A row's ratio is the median of the per-round ratios. A row counts as slower only when it is slower than both main workers.

The table combines two passes over all 1733 rows on the committed tables, each with fresh processes: one on a single GPU, one split over two other GPUs. A row's ratio is the geometric mean of the two passes. The two rows that the second commit put back carry the numbers of the b155ae8 worker.

How much the counts move:

  • The single passes give 250 and 255 rows above 2% after (108 and 110 above 5%, 14 and 18 above 10%), and 365 and 372 before.
  • The two main workers differ by 0.27% at the median, 1.1% at the 90th percentile and 3.2% at the 99th (0.3%, 1.4% and 4.0% to 4.4% in a single pass). About 70 rows sit between 2% and 3%, so single rows near the line do not carry signal; the counts do.
  • On the 1416 rows that run the same kernel before and after, 182 are above 2% on the "before" worker and 187 on the "after" worker (169 on both).
  • My last comment had 401 / 165 / 37 rows above 2% / 5% / 10% for b155ae8 from one pass on another GPU. Today's passes read 377 / 142 / 30 for the same tree.
Table Rows >2% slower, cold / warm / either: before after >5% / >10% (either): before after Geomean vs main, cold / warm: before after Worst row: before after
All affected rows 1733 342 / 281 / 377 234 / 170 / 257 142 / 30 102 / 14 -3.4% / -4.1% -5.0% / -5.7% +18.7% +14.3%
Gemma-4-26B-A4B 39 26 / 24 / 27 9 / 7 / 10 10 / 1 2 / 0 +1.7% / +1.7% -5.7% / -5.7% +13.8% +5.9%
Per table
Table Rows >2% slower, cold / warm / either: before after >5% / >10% (either): before after Geomean vs main, cold / warm: before after Worst row: before after
DeepSeek-V4 407 108 / 81 / 118 80 / 55 / 86 45 / 15 41 / 9 -1.9% / -3.0% -2.9% / -4.1% +15.7% +14.3%
Kimi-K3 294 64 / 56 / 69 38 / 33 / 45 29 / 6 13 / 3 -1.8% / -2.2% -3.2% / -3.5% +18.7% +11.9%
Qwen3.8-Flash-Next 131 28 / 29 / 33 19 / 16 / 20 13 / 3 8 / 0 -4.7% / -4.6% -6.9% / -7.0% +18.1% +9.6%
GLM-5 123 14 / 14 / 16 15 / 13 / 15 6 / 0 6 / 0 -4.3% / -5.3% -7.2% / -8.1% +8.4% +8.4%
MiniMax-M3 121 16 / 16 / 20 8 / 10 / 14 5 / 0 2 / 0 -3.0% / -3.3% -4.6% / -4.5% +8.6% +6.4%
Kimi-K2 90 27 / 17 / 31 23 / 11 / 23 14 / 0 15 / 0 -0.4% / -2.7% -1.3% / -4.1% +7.9% +9.8%
DeepSeek-V4.1 89 14 / 8 / 14 11 / 4 / 11 6 / 2 4 / 1 -4.7% / -5.9% -5.5% / -6.9% +17.0% +10.0%
MiniMax-M3 EAGLE 73 7 / 6 / 8 4 / 4 / 5 1 / 0 1 / 0 -4.4% / -4.5% -6.2% / -6.3% +6.7% +6.4%
gpt-oss 65 4 / 0 / 4 4 / 0 / 4 1 / 0 1 / 0 -6.3% / -7.2% -6.3% / -7.3% +7.1% +8.1%
Qwen3.5-397B 61 9 / 6 / 10 8 / 4 / 8 4 / 2 3 / 1 -2.9% / -3.3% -4.3% / -4.7% +16.1% +10.7%
Qwen 32B 51 8 / 8 / 8 3 / 3 / 3 3 / 0 2 / 0 -4.1% / -4.8% -6.1% / -7.1% +8.5% +6.6%
Llama 70B 45 0 / 0 / 0 0 / 0 / 0 0 / 0 0 / 0 -8.7% / -8.8% -10.6% / -10.5% +1.5% +1.3%
Llama 405B 44 0 / 0 / 0 0 / 0 / 0 0 / 0 0 / 0 -11.7% / -11.5% -13.7% / -13.4% +1.8% -0.3%
GLM-5.3-Flash 35 1 / 0 / 1 1 / 0 / 1 0 / 0 0 / 0 -4.8% / -5.2% -5.7% / -6.1% +3.5% +3.9%
DeepSeek-V3 29 9 / 8 / 9 7 / 6 / 7 3 / 1 3 / 0 -6.9% / -7.4% -9.9% / -10.0% +10.6% +8.4%
Mistral Large 4 23 5 / 5 / 6 2 / 1 / 2 2 / 0 1 / 0 -1.4% / -1.7% -5.0% / -5.8% +5.5% +5.4%
Kimi 5 2 / 2 / 2 2 / 2 / 2 0 / 0 0 / 0 -0.5% / +1.1% -0.5% / +1.1% +4.6% +4.9%
bf16_tuned_gemm 1 0 / 1 / 1 0 / 1 / 1 0 / 0 0 / 0 +1.8% / +2.3% +1.9% / +2.3% +2.2% +2.2%
4 other tables 7 0 / 0 / 0 0 / 0 / 0 0 / 0 0 / 0 -26.7% / -28.0% -26.8% / -28.5% -3.2% -2.9%

Of the 317 changed rows, 195 were above 2% before and 70 are after. Against the row it replaces, a changed row is 5.0% faster at the median (worse of the two modes) and 19% at the 10th percentile. Two changed rows read more than 1% slower than their old row in one mode and are faster in the other: 336x384x7168 (+1.4% warm, -0.6% cold) and 32x4x10240 (+1.0% cold, -3.4% warm). None reads more than 2% slower. 838 rows are more than 2% faster than main in both modes (741 before). Summed over the 1733 rows, the cold time is 5.9% below main (4.2% before). Of 90 control rows this PR does not touch, two are above 2% (worst +4.5%); they run the same kernels as main, so that is the noise of a single row.

How the screen was done
  • Catalog. get_flydsl_a16w16_configs gives 34,099,229 (row, config) pairs for the 1733 rows (144 to 95,323 per row, median 14,984) and 531,659 kernel names. Timing every pair was out of reach with the tuner as it is: it needs about 3 s per candidate here, because it traces and compiles each kernel in the timing process, copies A, B and C up to 101 times per candidate and times under the torch profiler. Compiling one kernel costs 0.3 to 0.7 s with up to 4 splits, 2 to 17 s with 7 or 8, and 30 s or more with 16.

  • Scratch changes to the tuner, not part of this PR. Candidates are compiled ahead of time on CPU into the AOT cache. run_perftest times by HIP-graph replay: 12 to 16 calls over as many copies of the weights, the activations and the output, a 512 MiB copy before each timed replay so that the weights are cold, and eager calls that must return the same bits. The catalog of a shape is read from a file instead of rebuilt. The catalog, the worker pool, the accuracy check and the selection are the tuner's own.

  • Does it rank like the harness? On 60 configs of 288x2272x7168 the rank correlation with the harness's cold timing is 0.98 (0.96 with its warm timing). It times with cold activations, which is what the tuner's argument rotation does too; the finalists then went through the harness in both modes, because cold and warm winners differ.

  • Stages.

    1. Every (tile, block_k, split_k, waves, policy) class of the catalog with 1 to 4 splits, at the stage count nearest 4: 1550 rows, 1.47 M pairs. For the last 750 of these rows only classes with 128 <= tiles x split_k < 512.
    2. The same with 5 to 8 splits, for the 1213 rows that were slower than main or use 4 or more splits: 1.13 M pairs.
    3. Tile sizes the kernel accepts and the catalog does not list (block_m 112 to 240, block_n 48 and 112 to 240), for 258 of the slow rows: 312 k pairs.
    4. Every stage count of the best classes (1082 rows, 51 k pairs), the k_stagger and b_non_temporal variants of the best configs (118 rows), and the best 8 to 12 configs per row again, cold and warm, next to the kernel of the current row.
    5. The best 4 to 7 per row in the interleaved harness against main, the current row and a second main worker.

    In total 3.0 M pairs were timed in the tuner, on 1637 of the 1733 rows. Besides FlyDSL, stage 1 timed torch, Triton and the asm kernels with 1 and 2 splits on every row. hipBLASLt solution indices were not candidates.

  • What a row had to pass. In the harness: bitwise equal in 8 calls, at the accuracy of the exact reduction, and a worst-mode ratio against main more than one point below the current row's. Rows that were not slow before also needed 3% in both modes. Then, in further passes, not more than 1% slower than the b155ae8 row in either mode. 357 rows got that far; 38 of them failed the last check and stayed on their b155ae8 row, and two more went back after the rerun on the committed tables (second commit).

  • Not covered. Configs with more than 8 splits beyond what the tables already hold (7.0 M pairs of the catalog; their kernels take 30 s and more to compile). 96 rows had no tuner pass and 87 more only the 5-to-8-split pass. Another job shared the GPUs during most of the screening (not during the timing above), so single-sample screening rounds can have missed good candidates. A quiet, longer run may find more.

  • Two tuner findings on the way. The AOT cache looks an entry up with a directory glob, which gets slow once the directory holds several hundred thousand files. A tuner worker stops with JIT session error: Cannot allocate memory after about 20 k candidates (vm.max_map_count is 65,530 here) and is restarted by the pool; the candidate in flight is lost.

What it found

  • Fewer splits plus k-waves on the large rows. 288x2272x7168 moves from t96x96x64x5 with 7 splits to t96x96x128x3 with 3 splits and two k-waves. The reduction then moves 3 partial tiles instead of 7, and the kernel is as fast as main's:

    288x2272x7168, cold, us main (atomics) K loop only + fp32 partial stores whole kernel
    7 splits (t96x96x64x3 ks7, main's config) 21.5 17.6 20.0 25.3
    3 splits x 2 k-waves (t96x96x128x3 ks3) 21.5 18.9 20.0 21.3
  • The skinny kernel on decode rows. 65 rows with M from 1 to 48 (GLM-5, Qwen3.8-Flash-Next, Gemma-4, Kimi-K3, MiniMax-M3 EAGLE, Llama 70B and others) move to it and are 17% faster than their b155ae8 row at the median (2% to 28%).

  • Other FlyDSL rows. 139 take more splits than before, 39 fewer, 66 the same number on another tile, wave layout or stage count; 46 add k-waves.

  • Tile sizes outside the catalog. In the screen's first pass (one sample per config) the best such config beat the best catalog config on 18 of 258 rows. None is in this push: the tables only hold catalog configs. That needs a proper run before anything follows from it.

The 257 rows that stay slower

More than 2% 3% 5% 10% 15%
before (b155ae8) 377 274 142 30 7
after 257 190 102 14 0
  • 147 are slower in both modes, 87 only cold, 23 only warm.
  • 236 use 3 or more splits on main (74 with 4, 69 with 8, 55 with 7); 19 use 2.
  • Main's kernel takes 6 to 12 us on 158 of them, under 6 us on 35, 12 to 20 us on 41 and more on 23.
  • In absolute terms they cost 0.40 us per call more than main at the median (0.84 us at the 90th percentile, 2.6 us at most).
  • By table: DeepSeek-V4 86, Kimi-K3 45, Kimi-K2 23, Qwen3.8-Flash-Next 20, GLM-5 15, MiniMax-M3 14, DeepSeek-V4.1 11, Gemma-4 10, others 33.
  • By M: 8 rows with M <= 16, 109 with M from 17 to 128, 71 from 129 to 512, 69 above 512 (59 of those in the DeepSeek-V4 table, 43 with N = 64). A tuned row serves a range of M (24 values at the median for these rows). How often those M occur in serving is not measured.
Where the time goes on these rows

Kernel time (cold, us) of 11 of these rows with their tuned config and parts of the reduction switched off:

M x N x K main (atomics) K loop only + fp32 partial stores whole kernel
1664x64x7168 8.20 7.17 7.88 9.32
160x768x7168 9.03 7.89 8.12 9.92
176x768x7168 9.28 7.92 8.18 9.94
928x64x7168 7.16 5.61 5.97 7.76
1408x64x7168 8.06 7.15 7.69 9.08
1984x64x7168 8.81 7.72 8.37 9.72
768x64x7168 6.90 5.56 5.94 7.44
104x384x7168 6.94 5.43 5.86 7.53
1088x64x4096 6.17 4.54 5.18 6.54
80x1280x2560 5.96 4.88 5.03 6.42
512x256x7168 8.80 7.51 7.77 9.26

The K loop alone is 0.9 to 1.6 us faster than main's whole kernel, which puts the cost of main's atomics at about 0.9 to 1.6 us (on 9 of the 11 rows the tuned config is not main's config, so this is an estimate; on the two rows with the same config it is 1.3 and 1.6 us). The fp32 reduction costs 1.5 to 2.2 us: 0.2 to 0.7 us for the partial stores and 1.4 to 1.8 us for learning that every split has stored and reading the partials back. Those are two memory round trips after the K loop, and the atomics have none: main's kernel ends when it has issued them. On a 6 to 9 us kernel the 0.4 to 1.1 us of difference is 5% to 14%.

On these rows the screen found no split, tile or wave class with 1 to 8 splits that is faster: they are small in M x N and long in K, so they need many workgroups along K, and with fewer splits the K loop loses more than the reduction gains. In the screen's own timing (one sample per config) the best 1-split, 2-split and 4-split configs of 1664x64x7168 are 36%, 16% and 4% slower than its best 8-split config.

Ways to treat them:

  1. Accept a threshold. 257 rows at 2%, 190 at 3%, 102 at 5%, 14 at 10%, none at 15%.
  2. Go back to the atomics on these rows. That makes them as fast as main and non-repeatable again on every row with 3 or more splits (236 of the 257). Not built.
  3. A cheaper reduction in the kernel. To match main it has to lose 0.4 to 1.1 us of its 1.5 to 2.2 us. What I can see is 0.2 to 0.4 us (the last split to arrive need not store its partial; the read-back could be issued together with the arrival count). That is an estimate, nothing is built, and it would not close the gap.

Checks on MI355X

  • python op_tests/test_flydsl_hgemm.py: exit 0, 30 exact-and-deterministic cases. python op_tests/test_gemm_a16w16.py and python op_tests/test_gemm_a16w16.py -t normal out compile -d bf16: exit 0; both print checkAllclose ... failed! for the two asm variants at 64x256x5120, as they do at b155ae8. python op_tests/test_gemm_codegen.py: 74 passed. pytest op_tests/test_graph_alloc.py: 7 passed, 1 skipped. Run at both new commits.
  • pytest op_tests/tuning_tests/{test_a16w16_tuned_config_lookup,test_csv_validation,test_config_shape_collision,test_asm_splitk_guard}.py: 71 passed, 8 failed. The 8 are the test_gfx1250_legacy_wrapper_routing subtests that fail the same way at b155ae8.
  • Repeatability under load, through aiter.tuned_gemm, while two other processes run GEMMs on the same GPU. Per case 32 outputs must be bitwise equal: 8 back-to-back eager calls, 4 eager calls with a sync after each, 4 eager calls alternated with a GEMM of another shape, and a 4-call graph replayed 4 times. All 2819 FlyDSL rows, the 312 changed ones also at M-1 and at the smallest M the row serves (3337 cases): 0 differ. All 1038 torch, Triton and skinny-default rows, the 7 changed ones also at the other M: 0 differ. The asm split-K rows this PR does not move still differ (84 rows: 29 with bf16 output, 55 with fp32 output).
  • Accuracy against fp64: relative L2 error of the FlyDSL rows is 0.00166 at the median and 0.00171 at the 99th percentile; the largest values (up to 0.0021) are on rows with at most 512 outputs. The torch rows (hipBLASLt) give 0.00166 at the median and 0.00169 at most. On the changed rows at most 0.05% of the outputs are more than 1 bf16 ulp from the correctly rounded value, the same as with the rows they replace.
  • Llama-3.1-70B in vLLM on one MI355X, 8 prompts, temperature 0, prefix caching off: main returns 6 different outputs in 6 identical calls (in each of three processes), this push 1, with the same output hash in four processes (two per commit) and the same as at b155ae8. Throughput at 32 prompts x 128 tokens, median of 7 runs: 1190, 1187 and 1167 tok/s on main, 1185, 1187, 1182 and 1186 tok/s with this push.
  • Not run: gfx942 and gfx1250 (no row or kernel of theirs changes), fp16 inputs, the 128-CU gfx950 tables.

AI assistance (Claude Code) was used for the screen, the measurements and the commits.

@AndreasKaratzas

Copy link
Copy Markdown
Contributor Author

Decision on the rows that stay slower than main: I'm accepting them. After the retune, 257 of the 1733 affected rows are more than 2% slower than main, 102 more than 5%, 14 more than 10% and none more than 15%, with a median extra cost of 0.4 us per call. Against that, the kernel is 5.0% to 5.7% faster than main in geomean, returns the same bits on every call, and is as accurate as hipBLASLt. Switching those rows back to the atomic reduction would make 236 of them non-repeatable again, which is what this PR is here to remove.

Still open as follow-up tuning, not for this PR: the screen covered 3.0 M of the 34.1 M (row, config) pairs, with nothing above 8 splits and 96 rows that got no pass.

Taking this out of draft so the GPU CI runs.

@AndreasKaratzas
AndreasKaratzas marked this pull request as ready for review November 28, 2026 20:53
@AndreasKaratzas
AndreasKaratzas requested a review from a team November 28, 2026 20:53
…artials

Resolve the two tuned BF16 GEMM tables per shape key. Rows both sides
agree on and rows only this branch changed keep this branch's row; rows
only main changed keep main's row unless their kernel uses the FlyDSL
gfx950 split-K or slice-K reduction this branch replaces.

Those rows, and every key both sides changed, were timed on the merged
tree (cold and warm HIP-graph replay plus the tuner's profiler timing,
two passes, candidates alternated) among this branch's, main's and the
merge-base config, and the fastest one that is exact on integer inputs
and bitwise repeatable is kept, with us/tflops/bw/err_ratio rewritten
from that measurement.

- llama405B: 54 same, 5 branch-only, 71 main-only kept as is; 9
  main-only split-K/slice-K rows and 17 keys changed by both re-timed
  (11 take this branch's config, 15 main's).
- minimax_m3_eagle: 260 same, 49 branch-only, 9 main-only kept as is;
  the 9 new main split-K rows re-timed: 7 keep main's config, and
  480/496x9216x6144 move to torch, which is about 30% faster than the
  ks3 config under the fp32 reduction.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
Conflicts:
- gemm_a16w16_gfx950.py vs ROCm#8929: keep this branch's 4-argument
  write_cshuffle_vec_to_global (main's out_buf/is_split_k only serve the
  atomic split-K store this branch removes) and use main's int64 C offset
  at all three C stores, including store_c_vec of the slice-K combine and
  split-K reducers, which main does not have.
- test_flydsl_hgemm.py: add 31777x67712x512 ft k_waves=2, a C past 2^31
  elements through store_c_vec. It fails with an illegal memory access
  when store_c_vec uses an int32 offset.
- kimik3 table vs ROCm#8915: 11 of the 12 _bnt rows take main's row; the 8
  without split-K/slice-K as is, 1x6016, 8x6016 and 32x6016 after
  re-timing under the fp32 reduction. 32x6288x7168 keeps this branch's
  ks4 row (tuner time tied, faster with warm weights).

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
@AndreasKaratzas

Copy link
Copy Markdown
Contributor Author

@eppaneamd the cached per-stream workspace is in now (982be6a). it uses power-of-two size buckets that are never freed, since a captured graph keeps the address. eager host overhead per split-K call went from about +7.2 us to about +1.7 us vs main. does that cover your concern?

@AndreasKaratzas

Copy link
Copy Markdown
Contributor Author

@aoli26 @coderfeli @xytpai main is merged in again, could you take a look when you have time?

Conflict in gemm_a16w16_gfx950_utils.py vs ROCm#8460: main adds an s_nop 1
after the inline-asm global_store_dwordx4 in store_global_f32_vec and in
SplitKProtocol.zero_c. This branch removes both (no zero-init of C, no
atomic split-K store); its workspace and C stores go through BufferCopy128b
and write_cshuffle_vec_to_global, which LLVM emits and pads itself. No
inline-asm store is left in the A16W16 kernel, so the branch side is kept.

gptoss_bf16_tuned_gemm.csv merges cleanly: the branch's gfx950 rows plus
main's 14 gfx1250 rows from ROCm#8862, no duplicate keys.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants