Repository navigation
[ASM] [HIP] Walk prefix and extend as one tile stream in gfx950 MLA sparse prefill - #7897
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR 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 rewritten BF16 16mx1 split-K path lacks reference-checked tests with explicit split counts covering a partial prefix/extend boundary and an empty split on a 256-CU gfx950.
1 open issue
What changed in this PR
This PR extends earlier OPUS sparse-prefill optimizations by processing prefix and extend tiles as one stream in gfx950 MLA kernels, reducing pipeline drains and repeated synchronization.
Changes:
- Unifies tile traversal and updates prefetching across BF16, FP8, and mixed FP4/FP8 kernels.
- Combines row-maxima and FP32 probability exchange in v4 16mx1 kernels and refits automatic split-K selection.
- Adds window-based CLI inputs matching DeepSeek inference workloads while preserving existing pytest cases.
| File | Description |
|---|---|
op_tests/test_mla_sparse_prefill.py |
Adds window-based extend inputs and updates CLI defaults. |
csrc/kernels/mla/opus/gfx950/mla_v41_prefill_a8w8_16mx4_64nx1.hpp |
Streams prefix and extend tiles through one pipeline. |
csrc/kernels/mla/opus/gfx950/mla_v41_prefill_a8w8_16mx1_16nx4.hpp |
Unifies traversal and advances page-index prefetching. |
csrc/kernels/mla/opus/gfx950/mla_v41_prefill_a8w4_16mx4_64nx1.hpp |
Reuses staged queries across the FP4-to-FP8 handoff. |
csrc/kernels/mla/opus/gfx950/mla_v41_prefill_a8w4_16mx1_16nx4.hpp |
Joins extend and prefix processing with format-specific stages. |
csrc/kernels/mla/opus/gfx950/mla_v4_prefill_traits.h |
Updates shared-memory sizing for FP32 probability exchange. |
csrc/kernels/mla/opus/gfx950/mla_v4_prefill_a8w8_32mx4_32nx1.hpp |
Refactors segment selection, prefetching, and tail masking. |
csrc/kernels/mla/opus/gfx950/mla_v4_prefill_a8w8_16mx1_16nx4.hpp |
Unifies traversal and combines cross-wave softmax exchange. |
csrc/kernels/mla/opus/gfx950/mla_v4_prefill_a16w16_32mx4_32nx1.hpp |
Simplifies stream addressing and segment-tail handling. |
csrc/kernels/mla/opus/gfx950/mla_v4_prefill_a16w16_16mx1_16nx4.hpp |
Shares the pipelined implementation between split and unsplit paths. |
aiter/ops/mla_sparse_prefill.py |
Refits gfx950 and gfx1250 automatic split-K constants. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The DMA/LDS hand-offs and register-lifetime changes require native gfx950 review and exact-head GPU validation, while rebuilt code-object parity and gfx1250 performance remain unverified.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
…parse prefill (#7897) * Walk prefix and extend as one tile stream in gfx950 MLA sparse prefill * Refit the auto split-k parameters of MLA sparse prefill * Keep the NVFP4 dequant interleaved with the PV MFMAs
…2 rows Measured on MI355X against main's OPUS, whose H > 32 kernel #7784 and #7897 sped up: - H=64: OPUS takes 0.90x the triton backend's time on index lists captured from GLM-5.3-Flash prefill and 0.83-0.94x on uniformly random ones, so backend=None keeps OPUS there. backend="triton" still serves H=64. - H=32: OPUS takes 1.09x the triton backend's time on the captured lists and 1.75-2.07x on the random ones, but below 512 query rows 0.39-0.95x, so the bound rises from 64 to 512. test_default_backend_gfx950 runs at the bound, expects OPUS at H=64, and adds a case one row below the bound, which expects OPUS. Signed-off-by: Rony Leppänen <[email protected]>

Summary
v_pk_mul_f32run back to back, so they wait for a running MFMA once per group instead of once per pair.packedfactor.test_mla_sparse_prefill.py: the CLI inputs follow DeepSeek V4/V4.1 inference.--window(each token's last W extend rows, default 128) replaces--total_tokens.--topkis the prefix count (default 512 1024).-ndefaults to 1024 4096 16384.Performance
MI355X. Default sweep of
op_tests/test_mla_sparse_prefill.py --backend opus --no-verify: N 1024/4096/16384, H 16/32/64/128, topk 512/1024, window 128, total_pages 64K/1M. Median of 3 runs; speedups are geomeans.Across all 192 cases this PR is 1.022x over main (0.986x to 1.074x). #7784 only replaced the 16mx8 kernels with 32mx4 for H > 32.
Split-K: auto only splits when the grid underfills (N up to ~512).
Testing
pytest op_tests/test_mla_sparse_prefill.py: 38 passed.num_kv_splitsauto, 1, 2, 3, 7, 32;All pass.