Skip to content

[Bugfix] Avoid FlashAttention 3 with batch invariance on Hopper#48694

Open
dumko2001 wants to merge 3 commits into
vllm-project:mainfrom
dumko2001:fa3-batch-invariant-hopper
Open

[Bugfix] Avoid FlashAttention 3 with batch invariance on Hopper#48694
dumko2001 wants to merge 3 commits into
vllm-project:mainfrom
dumko2001:fa3-batch-invariant-hopper

Conversation

@dumko2001

@dumko2001 dumko2001 commented Jul 15, 2026

Copy link
Copy Markdown

Purpose

VLLM_BATCH_INVARIANT=1 still selected FlashAttention 3 on Hopper. That
breaks the determinism guarantee reported in #47069. Downgrade FA3 to FA2
when batch invariance is enabled on SM90, including an explicit FA3 request.
The FlashAttention MLA backends run FA3 on Hopper as well, so they now report
no batch-invariance support and the selector falls back to an invariant
backend.

Fixes #47069

Related work: I searched open and closed PR references for #47069 and found no
overlapping PR. AI assistance was used; I reviewed the changed code and the
validation results.

Test Plan

uv tool run ruff check repro/gpu_validate_fa3_batch_invariant.py
uv run --no-project python -m py_compile \
  repro/gpu_validate_fa3_batch_invariant.py
python repro/gpu_validate_fa3_batch_invariant.py

The GPU validation ran on an H100 SXM with CUDA 13.0 and the vLLM wheel from
commit 1ff942965. The script was run once with the stock wheel and once
after overlaying:

vllm/v1/attention/backends/fa_utils.py

Added a CPU unit test for the batch-invariant MLA backend gate. Its follow-up
commit stubs the CUDA extension modules so the selection check runs during
CPU-only collection.

Test Result

Unpatched:

FA_UTILS_VARIANT: UNPATCHED
FA_VERSION_BATCH_INVARIANT: 3

Patched:

FA_UTILS_VARIANT: PATCHED
FA_VERSION_BATCH_INVARIANT: 2
PASS: patched Hopper selection downgrades FA3 to FA2

The patched run also emitted the expected Hopper batch-invariance downgrade
warning. The varlen probe was not counted as a result. The first run skipped
it because the call used the wrong positional cu-seqlens signature; the probe
now passes the cu-seqlens as tensor keyword arguments.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Downgrade FlashAttention 3 to FlashAttention 2 on SM90 when batch invariance is enabled.

Fixes vllm-project#47069

Co-authored-by: Devin AI <noreply@devin.ai>

Signed-off-by: Sidharth Rajmohan <dumko.raj@gmail.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@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.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@mergify mergify Bot added v1 bug Something isn't working labels Jul 15, 2026
@devin-ai-integration devin-ai-integration Bot force-pushed the fa3-batch-invariant-hopper branch from 7946e52 to 418b42c Compare July 15, 2026 06:26

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7946e525a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vllm/v1/attention/backends/fa_utils.py
Signed-off-by: Sidharth Rajmohan <dumko.raj@gmail.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Sidharth Rajmohan <dumko.raj@gmail.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Concurrent temperature=0 non-determinism in vLLM, FLASH_ATTN batch-invariant path on Hopper

1 participant