Repository navigation
Conversation
New pipeline opus_gemm_pipeline_a16w16_4wave_gfx950.cuh (gemm_a16w16_4wave_kernel)
with traits/kargs opus_gemm_a16w16_4wave_traits_gfx950 / _kargs_gfx950:
- all four storage layouts via A_T / B_T (K-contiguous operands: swizzled b128
copies + ds_read_b128; M/N-contiguous operands: 32-byte window swizzle +
ds_read_b64_tr_b16)
- tiles B_M x B_N in {64,128,256}^2, B_K = 64, 4 waves (2x2), MFMA 16x16x32 bf16,
A/B operands and C pinned to fixed AGPR/VGPR ranges (needs the pinning toolchain)
- arbitrary M/N (OOB reads return 0, masked C stores), padded leading dims (x8)
- bf16 or fp32 output, optional per-N bias
- split-K: fp32 workspace [split][batch][padded_M][padded_N] for
splitk_reduce_gfx950.cuh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the fp32 output option (D_C is bf16); split-K keeps its fp32 workspace for splitk_reduce_kernel, which writes bf16 C. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New traits options PIN / WG_PER_CU. Tiles larger than 128x128 keep the pinned AGPR/VGPR layout (they need every register); smaller tiles leave registers to the allocator (~100-200 registers) and hint 2 workgroups per CU. Without pins the small tiles run as fast as pinned ones when built with a current LLVM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The offline .co entry points (extern "C") need a device-callable body; the templated __global__ now forwards to gemm_a16w16_4wave_body. Device ISA of all 96 (tile, layout, variant) instances is byte-identical (labels normalized). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….co offline
gen_co/co_kernels_gfx950.json declares 8 tiles x {a16w16_4wave (direct),
a16w16_4wave_ws (fp32 split-K workspace + reduce)}. Each kid launches one of
several pre-built images <symbol>_<nt|nn|tt|tn>[_bias] chosen from the tensor
strides at runtime. build_co.py --arch gfx950 builds the 96 images with the
AGPR-pinning LLVM (kernarg 96 B, LDS mirrored from the traits, ELF gfx950);
all 96 have 0 spills. Registry: kids are filtered on image presence like the
gfx1250 CO kids, are bias-aware (direct), bf16-Y only, and join the default
gfx950 compile set (host-only launchers).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-wave kids * include/gfx950/opus_co_launch_gfx950.cuh: per-device loader of the pre-built gen_co/gfx950 images (ELF gfx950 check, 96-byte kargs). * codegen: host-only emitter for a16w16_4wave (direct ABI, bias image) and a16w16_4wave_ws (workspace ABI, fp32 partials + splitk_reduce_kernel). The launcher detects NT/NN/TT/TN from the XQ/WQ strides, validates pitches, alignment and 32-bit offsets, and clamps split_k to (K/64)/2. The direct kernel stores C rows in 16-byte vectors, so it requires N % 8 == 0. * gen_instances: the reduce TU is also emitted for host-only split-K kids. * python: kid-aware layout check (M/N-contiguous operands only for the 4-wave kids), plan support/split-K clamp, tuner shape filter. * op_tests/test_opus_a16w16_4wave.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Buffer range checks are per dword; a bf16 bias of odd length ended mid-dword, so its last element read back as 0 (affects every gfx950 split-K kid with bias and odd N). Round the bias buffer size up to whole dwords. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, document gen_co/gfx950 Keeps test_opus_a16w16_registry's distinct-local-id check covering the new kids; README describes the kid table, layout-by-stride images and rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The C store used 16-byte vectors masked only by their first column, so with N % 8 != 0 the last vector of a row spilled into the next row. Tiles whose last column chunk straddles N now take a compact per-element store loop (decided per tile, so every other tile keeps the vector path and the code size stays close); the bias buffer size is rounded up to whole dwords (range checks are per dword). Drop the N % 8 rejections from the launcher, launch plan and tuner; test odd N. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like most gfx950 a16w16 families (persistent, mono_tile, 4g_safe, cpol), the direct 4-wave kids (1000-1007) no longer take a bias; a bias goes through the split-K kids (1008-1015), whose splitk_reduce_kernel adds it (split_k 1 included). Drops HAS_BIAS / ptr_bias / stride_bias_batch from the traits and kargs (88-byte kernarg), the 32 *_bias images (64 left) and the bias code in the kernel; the default kernels' ISA only changes in the kernarg offsets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
opus_gemm_gfx950_4wave_bf16_* / opus_gemm_gfx950_splitk_4wave_bf16_ws_* (other dtypes of the 4-wave family may follow); images rebuilt under the new names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…16.json Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
opus_gemm_a16w16_{nt,nn,tt,tn}(XQ, WQ, Y, bias=None, *, kid, split_k, workspace):
logical [M,K] x [N,K] (or batch-first 3D) with the direction given by the
strides, as the MXFP8 blockscale direction APIs. Each checks that the tensors
match its direction and (NN/TT/TN) that the kid is a gfx950 4-wave kid, then
launches through the shared a16w16 path; one 4-wave kid serves every direction.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the kid table file carries bf16 (co_kernels_gfx950_bf16.json); kernel and image names are back to opus_gemm_gfx950_4wave_* / *_splitk_4wave_ws_*, with the images of fd2b8d5 restored byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
opus_gemm_common.py: images are (layout, symbol) (no bias variants left), a short JSON loader, no unused group key, BIAS_AWARE_KIDS back to upstream form. opus_gemm_tune.py: reuse the tag set from opus_gemm_common, one-line shape rule. build_co.py / codegen: follow the image tuple; drop has_bias from build_info. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_launch_a16w16_gemm / _bmm (reached from opus_gemm / opus_bmm, so also from
tuned_gemm) now go through _launch_a16w16_route: a gfx950 4-wave kid is sent to
_launch_a16w16_{nt,nn,tt,tn} by its operand strides, other kids keep the plain
path. Replaces the exported opus_gemm_a16w16_{nt,nn,tt,tn} APIs; dispatch.py is
unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gemm_op_a16w16.py is upstream plus the route: _launch_a16w16_gemm / _bmm ->
_launch_a16w16_route -> _launch_a16w16_{nt,nn,tt,tn} for 4-wave kids. Their
stride / pitch / alignment checks live in the generated C++ launcher only (the
Python copies and the shape-driven API change are dropped); other kids keep the
upstream K-contiguous check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kernel launch_plan: reuse the tag set, drop the split-K / 2^31 / 4 GiB checks the generated launcher already does. build_co: drop the LDS mirror, disassembly stats, agpr/pin/asm records and the subset merge; fix stale comments. Loader: drop the ELF and device-arch checks (the kid is gfx950-only and AiterAsmKernelFast validates the image). codegen: one tag list, shorter assert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Name the operand builders by operand and path: make_layout_{g,s,r}{a,b}_k for
[M,K] / [N,K] (shared K-contiguous builders) and make_offsets_{g,r}{a,b}_mn for
[K,M] / [K,N] (offset tables: the 32-byte swizzle varies per k row), with the
layout-to-path table on top. Drop async_load_imm (one m0 + MUBUF immediates):
the K path uses opus async_load, the M/N path one async_load per issue.
MFMA / load counts unchanged, 0 spills; m0 writes per kernel 20 -> 30..80.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The K-contiguous check moves from _execute_a16w16 to _launch_a16w16_route's plain branch (the NT-only kids, whose launchers do not check strides); the four direction branches call _execute_a16w16 unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_launch_a16w16_gemm / _bmm -> _execute_a16w16_by_layout -> _execute_a16w16_{nt,nn,tt,tn}:
NT runs the upstream K-contiguous check (every kid), NN / TT / TN require a kid
that takes M/N-contiguous operands (gfx950 4-wave); all then call the shared
_execute_a16w16 (plan + launch, no layout check). Replaces the route and its
kid-type branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_launch_a16w16_gemm / _bmm pick NT / NN / TT / TN from the operand strides and call the matching execute: NT is the unchanged upstream _execute_a16w16 (every kid); _execute_a16w16_nn / _tt / _tn are its copies that require a gfx950 4-wave kid instead of the K-contiguous check. No shared router. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_launch_a16w16_gemm / _bmm pick _execute_a16w16_{nt,nn,tt,tn} from the operand
strides; each checks its layout (NT: the upstream K-contiguous check, every
kid; NN / TT / TN: a gfx950 4-wave kid) and calls the unchanged
_execute_a16w16 (minus that check). Replaces the three full copies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
make_layout_{g,s,r}{a,b}_mn replace the offset tables, as the MXFP8 TT/TN
pipelines do: a copy issue now spans 64/E k rows (row = (64/E) i + (16/E) w
+ kr), so the 32-byte window swizzle depends on lane and wave only and goes
into the copy layout's window coordinate; the M/N path uses the same
async_load(g, smem, u_g, u_s, offset) as the K path. The TR16 read layout is
linear and the per-(e, h) swizzle is added on top (mn_r_xor). Same LDS image;
NT ISA unchanged, NN/TT/TN instruction counts within -2..+1%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ule) Computing layout offset + swizzle inside the TR16 read lambda left the address math in the scheduled regions and sched_group_barrier stopped interleaving the TR16 reads / LDS-DMA copies with the MFMAs (C01 bunched them: NN/TN 256x256 ~10% slower). Build the per-lane [e][h] bases (linear layout + swizzle) once, like MXFP8's u_ra(mi); the reads only add the K-step / half immediates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_layout_{ga,sa,ra,gb,sb,rb}_{nt,nn,tt,tn}, each written out in full (no
shared builders / forwarders); the kernel picks the direction's six and the
copies / reads no longer branch on the operand path. Main loop identical to
the previous version for all 32 kernels (up to register numbering).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NT's A [M,K] and B [N,K] are symmetric: make_layout_{g,s,r}_nt take the
operand's rows / E and wave roles (A: HALF_B_M / E_M, wave_m, wave_n; B:
HALF_B_N / E_N, wave_n, wave_m). 21 layout builders; ISA byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TN's A [K,M] and B [K,N] are symmetric: make_layout_{g,s,r}_tn take the
operand's E (A: E_M, reads with wave_m; B: E_N, reads with wave_n).
18 layout builders; ISA byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_layout_{g,s,r}_{nt,tn}<T, OPERAND_A / OPERAND_B>: _nt is the
K-contiguous path ([M,K] / [N,K]), _tn the M/N-contiguous one ([K,M] / [K,N]);
the tag picks E_M / E_N and the wave roles from the traits (no HALF_ROWS / E
template numbers, no wave swapping at the call). NN / TT reuse them (table in
the header). Main loop identical for all 32 kernels, 0 spills.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…les pinned
- bf16 operands addressed in elements (VEC_A = 8, B_K = 64, bf16 pointers);
LDS reads through opus load, LDS stage pointers typed.
- Layout builders in the opus reference style: make_layout_{ga,sa,ra,gb,sb,rb};
the TN layouts written from the traits (VEC_TR = 4 for ds_read_b64_tr_b16);
the TN global layout swizzles the lane index directly.
- Operands split per MFMA like the fp4 kernel: v_a[half][kk][repeat], each
operand (8 bf16) pinned on its own; no op8_t joins / slices.
- Every tile pinned (no PIN / WG_PER_CU template parameters, launch-bounds hint
1): registers packed as A a[0, 16 E_M), B a[.., + 16 E_N), then C; the small
tiles keep their occupancy (128x64 / 64x128: 3 waves per SIMD).
- Buffer sizes computed inline after the pointers (computed first they split
the kernel-argument loads into two rounds, ~0.3 us on small K).
64 .co rebuilt, 0 spills. Main loops: no v_accvgpr moves (was 76 over 64
kernels). Harness 200/200 valid; perf vs the previous .co median 1.000
(large tiles 0.995-1.001, small tiles 0.986-1.058).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Python changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hard 0) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…16w16/ Add a dtype level under the arch directory so other gfx950 families can sit next to a16w16. The 64 .co files and build_info.json are moved unchanged; the runtime loader, the Python image check and the build_co.py default output dir now use gfx950/a16w16. Comments no longer spell out the directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts with ROCm#6696 (gfx950 a8w8 blockscale bpreshuffle CO path), which added the same gfx950 CO loader header and gfx950 support in build_co.py: - include/gfx950/opus_co_launch_gfx950.cuh: one loader for both gfx950 CO families, sharing read_co_image / CoModule(path). co_kernel(symbol, image_name) + opus_co_launch_gfx950 serve a8w8_blockscale_bpreshuffle (gfx950/a8w8_blockscale_bpreshuffle/), co_kernel(symbol, device) + launch serve the a16w16 4-wave images (gfx950/a16w16/). launch is a template, so the header no longer includes the a16w16 traits. - gen_co/build_co.py: --arch gfx950 takes --family {a8w8_blockscale_bpreshuffle (default), a16w16}; the a16w16 helpers are renamed (build_one_a16w16_gfx950, _build_a16w16_gfx950, ...) so they no longer shadow upstream's build_one_gfx950 / _GFX950_STUB_TEMPLATE; --kids follows the new nargs form; the default output dir is gen_co/gfx950/<family>. - opus_gemm_common.py / gen_instances_gfx950.py: keep both sides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Align the gfx950 a16w16 4-wave family with the other gfx950 CO families (a4w4, a4w4_bpreshuffle): - include/gfx950/opus_co_launch_gfx950.cuh: same loader as the a4w4 PRs, co_kernel(symbol, image, co_dir) + opus_co_launch_gfx950<KARGS_BYTES>; the a16w16-only co_kernel(symbol, device) / launch overloads are dropped (AiterAsmKernelFast already resolves the kernel on the current device). - The launchers call co_kernel(image, image + ".co", A16W16_CO_DIR) and opus_co_launch_gfx950<88>. - gen_co/co_kernels_gfx950_bf16.json -> co_kernels_gfx950_a16w16.json; A16W16_CO_JSON / A16W16_CO_DIR, a16w16_co_kernels_declared / _list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/tt/tn_gemm # Conflicts: # csrc/opus_gemm/gen_instances.py
main's op_tests/test_opus_co_builder.py calls _default_co_output_dir(arch, offload_arch) with two arguments; give family a default (gfx950 falls back to a8w8_blockscale_bpreshuffle, matching main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the host-row scan from the split-K reduce arch bucketing and the reduce-TU check; use main's version (ROCm#7387) as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Add an OPUS backend for bf16 GEMM on gfx950 that takes all four operand layouts (NT / NN / TT / TN) directly, without a transpose copy. Register 16 pre-built 4-wave kernels (kids 1000-1015) in the existing a16w16 OPUS interface; the layout is detected from the operand strides at runtime.
Details
ds_read_b128; M/N-contiguous operands read withds_read_b64_tr_b16(transposing reads), so NN / TT / TN need no extra transpose.