[Bugfix][Attention] Fall back to native FlashInfer decode when XQA cannot serve a KV-cache group's head_dim - #53111
Merged
Conversation
…nnot serve a KV-cache group's head_dim
FlashInfer's dedicated XQA decode API accepts head dimensions in [16, 256]
that are divisible by 16. Hybrid-attention models such as Gemma 4 combine
sliding-attention groups at head_dim=256 with global-attention groups at
head_dim=512. The decode kernel was resolved once per metadata builder, so a
single ineligible group made the engine unstartable:
ValueError: Invalid head_dim: 512, must be divisible by 16 and in
range [16, 256]
raised from profile_cudagraph_memory() during determine_available_memory().
Resolve XQA eligibility per KV-cache group instead, mirroring the existing
DCP guard immediately below: ineligible groups revert to native FlashInfer
decode while eligible groups keep XQA.
Co-authored-by: Andrii Skliar <askliar@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Stefano Castagnetta <scastagnetta@nvidia.com>
stecasta
requested review from
mgoin,
pavanimajety and
vadiklyutiy
as code owners
August 20, 2026 13:24
Member
|
/ci run |
|
✅ @stecasta, CI is now available for this PR.
|
|
✅ Triggered Buildkite CI #85019 for commit |
mgoin
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Serving a hybrid-attention model with the FlashInfer TRTLLM/XQA decode path crashes at engine init:
raised from
profile_cudagraph_memory()duringdetermine_available_memory().The dedicated FlashInfer XQA decode API accepts head dimensions in
[16, 256]that are divisible by 16. Gemma 4 is a hybrid-attention model that combines sliding-attention groups athead_dim=256with global-attention groups athead_dim=512.FlashInferMetadataBuilderresolves the decode kernel once, so a single group the XQA API cannot serve makes the server unstartable instead of degrading to a supported kernel.This became reachable on SM12x via #49718, which enabled the dedicated XQA decode path there. The same crash occurs on any platform where XQA is selected for such a model.
Fix
Resolve XQA eligibility per KV-cache group. When the resolved kernel is XQA and a group's
head_dimfalls outside the supported range, that group reverts to native FlashInfer decode and warns once. Eligible groups keep XQA. This mirrors the existing DCP guard immediately below in the same function.Reproducer
vllm serve nvidia/Gemma-4-26B-A4B-NVFP4 \ --attention-backend FLASHINFER \ --attention-config '{"use_trtllm_attention": true}' \ --kv-cache-dtype fp8 --max-model-len 262144 --language-model-onlyBefore:
ValueError: Invalid head_dim: 512at startup. After: the server starts, the log records the fallback, and the sliding-attention groups still run XQA.Testing
Hardware: RTX PRO 6000 Blackwell Max-Q (SM120), FlashInfer 0.6.16.post3.
Backend selection confirmed from the serve log, showing both kernels in use as intended:
End-to-end benchmark at ISL 150k / OSL 4k / concurrency 1:
TRITON_ATTNbaselineLint:
pre-commit run --files vllm/v1/attention/backends/flashinfer.pypasses, includingmypy-3.10.No new unit test is included. The guard lives in
FlashInferMetadataBuilder.__init__, and the sibling DCP guard directly below it is likewise untested. Happy to add coverage if reviewers prefer.Why this is not a duplicate
Searched open issues and PRs for XQA/head_dim, FlashInfer head_dim, and Gemma attention. #48162 routes backends at batch level, which is orthogonal to per-KV-cache-group kernel eligibility. No open PR addresses the head_dim gate.
AI assistance
AI assistance (Claude) was used to diagnose the failure, locate the fix, and prepare this PR, as disclosed in the commit trailers.