Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
1be6485 to
b9bd7da
Compare
…ackend Add OPUS MXFP4 x MXFP4 NT GEMM kernels for gfx950 aiter.gemm_a4w4(bpreshuffle=True) inputs (A row-major fp4x2, B shuffle_weight(16, 16), 1x32 UE8M0 e8m0_shuffle scales, bf16 C): - 2x2 4-wave pipeline, 18 pre-compiled .co (tiles 128/192/256 x 128/192/256; persistent, one tile per block, split-K, no-boundary), registered in gen_co/co_kernels.json under gfx950 and rebuilt byte-identically by build_co.py --arch gfx950; - 1x4 small-tile pipeline (M <= 512), JIT-built with stock ROCm, in-block K split for very small M. Family a4w4 / gfx950 with local kids 0-5, 10-15, 21-25, 30 (.co) and 410-416 (small), launched through opus_gemm / opus_bmm (family="a4w4", layout="bpreshuffle"); Python plans split-K and allocates Torch workspaces. aiter.gemm_a4w4 dispatches tuned rows whose kernelName is the OPUS instance name (kernelId = local kid), as the a8w8 / bf16 OPUS rows do. The a4w4 tuner gets an opus backend. a4w4_blockscale_tuned_gemm.csv: 692 of 1464 gfx950 rows switch to OPUS kernels where they beat the best asm / CK kernel in the same tuning run (MI355X); all other rows unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b9bd7da to
c745d9c
Compare
…igned get_GEMM_config reuses a row tuned at a padded M for every M that pads up to it, so a row tuned with the no-bounds-check 256x256x256_nob kernel (needs M % 256 == 0 and N % 256 == 0) is also returned for e.g. M=1664 via the M=2048 row. _gemm_a4w4_opus launched it anyway and _a4w4_plan raised ValueError, failing op_tests/test_gemm_a4w4.py (M=1664, N=8192, K=28672). Switch to the same tile without _nob in that case (None -> CK/asm fallback if no twin is registered). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w4_bpreshuffle/ Gives the bpreshuffle family its own directory (and build_info.json) under gen_co/gfx950/ instead of sharing the arch root. Files are moved unchanged; build_co.py's default gfx950 output, the runtime loader and co_image_path follow the new location. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The JSON list key now matches the image directory (A4W4_CO_KEY, relative to gen_co/), so co_image_path and build_co.py's default output derive from it. The manifest test checks the arch part of "<arch>/<family>" keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the gfx950 a4w4 bpreshuffle entries out of the shared co_kernels.json (back to its main content) into gen_co/co_kernels_gfx950_a4w4_bpreshuffle.json; images stay in gen_co/gfx950/a4w4_bpreshuffle/ (A4W4_CO_DIR). Drops the previous key rename and its manifest-test change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
opus_co_launch_mxfp4_gfx950.cuh becomes the family-agnostic opus_co_launch_gfx950.cuh: the launcher passes its image directory under gen_co/ (co_kernel(symbol, co_dir), cache keyed by co_dir/symbol) and calls opus_co_launch_gfx950. Read / ELF check / launch logic unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New a8w8_mxfp8 opus_gemm family: MXFP8 x MXFP8 with 1x32 UE8M0 scales (row-major x_scale [M, K/32] / w_scale [N, K/32], not shuffled), B in shuffle_weight(16, 16), bf16 output, in all four operand layouts (NT = gemm_a8w8_mxfp8_bpreshuffle's inputs; NN: B stored [K, N]; TT: A stored [K, M]; TN: both). - 2x2-wave pipeline (pre-compiled .co, pin toolchain): tiles 256/192/128 x 256/192/128, one tile per block / persistent / split-K, M/N boundary handling; transposed operands go through LDS k-major and ds_read_tr8. Kids 0-16 (co_kernels_gfx950_a8w8_mxfp8_bpreshuffle.json), one image per layout in gen_co/gfx950/a8w8_mxfp8_bpreshuffle/. - Split-K: fp32 partials summed by splitk_reduce_kernel. - opus layer: _launch_a8w8_mxfp8_gemm picks the layout from the XQ / WQ strides (as the a16w16 4-wave family); A stored [K, M] needs M % 16 and B stored [K, N] needs N % 32. - gemm_a8w8_mxfp8_bpreshuffle runs libtype "opus" rows of the tuned CSV (NT), falling back to FlyDSL when the tile does not fit; the tuner adds the OPUS kids as candidates. No tuned-CSV changes. Shares the gfx950 pre-compiled .co infrastructure with the MXFP4 NT PR (ROCm#7979): its code is included here, its kid table, .co images and tuned CSV are not (they come with ROCm#7979). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y lookup
- test_gemm_a4w4: tuned_shapes()/baseline use _A4W4_PRESHUFFLE_PREFIXES so the
OPUS rows run in CI; opus_a4w4_kid_sweep() launches every registered kid
(off-grid M, forced split_k=2 on split-K and small-tile kids); add padded-M
shapes that reach OPUS rows; assert only the tuned kernel (the default ASM
baseline is wrong on some large-M shapes, e.g. M=6528 N=7040 K=5632).
- gemm_a4w4_blockscale_tune: opus_candidates returns {} for a CU count with no
OPUS a4w4 table instead of aborting the default-backend tune.
- get_GEMM_config: document why OPUS rows also serve a padded M.
- a4w4 traits: the split-K counter block is zeroed by the launcher every launch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…impler dispatch
The a4w4 family now has two layouts; this PR is layout="bpreshuffle" and every
name it adds carries it, so it can coexist with layout="plain" kids.
- Naming: tags a4w4_mxfp4_nt_bpreshuffle_co / a4w4_mxfp4_nt_bpreshuffle_small,
headers opus_gemm_{pipeline,traits}_a4w4_mxfp4_nt_bpreshuffle[_small]_gfx950.cuh,
kargs / traits / kernel functions / OPUS_MXFP4_BPRESHUFFLE_* and the
opus_gemm_common.py constants, .co symbols
opus_gemm_gfx950_a4w4_mxfp4_nt_bpreshuffle_co_*, tuned CSV kernelNames.
Kids are unchanged (0-30, 410-416).
- C++ entry opus_gemm_a4w4_bpreshuffle_launch (own e8m0_shuffle scale checks);
opus_check_a8_family_tensors takes the A/B dtype.
- .co pipeline: 64-bit tile base offsets (batch strides long long, row / column
offsets widened, host kargs too), buffer ranges bounded to one tile; a Y of
> 2^31 elements no longer overflows (reachable through the padded-M lookup,
e.g. M >= 262145, N = 6144, K = 16384 on the M = 8192 row). 18 .co rebuilt,
kernarg 136 B.
- aiter/ops/opus/gemm_op_a4w4.py follows the a8w8 structure:
_launch_a4w4_bpreshuffle_gemm / _bmm picked by dispatch, shape checks left to
the C++ entry, split-K pick folded into _a4w4_bpreshuffle_plan.
- gemm_a4w4: OPUS rows match the "opus_" prefix; _gemm_a4w4_opus maps the
name to its kid (nob -> bounded twin when M/N are not tile-aligned) and lets
the C++ entry check shapes; kernelId is no longer threaded through.
- test_gemm_a4w4: > 2^31-element Y through kids 0, 10, 30.
All 692 OPUS rows pass, every kid passes the sweep (incl. split_k=2), and the
large-offset case passes; .co kids are within 0.3% of the previous build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ines Big pipeline: own namespace (opus_mxfp4_bpreshuffle), constexpr cache policies, ROW_PAIR / A_SPLIT_PAIR / B_SPLIT_PAIR, async_load_rows / async_load_blocks, opus layouts for the e8m0_shuffle scale panels (make_layout_gsf / ssf / rsf), one generic sched_quadrant (the hand-tuned 256x256 schedules are dropped), mma_quadrant as a function, the odd K tile step with a compile-time stage, and no split_k < 0 separate-reduce mode (aiter launches S > 0 only). Small pipeline: g_a / g_b / g_sfa / g_sfb up front with out-of-range K tiles by offset, wave-dim layouts, one LDS array with restrict read views, tiled MMA + mma_step / sched_step, KS partials in the ring, nt C stores with an OOB offset; B and the raw scale dwords stay in the register ring. kargs gain stride_b. All 18 .co rebuilt; every .co / small / split-K kid gives bitwise the same C as before (153 cases). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts with ROCm#6696 (gfx950 blockscale MXFP8 .co) and ROCm#6067 (ASM f4gemm _ps): - opus_co_launch_gfx950.cuh: main's loader with an optional co_dir for co_kernel() and an optional kernarg size for opus_co_launch_gfx950 (the defaults keep the a8w8 blockscale bpreshuffle images); the a4w4 bpreshuffle launcher passes "<name>.co", gfx950/a4w4_bpreshuffle and 136. - build_co.py: main's builder plus --family a4w4_bpreshuffle (build_one_a4w4_bpreshuffle, device-only clang++ on the pin toolchain); it rebuilds the 18 committed .co byte-identically. - opus_gemm_common.py / gen_instances*.py: both families registered. - a4w4_blockscale_tuned_gemm.csv: for each shape both sides retuned, the row with the lower us (121 OPUS, 267 main ASM). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thout family Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Add an OPUS backend for MXFP4 x MXFP4 NT GEMM with B preshuffle on gfx950. gemm_a4w4(bpreshuffle=True) interface to select tuned OPUS kernels.
Details
Speedup Distribution
Across all 1464 gfx950/CU256 shapes, the tuned table selects OPUS for 692 shapes: