Skip to content
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

Fix flex_attention in training mode #35605

Merged
merged 3 commits into from
Jan 10, 2025
Merged

Fix flex_attention in training mode #35605

merged 3 commits into from
Jan 10, 2025

Conversation

Cyrilvallez
Copy link
Member

@Cyrilvallez Cyrilvallez commented Jan 10, 2025

What does this PR do?

As per the title.
In training mode, the in-place operation would produce RuntimeError: FakeTensor is wrapped to wrong device, found cpu, expected cuda:1. It is however working when gradients are not required (i.e. with generate), which is the reason why it wasn't detected before.
I am not entirely sure what's happening behind the scene and the root of the issue, but switching to explicit operation fixes the issue.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Cyrilvallez Cyrilvallez merged commit ccc0381 into main Jan 10, 2025
26 checks passed
@Cyrilvallez Cyrilvallez deleted the fix-flex branch January 10, 2025 10:49
ArthurZucker pushed a commit that referenced this pull request Jan 10, 2025
@bursteratom
Copy link

thank you so much @ArthurZucker @Cyrilvallez ! I will test it out later today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants