Skip to content

Alizaidy/bf16 gemm tuning 081426 - #4749

Merged
junhaha666 merged 17 commits into
mainfrom
alizaidy/bf16-gemm-tuning-081426
Aug 19, 2026
Merged

junhaha666 merged 17 commits into
mainfrom
alizaidy/bf16-gemm-tuning-081426

Conversation

@azaidy

@azaidy azaidy commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

GEMM A16W16 tuned kernel time (µs)

DSv4 Pro K=7168

N=64, K=7168

M opus (us) Triton (us) chosen
1 3.82 3.54 triton (1.08x)
2 4.00 3.62 triton (1.10x)
4 4.03 3.71 triton (1.09x)
8 3.85 4.73 opus (1.23x)
16 4.55 4.88 opus (1.07x)
32 4.04 3.99 triton (tie)
64 4.29 4.46 triton (tie)
128 4.47 4.34 triton (tie)
256 5.56 4.36 triton (1.28x)
512 6.63 9.24 opus (1.39x)
1024 8.18 9.58 opus (1.17x)
2048 13.56 10.01 triton (1.35x)
4096 — 11.02 triton (no tuned opus kernel)
8192 — 12.89 triton (no tuned opus kernel)
16384 — 17.06 triton (no tuned opus kernel)

N=384, K=7168

M opus (us) Triton (us) chosen
1 5.26 4.86 triton (1.08x)
2 5.51 4.90 triton (1.12x)
4 4.29 4.89 opus (1.14x)
8 4.47 5.19 opus (1.16x)
16 4.80 5.31 opus (1.11x)
32 4.78 4.82 triton (tie)
64 4.90 5.00 triton (tie)
128 6.83 5.91 triton (1.16x)
256 7.87 7.00 triton (1.12x)
512 10.29 11.23 opus (1.09x)
1024 15.21 12.49 triton (1.22x)
2048 20.46 13.87 triton (1.47x)
4096 31.85 31.51 triton (tie)
8192 59.70 38.72 triton (1.54x)
16384 109.78 57.22 triton (1.92x)

N=512, K=7168

M opus (us) Triton (us) chosen
1 5.35 4.89 triton (1.09x)
2 5.44 4.91 triton (1.11x)
4 4.35 4.45 triton (tie)
8 4.41 5.45 opus (1.24x)
16 4.55 6.01 opus (1.32x)
32 5.18 5.30 triton (tie)
64 5.43 5.38 triton (tie)
128 6.96 6.75 triton (tie)
256 9.00 7.85 triton (1.15x)
512 11.54 11.21 triton (tie)
1024 14.64 12.86 triton (1.14x)
2048 20.89 16.46 triton (1.27x)
4096 33.87 34.51 triton (tie)
8192 63.97 40.26 triton (1.59x)
16384 119.10 64.95 triton (1.83x)

N=1024, K=7168

M opus (us) Triton (us) chosen
1 5.52 5.03 triton (1.10x)
2 5.58 5.14 triton (1.08x)
4 5.68 3.75 triton (1.52x)
8 5.33 4.58 triton (1.16x)
16 5.48 5.19 triton (1.06x)
32 6.32 5.38 triton (1.17x)
64 7.36 5.81 triton (1.27x)
128 9.20 8.28 triton (1.11x)
256 10.97 9.81 triton (1.12x)
512 14.18 14.30 triton (tie)
1024 20.21 20.83 triton (tie)
2048 32.70 24.53 triton (1.33x)
4096 60.18 88.98 opus (1.48x)
8192 115.84 103.20 triton (1.12x)
16384 222.29 110.85 triton (2.01x)

N=2048, K=7168

M opus (us) Triton (us) chosen
1 7.32 5.21 triton (1.40x)
2 7.65 5.29 triton (1.45x)
4 7.69 5.10 triton (1.51x)
8 8.07 6.28 triton (1.29x)
16 8.47 6.36 triton (1.33x)
32 7.53 6.76 triton (1.11x)
64 9.81 7.76 triton (1.26x)
128 11.28 9.96 triton (1.13x)
256 14.26 12.51 triton (1.14x)
512 20.32 18.10 triton (1.12x)
1024 32.13 33.97 opus (1.06x)
2048 59.69 38.99 triton (1.53x)
4096 113.01 174.58 opus (1.54x)
8192 223.10 191.68 triton (1.16x)
16384 443.00 189.15 triton (2.34x)

N=32320, K=7168

M opus (us) Triton (us) chosen
1 — 25.53 triton (no tuned opus kernel)
2 39.26 25.52 triton (1.54x)
4 40.53 26.27 triton (1.54x)
8 — 25.47 triton (no tuned opus kernel)
16 — 24.96 triton (no tuned opus kernel)
32 — 26.15 triton (no tuned opus kernel)
64 65.21 31.86 triton (2.05x)
128 88.88 44.35 triton (2.00x)
256 124.81 76.41 triton (1.63x)
512 219.32 202.82 triton (1.08x)
1024 431.35 397.84 triton (1.08x)
2048 884.60 767.42 triton (1.15x)
4096 1760.80 1502.52 triton (1.17x)
8192 3509.31 2993.28 triton (1.17x)
16384 6998.73 3345.41 triton (2.09x)

DSv4 Flash K=4096

N=64, K=4096

M opus (us) Triton (us) chosen
1 3.49 3.43 opus (tie)
2 3.61 2.77 triton (1.30x)
4 3.64 2.91 triton (1.25x)
8 3.63 3.04 triton (1.19x)
16 3.72 3.75 triton (tie)
32 3.68 2.95 triton (1.25x)
64 3.83 2.96 triton (1.30x)
128 4.13 3.49 triton (1.19x)
256 4.44 3.59 triton (1.24x)
512 5.21 3.77 triton (1.38x)
1024 6.57 4.88 triton (1.35x)
2048 — 5.02 triton (no tuned opus kernel)
4096 — 5.80 triton (no tuned opus kernel)
8192 — 8.59 triton (no tuned opus kernel)
16384 — 11.92 triton (no tuned opus kernel)

N=256, K=4096

M opus (us) Triton (us) chosen
1 5.04 4.73 triton (1.07x)
2 5.00 4.77 triton (tie)
4 5.06 4.79 triton (1.06x)
8 3.87 3.65 triton (1.06x)
16 3.70 3.53 triton (tie)
32 3.96 3.80 triton (tie)
64 4.07 3.85 triton (1.06x)
128 4.52 3.77 triton (1.20x)
256 5.78 5.03 triton (1.15x)
512 7.27 5.85 triton (1.24x)
1024 9.55 7.13 triton (1.34x)
2048 11.54 8.78 triton (1.32x)
4096 17.63 13.66 triton (1.29x)
8192 26.17 15.40 triton (1.70x)
16384 56.37 25.94 triton (2.17x)

N=512, K=4096

M opus (us) Triton (us) chosen
1 4.97 4.79 opus (tie)
2 4.99 4.85 triton (tie)
4 5.15 4.96 triton (tie)
8 4.09 3.80 triton (1.08x)
16 4.13 3.73 triton (1.11x)
32 4.14 3.85 triton (1.07x)
64 4.33 3.88 triton (1.11x)
128 5.45 4.05 triton (1.34x)
256 7.41 6.71 triton (1.10x)
512 9.35 6.82 triton (1.37x)
1024 11.39 8.74 triton (1.30x)
2048 14.69 11.05 triton (1.33x)
4096 22.60 14.94 triton (1.51x)
8192 38.57 20.57 triton (1.87x)
16384 73.08 45.76 triton (1.60x)

N=1024, K=4096

M opus (us) Triton (us) chosen
1 5.15 4.89 triton (1.05x)
2 4.98 4.95 triton (tie)
4 5.13 5.00 triton (tie)
8 4.54 4.53 opus (tie)
16 4.70 3.98 triton (1.18x)
32 4.94 4.88 triton (tie)
64 5.35 4.70 triton (1.14x)
128 7.24 4.96 triton (1.46x)
256 9.08 6.86 triton (1.32x)
512 10.65 8.65 triton (1.23x)
1024 — 10.96 triton (no tuned opus kernel)
2048 21.59 14.89 triton (1.45x)
4096 34.60 20.75 triton (1.67x)
8192 69.99 44.33 triton (1.58x)
16384 134.07 82.46 triton (1.63x)

N=2048, K=4096

