[Perf] Optimize SM90 DOTS3 MLA sliding-window decode #9511
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 #9511"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
<!-- Suggested title: [Perf] Optimize SM90 DOTS3 MLA sliding-window decode -->
📌 Description
This PR further optimizes the SM90 DOTS3 MLA+sliding-window backend merged in #6823. It improves the existing
flashinfer.mla.batch_decode_with_kv_cache_mla_swaimplementation without changing its public signature, workspace-size API, or precision contract.Changes
s_q=4.The existing contract remains BF16 Q/KV/output, local Hq=64, Dq=1088, Dv=1024, Page64,
window_left=512(513 tokens including the current token), local B in {1,2,4,8,16}, ands_qin {1,4}. Scores, PV accumulators, and all split-reduction payloads/calculations remain FP32. This does not introduce BF16 partial reduction.Performance
GPU: NVIDIA H100 80GB HBM3, 132 SMs; local Hq=64, Hkv=1, Dq=1088, Dv=1024, W513/Page64, BF16 input/output and FP32 partial/reduction. Measurements use the same GPU/process/inputs, preallocated workspace/output, complete-op latency including split combine, and 12 balanced/interleaved rounds × 300 warm CUDA Graph replays.
Fallback is the original SGLang Triton MLA+SWA op,
forward_dense_kvlora_swa_torch_fallback, pinned at SGLang commit0dcac68751189e6d3417daafad52393bff01b0c9. It is not a previous FlashInfer release or the standalone benchmark's PyTorch reference.Latency reduction = (fallback latency − this PR's latency) / fallback latency × 100%. Across all 20 cases, latency is 21.7%–53.8% lower than fallback. The geometric-mean speedup is 1.542×, corresponding to 35.1% lower latency; this aggregate is not an arithmetic average of the row percentages.
B below is the local, per-device batch size. For attention-DP8, the corresponding global batch is 8 × B; these are attention-op measurements, not eight-device end-to-end throughput results. The tables use the qualified optimized kernel's archived paired measurements before publication-only formatting/comment/documentation cleanup; the Release rebuild was checked separately under Tests.
s_q = 1
| Local B | KV length | Tactic | Fallback (µs) | This PR (µs) | Speedup |
|---:|---:|---|---:|---:|---:|
| 1 | 4096 | M8-S9 | 19.249 | 9.268 | 2.08× |
| 1 | 4127 | M8-S9 | 19.281 | 8.902 | 2.17× |
| 2 | 4096 | M8-S5 | 20.043 | 11.451 | 1.75× |
| 2 | 4127 | M8-S5 | 19.922 | 11.768 | 1.69× |
| 4 | 4096 | M8-S3 | 22.618 | 15.081 | 1.50× |
| 4 | 4127 | M8-S3 | 22.647 | 15.020 | 1.51× |
| 8 | 4096 | M16-S4 | 25.654 | 17.173 | 1.49× |
| 8 | 4127 | M16-S4 | 25.774 | 17.872 | 1.44× |
| 16 | 4096 | M16-S2 | 38.477 | 21.899 | 1.76× |
| 16 | 4127 | M16-S2 | 38.572 | 22.986 | 1.68× |
s_q = 4
| Local B | KV length | Tactic | Fallback (µs) | This PR (µs) | Speedup |
|---:|---:|---|---:|---:|---:|
| 1 | 4096 | M8-S3 | 21.051 | 14.463 | 1.46× |
| 1 | 4127 | M8-S3 | 21.144 | 14.334 | 1.48× |
| 2 | 4096 | M16-S4 | 22.551 | 15.662 | 1.44× |
| 2 | 4127 | M16-S4 | 22.511 | 16.185 | 1.39× |
| 4 | 4096 | M16-S2 | 26.385 | 20.020 | 1.32× |
| 4 | 4127 | M16-S2 | 26.497 | 20.757 | 1.28× |
| 8 | 4096 | M32-S2 | 36.692 | 26.318 | 1.39× |
| 8 | 4127 | M32-S2 | 36.620 | 27.424 | 1.34× |
| 16 | 4096 | M32-S1 | 62.248 | 41.366 | 1.50× |
| 16 | 4127 | M32-S1 | 62.292 | 42.018 | 1.48× |
To measure the current FlashInfer op and run its FP64 reference check:
This standalone command requires no SGLang installation or model weights. Its
pytorch_reference_usfield is a gather/mask reference, not the Triton fallback in the tables. The fallback comparison was collected with the paired development harness (optimization_archive/iterations/20261029_table_driven_optimization/benchmark.pyin the development archive), using the pinned SGLang fallback; that harness is not part of this FlashInfer PR.🔍 Related Issues
Follow-up to https://github.com/flashinfer-ai/flashinfer/pull/6823.
🚀 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.Before the November 15 rebase, changed-file checks passed with the repository's hooks: clang-format 19.1.1, Ruff, mypy, and the standard file checks. Hooks were run with
pre-commit run --files <changed files>; the whole-repository checkbox above is intentionally not claimed. These are historical results, not a fresh hook run against the rebased head.🧪 Tests
unittest, etc.).Reason: Not requested; changes are confined to the SM90 MLA+SWA backend.
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_mla_swa_sm90.py tests/trace/test_mla_swa.pyTargeted validation command:
Historical GPU validation of the pre-rebase publication commit
df6d7e550f04ea79775a3123bbd20169594504a8, on H100 80GB HBM3 with PyTorch 2.14.1+cu130 / CUDA 13.0:-DNDEBUGand no--device-debug.(B=16, s_q=4, KV=4127)measured +2.15%. These publication checks are separate from the fallback comparison above; no new speedup is claimed from formatting or rebasing.The all-tests checkbox remains open pending PR CI: the full repository suite and full default AOT matrix were not rerun locally. Release validation explicitly used
FLASHINFER_JIT_DEBUG=0.November 15, 2026 rebase verification
dots3_swa_perfonto upstreammainat67d996c0a454cf975e91fd97dcce457b4a54b202; the new head is1c0d86e2322eb2d8ac7a63c0adabdda2072498e5.git range-diffreports an identical patch, and SHA-256 checks confirm that all 24 files changed by this PR are byte-for-byte identical to the previously validated publication tree. The CUTLASS and CCCL submodule revisions are unchanged as well.git diff --checkand Python AST parsing of the three modified Python files passed after rebasing.🔬 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
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Added an additional SM90 attention tactic, expanding the available options from six to seven.
Added cooperative execution for eligible workloads, with existing execution paths used when cooperative execution is unavailable.
Updated default tactic selection and tuning to include the new option.
Bug Fixes
Updated SM90 shared-memory requirements and improved coverage for correctness across tactics and context lengths.
Documentation
Updated SM90 requirements, tactic options, and execution behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->