← Back to Pull requests

perf(prims-ts): run sparse MLA on SM107 and trim the NVFP4 KV converter #8186

Closed
unknown closed this pull request without merging on Nov 02, 2026 03:02 UTC
View on GitHub
unknown unknown commented on Nov 01, 2026 09:17 UTC
Author

<!-- .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.

  • SM107 support. Sparse MLA planning only accepted SM100/SM103, although the other Prims-TS attention paths already run on SM107. The plan now uses the shared _validate_runtime_device check. The sparse MLA tests also run on SM107, and skip when the installed CuTe DSL cannot target the GPU.

  • SM107 NVFP4 converter. SM107's ptxas rejects the packed 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()), including sm_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.py matches main up to register numbering (which also varies between builds of identical kernel code).

    sm_100f also lacks the packed multiply: on main, NVFP4 sparse MLA fails in ptxas with CUTE_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

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).

  • I have installed the hooks with pre-commit install.

  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.
  • If you are unsure about how to set up pre-commit, see the pre-commit documentation.

    🧪 Tests

  • Tests have been added or updated as needed.

  • All tests are passing (unittest, etc.).

  • This PR requires full-scope CI, not targeted tests (expensive; justify below).

  • Reason: <!-- e.g. cross-cutting change to shared infrastructure -->

    Suggested CI test targets (optional; paths under tests/, whitespace-separated — a starting
    point 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. -->

  • This PR is experimental: it adds or changes code under 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 from backend="auto" without FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an @flashinfer_experimental_api or 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-tests tag — the experimental-track
    watcher 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

  • Lint: ruff check and ruff format --check pass on the changed files. The full pre-commit suite was not run locally.

  • SM107 (Rubin): tests/attention/test_attention_ts_sparse_mla.py 182 passed, tests/attention/test_attention_ts_mla_decode.py 192 passed.

  • SM103 (B300): tests/attention/test_attention_ts_sparse_mla.py 182 passed; with CUTE_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 -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: qsang-nv Review duration: 1064m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%