Skip to content

[OPUS] [JIT] [Build] opus bf16 gemm co integration - #4903

Merged
junhaha666 merged 18 commits into
mainfrom
blyu/opus_co_integration
Aug 26, 2026
Merged

junhaha666 merged 18 commits into
mainfrom
blyu/opus_co_integration

Conversation

@demonsan

@demonsan demonsan commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Test Result

Golden sweep 6/6. Every tuned shape passes the accuracy gate, worst err_ratio
0.0169 against the 0.05 line.

Per-kid dtype selection reaches both ends, verified by the accuracy signature
flipping with the table entry (512x2048x7168, max abs error vs fp64):

partial splitK=1 2 4 8
fp32 0.00040 0.00022 0.00012 0.00009
bf16 0.99998 1.05208 0.96465 0.90603

Candidate-set scoping, previously silent losses:

shape before after
256x384x7168 6 candidates, one tile, no split-K 106
512x32320x7168 74 118

N=384 was the visible symptom -- a flat ~25 us floor that did not scale with M,
because only 12 workgroups were reachable and split-K was unavailable:

M before after triton before after
256 24.2 us 6.6 us 8.2 us 0.34x 1.23x
512 24.7 us 8.5 us 11.7 us 0.47x 1.38x
1024 24.7 us 12.0 us 13.9 us 0.56x 1.16x
2048 26.0 us 15.4 us 16.5 us 0.63x 1.07x

Adding the B_K=256 tiles the .co families had been missing accounts for the
rest. Checking each _ws winner's tile against the .co pipeline's own
constraints, 25 of 38 were already legal there and simply had no entry; 15
entries and two rounds of re-tuning moved 13 shapes over. The second round was
needed because a new candidate does nothing for a shape nobody re-tunes, and the
tuned CSV gives no sign that it is out of date.

Over all 84 shapes opus wins 79, geomean 1.344x, 1.433x on total time, range
4.68x to 0.92x, with 4wave_wl_co taking 58 of them. dsv4_bf16_tuned_gemm.csv
is updated for those 84 rows only -- M < 256, other architectures and every
shape outside this sweep are untouched and verified byte-identical.

GEMM A16W16 tuned kernel time (µs) — opus with the .co 4wave family
nominated and the split-K workspace fixed, against a triton tune from the same
session. M < 256 was not part of this sweep and is unchanged in the tuned CSV.

DSv4 Pro K=7168

N=64, K=7168

M opus (us) Triton (us) chosen
256 5.57 6.10 opus (1.10x)
512 6.31 12.64 opus (2.00x)
1024 7.34 10.59 opus (1.44x)
2048 10.02 13.92 opus (1.39x)
4096 12.00 15.80 opus (1.32x)
8192 14.49 17.70 opus (1.22x)
16384 25.15 27.42 opus (1.09x)

N=384, K=7168

M opus (us) Triton (us) chosen
256 6.64 8.17 opus (1.23x)
512 8.46 11.66 opus (1.38x)
1024 11.95 13.86 opus (1.16x)
2048 15.42 16.45 opus (1.07x)
4096 24.76 34.02 opus (1.37x)
8192 29.18 37.32 opus (1.28x)
16384 43.25 60.40 opus (1.40x)

N=512, K=7168

M opus (us) Triton (us) chosen
256 8.22 8.56 opus (tie)
512 10.09 11.76 opus (1.17x)
1024 12.90 14.12 opus (1.09x)
2048 16.38 19.64 opus (1.20x)
4096 25.44 34.66 opus (1.36x)
8192 31.38 40.38 opus (1.29x)
16384 53.93 69.06 opus (1.28x)

N=1024, K=7168

M opus (us) Triton (us) chosen
256 9.35 11.68 opus (1.25x)
512 12.76 15.61 opus (1.22x)
1024 16.51 21.60 opus (1.31x)
2048 25.68 27.47 opus (1.07x)
4096 30.47 92.03 opus (3.02x)
8192 51.18 103.67 opus (2.03x)
16384 109.00 123.94 opus (1.14x)

N=2048, K=7168

M opus (us) Triton (us) chosen
256 12.81 17.08 opus (1.33x)
512 16.74 20.55 opus (1.23x)
1024 26.49 35.30 opus (1.33x)
2048 31.88 40.23 opus (1.26x)
4096 51.08 238.90 opus (4.68x)
8192 107.80 267.12 opus (2.48x)
16384 243.27 238.43 triton (tie)

N=32320, K=7168

M opus (us) Triton (us) chosen
256 58.90 77.21 opus (1.31x)
512 116.33 288.00 opus (2.48x)
1024 245.52 567.27 opus (2.31x)
2048 485.23 1063.95 opus (2.19x)
4096 938.75 2116.84 opus (2.25x)
8192 1875.08 4221.15 opus (2.25x)
16384 3899.89 4238.80 opus (1.09x)

DSv4 Flash K=4096

N=64, K=4096

M opus (us) Triton (us) chosen
256 5.13 6.45 opus (1.26x)
512 5.76 7.92 opus (1.37x)
1024 6.36 9.17 opus (1.44x)
2048 8.03 7.92 triton (tie)
4096 10.11 9.57 triton (1.06x)
8192 10.59 14.99 opus (1.42x)
16384 15.18 16.50 opus (1.09x)

N=256, K=4096

M opus (us) Triton (us) chosen
256 5.68 5.94 opus (tie)
512 7.05 6.94 triton (tie)
1024 8.26 8.58 opus (tie)
2048 9.38 11.98 opus (1.28x)
4096 10.94 14.22 opus (1.30x)
8192 15.60 21.86 opus (1.40x)
16384 18.84 30.48 opus (1.62x)

N=512, K=4096

M opus (us) Triton (us) chosen
256 6.77 8.05 opus (1.19x)
512 8.10 8.26 opus (tie)
1024 9.43 10.70 opus (1.13x)
2048 10.48 12.76 opus (1.22x)
4096 15.13 20.67 opus (1.37x)
8192 18.18 25.72 opus (1.41x)
16384 32.98 43.83 opus (1.33x)

N=1024, K=4096

M opus (us) Triton (us) chosen
256 7.88 7.26 triton (1.09x)
512 9.57 10.21 opus (1.07x)
1024 10.56 13.01 opus (1.23x)
2048 16.29 18.73 opus (1.15x)
4096 18.44 24.72 opus (1.34x)
8192 29.97 45.24 opus (1.51x)
16384 62.51 85.87 opus (1.37x)

N=2048, K=4096

M opus (us) Triton (us) chosen
256 9.26 9.34 opus (tie)
512 10.61 12.31 opus (1.16x)
1024 15.82 18.27 opus (1.16x)
2048 18.64 24.43 opus (1.31x)
4096 30.83 42.04 opus (1.36x)
8192 62.41 85.64 opus (1.37x)
16384 132.82 180.33 opus (1.36x)

N=129280, K=4096

M opus (us) Triton (us) chosen
256 151.79 226.02 opus (1.49x)
512 292.13 420.82 opus (1.44x)
1024 575.83 798.37 opus (1.39x)
2048 1127.10 1491.52 opus (1.32x)
4096 2188.40 2908.01 opus (1.33x)
8192 4289.75 5735.09 opus (1.34x)
16384 8730.50 11598.55 opus (1.33x)

Submission Checklist

demonsan and others added 7 commits August 19, 2026 06:50
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]>
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]>
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]>
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]>
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]>
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]>
@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 4903 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

