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

Add in checkpointing capability #255

Merged
merged 30 commits into from
Mar 2, 2022
Merged

Add in checkpointing capability #255

merged 30 commits into from
Mar 2, 2022

Conversation

muellerzr
Copy link
Collaborator

Closes #171

This PR adds in two functions, Accelerator.save_state and Accelerator.load_state, which will go through and checkpoint the current state of everything accelerator touches.

I've included a testing script, but this needs to be properly turned into a test, as currently it is just a script with a bunch of asserts. I have tested successfully on:

  • Single GPU
  • Single CPU
  • Multi-GPU

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 a lot for working on this! I've left a few comments on the general API and some nits. The most important thing is to figure out how to save the LR scheduler with the rest :-)

src/accelerate/accelerator.py Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
muellerzr and others added 2 commits February 18, 2022 09:55
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
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 a lot for continuing your work on this. Just left some nits and one last comment on the test you added, then we can merge this!

src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
tests/test_state_checkpointing.py Outdated Show resolved Hide resolved
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.

Add utility function to save/load all models/optimizers stored in an accelerator
2 participants