transformers - ✅(Solved) Fix Incorrect PyTorch version check for AuxRequest import in flex_attention [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#45446Fetched 2026-04-17 08:22:50
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #45445: Update Torch version check for flex attention

Description (problem / solution / changelog)

This commit corrects the PyTorch version check for importing AuxRequest from torch.nn.attention.flex_attention(line51). 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. You can view the introduced version of AuxRequest at https://docs.pytorch.org/docs/2.9/nn.attention.flex_attention.html. Fixes #45446

Changed files

  • src/transformers/integrations/flex_attention.py (modified, +1/-1)

Code Example

import torch

#This will fail in PyTorch 2.9.0
from torch.nn.attention.flex_attention import AuxRequest
RAW_BUFFERClick to expand / collapse

System Info

In src/transformers/integrations/flex_attention.py, the code currently checks for PyTorch version >= 2.9.0 to import AuxRequest from torch.nn.attention.flex_attention. However, AuxRequest was actually introduced in PyTorch 2.9.1. According to the official PyTorch documentation, AuxRequest is available starting from version 2.9.1:https://docs.pytorch.org/docs/2.9/nn.attention.flex_attention.html.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import torch

#This will fail in PyTorch 2.9.0
from torch.nn.attention.flex_attention import AuxRequest

Expected behavior

The version check should be updated to >= 2.9.1 to ensure compatibility with PyTorch 2.9.0.

extent analysis

TL;DR

Update the PyTorch version check in flex_attention.py to require version 2.9.1 or higher to correctly import AuxRequest.

Guidance

  • Verify the PyTorch version being used by checking the documentation or running torch.__version__ in Python.
  • Update the version check in src/transformers/integrations/flex_attention.py to >= 2.9.1 to ensure compatibility.
  • Test the updated code with PyTorch version 2.9.1 or higher to confirm the fix.
  • If using PyTorch 2.9.0, consider upgrading to a compatible version to use AuxRequest.

Example

import torch

# Check PyTorch version
if torch.__version__ >= '2.9.1':
    from torch.nn.attention.flex_attention import AuxRequest
else:
    print("PyTorch version 2.9.1 or higher required for AuxRequest")

Notes

This fix assumes that the only issue is the incorrect version check and that AuxRequest is correctly used in the code.

Recommendation

Apply workaround: Update the version check to >= 2.9.1 to ensure compatibility with PyTorch versions that support AuxRequest.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The version check should be updated to >= 2.9.1 to ensure compatibility with PyTorch 2.9.0.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

transformers - ✅(Solved) Fix Incorrect PyTorch version check for AuxRequest import in flex_attention [1 pull requests, 1 comments, 1 participants]