Skip to content

[Attention] Add FlashInfer XQA decode support on SM12x - #49718

Merged
pavanimajety merged 12 commits into
vllm-project:mainfrom
askliar:askliar/xqa-full-features
Aug 11, 2026
Merged

pavanimajety merged 12 commits into
vllm-project:mainfrom
askliar:askliar/xqa-full-features

Conversation

@askliar

@askliar askliar commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable FlashInfer XQA decode on SM120/SM121 through FlashInfer's dedicated XQA API.

  • Select XQA for SM12x decode.
  • Support uniform and ragged speculative decode through q_len_per_req and q_cu_seq_lens.
  • Build the packed causal or non-causal draft mask required by XQA.
  • Support sliding-window decode, attention sinks, non-causal draft attention, and uniform-batch CUDA graphs on SM12x.
  • Keep the existing SM90 shared-XQA path and SM100 trtllm-gen path unchanged.
  • Align the Python, cubin, JIT-cache, and Docker pins on FlashInfer 0.6.16.post1.

Dependency

This PR requires FlashInfer 0.6.16.post1, which includes the required upstream support from flashinfer#4137 and flashinfer#4199. The Python, cubin, and CUDA-specific JIT-cache artifacts are available in the release.

Scope

This is not a duplicate of #47306 or #37592. Those drafts target the legacy shared decode API and older FlashInfer/base revisions; this PR is limited to SM12x and targets the dedicated 0.6.16.post1 XQA API.

SM90 enhancements and SM100 changes are intentionally excluded and will be handled separately.

SM12x NVFP4 KV-cache support is also out of scope and should build on this PR through #49818.

Validation

pre-commit run --files docker/Dockerfile docker/versions.json requirements/cuda.txt tests/kernels/attention/test_use_trtllm_attention.py tests/v1/attention/test_attention_backends.py vllm/utils/flashinfer.py vllm/v1/attention/backends/flashinfer.py

.venv/bin/python -m pytest tests/kernels/attention/test_use_trtllm_attention.py -q
.venv/bin/python -m pytest tests/v1/attention/test_attention_backends.py::test_flashinfer_xqa_draft_masks tests/v1/attention/test_attention_backends.py::test_flashinfer_xqa_query_lens_preserve_cudagraph_padding tests/v1/attention/test_attention_backends.py::test_flashinfer_xqa_query_lens_require_exact_uniform_product tests/v1/attention/test_attention_backends.py::test_flashinfer_xqa_decode_correctness -q
  • Pre-commit passed, including Ruff, formatting, mypy, dependency compilation, and Docker version consistency.
  • The focused pytest commands could not run in the current checkout because its local .venv is absent; no local CUDA runtime is available.
  • SM121 validation confirmed decode_backend=xqa and GSM8K at concurrency 64: 0.8764 flexible / 0.8749 strict. A concurrency-1 run exposed the CUDA-graph padding mismatch addressed by the current q_cu_seq_lens handling; that fix still needs a post-change GPU rerun.

AI assistance was used to prepare this pull request.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork β€” automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@askliar
askliar marked this pull request as draft July 24, 2026 12:14
@mergify

mergify Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @askliar.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 25, 2026
Use FlashInfer’s dedicated XQA API on SM90 and SM12x. Enable uniform and ragged speculative decode, non-causal draft masks, attention sinks, and uniform-batch CUDA graphs.

Pin FlashInfer 0.6.16, which provides the required public API.

Assisted-by: OpenAI Codex
Signed-off-by: Andrii Skliar <askliar@nvidia.com>
@askliar
askliar force-pushed the askliar/xqa-full-features branch from 68a4297 to 69bdc0c Compare July 29, 2026 10:45
@mergify mergify Bot added the ci/build label Jul 29, 2026
@askliar askliar changed the title WIP: Add XQA into vLLM [Attention] Add FlashInfer XQA decode support Jul 29, 2026
@mergify mergify Bot removed the needs-rebase label Jul 29, 2026
@askliar
askliar marked this pull request as ready for review July 29, 2026 11:00
@askliar
askliar requested review from Harry-Chen and khluu as code owners July 29, 2026 11:00

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork β€” automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Andrii Skliar and others added 3 commits July 29, 2026 13:08
FlashInfer fixed the FP8-Q sliding-window prefill hang in vllm-project#3682, and the fix is included in the pinned dependency.

