refactor(prims-ts): derive MLA CP bounds from global sequence lengths #9641
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
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 #9641"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Follow up merged #5489 by replacing Prims-TS MLA decode's
use_kv_bounds/ per-querykv_boundsinterface with context-parallel topology and global request lengths.plan()specializescp_worldandcp_interleave_size.run()receivescp_rankand graph-live globalseq_lens_kv, including the current query tokens. Plannedmax_kv_lenand block tables remain rank-local physical capacity.qo_indptrdifferences; rank changes do not enter the compilation key.The branch is based on upstream main. CP documentation updates are confined to the PrimTS READMEs;
docs/development/backend_notes.mdis unchanged. No new context-kernel or standard-attention changes are introduced by this PR.Retained integration performance evidence
Same MLA implementation validated in the TRT-LLM integration, with full FP8 KV cache, page size 128, 96 heads, latent/RoPE dimensions 512/64. H-D1/H-D8: local batch 1/8, Q=8, CP8 rank 0, local history 512 (global total 4104). D-D8/D-D16: local batch 8/16, Q=6, CP1, history 4096.
Values are previous PrimTS → updated PrimTS microseconds, using the conservative order of balanced AB/BA runs and predefined confirmations. These are retained integration-snapshot measurements, not a new GPU run on this freshly main-based PR head.
| Scope | Case | Rubin SM107 | B200 SM100 | B300 SM103 |
|---|---|---|---|---|
| Raw generation | H-D1 | 14.240 → 13.752 | 20.480 → 20.480 | 20.448 → 18.432 |
| Raw generation | H-D8 | 18.000 → 17.936 | 16.368 → 16.384 | 16.352 → 16.368 |
| Raw generation | D-D8 | 26.656 → 26.624 | 36.832 → 36.864 | 34.784 → 34.816 |
| Raw generation | D-D16 | 30.552 → 30.584 | 65.504 → 65.536 | 65.792 → 66.261 |
| Attention backend | H-D1 | 17.680 → 17.536 | 24.576 → 24.608 | 24.448 → 22.560 |
| Attention backend | H-D8 | 23.360 → 23.840 | 24.576 → 24.472 | 22.496 → 22.496 |
| Attention backend | D-D8 | 30.464 → 30.472 | 40.960 → 40.944 | 38.896 → 38.896 |
| Attention backend | D-D16 | 36.984 → 36.992 | 73.712 → 73.712 | 73.744 → 73.752 |
50 warmups and 100 CUDA-event samples per process, CUDA graph replay, 2×L2 flush outside event intervals, clocks unlocked; startup/JIT/reference work excluded. Backend timing includes metadata/preprocessing/cache work, raw generation does not. TRT-LLM still prepares compatibility bounds for other providers, so no eliminated producer cost is claimed. Rubin H-D8 backend has a valid +2.055% regression, narrowly above the predefined 2% cap; other Rubin generation scopes and all Blackwell scopes pass. These are rank-local component results, not CP communication, full-model throughput or TTFT.
The consumer also contains a separate native single-
is_lsemerge cleanup and dispatch-policy update; those are not FlashInfer changes.🔍 Related Issues
🚀 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_cp.py tests/attention/test_attention_ts_mla_decode.py tests/trace/test_fi_trace_template_consistency.pyCurrent-head local results:
test_attention_ts_mla_decode.py: 9 passed.🔬 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_api. Tracking context: #5489, #4829, #5059, #5082; a separate graduation-tracking issue is not claimed.- [ ] 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.- [x] 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.)- [x] 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
`tests/experimental/test_experimental_api.py
As in #5489, this scope covers shared experimental opt-in behavior, not kernel correctness. Existing PrimTS implementation/tests remain under flashinfer/attention/prims_ts/
andtests/attention/`; the targeted attention tests above cover the kernels. Relocation/graduation is outside this follow-up.Reviewer Notes
Please focus on global-to-local prefix arithmetic, packed-query alignment, split-reduction empty rows and graph-live metadata. This was developed and validated with Codex assistance. No NVIDIA-specific notices were added to FlashInfer files.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Added context-parallel support for paged MLA decode, with configurable rank and interleave settings. Global KV lengths are mapped to rank-local cache prefixes.
Empty rows on ranks with no locally visible KV tokens now return zero output and negative-infinity LSE by default; this behavior can be disabled.
Bug Fixes
Improved handling of supported cluster sizes when selecting attention launch configurations.
Documentation
* Updated MLA decode guidance and trace examples for context-parallel settings, local cache capacity, and empty-row behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->