Skip to content

[OPUS] Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm - #8283

Open
Fyzyukk wants to merge 3 commits into
ROCm:mainfrom
Fyzyukk:fyz/opus_mxfp8_blockscale_nn_tt_tn_v2
Open

Fyzyukk wants to merge 3 commits into
ROCm:mainfrom
Fyzyukk:fyz/opus_mxfp8_blockscale_nn_tt_tn_v2

Conversation

@Fyzyukk

@Fyzyukk Fyzyukk commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the NN, TT and TN operand layouts to the gfx950 OPUS MXFP8 1x128 blockscale GEMM with B preshuffle (the NT kernel from #6696 / #7387), so callers whose A is stored [K, M] or whose B is stored [K, N] run directly, with no transpose copy.

Details

  • One pipeline for three layouts: opus_gemm_pipeline_mxfp8_4wave_gfx950.cuh / opus_gemm_traits_mxfp8_4wave_gfx 950.cuh. Each operand picks its LDS path by its storage: A_T (A stored [K, M]) and B_T (B stored [K, N]) read with ds_read_b64_tr_b8. NN = (0, 1), TT = (1, 0), TN = (1, 1). 2x2 waves, LDS-DMA copies, A / B and part of C pinned to AGPRs.

  • Formats: same as NT. FP8 A / B, E8M0 scales (1x128 for A, 128x128 for B), BF16 C. B is the shuffle_weight(layout=(16, 16)) of its own storage ([N, K] or [K, N]).

  • Interface: the existing exact-kid entry opus_gemm(..., family="a8w8_blockscale_bpreshuffle", layout="bpreshuffle", kid=...). The direction comes from the kernel name; the generated launcher checks that direction's operand / scale strides, so a tensor of another layout is rejected. The shape heuristic and the NT tuner never pick these kids, so default_compiled_keys adds them to the gfx950 compile set.

Performance

MI355X (gfx950, CU256), BF16 output. NT is the fastest NT CO kernel for the shape; NN / TT / TN are each direction's fastest kid. All four run in the same process, alternated over 3 rounds (min, spread <= 2.6%).

| Shape (M x N x K) | NN (us / vs NT) | TT (us / vs NT) | TN (us / vs NT) |
|---|---|---|---|---|
| 16384 x 16384 x 16384 | -6.6% | +3.1% | +1.1% |
| 8192 x 8192 x 8192 | +1.0% | +2.6% | +3.4% |
| 4096 x 4096 x 4096 | +2.9% | +2.0% | +2.8% |
| 2048 x 7168 x 7168 | +2.9% | +1.9% | +1.7% |
| 8192 x 7168 x 2048 | +3.2% | +2.3% | +2.5% |

Test Plan

  • op_tests/test_opus_a8w8_interface.py: 8 passed.
  • op_tests/test_opus_co_integration.py -k gfx950: 38 passed.

@Fyzyukk
Fyzyukk requested a review from a team November 19, 2026 08:03
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 8283 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm [HIP] [OPUS] Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm Nov 19, 2026
@aiter-bot

aiter-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 615eff1da32f · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_opus_co_integration.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@Fyzyukk
Fyzyukk force-pushed the fyz/opus_mxfp8_blockscale_nn_tt_tn_v2 branch from 87d9ffd to ad4ab51 Compare November 19, 2026 08:15
@zufayu
zufayu requested review from demonsan and yifehuan November 20, 2026 01:24
Extends the gfx950 OPUS MXFP8 blockscale GEMM (FP8 A / B, E8M0 scales 1x128 for
A and 128x128 for B, BF16 C) from NT to the three other operand layouts, without
a transpose copy. Stacked on PR ROCm#7387.

- One pipeline / traits pair for the three directions:
  opus_gemm_pipeline_mxfp8_4wave_gfx950.cuh / opus_gemm_traits_mxfp8_4wave_gfx950.cuh.
  Each operand picks its LDS path from its storage: A_T (A stored [K, M]) and B_T
  (B stored [K, N]) read with ds_read_tr8; NN = (0, 1), TT = (1, 0), TN = (1, 1).
  2x2 waves, LDS-DMA copies, A / B and part of C pinned to AGPRs; TR8 reads use
  the ds_read_tr8 builtin so their results land in AGPRs.
- Traits <BM, BN, PadM, GroupM>: 256x256 or 256x128 tiles, optional PadM, GroupM
  0 (2x2 raster) / 4 / 8 / 16 as NT's gm.
- CO kids 56-85, appended to co_kernels_gfx950_a8w8_blockscale_bpreshuffle.json;
  images and build records in gen_co/gfx950/a8w8_blockscale_bpreshuffle/
  (pin toolchain, 0 spills):
    56-67  NN / TT / TN x {256x256, 256x256 PadM, 256x128, 256x128 PadM}
    68-85  NN / TT / TN x {256x256, 256x128} x GroupM {4, 8, 16}
- Same kargs and launcher family as NT (a8w8_blockscale_bpreshuffle); the
  direction comes from the kernel name (_mxfp8_(nn|tt|tn)_) and the generated
  launcher checks that direction's operand / scale strides.
- Called through the public exact-kid entry opus_gemm(..., family=
  "a8w8_blockscale_bpreshuffle", layout="bpreshuffle", kid=56..85); a tensor
  layout of another direction is rejected by the launcher's stride check. The
  shape heuristic / tuner never pick the direction kids. Like the other gfx950
  MXFP8 kids they are compiled on request (tuned rows, the compiled-kids sidecar
  or opus_gemm_tune._ensure_kids_compiled), not by default.
- build_co: the pin check of the direction kids accepts AGPR ranges filled by
  plain or TR8 LDS reads.
- test_opus_co_integration.py: NN / TT / TN kids (256x256 across the scale panel,
  256x128 PadM, GroupM 16) against a torch reference, and another direction's
  launcher rejecting the strides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fyzyukk
Fyzyukk force-pushed the fyz/opus_mxfp8_blockscale_nn_tt_tn_v2 branch from ad4ab51 to 8673a97 Compare November 20, 2026 13:07
@github-actions github-actions Bot changed the title [HIP] [OPUS] Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm [OPUS] Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm Nov 20, 2026
@github-actions github-actions Bot removed the HIP label Nov 20, 2026
Fyzyukk and others added 2 commits November 21, 2026 11:10
… TT / TN

- aiter.ops.opus.gemm_a8w8_blockscale_bpreshuffle_opus(XQ, WQ, x_scale,
  w_scale, dtype, *, kernelId=None, out=None): reads NN / TT / TN from the
  operand strides, rejects NT, and picks a kid by shape when kernelId is
  not given (256x128 for N % 256 or outputs up to 2048 x 2048, GroupM 16
  from M = 16384, PadM only when M % 256).
- default_compiled_keys adds kids 56-85 on gfx950, so the API runs on a
  fresh JIT build; no tuned row or heuristic requests these kids.
- test_opus_co_integration: every kid 56-85 against the reference, plus
  API tests (shape-picked kid per layout, explicit kernelId + out, NT and
  unsupported-shape rejection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…T / TN

Merge _BPRESHUFFLE_ARGUMENTS and _mxfp8_direction_arguments into one
_bpreshuffle_arguments(direction) template; only the XQ/WQ layout check,
the scale layout check and stride_a / stride_b / stride_sfb differ per
direction. Read the direction from the CO manifest "pipeline" field
instead of matching the kernel name.

Generated NT sources (8784 instances) are byte-identical; the 30 NN/TT/TN
sources differ by one line break only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants