Skip to content

Commit 7946e52

Browse files
committed
fix(attention): avoid FA3 with batch invariance on Hopper
Downgrade FlashAttention 3 to FlashAttention 2 on SM90 when batch invariance is enabled. Fixes #47069 Co-authored-by: Devin AI <noreply@devin.ai> Signed-off-by: Sidharth <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>
1 parent 1ff9429 commit 7946e52

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

vllm/v1/attention/backends/fa_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ def get_flash_attn_version(
171171
):
172172
fa_version = vllm_config.attention_config.flash_attn_version
173173

174+
if (
175+
envs.VLLM_BATCH_INVARIANT
176+
and device_capability.major == 9
177+
and fa_version == 3
178+
):
179+
logger.warning_once(
180+
"Cannot use FlashAttention 3 with batch invariance on "
181+
"Hopper; defaulting to FlashAttention 2."
182+
)
183+
fa_version = 2
184+
174185
# 3. fallback for unsupported combinations
175186
if device_capability.major >= 10 and fa_version == 3:
176187
logger.warning_once(

0 commit comments

Comments
 (0)