binglue.lyu and others added 3 commits August 21, 2026 07:48
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]>
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]>
…k/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]>
@demonsan
demonsan requested a review from valarLip August 21, 2026 11:08
@demonsan
demonsan marked this pull request as ready for review August 21, 2026 11:09
@demonsan
demonsan requested a review from a team August 21, 2026 11:09
@github-actions github-actions Bot changed the title Blyu/opus co integration [OPUS] [JIT] [Build] Blyu/opus co integration Aug 21, 2026
@demonsan demonsan changed the title [OPUS] [JIT] [Build] Blyu/opus co integration [OPUS]opus bf16 gemm co integration Aug 21, 2026
@github-actions github-actions Bot changed the title [OPUS]opus bf16 gemm co integration [OPUS] [JIT] [Build] opus bf16 gemm co integration Aug 21, 2026
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]>
@demonsan demonsan changed the title [OPUS] [JIT] [Build] opus bf16 gemm co integration [OPUS] opus bf16 gemm co integration Aug 24, 2026
binglue.lyu and others added 3 commits August 24, 2026 03:41
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]>
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]>
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]>
@github-actions github-actions Bot changed the title [OPUS] opus bf16 gemm co integration [OPUS] [JIT] [Build] opus bf16 gemm co integration Aug 24, 2026
demonsan and others added 2 commits August 24, 2026 18:33
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]>
@junhaha666
junhaha666 merged commit 9225812 into main Aug 26, 2026
63 checks passed
@junhaha666
junhaha666 deleted the blyu/opus_co_integration branch August 26, 2026 09:42
Fyzyukk added a commit to Fyzyukk/aiter that referenced this pull request Aug 27, 2026
- port 219 prebuilt gfx1250 BF16 A16W16 CO kernels
- register CO kernels in the canonical exact-kid registry
- emit host launchers and load packaged CO images at runtime
- preserve caller-owned workspace and the current launch-plan architecture
- add CO manifest, builder, packaging support, tuning routes, and tests
- avoid restoring the legacy shape dispatcher and C++ workspace allocation
Fyzyukk added a commit to Fyzyukk/aiter that referenced this pull request Aug 27, 2026
Match PR ROCm#4903 by removing the complete duplicate dsv4pro table instead of retaining its unmatched Triton rows.
Fyzyukk added a commit to Fyzyukk/aiter that referenced this pull request Aug 27, 2026
Restore the remaining dsv3 and dsv4 tuning updates from PR ROCm#4903 so the shipped gfx1250 routes match the original CO integration results.
yifehuan pushed a commit that referenced this pull request Sep 17, 2026
…4961)

* [OPUS] Reapply Task1 and Task2 on upstream/main

Reapply the final Task1 Torch-owned split-K workspace and Task2 caller-resolved exact-kid interface state on top of upstream/main@a43694f1.\n\nThis is a squashed final-state review commit; obsolete intermediate Task1/Task2 implementations are intentionally not replayed. The resulting task files match the validated merge candidate.

* [OPUS] Consolidate task documentation

* [OPUS] Document Task1 and Task2 validation workflow

* [OPUS] Preserve upstream MXScale tuned config

* [OPUS] Guard C ABI priming on tensor device

* [OPUS] Drop Task1 and Task2 validation docs

* [OPUS] Optimize Task2 Python dispatch hot paths

