Skip to content

[ASM] [HIP] [JIT] Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters - #7390

Merged
JiaoliangYu merged 3 commits into
mainfrom
kaiyang-1/mla_split_fuse_reduce
Nov 4, 2026
Merged

JiaoliangYu merged 3 commits into
mainfrom
kaiyang-1/mla_split_fuse_reduce

Conversation

@kaiyang-1

@kaiyang-1 kaiyang-1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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.
  • Both v4.1 code objects gain a _cluster_kernel entry. The existing split kernel now also stores partial_o through 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 plus pa_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 optional packed factor 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):

H N topk 512 topk 1024
16 8 6.10 → 4.98 (-18%) 9.78 → 5.67 (-42%)
16 16 6.22 → 5.41 (-13%) 10.00 → 6.12 (-39%)
16 32 6.29 → 6.32 10.09 → 6.96 (-31%)
16 64 6.42 → 6.41 10.33 → 7.59 (-27%)
64 8 9.22 → 7.45 (-19%) 15.26 → 8.36 (-45%)
64 16 9.34 → 8.17 (-13%) 15.46 → 9.77 (-37%)
64 32 9.52 → 9.16 (-4%) 15.80 → 11.32 (-28%)
64 64 9.76 → 9.74 16.27 → 13.80 (-15%)
128 8 9.37 → 8.11 (-13%) 15.42 → 9.69 (-37%)
128 16 9.52 → 9.15 (-4%) 15.76 → 11.23 (-29%)
128 32 9.62 → 9.22 (-4%) 16.27 → 13.80 (-15%)

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.py passes (41 cases), including new explicit v4.1 split counts 2/3/4/8/16/32 with empty trailing splits.

@kaiyang-1
kaiyang-1 requested review from a team and a balanced review from Copilot November 3, 2026 10:02
@github-actions

github-actions Bot commented Nov 3, 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 7390 --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.

@github-actions github-actions Bot changed the title Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters [ASM] [HIP] Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters Nov 3, 2026

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

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

Copilot AI balanced review requested due to automatic review settings November 4, 2026 03:38
@github-actions github-actions Bot changed the title [ASM] [HIP] Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters [ASM] [HIP] [JIT] Fold gfx1250 MLA v4.1 sparse prefill split-K in-kernel with workgroup clusters Nov 4, 2026
@github-actions github-actions Bot added the JIT label Nov 4, 2026

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 cluster fold’s 32-bit byte offsets cannot represent supported large head strides and can alias earlier output heads, creating a critical correctness risk.

1 open issue
2 resolved since last review

Review effort: Balanced

@ROCm ROCm deleted a comment from aiter-bot Nov 4, 2026
Copilot AI balanced review requested due to automatic review settings November 4, 2026 04:04
@ROCm ROCm deleted a comment from aiter-bot Nov 4, 2026

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

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

@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 48b77f24e595 · 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

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

@kaiyang-1
kaiyang-1 requested a review from JiaoliangYu November 4, 2026 10:45
@JiaoliangYu
JiaoliangYu merged commit 0f61f2b into main Nov 4, 2026
@JiaoliangYu
JiaoliangYu deleted the kaiyang-1/mla_split_fuse_reduce branch November 4, 2026 10:50
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…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
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.

5 participants