perf(attention): e4m3-query FA2 tensor-core decode on SM120 #6574
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
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.02 · 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.344
Real PR Conversation Timeline
1 comments
"Review active on #6574"
general
weight: 0.35
lesj0610
<!-- .github/pull_request_template.md -->
📌 Description
FA2 tensor-core decode now takes an e4m3 query over an e4m3 KV cache. Q·Kᵀ and P·V both run on m16n8k32 e4m3 MMA, so no K or V element is converted to bf16. The softmax uses the VO-split layout, here from head_dim_vo 256: each KV warp stages its probabilities in shared memory as e4m3 words (P × 256) and multiplies the whole 64-token tile into its own 64-dim output slice. A thread then keeps 32 output accumulators instead of 128, and no cross-warp output merge is needed. The denominator stays the fp32 cross-warp sum. The query scale reaches the kernel the existing way,
run(q_scale=...)folded intosm_scale.The query dtype is part of the JIT module key, so bf16 and fp16 query modules do not change; their SASS matches the merge base. The ragged kernel is not instantiated for an e4m3 query.
plan()accepts an e4m3 query only where it was validated: SM120, single-token decode, e4m3 KV cache, bf16 output, head_dim 256, no RoPE or soft cap, and 1, 2, 4 or 8 query heads per KV head. Anything else raisesNotImplementedError, andfast_decode_plan()rejects multi-token requests for this query.🔍 Related Issues
The FA3 and trtllm-gen paths already take an fp8 query; FA2 did not.
🚀 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 --files <changed files>and fixed any reported issues.🧪 Tests
unittest, etc.).test_tensor_core_decode_fp8_querycompares the e4m3-query decode against the bf16-query decode on the same query values (q_scale 0.5, exact in bf16), for 1, 2, 4 and 8 query heads per KV head. All four pass on SM120; the test is skipped elsewhere.Further checks on one SM120 GPU (16 query heads, 8 KV heads, head_dim 256, e4m3 KV with k/v scales):
| Comparison | Profile 1 | Profile 2 |
|---|---|---|
| e4m3 query / bf16 query (this decode) | 0.963 | 0.962 |
| e4m3 query / vLLM Triton unified attention, both given a pre-quantized query | 0.961 | 0.960 |
| The same, both quantizing the query inside the call | 0.962 | 0.962 |
The e4m3 query was faster than the bf16 query at every batch size.
🔬 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
<!-- Optional: anything you'd like reviewers to focus on, concerns, etc. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added support for FP8 E4M3 queries in FlashAttention 2 batch prefill when the query and KV cache use the matching format.
Added support for FP8 E4M3 queries in paged prefill on SM120 when the query and KV cache use the matching format.
Added support for FP8 E4M3 queries in tensor-core decode on SM120, with BF16 outputs and query-to-KV head ratios of 1, 2, 4, or 8. Decode is limited to single-token queries and supported attention configurations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->