* [OPUS] Adapt upstream gfx1250 split-K fixes (#4246)

Reapply upstream commit 1b741c0 on top of the unified public API, canonical exact-kid registry, and caller-owned Torch workspace design.

Adopt the policy-tag N-D TDM API, clusterlaunch grid round-up, compile-time gfx1250 reducer dispatch, mixed-arch device guards, tuned configs, and the final decision to leave the fused family unregistered.

* [OPUS] Document gfx942 and gfx1250 validation plan

* [OPUS] Optimize A16 C ABI launch path

Reuse thread-local tensor descriptors and avoid redundant error calls so MI308 workspace performance stays within repeat noise. Record the full correctness and ABBA validation results.

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

* [OPUS] Isolate A16W16 caller policy

Move the architecture heuristics and tuned-candidate validation into a dedicated policy module while keeping exact execution in the family launcher. Preserve the upstream skinny-to-Torch fallback when no valid tuned row exists.

* [OPUS] Split public GEMM and BMM adapters

* [OPUS] Consolidate launch policy and repair tune routes

* Minimize OPUS integration changes

* Remove generated HTML reports

* Reconcile OPUS branch with latest upstream

* Trim redundant OPUS tests and benchmarks

* Focus OPUS tests on representative regressions

* Drop redundant OPUS interface tests

* Optimize A16 eager dispatch and remove legacy workspace registry

* Add OPUS validation coverage and update documentation

* Add MI308X gfx942 OPUS validation guide

* Remove MI308X OPUS validation guide

* Remove branch-only OPUS test files

* Fix OPUS lint failures

* Fix gfx950 MXFP8 split-K Cvoid compilation

* Format MXFP8 split-K regression test

* Fix no-argument OPUS A16W16 test entry

* Fix OPUS compatibility and tuning paths

* [OPUS] Integrate PR #4903 gfx1250 CO kernels with exact-kid dispatch

- port 219 prebuilt gfx1250 BF16 A16W16 CO kernels
- register CO kernels in the canonical exact-kid registry
- emit host launchers and load packaged CO images at runtime
- preserve caller-owned workspace and the current launch-plan architecture
- add CO manifest, builder, packaging support, tuning routes, and tests
- avoid restoring the legacy shape dispatcher and C++ workspace allocation

* [OPUS] Remove obsolete dsv4pro BF16 tuning config

Match PR #4903 by removing the complete duplicate dsv4pro table instead of retaining its unmatched Triton rows.

* [OPUS] Align BF16 tuning tables with PR #4903

Restore the remaining dsv3 and dsv4 tuning updates from PR #4903 so the shipped gfx1250 routes match the original CO integration results.

* [OPUS] Address PR 4961 must-fix review

Separate public exact-kid dispatch from GEMM and MoE family implementations, and restore the established general A8W8 API boundary.

Tighten fixed-contract attribute access while retaining the develop adapter required by the aiter_tensor_t ABI and HIP stream propagation. Add gfx1250 CO exact-kid numerical and loader-path coverage.

* [OPUS] Keep family modules in the flat package

Move the A16, A8, and MoE family implementations back beside dispatch.py and restore all callers to the original module paths. This avoids changing CK tuner and MoE imports solely for package nesting.

* [OPUS] Address PR 4961 should-fix review

Reuse shared architecture constants in launch planning and policy. Add deterministic source and artifact fingerprints for packaged gfx1250 CO kernels, with CPU verification in the integration suite and OPUS test entry point.

* [OPUS] Fix Python style checks

* Fix MXFP8 BMM policy review issues

* Address OPUS A16W16 review feedback

* Refresh OPUS CO source provenance

The opus.hpp update restores comment formatting only. Refresh the source fingerprint while keeping the verified artifact digest unchanged.

* Simplify OPUS tuned GEMM integration

* Remove OPUS A16W16 C ABI launch path

* [FlyDSL] Remove stale TopK availability checks (#5210)

FlyDSL is required after #5116, so the removed helper breaks test collection and silently disables decode dispatch.

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

* Drop unrelated setup.py comment change

* Revert "Drop unrelated setup.py comment change"

* Drop comment-only packaging diffs

* Remove SHA markers from OPUS policy parity test

* Fix gfx942 split-K launch validation for short K

* Size gfx942 workspace from converged split-K

* Add OPUS A8W8 tuning and exact BMM replay

* Gate OPUS A8W8 tuner to gfx950

* Keep OPUS CO build tooling and artifacts aligned with upstream

Restore gen_co files to the merged upstream version and remove the added
provenance check, CI invocation, and dedicated test. Keep the exact-kid
CO integration and its existing registry, loader, and contract coverage.

Validation: 7 CPU integration tests passed; all 219 CO records match the
current registry. GPU tests were not run for this tooling cleanup.

* Restore upstream OPUS JIT configuration

Reuse upstream cluster-launch handling and CO path define spelling.
The extra JSON escaping produced the same evaluated compiler flag.

Validation: 30 architecture/version gate comparisons and 7 CPU CO
integration tests passed; Ruff and Black passed. No GPU tests were run.

* [OPUS] Fix launch validation and compatibility follow-ups

- converge A16 split-K before workspace sizing across architectures\n- validate MXFP8 saved rows and prefetch constraints before launch\n- restore gfx942 compatibility redirects while keeping exact APIs strict\n- distinguish direct/workspace compiled-table availability\n- align gfx1250 cluster candidate and default-build coverage

* [OPUS] Consolidate redundant regression coverage

Keep exhaustive heuristic, shipped-config, artifact identity, and hardware launch coverage while collapsing duplicate planner, route, compatibility, and tuner cases into their maintained owners.

Validated with Black, Ruff, Python syntax checks, git diff --check, and 98 focused CPU/meta tests plus 22 subtests. GPU tests were not run locally.

* [OPUS] Simplify A16W16 merge resolution

Keep exact-kid launch validation isolated from main's production benchmark path and remove duplicate shape-driven wrappers.

* [OPUS] Remove A16 tuned sweep from test entry

* [CI] Retrigger failed workflows

* [OPUS] Simplify and activate test coverage

* [OPUS] Preserve A16 benchmark data initialization

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: vorapolsiloai <[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.

2 participants