Fixing flex attention for torch=2.6.0#37285
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.
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
There was a problem hiding this comment.
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.
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 <48595927+ArthurZucker@users.noreply.github.com>
* adding compile kwarg for torch 2.6 * fixing dynamic * addressing comment * typo * Update src/transformers/integrations/flex_attention.py --------- Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
* adding compile kwarg for torch 2.6 * fixing dynamic * addressing comment * typo * Update src/transformers/integrations/flex_attention.py --------- Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
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