Assisted-by: OpenAI Codex
Signed-off-by: Andrii Skliar <askliar@nvidia.com>
Account for CUDA-graph padding in ragged XQA offsets, vectorize draft masks, keep DCP graph support conservative, and validate native sink prefill.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Andrii Skliar <askliar@nvidia.com>
Keep CUDA-graph padding as zero-length ragged requests and require an exact token product before using uniform XQA metadata.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Andrii Skliar <askliar@nvidia.com>

Copy link
Copy Markdown

SM12x NVFP4 integration note

This PR's SM12x XQA routing and the NVFP4 enablement in #49818 are complementary, but they overlap in vllm/utils/flashinfer.py and vllm/v1/attention/backends/flashinfer.py and will need an explicit integration order.

The current revision here enables XQA for SM90/SM12x only when kv_cache_dtype.startswith("fp8"). Its NVFP4 initialization still requires both TRTLLM prefill and decode support, and the wrapper path still treats NVFP4 as trtllm-gen-only. Therefore this PR does not enable SM120 NVFP4 KV.

The accompanying claim that XQA does not support NVFP4 KV needs narrowing. FlashInfer 0.6.15's XQA implementation has an SM120 NVFP4-KV path. #49818 carries the additional vLLM-side pieces required to reach it safely:

That layout point is load-bearing on RTX 5090: current-main gates without it produced token-id-0 collapse 5/5, while changing only the NVFP4 layout produced 5/5 correct; the resulting branch also passed 8/8 concurrency with a 13,158-token needle. The fuller masked-XQA validation behind #49010 passed 3/3 cold and 3/3 cached ~31k needles under true FULL MTP, with mask rows 1, 3, 7, 15 for q_len=4.

Suggested split: keep this PR as the generic XQA API/mask/cudagraph foundation, then rebase/compose #49818's distinct SM120 NVFP4 contract and layout changes on top. I can run the integrated revision on RTX 5090 once the required FlashInfer 0.6.16 artifacts are available. Related root-cause trail: #49010, #49011, #49818.

Disclosure per AGENTS.md: this diff audit and comment were AI-assisted. The cited hardware runs and measurements were produced and verified by me.

@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @askliar.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

randomvariable added a commit to randomvariable/vllm that referenced this pull request Aug 13, 2026
randomvariable added a commit to randomvariable/vllm that referenced this pull request Aug 13, 2026
… SM12x

- flashinfer-jit-cache pyproject.toml: add filelock to build-system.requires
  (build backend imports flashinfer which imports filelock)
- Remove Dockerfile system-Python workaround now that pyproject carries it
- Revert vllm-project#49718 (XQA decode SM12x) per upstream vllm-project#51987: GPQA eval on DGX
  Spark produced gibberish (1081 harmony parse errors vs 0 baseline)
randomvariable added a commit to randomvariable/vllm that referenced this pull request Aug 13, 2026
randomvariable added a commit to randomvariable/vllm that referenced this pull request Aug 13, 2026
Replaces the XQA SM12x revert (vllm-project#51987) with the proper fix from
vllm-project#52148: when a model has attention sinks on SM12x,
route prefill through BatchAttentionWithAttentionSinkWrapper instead
of the plain BatchPrefillWithPagedKVCacheWrapper. The original XQA
decode path (vllm-project#49718) is restored.
randomvariable added a commit to randomvariable/vllm that referenced this pull request Aug 19, 2026
…-project#49718)"

This reverts commit 74f483d690363647a5d5e2f52c5372ba94f52ae4.
@Suppressor72

Copy link
Copy Markdown

Thanks for the XQA + ragged q_cu foundation β€” we built conditional device/CPU query-length-mismatch support for adaptive verification directly on top of it (SM120, validated locally): details and measurements in our comment on #51303, branch here.

michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…49718)

Signed-off-by: Andrii Skliar <askliar@nvidia.com>
Signed-off-by: Andrii Skliar <andreyws96@gmail.com>
Co-authored-by: Andrii Skliar <askliar@nvidia.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants