perf(prims-ts): run sparse MLA on SM107 and trim the NVFP4 KV converter #8186
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 #8186"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Enable Prims-TS sparse MLA on SM107 (Rubin) and speed up its NVFP4 KV converter there. SM100/SM103 (
sm_100a/sm_103a) compile the same code as before._validate_runtime_devicecheck. The sparse MLA tests also run on SM107, and skip when the installed CuTe DSL cannot target the GPU.mul.e4m3x4.e2m1x4, so NVFP4 K/V is converted one value pair at a time: F2FP (E2M1 → f16x2), HMUL2 by the scale, then F2FP (f16x2 → E4M3). Only on SM107 targets (use_sm107_nvfp4_converter()), includingsm_100f, the family target SM107 uses with CuTe DSL < 4.8:- Each block16 scale is prepared once per 16 values (
prepare_nvfp4_scale). The f16x2 scale is built on the FMA pipe instead of with an ALU F2FP: a non-negative E4M3 byte placed at bit 7 of an f16 lane is exactly scale × 2⁻⁸, and one HMUL2 by 256 restores it.- The E4M3 RoPE tail, which needs no conversion, is moved as 8-byte pieces (four rows per warp access) instead of two bytes per lane per row.
Outputs are bit-identical before and after on SM107 (1-CTA whole-record, 1-CTA panel, 2-CTA and FP8 paths). On SM103 (B300) the SASS of all 194 kernels built by
tests/attention/test_attention_ts_sparse_mla.pymatches main up to register numbering (which also varies between builds of identical kernel code).sm_100falso lacks the packed multiply: on main, NVFP4 sparse MLA fails in ptxas withCUTE_DSL_ARCH=sm_100f(checked on B300). With this PR it builds and passes.Performance. Rubin (SM107), CUDA 13.4, CuTe DSL 4.8.0. NVFP4 sparse MLA with D576, top-k 2048 and 128k KV; "Before" is SM107 with the existing converter. Times are CUPTI medians with a cold L2, inside CUDA graphs.
| Heads | Case | Before (µs) | After (µs) | Speedup |
|---:|---|---:|---:|---:|
| 12 | decode B16 Sq8 | 36.0 | 34.3 | 1.05x |
| 12 | decode B64 Sq8 | 98.5 | 93.5 | 1.05x |
| 12 | decode B256 Sq8 | 318.6 | 296.2 | 1.08x |
| 12 | prefill S8192 | 1150.2 | 1095.2 | 1.05x |
| 24 | prefill S8192 | 1265.8 | 1227.8 | 1.03x |
| 48 | decode B64 Sq8 | 108.6 | 106.3 | 1.02x |
| 48 | prefill S8192 | 1316.0 | 1275.7 | 1.03x |
| 96 | decode B64 Sq8 | 116.1 | 116.4 | 1.00x |
| 96 | prefill S8192 | 1726.4 | 1726.3 | 1.00x |
FP8 and the other backends are unchanged.
🔍 Related Issues
None.
🚀 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_sparse_mla.py tests/attention/test_attention_ts_mla_decode.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
andruff format --checkpass on the changed files. The full pre-commit suite was not run locally.182 passed,tests/attention/test_attention_ts_mla_decode.py192 passed.182 passed; withCUTE_DSL_ARCH=sm_100f`, its 44 NVFP4 tests pass (main fails to build them).🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Sparse MLA decoding now supports runtime-validated devices, including SM107 Rubin, when the required architecture support is available.
NVFP4 key/value decoding supports conversion paths qualified for supported Blackwell and Rubin GPU families, with compatible handling of NVFP4 scales and D576 RoPE data on SM107.
Documentation
* GPU family documentation now includes SM107 Rubin alongside SM100 and SM103.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->