Repository navigation
[ASM] [HIP] [JIT] Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters - #7390
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
A critical bounds-checking flaw can corrupt adjacent-token output or overrun the allocation, and explicit coverage of split specializations and edge cases is missing.
2 open issues
What changed in this PR
This PR adds in-kernel split-K reduction to gfx1250 MLA v4.1 a8w8 sparse prefill, using workgroup clusters to avoid a separate reduction launch for supported split counts.
Changes:
- Adds cluster folding for 2/4/8/16 splits while preserving the separate-reduce fallback.
- Stages partial outputs through shared memory and tensor data-movement stores.
- Refits automatic split selection for cluster execution.
| File | Description |
|---|---|
csrc/kernels/mla/opus/mla_prefill_split.h |
Adds shared split-count and cluster-size helpers. |
csrc/kernels/mla/opus/gfx1250/mla_v41_split.hpp |
Implements partial-output stores and cluster reduction. |
csrc/kernels/mla/opus/gfx1250/mla_v41_prefill_traits.h |
Defines fp32 partial-output staging layouts. |
csrc/kernels/mla/opus/gfx1250/mla_v41_prefill_a8w8_16mx4_64nx1.hpp |
Integrates cluster folding into the wide-head kernel. |
csrc/kernels/mla/opus/gfx1250/mla_v41_prefill_a8w8_16mx4_64nx1.cu |
Exposes the wide-head cluster kernel entry point. |
csrc/kernels/mla/opus/gfx1250/mla_v41_prefill_a8w8_16mx1_16nx4.hpp |
Integrates cluster folding into the narrow-head kernel. |
csrc/kernels/mla/opus/gfx1250/mla_v41_prefill_a8w8_16mx1_16nx4.cu |
Exposes the narrow-head cluster kernel entry point. |
csrc/kernels/mla/opus_mla_prefill_fwd.cu |
Dispatches supported split counts to cluster launches. |
aiter/ops/mla_sparse_prefill.py |
Updates automatic split costs and documents cluster counts. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Critical split-epilogue defects can overflow attention-sink normalization and write beyond valid head rows, while regression tests do not explicitly exercise the new split configurations.
2 open issues
1 resolved since last review
Review effort: Balanced
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 |
…nel with workgroup clusters (ROCm#7390) * Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters * Merge the opus MLA prefill kargs headers and tidy comments


Summary
On gfx1250, the MLA v4.1 a8w8 sparse prefill kernels can now run a token's 2, 4, 8 or 16 KV splits as one workgroup cluster along x that folds the splits in-kernel, so split-K no longer needs a separate reduce launch. Small-N prefills can now fill the GPU instead of leaving most CUs idle.
Changes
gfx1250/mla_v41_split.hpp(new): each split stages its fp32 O in LDS and stores it with TDM. After the cluster barrier, each workgroup folds its 1/S share of the heads, reading its own rows straight from LDS, and writes bf16 O._cluster_kernelentry. The existing split kernel now also storespartial_othrough LDS + TDM instead of per-lane scattered stores. The non-split kernels are instruction-identical to before.opus_mla_prefill_fwd.cu: 2/4/8/16 splits launch the cluster kernel over grid (N·S, head blocks) with cluster (S, 1, 1). Other counts keep the split kernel pluspa_decode_ps_reduce_hip_kernel.mla_sparse_prefill.py: the gfx1250 v4.1 auto split now picks from the cluster counts with a refit cost. A new optionalpackedfactor covers splits that put more than one workgroup on a CU; it defaults to 1.0, so other fits are unchanged.Performance
Prefix only, per-call GPU time from CUDA-graph replays (best of 8 rounds), before → auto split (µs):
The gain grows as N shrinks and topk grows; shapes that already fill the GPU (larger N) stay unsplit and are unchanged.
Testing
op_tests/test_mla_sparse_prefill.pypasses (41 cases), including new explicit v4.1 split counts 2/3/4/8/16/32 with empty trailing splits.