Skip to content

[ASM] [HIP] [OPUS] Add gfx1250 MLA v4.1 a8w8 sparse prefill kernels - #7314

Merged
shengnxu merged 4 commits into
mainfrom
kaiyang-1/mla_v41_gfx1250
Nov 3, 2026
Merged

shengnxu merged 4 commits into
mainfrom
kaiyang-1/mla_v41_gfx1250

Conversation

@kaiyang-1

Copy link
Copy Markdown
Contributor

Summary

Adds the gfx1250 (wave32, WMMA, TDM) backend of mla_sparse_prefill_v41, which previously ran on gfx950 only.

Changes

  • Kernels: csrc/kernels/mla/opus/gfx1250/ holds the sources of two prebuilt code objects in hsa/gfx1250/mla_opus/: 16mx1_16nx4 (16 heads per workgroup, two workgroups per CU) for H <= 32 and 16mx4_64nx1 (64 heads per workgroup) above that. Both take the existing opus_mla_v41_prefill_kargs, so the kernel argument ABI is shared with gfx950, and both run prefix and extend rows as one pipelined tile stream.
  • Build: ARCH=gfx1250 csrc/kernels/mla/opus/build_co.sh rebuilds the code objects with the amdgpu-named-reg-pin-std LLVM (16mx4_64nx1 needs amdgpu_pin_vgpr). The gfx950 build command is unchanged: a rebuilt gfx950 code object disassembles identically to the committed one.
  • Launcher: opus_mla_v41_prefill_a8w8_gfx1250_fwd is added, and the v4.1 validation and kernel argument setup are shared with the gfx950 entry. Split-K reuses the existing reduce.
  • Python: mla_sparse_prefill_v41 dispatches to gfx1250, and the split-K cost fit for both tiles was measured on gfx1250 (auto picks within ±4% of the best fixed split count).
  • opus: the TDM builtin descriptor groups now bind to either signedness, so opus.hpp builds with the ROCm, internal and named-reg-pin LLVMs.

Performance

gfx1250, N=4096, total_pages=65536, total_tokens=4096, with sink, opus backend, num_kv_splits=1, op_tests/test_mla_sparse_prefill.py --no-verify, median of 3 runs (us):

H topk v4.1 a8w8 v4 a8w8 bf16
16 512 112.5 139.3 (1.24x) 153.1 (1.36x)
16 1024 201.5 251.2 (1.25x) 280.9 (1.39x)
64 512 284.8 363.6 (1.28x) 333.4 (1.17x)
64 1024 499.2 607.5 (1.22x) 600.6 (1.20x)

The bf16 H=64 kernel draws the most power, so the GPU clock drops furthest under sustained load. Back-to-back after warm-up, it settles at about 600 us at topk=1024, about 1.2x the v4.1 time.

Tests

  • pytest op_tests/test_mla_sparse_prefill.py: 24 passed on gfx1250 (bf16, v4, v41).
  • v4.1 split-K on gfx1250: 96 cases passed (H 8 to 128, num_kv_splits 1/2/4/8, topk 300/1024).
  • module_mla_prefill_opus builds for gfx950.

@kaiyang-1
kaiyang-1 requested review from a team and a balanced review from Copilot November 2, 2026 07:28
@github-actions github-actions Bot changed the title Add gfx1250 MLA v4.1 a8w8 sparse prefill kernels [ASM] [HIP] [OPUS] Add gfx1250 MLA v4.1 a8w8 sparse prefill kernels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

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 (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 gfx1201 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 7314 --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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both kernel variants produce NaNs for masked entries when softmax_scale is zero, corrupting attention outputs, while the new split kernels and reduction integration lack committed regression coverage.

2 open issues
What changed in this PR

Adds a gfx1250 backend for MLA v4.1 sparse prefill, extending the existing gfx950 implementation through the shared OPUS API.

Changes:

  • Adds narrow- and wide-head gfx1250 kernels with split-K entry points.
  • Integrates architecture dispatch, shared argument validation, and gfx1250 split-K cost fits.
  • Extends code-object builds and test eligibility, and adapts TDM descriptor arguments to compiler signedness differences.
File Description
op_tests/​test_mla_sparse_prefill.py Enables the v4.1 OPUS test candidate on gfx1250.
csrc/​kernels/​mla/​opus/​gfx1250/​mla_v41_prefill_traits.h Defines tile geometry and shared-memory layouts.
csrc/​kernels/​mla/​opus/​gfx1250/​mla_v41_prefill_a8w8_16mx4_64nx1.hpp Implements the wide-head attention kernel.
csrc/​kernels/​mla/​opus/​gfx1250/​mla_v41_prefill_a8w8_16mx4_64nx1.cu Exposes wide-head standard and split-K kernels.
csrc/​kernels/​mla/​opus/​gfx1250/​mla_v41_prefill_a8w8_16mx1_16nx4.hpp Implements the narrow-head attention kernel.
csrc/​kernels/​mla/​opus/​gfx1250/​mla_v41_prefill_a8w8_16mx1_16nx4.cu Exposes narrow-head standard and split-K kernels.
csrc/​kernels/​mla/​opus/​build_co.sh Adds architecture-specific source selection and build flags.
csrc/​kernels/​mla/​opus_mla_prefill_fwd.cu Shares validation and adds the gfx1250 launcher.
csrc/​include/​opus/​opus.hpp Supports signed and unsigned TDM builtin arguments.
aiter/​ops/​opus/​mla.py Declares the gfx1250 Python binding.
aiter/​ops/​mla_sparse_prefill.py Adds gfx1250 dispatch and split-K cost fits.

Review effort: Balanced

@ROCm ROCm deleted a comment from aiter-bot Nov 2, 2026
kaiyang-1 and others added 2 commits November 2, 2026 08:16
…1250

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

# Conflicts:
#	aiter/ops/mla_sparse_prefill.py
#	aiter/ops/opus/mla.py
#	csrc/kernels/mla/opus_mla_prefill_fwd.cu
#	op_tests/test_mla_sparse_prefill.py
Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:20
@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision b8146e8d1074 · 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_mla_sparse_prefill.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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The committed pytest cases all select a single KV split on gfx1250, leaving the new split kernels and their partial-output and metadata paths untested; explicit multi-split coverage is needed for both head tiles and empty or partial-tail splits.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread op_tests/test_mla_sparse_prefill.py Resolved
@shengnxu
shengnxu merged commit 46cdc4c into main Nov 3, 2026
@shengnxu
shengnxu deleted the kaiyang-1/mla_v41_gfx1250 branch November 3, 2026 02:40
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…OCm#7314)

* Bind TDM builtin groups to either signedness across LLVM builds

* Add gfx1250 MLA v4.1 a8w8 sparse prefill kernels

* Rebuild the gfx1250 MLA v4.1 code objects for the separate prefix and extend strides

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

---------

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants