Repository navigation
[ASM] [HIP] [OPUS] Add gfx1250 MLA v4.1 a8w8 sparse prefill kernels - #7314
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 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
…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
… extend strides Co-authored-by: Cursor <[email protected]>
NOT READY FOR HUMAN REVIEWPR 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 |
There was a problem hiding this comment.
🟡 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
…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]>


Summary
Adds the gfx1250 (wave32, WMMA, TDM) backend of
mla_sparse_prefill_v41, which previously ran on gfx950 only.Changes
csrc/kernels/mla/opus/gfx1250/holds the sources of two prebuilt code objects inhsa/gfx1250/mla_opus/:16mx1_16nx4(16 heads per workgroup, two workgroups per CU) for H <= 32 and16mx4_64nx1(64 heads per workgroup) above that. Both take the existingopus_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.ARCH=gfx1250 csrc/kernels/mla/opus/build_co.shrebuilds the code objects with the amdgpu-named-reg-pin-std LLVM (16mx4_64nx1needsamdgpu_pin_vgpr). The gfx950 build command is unchanged: a rebuilt gfx950 code object disassembles identically to the committed one.opus_mla_v41_prefill_a8w8_gfx1250_fwdis added, and the v4.1 validation and kernel argument setup are shared with the gfx950 entry. Split-K reuses the existing reduce.mla_sparse_prefill_v41dispatches 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.hppbuilds 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):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).module_mla_prefill_opusbuilds for gfx950.