perf(prims-ts): unroll runtime-split MLA reduction in dispatched windows #8103
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8103"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Fixes a prims-ts MLA decode latency regression from #6925 (runtime split-KV).
The 1CTA MLA kernel now compiles with an SM-bounded split capacity and takes the active split count at launch. The parallel G1 split-KV reducer kept its fully unrolled loop only for exactly 32 splits. Any other count fell back to
cutlass.range(..., unroll=4), which serializes the partial-O loads. With 36 splits (GLM-style bs1 decode) the reducer went from 2.66 us to 4.57 us. The attention kernel itself is unchanged.This PR compiles fixed unrolled windows of 8, 16, 32, 48, 64, 96 and 128 splits into the reducer. The live count selects one at runtime.
max_kv_lenplans, the number of distinct compiled MLA kernels matches main. Static-split kernels keep their exact unrolled loop.GB300,
flashinfer_benchmark.py --routine BatchMLAPagedAttentionWrapper --backends prims-ts, batch 1, s_qo 1, ckv 512 / kpe 64, median us:| Case | Before #6925 | main | This PR |
|---|---|---|---|
| fp8, 8 heads, s_kv 9216, page 64 | 9.77 | 11.62 | 10.19 |
| bf16, 12 heads, s_kv 3840, page 32 | 10.94 | 12.35 | 10.87 |
Reducer kernel only, fp8, 8 heads (main → this PR): 36 splits 4.80 → 3.31 us, 96 splits 8.45 → 4.19 us, 128 splits 10.41 → 4.92 us.
🔍 Related Issues
Regression introduced by #6925 (e46d856).
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).Reason: <!-- e.g. cross-cutting change to shared infrastructure -->
Suggested CI test targets (optional; paths under
tests/, whitespace-separated — a startingpoint for
@flashinfer-bot run <targets>//bot run <targets>, reviewers may adjust):tests/attention/test_attention_ts_mla_decode.py tests/attention/test_attention_ts_sparse_mla.py🔬 Experimental Track
<!-- Only for PRs submitted under the experimental policy (CONTRIBUTING.md → "Experimental APIs and Backends").
Leave this section untouched for normal PRs. -->
flashinfer/experimental/and/or an@flashinfer_experimental_api. Tracking issue: #- [ ] The tracking issue names an owner, the reason for the experimental path, and a graduation plan with a target release.
- [ ] Core changes are limited to a thin entry point (signature, shared validation, feature-gate check, backend selection, handoff).
- [ ] Tests live in
tests/experimental/and were validated on the intended hardware; a runnable example is included.- [ ] Nothing is registered in
flashinfer/aot.py, and no experimental backend is reachable frombackend="auto"withoutFLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an@flashinfer_experimental_apior naming a backend explicitly is itself the opt-in and needs no environment variable.)- [ ] Test scope declared below. The experimental CI lane runs exactly these targets, so keep them as narrow as the change allows.
<!-- Required for experimental PRs. Replace the commented lines below with your targets.
Do not delete the fence or change its
experimental-teststag — the experimental-trackwatcher reads it verbatim to decide which targets to ask CI for. -->
``
experimental-tests
`One target per line: a directory or a file. (A pytest ::selector is not
supported -- the sharding runner cannot consume one.) Must be under
tests/experimental/ and must exist. Delete these comment lines and add yours, e.g.
# tests/experimental/test_my_backend.py
tests/experimental/my_backend/
# Declaring the whole tree (tests/experimental/) is allowed but means every
experimental PR pays for every other feature's tests, in every matrix cell.
Reviewer Notes
now pins both sides of every reducer window boundary (8/9 … 128/129) and adds a Q8 case.- A per-plan window in the compile signature was faster on fp8 (10.07 us), but added +14 / +16 compiled kernels per 512 plans.
- Software-pipelined chunks were slower (10.9 us).
- A denser window set (every 8 up to 64) was slower: each window adds code that the short reducer launch has to fetch.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Performance
Improved attention decoding across a wider range of split counts, including large counts.
* Runtime workloads now use appropriately sized reduction windows, with chunked handling for counts beyond the largest window. This broadens support for varying workload sizes while retaining exact-count handling for fixed split counts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->