From 7af0112dbb3785326a39dc3cb76d8279191741c1 Mon Sep 17 00:00:00 2001 From: Zeng Shenglin <142322697+ZSLsherly@users.noreply.github.com> Date: Wed, 15 Apr 2026 11:03:14 +0800 Subject: [PATCH] Update Torch version check for flex attention This commit corrects the PyTorch version check for importing `AuxRequest` from `torch.nn.attention.flex_attention`. The `AuxRequest` class was actually introduced in PyTorch 2.9.1, not 2.9.0. The current code attempts to import it for any version >= 2.9.0, which causes an `ImportError` in PyTorch 2.9.0 environments. --- src/transformers/integrations/flex_attention.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/integrations/flex_attention.py b/src/transformers/integrations/flex_attention.py index 91247b035b88..f109a6a3ec12 100644 --- a/src/transformers/integrations/flex_attention.py +++ b/src/transformers/integrations/flex_attention.py @@ -40,7 +40,7 @@ ) -_TORCH_FLEX_USE_AUX = is_torch_greater_or_equal("2.9.0") +_TORCH_FLEX_USE_AUX = is_torch_greater_or_equal("2.9.1") if is_torch_flex_attn_available():