M opus (us) Triton (us) chosen
1 6.70 4.80 triton (1.40x)
2 6.80 5.03 triton (1.35x)
4 6.96 5.14 triton (1.36x)
8 6.57 5.16 triton (1.27x)
16 6.73 5.17 triton (1.30x)
32 6.32 5.10 triton (1.24x)
64 7.42 5.42 triton (1.37x)
128 8.65 6.24 triton (1.39x)
256 10.73 8.70 triton (1.23x)
512 14.26 11.27 triton (1.26x)
1024 — 15.39 triton (no tuned opus kernel)
2048 34.83 20.81 triton (1.67x)
4096 — 45.65 triton (no tuned opus kernel)
8192 — 80.44 triton (no tuned opus kernel)
16384 — 158.21 triton (no tuned opus kernel)

N=129280, K=4096

M opus (us) Triton (us) chosen
1 — 57.36 triton (no tuned opus kernel)
2 — 58.03 triton (no tuned opus kernel)
4 — 58.09 triton (no tuned opus kernel)
8 — 59.84 triton (no tuned opus kernel)
16 — 59.39 triton (no tuned opus kernel)
32 — 62.70 triton (no tuned opus kernel)
64 120.25 90.33 triton (1.33x)
128 162.98 95.38 triton (1.71x)
256 275.49 176.82 triton (1.56x)
512 504.16 330.76 triton (1.52x)
1024 996.70 620.63 triton (1.61x)
2048 1981.32 1205.61 triton (1.64x)
4096 3941.06 2384.48 triton (1.65x)
8192 7841.76 4732.71 triton (1.66x)
16384 — 9488.02 triton (no tuned opus kernel)

@azaidy
azaidy requested review from a team, ahmed-bsod, k50112113 and valarLip August 14, 2026 05:00
@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; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4749 --add-label <label>

@junhaha666
junhaha666 merged commit bdfcdd0 into main Aug 19, 2026
61 checks passed
@junhaha666
junhaha666 deleted the alizaidy/bf16-gemm-tuning-081426 branch August 19, 2026 07:42
nsakkine pushed a commit to nsakkine/aiter that referenced this pull request Aug 21, 2026
* Use triton for DSv4 Pro bf16 GEMM

* Add bf16 GEMM tuning for DSv4 Pro

* Tune triton BF16 GEMMs more for DSv4

* tuned m=64,128

* tuned m=1,32

* tuned m=256

* tuned m=16k

* black formatting fix

* fixes WAR hazard in kernel rn due to compiler issuing tdm load to same buffer as the ds_load without waiting for all the ds_loads to drain. we leave one buffer gap between tdm load and lds read now

* Add time, tf, BW

* Resolve conflicts with main

* Add DSv4 Flash configs

* Fix configs

* Restore opus on shapes where it performs better

* Adjust configs

---------

Co-authored-by: ahmed-bsod <[email protected]>
nsakkine pushed a commit to nsakkine/aiter that referenced this pull request Aug 24, 2026
* Use triton for DSv4 Pro bf16 GEMM

* Add bf16 GEMM tuning for DSv4 Pro

* Tune triton BF16 GEMMs more for DSv4

* tuned m=64,128

* tuned m=1,32

* tuned m=256

* tuned m=16k

* black formatting fix

* fixes WAR hazard in kernel rn due to compiler issuing tdm load to same buffer as the ds_load without waiting for all the ds_loads to drain. we leave one buffer gap between tdm load and lds read now

* Add time, tf, BW

* Resolve conflicts with main

* Add DSv4 Flash configs

* Fix configs

* Restore opus on shapes where it performs better

* Adjust configs

---------

Co-authored-by: ahmed-bsod <[email protected]>
junhaha666 pushed a commit that referenced this pull request Aug 26, 2026
* opus: pre-compiled (.co) a16w16 kid family for gfx1250

