-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Fixing flex attention for torch=2.6.0 #37285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
if self._is_flex_compiled is False: | ||
self._compiled_flex_attention = torch.compile(flex_attention, dynamic=False) | ||
if not self._is_flex_compiled: | ||
if _torch_version == "2.6.0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment here to describe why this is the case, e.g. by linking to the issue with a small description?
Might be also nice to use/create something like
def is_torch_greater_or_equal(library_version: str, accept_dev: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on my end this should fix training!
Seems like the llama4 addition changed flex compilation #37307 😄 |
Flex was not working for decoding! |
if self._is_flex_compiled is False: | ||
self._compiled_flex_attention = torch.compile(flex_attention, dynamic=False) | ||
if not self._is_flex_compiled: | ||
if _torch_version == "2.6.0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on my end this should fix training!
* adding compile kwarg for torch 2.6 * fixing dynamic * addressing comment * typo * Update src/transformers/integrations/flex_attention.py --------- Co-authored-by: Arthur <[email protected]>
* adding compile kwarg for torch 2.6 * fixing dynamic * addressing comment * typo * Update src/transformers/integrations/flex_attention.py --------- Co-authored-by: Arthur <[email protected]>
* adding compile kwarg for torch 2.6 * fixing dynamic * addressing comment * typo * Update src/transformers/integrations/flex_attention.py --------- Co-authored-by: Arthur <[email protected]>
What does this PR do?
This PR fixes this issue originally raised in pytorch core pytorch/pytorch#146260 for flex attention on 2.6.0, by setting
mode="max-autotune-no-cudagraphs"
.Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@ArthurZucker