Repository navigation
[HIP] [OPUS] [JIT] Add Blockscale_mxfp8 OPUS GEMM - #6696
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Use matching descriptive names for CO files, ELF entries, launchers, and tuned rows. Share identical configurations while preserving all dispatch IDs and launch constraints. Rebuild the COs and verify unchanged machine code and resource metadata.
Tune available legal OPUS candidates in one mp_tuner pass alongside FlyDSL. Require prebuilt COs, reuse JIT preparation, and remove staged search and duplicate task construction. Simplify gfx950 instance generation and registration, and share CO metadata parsing while preserving kernel IDs and generated launch code.
Consolidate bpreshuffle candidate filtering and CO/JIT generation, and remove unused registration wrappers and empty candidate expansion. Preserve all 56 local-kid configurations and CO identities. Reuse the public OPUS launcher with the existing packed scale bytes, restore upstream comments and CSV handling, and fix Black formatting and Ruff import order. Validation: CPU candidate-selection parity, complete registry/CO metadata equivalence, generated-source equivalence, repository Black and Ruff, and diff checks. No native build or GPU execution.
Express layouts with named shape and dimension tuples followed by unfolded strides and partition coordinates. Group matrix A, matrix B, scale A, scale B and output layouts consistently across the three pipelines. Preserve offset order, XOR swizzles and kernel schedules, including the direct B VGPR path. Validation: static structure checks, CPU layout/address equivalence and diff checks; no native compilation or GPU execution.
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 |
db342eb to
1089467
Compare
1089467 to
fedcaeb
Compare
Enforce shape-specific CO launch contracts and route FP16 outputs through a supported fallback. Restore production validation in the MXFP8 tuner and add integration coverage. Restore the original FlyDSL records for five configurations after paired rechecks.
Compile the gfx950 regression kernels with the same AITER package and resolved JIT directory as the pytest parent. Prevent installed-wheel tests from loading a different subset binary and reporting unknown kernel IDs.
Include the gfx950 bpreshuffle family in mandatory non-A16W16 compilation. Fresh JIT code generation now covers the default MXFP8 tuned table without tuner sidecars or extra kernel keys. Add a CPU regression check using the production blob generation command and validate each tuned kernel against its generated dispatch table.
Remove unselected geometry and schedule groups from generation parameters while preserving surviving kernel IDs. Restore the two affected tuned rows to the original FlyDSL nb5 baseline and remove the two OPUS Python tests requested for this PR.
Keep the full tuning table while limiting this branch's tuning changes to M > 1024. Retain the 15 records added on main so the small-shape integration can preserve them.
Remove the 15 gfx1250 records copied from main. Restore the A8W8 CPU interface regression test unchanged from main. Validation: all 8 interface tests pass. The CSV merges cleanly with main and preserves its gfx1250 records.
Pass the merged mxscale bpreshuffle tuning table to module_deepgemm_opus codegen. Select gfx950 bpreshuffle kernels from tuned rows, saved compiled keys and explicit requests, without the mandatory sweep or unconditional kid 0 floor. Keep --tune for full sweep builds. Report missing literal tuned files while allowing optional model globs. Validation: clean gfx942;gfx950 module prebuild with ROCm 7.2.4 and 64 workers succeeded in 51.5s. The gfx950 MXFP8 selection contains 55 JIT kernels and 33 CO entries. Selection, saved-key/request expansion, missing CSV, 5 A16W16 registry tests, Ruff and Black checks passed.
Conflict in aiter/ops/flydsl/mxfp8_bpreshuffle_gemm_gfx1250.py with #7659 (32x32 w_scale + bmm): both sides added independent parameters to _run_mxfp8_bpreshuffle_gemm_a8_gfx1250 and to the 2-D launch specialization. Kept both: main's w_scale_32x32 / batch in place with this branch's a_scale_preload after them, main's stride_ascale_k = batch * k_blocks for mxfp8_32 (which never reads a row-major A scale, a_scale_m_major = False), and w_scale_32x32 followed by a_scale_m_major in the specialization key. #6696 (OPUS mxfp8 bpreshuffle) needs no change here: its rows are gfx950 only, they run from _gemm_mxscale_bpreshuffle, which gets column-major x_scale bytes (a row-major one is transposed first), and on gfx1250 the mxfp8_128 config ignores any non-triton/flydsl row, so the row-major query and the dispatch keep resolving the same FlyDSL kernel. Co-authored-by: Cursor <[email protected]>
…ily a4w4) OPUS gfx950 MXFP4 x MXFP4 NT GEMM with plain row-major A / B / 1x32 e8m0 scales (layout="plain", the layout of Triton gemm_afp4wfp4): - 2x2 4-wave pipeline, pre-compiled .co (gen_co/gfx950/a4w4, kids 100-130), 64-bit tile addressing; - 1x4 small-tile JIT pipeline (kids 500-504): LDS-DMA ring for A / B and a K-deep scale panel per ring cycle, in-block K split, split-K through splitk_reduce; - policy.a4w4_heuristic_kid; gemm_afp4wfp4_opus drop-in; - op_tests/test_gemm_a4w4.py plain kid / large-offset / Triton sweep tests. Rebased on main (ROCm#6696): opus_co_launch_gfx950.cuh co_kernel() takes an optional co_dir and opus_co_launch_gfx950 an optional kernarg size (defaults keep the a8w8 blockscale bpreshuffle images); build_co.py --arch gfx950 --family a4w4 builds these images next to the a8w8 family. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
… MoE training
FP8 e4m3 grouped GEMMs with E8M0 block scales and no shuffling of operands or scales, on the
MXFP8 1x128 4-wave pipeline (1x32 scale MFMA 16x16x128), with the DeepGEMM interfaces of the
bf16 grouped GEMMs:
m_grouped_fp8_blockscale_gemm_{nt,nn}_contiguous / _nt_masked fwd / dgrad, x 1x128, W 128x128
k_grouped_fp8_blockscale_gemm_tn_contiguous wgrad, dY / X 128x1 along tokens
Unshuffled B takes A's copy / LDS / reader layouts ([N, K] as [M, K], [K, N] as [K, M]); wgrad's
per-column B scales take A's scale panel (op_sel per fragment). M-grouped: 256-row tiles numbered
by the bf16 grouped helpers (single-height branch added); K-grouped: the bf16 plan kernel, turn
counters and fp32 read-modify-write (deterministic segment order), bounds-checked VGPR offsets
so rows past a segment read 0. Kids: m_grouped 0 (256x256) / 1 (256x128), k_grouped 10;
images built by build_co.py --family a8w8_blockscale_grouped (shares build_co_a16w16_grouped's
builder; bf16 images unchanged). Outputs bit-identical to the ROCm#6696 NT kernel on dense shapes.
Test op_tests/test_opus_a8w8_blockscale_grouped_gemm.py: GLM-5.3 / Kimi-K3 shapes, 5 token
distributions, masked; vs SonicMoE blockwise FP8 (fwd 1.9-2.2x, dgrad 2.2-2.5x geomean on gfx950).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… MoE training
FP8 e4m3 grouped GEMMs with E8M0 block scales and no shuffling of operands or scales, on the
MXFP8 1x128 4-wave pipeline (1x32 scale MFMA 16x16x128), with the DeepGEMM interfaces of the
bf16 grouped GEMMs:
m_grouped_fp8_blockscale_gemm_{nt,nn}_contiguous / _nt_masked fwd / dgrad, x 1x128, W 128x128
k_grouped_fp8_blockscale_gemm_tn_contiguous wgrad, dY / X 128x1 along tokens
Unshuffled B takes A's copy / LDS / reader layouts ([N, K] as [M, K], [K, N] as [K, M]); wgrad's
per-column B scales take A's scale panel (op_sel per fragment). M-grouped: 256-row tiles numbered
by the bf16 grouped helpers (single-height branch added); K-grouped: the bf16 plan kernel, turn
counters and fp32 read-modify-write (deterministic segment order), bounds-checked VGPR offsets
so rows past a segment read 0. Outputs bit-identical to the ROCm#6696 NT kernel on dense shapes.
Kernels opus_gemm_gfx950_mxfp8_{m,k}_grouped_*: m_grouped kids 0 (256x256) / 1 (256x128),
k_grouped 10; images built by gen_co/build_co_a8w8_blockscale_grouped.py (the bf16 grouped
builder, parameterized by a Family; bf16 images unchanged).
Test op_tests/test_opus_a8w8_blockscale_grouped_gemm.py: GLM-5.3 / Kimi-K3 shapes, 5 token
distributions, masked; vs SonicMoE blockwise FP8 (fwd 1.9-2.2x, dgrad 2.2-2.5x geomean on gfx950)
and the dense ROCm#6696 kernel.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… MoE training
FP8 e4m3 grouped GEMMs with E8M0 block scales and no shuffling of operands or scales, on the
MXFP8 1x128 4-wave pipeline (1x32 scale MFMA 16x16x128), with the DeepGEMM interfaces of the
bf16 grouped GEMMs:
m_grouped_fp8_blockscale_gemm_{nt,nn}_contiguous / _nt_masked fwd / dgrad, x 1x128, W 128x128
k_grouped_fp8_blockscale_gemm_tn_contiguous wgrad, dY / X 128x1 along tokens
Unshuffled B takes A's copy / LDS / reader layouts ([N, K] as [M, K], [K, N] as [K, M]); wgrad's
per-column B scales take A's scale panel (op_sel per fragment). M-grouped: 256-row tiles numbered
by the bf16 grouped helpers (single-height branch added); K-grouped: the bf16 plan kernel, turn
counters and fp32 read-modify-write (deterministic segment order), bounds-checked VGPR offsets
so rows past a segment read 0. Outputs bit-identical to the ROCm#6696 NT kernel on dense shapes.
Kernels opus_gemm_gfx950_mxfp8_{m,k}_grouped_*: m_grouped kids 0 (256x256) / 1 (256x128),
k_grouped 10; images built by build_co.py --arch gfx950 --family a8w8_blockscale_grouped (a
second GROUPED_FAMILIES entry; bf16 images unchanged).
Test op_tests/test_opus_a8w8_blockscale_grouped_gemm.py: GLM-5.3 / Kimi-K3 shapes, 5 token
distributions, masked; vs SonicMoE blockwise FP8 (fwd 1.9-2.2x, dgrad 2.2-2.5x geomean on gfx950)
and the dense ROCm#6696 kernel.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… MoE training
FP8 e4m3 grouped GEMMs with E8M0 block scales and no shuffling of operands or scales, on the
MXFP8 1x128 4-wave pipeline (1x32 scale MFMA 16x16x128), with the DeepGEMM interfaces of the
bf16 grouped GEMMs:
m_grouped_fp8_blockscale_gemm_{nt,nn}_contiguous / _nt_masked fwd / dgrad, x 1x128, W 128x128
k_grouped_fp8_blockscale_gemm_tn_contiguous wgrad, dY / X 128x1 along tokens
Unshuffled B takes A's copy / LDS / reader layouts ([N, K] as [M, K], [K, N] as [K, M]); wgrad's
per-column B scales take A's scale panel (op_sel per fragment). M-grouped: 256-row tiles numbered
by the bf16 grouped helpers (single-height branch added); K-grouped: the bf16 plan kernel, turn
counters and fp32 read-modify-write (deterministic segment order), bounds-checked VGPR offsets
so rows past a segment read 0. Outputs bit-identical to the ROCm#6696 NT kernel on dense shapes.
Kernels opus_gemm_gfx950_mxfp8_{m,k}_grouped_*: m_grouped kids 0 (256x256) / 1 (256x128),
k_grouped 10; images built by build_co.py --arch gfx950 --family a8w8_blockscale_grouped (a
second GROUPED_FAMILIES entry; bf16 images unchanged).
Test op_tests/test_opus_a8w8_blockscale_grouped_gemm.py: GLM-5.3 / Kimi-K3 shapes, 5 token
distributions, masked; vs SonicMoE blockwise FP8 (fwd 1.9-2.2x, dgrad 2.2-2.5x geomean on gfx950)
and the dense ROCm#6696 kernel.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Motivation
Add an OPUS backend for blockscale mxfp8 GEMM with B preshuffle on gfx950, and improve performance for large shapes (M > 1024). Enable the existing gemm_a8w8_blockscale_bpreshuffle interface to select tuned OPUS kernels.
Details
4wave_pin_agpr: Uses a four-wave schedule with AGPR pinning to reduce VGPR/AGPR transfers in the main loop, with padded-M support.b_vgpr: Stages A through LDS and prefetches B directly into VGPRs, with regular and operand-overlap scheduling options.m_repeat: Stages A and B through LDS, computes one M repeat at a time, and replaces operands for the next tile after their last use.Speedup Distribution
421 gfx950/CU256 shapes, the tuned table selects OPUS for 359 shapes