The 4wave_compute pipeline needs __builtin_amdgcn_pin_vgpr, amdgpu_num_vgpr and
-mllvm -amdgpu-expert-scheduling-mode. A release ROCm toolchain has none of them,
and aiter's hip_flag_checker SILENTLY DROPS flags the compiler rejects -- so a JIT
build would not fail, it would quietly produce a differently-scheduled kernel.
Only the device compile is bypassed: the kernel is built ahead of time into
gen_co/<arch>/*.co and loaded at runtime, while the host launcher, manifest, tune
lookup, dispatch and CSV schema all come from the ordinary codegen. Moving the
family back to JIT later is a branch in codegen/gen_instances_gfx1250.py.

gen_co/co_kernels.json is the single source of truth: opus_gemm_common.py turns it
into the kid table that drives codegen, and build_co.py re-reads it to produce the
images, so the .co filename, its extern "C" symbol and the launcher symbol are one
string by construction.

Two pipelines. The reference one is a verbatim port of the standalone kernel
(128x256x128 only). The _wl_ one generalises it: the wave layout (4x1 / 2x2 / 1x4)
is a template parameter, the msb split is derived rather than fixed at 4, the pin
bases follow the accumulator block instead of sitting at a constant, and the macro
register lists are templates so their length can follow the tile. Layout turns out
to be a real per-shape tuning axis, not just a small-tile enabler: on 128x256 it
swings -3.9% to +11.4% by shape.

Tuning: candidate_kids_for_shape / kid_rejects_shape / candidate_splitK in
opus_gemm_tune.py learn about the family, so gemm_a16w16_tune.py --libtype opus
picks it up. On the PR #4749 M=2048 K=7168 slice it wins 4 of 6 N values, up to
2039 TFlops at N=32320.

143 variants ship, each verified for numerics, out-of-bounds writes, zero spills
and 100% pin retention. Three known defects are written up with reproducers in
gen_co/KNOWN_ISSUES.md; two are blocked by static_assert and the third (a race at
B_N <= 128 on large shapes, present in the reference pipeline too) is handled by
leaving the 60 affected variants out of the table.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* opus co: force 1 WG/CU via LDS padding, fixing a race at small tiles

Any variant whose A/B LDS segments fit twice in the 320 KB budget (<= 160 KB)
let a second workgroup co-reside on a CU, which oversubscribes the per-CU TDM
request budget. The result was non-deterministic wrong output at large grids:
same seed and data, the wrong-element count changed every run, including runs
that came out clean.

The predicate separated the population exactly -- of 203 variants, every one at
LDS <= 160 KB raced and every one above it was clean (50/50 at B_N=64, 10/51 at
B_N=128, 0/51 at B_N>=192). Both pipelines were affected, reference included, so
this predates the wave-layout work rather than coming from it.

Pad LDS_BYTES past 160 KB when the real footprint is below it, the same trick
opus_cluster_tdm_splitk_ws_traits_gfx1250 already uses in this header for the
same reason; the pad tail is never accessed. build_co.py mirrors the formula
host-side and had to learn about the pad -- its group_segment_fixed_size ==
traits check is what caught the drift instead of shipping it.

The 60 variants dropped in the previous commit are restored: 143 -> 204, all
verified over 9 shapes x 2 repeats covering large grids, N < B_N / M < B_M, and
M/N/K tails, with sentinel checks for out-of-bounds writes. Zero spills, zero
lost pins.

Two things that made this hard to see are written up in gen_co/KNOWN_ISSUES.md:
a tolerance check is a poor detector when the tolerance is the unknown (an
outlier comparison across kids, which all compute identical math, found it), and
a clean standalone replay proves nothing about a race.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* opus co: state what the 1-WG/CU evidence actually shows

The previous message asserted the mechanism -- "oversubscribes the per-CU TDM
request budget" -- which was borrowed from the split-K pipeline's comments and
never measured for this one.

What the data supports is narrower and now written down as such. VGPR and LDS
both scale with the tile, so the raw LDS<=160KB correlation cannot separate
them; the population contains the control that can. 71 variants whose registers
would admit two waves per SIMD but whose LDS does not are all correct, against
61 where both admit two and all are wrong. Those two groups differ only in the
LDS-driven occupancy, so the variable is workgroups-per-CU.

Why 2 WG/CU breaks it stays open, with the candidates and the experiment that
would separate them recorded. The fix rests on "correct at 1 WG/CU", which the
control establishes, not on the mechanism.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* opus co: rule out synchronisation as the cause of the 2 WG/CU corruption

Occupancy cannot by itself break a correct kernel, so the natural reading of the
previous commit was that 2 WG/CU merely exposes a latent sync hole. It does not.

With the LDS pad disabled so the kernel really runs at 2 WG/CU, neither skipping
the -3 cluster barrier when the cluster is 1x1, nor draining every outstanding
TDM and LDS read and taking a full s_barrier() before every single tile, changes
the failure at all -- the wrong-element counts stay in the same range and stay
non-deterministic. No ordering fix inside the workgroup closes it, so the fault
is not between this workgroup's own waves.

What remains is something shared per CU and not covered by barriers. The leading
suspect, recorded as a hypothesis rather than a finding, is the LDS address in
the TDM descriptor: it is workgroup-relative, and if the TDM engine does not add
the workgroup's LDS base then a second co-resident workgroup aims its transfers
into the first one's LDS -- immune to barriers, corrupting both, and vanishing at
1 WG/CU where the base is zero. Confirming it needs an ATT capture or the TDM ISA
description.

No functional change: the debug switches used for these experiments are removed
and the padded build is re-verified.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* opus splitk: make the partial workspace dtype a per-kid choice

The gfx1250 _ws split-K families declared an fp32 partial in the traits
(D_C) and then wrote a bf16 one, because the pipeline took its element
type from a build-wide OPUS_WS_BF16 macro instead of the traits. The
reduce, the explicit instantiations and the host allocator each carried
their own copy of that assumption, so -DOPUS_WS_BF16=0 moved only some of
them and produced NaN.

D_C is what the traits already documented the slot as, so let it be the
one source: the pipeline stores Traits::DataC, the reduce is instantiated
with the same D_C, the dispatch table and the explicit instantiations use
the kid's splitk_workspace_dtype, and the host sizes the buffer from the
same field. Both partial widths are instantiated since the choice is now
per instance. The generated launcher checks workspace.element_size()
against sizeof(D_C): a .so stale with respect to the kid table used to be
a GPU page fault with nothing pointing at the cause.

Default is bf16. It clears the gate the tuner actually applies -- at
rtol=atol=5e-2 for a bf16 output, err_ratio is 0.004-0.012 against a 0.05
line, flat from split_k=1 to 16 -- at half the workspace and half the
reduce's read traffic. Candidate selection drops fp32-partial kids unless
OPUS_TUNE_FP32_WS=1, and the 4 GiB workspace cap now measures in the kid's
own element width rather than assuming 4 bytes.

Two things that only bite during a sweep:

_get_opus_workspace was @functools.cache'd, pinning one buffer per
(device, shape, dtype) for the process lifetime. Bounded for inference,
which sees a handful of shapes; the tuner walks every (tile padding x
split_k) pair, which is 1065 distinct buffers totalling 450 GiB on a
432 GiB part. Nothing needs them to outlive the call.

BF16WS_EXACT_REDUCE_SHAPES is a gfx942 whitelist of N values, all powers
of two, gated only on "uses a bf16 workspace". That was equivalent to "is
a gfx942 kid" only while the gfx1250 kids declared fp32, so flipping the
default subjected them to it and erased the whole _ws family at N=384 /
32320 / 129280. Scoped to the family it was written for.

Co-authored-by: Cursor <[email protected]>

* opus co: fix the 4wave write-after-read and wire the family into tuning

Two structural bugs in the 4wave pipelines, both of which the earlier
1-WG/CU LDS pad only hid:

A step refills the slot it is reading -- slot g%P is consumed by step g
and reloaded at its end for step g+P -- so the handshake carries a
write-after-read as well as the fill it was written for. That needs the
reads retired, not merely issued: a barrier orders waves, not their
in-flight LDS traffic. Drain with s_wait_dscnt(0) before the handshake,
and arrive-and-wait as one s_barrier: split across kBarrierAhead WMMAs, a
wave that is ahead could signal for the next step into this step's count.

A step past the last is not a no-op transfer. Measured on gfx1250, one
whose origin is at or past either extent zero-fills its whole tile in LDS,
and C stages in a slot one of those is aimed at. The tensorcnt drain has
to happen before the staging rather than after the peeled step.

.co artifacts rebuilt for all 204 variants. build_co.py can now append
-DOPUS_CO_NO_1WG_PAD through --device-flag with _expected_lds following
suit, so the pad can be measured off without editing the table.

Tuning: the candidate filter nominates .co kids (top-N tiles by
grid-occupancy fit x top-N cluster dims, no split-K to minimise over), and
kid_rejects_shape answers both .co tags rather than only a16w16_4wave_co.
The wl variant used to fall through to the gfx942 bf16-workspace
whitelist, which rejected all 140 of its kids at any N outside that table
-- invisibly, since a candidate that was never nominated reads the same as
one that lost. At M=256 N=384 that left 6 of 106 candidates, all one tile
and no split-K, which looked like a fixed ~25us floor; with the family
restored the same shape tunes to 7.0us.

dsv4_bf16_tuned_gemm.csv carries the re-tuned winners for the 84 M>=256
DSV4 shapes, opus vs triton measured in one session. opus takes 72 of
them, 45 on 4wave_wl_co.

Co-authored-by: Cursor <[email protected]>

* opus co: add the B_K=256 tiles the wl family was missing

Of the 84 DSV4 shapes, 38 tuned to a JIT _ws kid. Checking each of those
winning tiles against the .co pipeline's own constraints says why: 25 of
them are legal in that pipeline today and simply had no entry, and the
bulk of those want B_K = 256, which the family had none of at any tile.
Only 10 are actually blocked by a static_assert, and 0 by the B_K>128
one -- every winning deep-K tile already has kNSub == 1.

So this is 15 entries and no code: 64x64x256 in the w1x4 and w2x2
layouts, 32x64x256 in w1x4 (w2x2 would need kExpM == 1), five clusters
each. They build clean -- no spills, LDS 198 KB and 161 KB against the
320 KB budget, wmma_dst_hi non-zero so the VGPR pin still takes -- and
all 15 verify numerically.

Re-tuning the 12 shapes those tiles had been losing moves 8 of them to
wl_co, 1.156x geomean and up to 1.331x, and takes the group from 7/12 to
12/12 against triton. Over all 84 that is 77 wins at 1.331x geomean.

The four it does not take are the informative ones: all four run at
splitK 2-5, and no .co family supports split-K, while the eight it takes
are at splitK 0 or 1. A .co entry can only win a shape that does not want
split-K, which is also how to price the remaining static_assert before
restructuring anything for it -- the tiles it guards are the smallest in
the set, and small tiles are what lean hardest on split-K.

Docs follow: the README covered only the compute family and predates the
wl one entirely, so it gains both families, the wave_layout field, the
--device-flag passthrough, and that split-K boundary. KNOWN_ISSUES records
the tuner-side defect that silently withheld the whole wl family from
nomination, and the measurement above in place of the guess that fixing
the two asserts was where the performance was.

Co-authored-by: Cursor <[email protected]>

* opus co: re-tune the shapes the new tiles reached, and price issue 3

Adding the B_K=256 entries only helped the 12 shapes that were re-tuned
against them. Ten more could reach the same tiles and had not been, which
is its own trap: a new candidate does nothing for a shape nobody re-tunes,
and the tuned CSV gives no sign that it is out of date. All ten improve --
1.083x geomean, up to 1.322x on 8192x64x4096, which had been running a
64x64 tile at half occupancy -- and the group goes 8/10 to 10/10 against
triton. Over all 84 that is 79 wins at 1.344x geomean, wl_co now taking 58.

The remaining gap is 8 shapes that no legal .co tile fills without split-K
but B_M=16 would, and B_M=16 is what issue 3's static_assert refuses. The
occupancy case for lifting it is real; the scheduling budget is what kills
it. A K step only has (B_K/64) * kNumNSub * kExpM * kExpNPerSub *
kExpKHalf WMMAs to hide the ds_reads, the handshake and the TDM issue in,
and every .co kernel winning a shape today has at least 16 of them.

That floor is now measured rather than guessed. 32x64x128 is legal today
and has the same grid as 32x64x256, so it differs only in K depth and
budget -- 8 against 16. Added as a probe and tuned head-to-head on the
five shapes 32x64x256 owns, it won none of them, inside noise at
0.975-1.017x. B_M=16 lands at 8 or 4, and widening B_N to buy budget
halves the grid and gives the occupancy straight back. The probe entries
are removed again; KNOWN_ISSUES records the numbers so the restructure is
not attempted on the occupancy argument alone.

Co-authored-by: Cursor <[email protected]>

* opus co: reorganise the .co docs and bring the branch back under black/ruff

The style checks were the urgent part. At the merge-base with main these
files are black-clean and carry 3 ruff findings; on this branch black
wanted 5 of them reformatted and ruff was up to 11. CI runs
psf/black@stable over the whole tree and pins ruff 0.16.0, so the branch
was red on both. Reformatted the nine Python files the branch touches and
cleared their ruff findings: subprocess.run in build_co.py now says
check=False explicitly -- it reads returncode itself so that CalledProcess
Error does not swallow hipcc's diagnostics -- and the file gets the exec
bit its shebang implies. The five findings left repo-wide are all in files
this branch never touched. black is clean across all 1063 files.

KNOWN_ISSUES was still shaped like a list of four live defects when two
are fixed and the other two have been measured and declined. Open
constraints now lead, each carrying its verdict; the resolved pair moves
below and issue 1 loses the forensic narrative it no longer needs, keeping
the reproducer, the occupancy control group and the damage geometry that
identified the write-after-read. The dead ends and the detection
techniques stay where they were -- they are the reusable part. Numbering
is unchanged so existing references still resolve.

README gains the two numbers that decide whether a tile is worth adding at
all: the grid it produces, which with no split-K is the only parallelism
available, and its WMMA budget, which is what the pipeline has to hide the
ds_reads, the handshake and the TDM issue in. Everything that wins a shape
today has at least 16 of the latter, and a tile with 8 won none of the
five it was aimed at -- so the additions worth making raise B_K, which
buys budget without costing grid.

Co-authored-by: Cursor <[email protected]>

* remove triton dsv4pro duplicate config

Signed-off-by: binglue.lyu <[email protected]>

* opus splitk: scope the bf16 partial to the gfx1250 _ws families

The bf16 split-K partial was applied by flipping the default on
OpusGemmInstance, which is every kid on every arch, not just the two
gfx1250 families it was measured on. gfx942's codegen reads
splitk_workspace_dtype to pick its own workspace type, so the flip
retargeted that arch's split-K families as well, and
em3en4_lds1_pgr2_sk static_asserts an fp32 workspace:

  static assertion failed due to requirement 'std::is_same_v<__bf16, float>'
  EM3EN4 LDS1/PGR2 splitK main kernel writes fp32 workspace

Invisible locally because everything here is built for gfx1250; the wheel
job builds gfx942;gfx950 and nothing else, so this only ever appeared in
CI. Default goes back to fp32 and the two _ws tags opt in by name after
the table is assembled, which also leaves the three gfx942 variants that
were already bf16 (kbuf1_sk, kbuf2v_bk128_sk, quad_mfma32_kbuf1_sk)
exactly as they were.

Verified by building module_deepgemm_opus with GPU_ARCHS="gfx942;gfx950"
-- the CI configuration -- which now compiles clean, and by re-checking
gfx1250: kid 20417 still declares a bf16 partial and the golden sweep is
6/6.

Co-authored-by: Cursor <[email protected]>

* opus: condense the comments added to the gfx1250 headers

The comments introduced with the WAR fix and the per-kid partial dtype ran
five and six lines, in files whose own comments are one to three and stay
inside 89 columns. Same points in 23 lines instead of 54, nothing over 86
columns. Comments only; the golden sweep is 6/6.

Co-authored-by: Cursor <[email protected]>

* opus: expose the gfx1250 matrix_a_reuse/matrix_b_reuse WMMA hints

wmma::operator() and the swap_ab adaptor take reuse_a/reuse_b as template
parameters and forward them to the builtins' last two arguments, which
until now were hardcoded false. Both default to false, so every existing
call site emits exactly the instruction it did before.

The hint asserts that this WMMA's operand repeats the previous one's and
may be read from the source cache rather than VGPR RAM; it is undefined if
the operand does not in fact repeat, so a caller has to be able to prove
it. matrix_a_reuse is a no-op on MI450, which is why the swap_ab adaptor
forwards them crossed -- under that adaptor `a` lands in SRC1, so reuse_a
is the one that reaches the bit that works.

No caller passes true yet.

Co-authored-by: Cursor <[email protected]>

* config: add the tuned 512x129280x7168 gfx1250 row

N=129280 had only been tuned at K=4096, so this shape had no row at all.
opus takes it at 555.84 us against triton's 1803.94 us (3.25x), both from
the same tuning session; the winner is 4wave_wl_co 128x128x256x128 w2x2
c4x4 at splitK=0, err_ratio 0.0.

Only the new row is added. 512x32320x7168 was re-tuned alongside it and is
left alone -- it already carries a faster measurement of the same kid --
and every other row is byte-identical.

Co-authored-by: Cursor <[email protected]>

* config: move the tuned 512x129280x7168 row to dsv3

512x129280x7168 is a dsv3 shape, not a dsv4 one -- it was added to the
dsv4 table in error. dsv3 already carried a placeholder row for it
(triton, us=0, kernelName=auto), so this replaces that with the measured
result rather than adding a row: opus at 555.84 us, 4wave_wl_co
128x128x256x128 w2x2 c4x4, splitK=0, err_ratio 0.0. Triton measured
1803.94 us on the same shape in the same session.

dsv4 goes back byte-for-byte to what it was before that row landed.

Co-authored-by: Cursor <[email protected]>

---------

Signed-off-by: binglue.lyu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: binglue.lyu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants