feat(mla): fuse native NVFP4 SM120 sparse prefill #9356
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 #9356"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Extend the sparse MLA mega API to native NVFP4 caches and port native prefill to CuTe C++ operations and CUTLASS barriers. IO warps gather KV and transpose/requantize V; math warps execute QK, online softmax and PV. Non-RoPE features use block-scaled FP4 with a BF16 RoPE tail. Fused and unfused specializations share the prefill implementation. NVFP4 mega execution requires a prefill plan; decode plans are explicitly rejected here and supported separately in #9439. Ordinary NVFP4 decode is unchanged.
Built-in prefill benchmark
RTX PRO 6000 Blackwell Server Edition, CUDA 13.4, SM120. Baseline: FP8 parent
5272e33c5b7ca3765f26c38714b3bf4db0ee47c9; PR:0548948996795c46e082f52ea93d3a09f62ff7c9. Warm-L2 CUDA Graph replay; 100 ms warmup / 500 ms measurement. GPU runs are serialized. Both original builtin shapes: B=1, Q=128, H=128, D=512, KV=8192, page=64, no secondary cache. Values are microseconds. Attention-only and complete-pipeline comparisons are separate; the complete baseline includes Q RoPE, original native NVFP4 attention, inverse output RoPE and FP8 quantization, timed as one sequence. Only benchmark/transform helpers are backported to the parent.| Selected KV | Parent attention | PR non-mega attention | Parent / PR attention | Parent separate kernels | PR mega | Parent separate / mega |
|---:|---:|---:|---:|---:|---:|---:|
| 128 | 46.65 | 39.89 | 1.170× | 65.49 | 43.18 | 1.517× |
| 512 | 144.65 | 119.86 | 1.207× | 163.49 | 124.99 | 1.308× |
🔍 Related Issues
Stack:
main← #8747 (FP8 prefill) ← #9274 (FP8 decode) ← this PR (NVFP4 prefill).🚀 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
test_sparse_mla_sm120*.pyfiles, using the repository deterministic CI runner (one worker, one shard, no sampling) on RTX PRO 6000 Blackwell Server Edition. Local environment: CUDA 13.4, Torch 2.14.0a0+4fdf77b940.nv26.08, Triton 3.8.0; this is not the internal CUDA 13.0 image. Repository-wide pre-commit and benchmark smoke checks pass.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_sparse_mla_sm120.py tests/attention/test_sparse_mla_sm120_binding_guards.py tests/attention/test_sparse_mla_sm120_cache_contracts.py tests/attention/test_sparse_mla_sm120_calibration.py tests/attention/test_sparse_mla_sm120_cute_prefill_integration.py tests/attention/test_sparse_mla_sm120_decode.py tests/attention/test_sparse_mla_sm120_dsv41_inline.py tests/attention/test_sparse_mla_sm120_dsv4_nvfp4.py tests/attention/test_sparse_mla_sm120_execution.py tests/attention/test_sparse_mla_sm120_lse_base.py tests/attention/test_sparse_mla_sm120_nvfp4_prefill_mega.py tests/attention/test_sparse_mla_sm120_policy.py tests/attention/test_sparse_mla_sm120_precision.py tests/attention/test_sparse_mla_sm120_prefill_mega_contract.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
Review against main. This delta adds native NVFP4 fusion, its CuTe prefill implementation, alignment/page-pitch coverage, and native graph/full-pipeline benchmark options. NVFP4 decode optimization follows in #9439. Implementation and validation were assisted by Codex.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
- Added NVFP4 support for sparse MLA prefill with fused RoPE and FP8 output.
- Expanded the experimental mega path to support NVFP4 caches, attention sinks, empty selections, and padded cache layouts.
- Added benchmark options for CUDA Graph timing, full-pipeline measurements, and mega mode.
- Removed the benchmark’s previous restriction on token counts above 64.
- Improved NVFP4 prefill handling across varied sequence lengths and query offsets.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->