feat(prims-ts): add mxfp8 output quant fusion to context and decode #9618
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
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 #9618"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Adds MXFP8 output to the prims-ts context and decode kernels.
API Changes
BatchPrefillTSWrapper.plan,BatchPrefillPagedTSWrapper.planandBatchDecodePagedTSWrapper.plantakeout_dtype=torch.float8_e4m3fntogether without_scale_dtype=torch.float8_e8m0fnu(torch.uint8is accepted as an alias).run(out_scale=...)returns(out, out_scale[, lse]).batch_prefill,batch_prefill_with_paged_kv_cacheandbatch_decode_with_paged_kv_cachetakeout_scale=, and the scale buffer's dtype selects the format.get_prims_ts_batch_decode_workspace_size(out_scale_dtype=...)sizes the quantized plan.round_up(tokens, 128) round_up(Hq Dv / 32, 4)bytes in the 128x4 swizzled layout of the block-scaled GEMMs, the same layout asmxfp8_quantize(..., is_sf_swizzled_layout=True). Padding entries are never written.(out_dtype, out_scale_dtype)inprims_ts/_quant_output.py, currently only having mxfp8.Performance
Tested on B300
32 Q Heads, 4 Kv heads, non-sliding window
| KV | Batch | Fused (µs) | Unfused (µs) | Speedup |
|:---:|:-----:|:----------:|:------------:|:-------:|
| 1K | 1 | 6.21 | 7.90 | 1.27× |
| 1K | 8 | 6.50 | 8.51 | 1.31× |
| 1K | 32 | 9.44 | 11.30 | 1.20× |
| 1K | 128 | 24.90 | 27.20 | 1.09× |
| 1K | 512 | 81.38 | 85.09 | 1.05× |
| 1K | 2048 | 309.4 | 319.3 | 1.03× |
| 1K | 8192 | 1221 | 1254 | 1.03× |
| 8K | 1 | 7.39 | 8.96 | 1.21× |
| 8K | 8 | 15.04 | 17.02 | 1.13× |
| 8K | 32 | 42.30 | 44.64 | 1.06× |
| 8K | 128 | 158.0 | 161.0 | 1.02× |
| 8K | 512 | 606.9 | 611.6 | 1.01× |
| 8K | 2048 | 2381 | 2394 | 1.01× |
| 8K | 8192 | 9495 | 9534 | 1.00× |
| 32K | 1 | 12.13 | 13.76 | 1.13× |
| 32K | 8 | 44.53 | 46.72 | 1.05× |
| 32K | 32 | 155.2 | 157.3 | 1.01× |
| 32K | 128 | 608.6 | 610.9 | 1.00× |
| 32K | 512 | 2401 | 2406 | 1.00× |
| 32K | 2048 | 9480 | 9486 | 1.00× |
32 Q Heads, 4 Kv heads, sliding window 128
| KV | Batch | Fused (µs) | Unfused (µs) | Speedup |
|:--:|:-----:|:----------:|:------------:|:-------:|
| 8K | 1 | 5.04 | 6.69 | 1.33× |
| 8K | 8 | 5.41 | 7.49 | 1.38× |
| 8K | 32 | 5.86 | 7.90 | 1.35× |
| 8K | 128 | 10.69 | 11.68 | 1.09× |
| 8K | 512 | 27.30 | 24.42 | 0.89× |
| 8K | 2048 | 93.70 | 78.08 | 0.83× |
| 8K | 8192 | 359.4 | 290.0 | 0.81× |
🔍 Related Issues
<!-- Link any related issues here -->
🚀 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/...🔬 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 -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Context and decode attention support block-scaled MXFP8 outputs with optional scale buffers.
Select a supported scale format, provide a compatible buffer, or let the API allocate one. Quantized calls return the output and scales, with log-sum-exp included when requested.
Support is limited to compatible attention configurations; quantized output is unavailable for some input and attention modes.
Documentation
Added guidance on scale layout, buffer sizing, graph capture, and supported configurations.
Known Limitations
Attention tracing does not support quantized outputs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->