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 CPU error always being raised #1175

Merged
merged 4 commits into from
Mar 10, 2023
Merged

Fix CPU error always being raised #1175

merged 4 commits into from
Mar 10, 2023

Conversation

muellerzr
Copy link
Collaborator

Turns out I've discovered a neat behavior in the library, that was "broken" with the State rewrite. With how Accelerate will work, if the user defines cpu=False initially then goes cpu=True, then a value error will be raised and the state will be changed. But if cpu=True is passed first then cpu=False, nothing will change and no error will be raised. The reason for this is simply because its the default and its a way for State to not override the first choice, so we assume CPU all the time.

Also brings back the ACCELERATE_USE_CPU env flag, as this was removed in the State refactor.

This brings back this behavior and adds a test to the AcceleratorTester class.

Closes #1174

@muellerzr muellerzr added the bug Something isn't working label Mar 10, 2023
@muellerzr muellerzr requested a review from sgugger March 10, 2023 14:57
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 10, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@muellerzr muellerzr merged commit 3ca8c9a into main Mar 10, 2023
@muellerzr muellerzr deleted the fix-cpu branch March 10, 2023 15:22
sgugger pushed a commit that referenced this pull request Mar 13, 2023
* Save state

* Revert to old behavior

* Fix failing test/update

* Remove duplicate test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accelerate.prepare fails on optimizer prepare when forcing CPU
3 participants