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

Introduce CheckpointIO Plugin #8743

Merged
merged 40 commits into from
Aug 13, 2021
Merged

Introduce CheckpointIO Plugin #8743

merged 40 commits into from
Aug 13, 2021

Conversation

SeanNaren
Copy link
Contributor

@SeanNaren SeanNaren commented Aug 5, 2021

What does this PR do?

Closes #8118.

This is a V0 where we've abstracted the checkpointing logic into a class that eventually can be plugged in via the trainer.

Few outstanding issues that I'll tag throughout the PR!

The goal is to be able to do this:

trainer = Trainer(DDPPlugin(checkpoint_plugin=MyCustomCheckpointIO()))

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Aug 5, 2021

Hello @SeanNaren! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-08-13 11:28:41 UTC

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

I like this idea <3

pytorch_lightning/plugins/training_type/deepspeed.py Outdated Show resolved Hide resolved
@awaelchli awaelchli added checkpointing Related to checkpointing feature Is an improvement or enhancement labels Aug 5, 2021
@codecov
Copy link

codecov bot commented Aug 6, 2021

Codecov Report

Merging #8743 (8f234e0) into master (b47e3ab) will increase coverage by 0%.
The diff coverage is 91%.

@@          Coverage Diff           @@
##           master   #8743   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files         169     172    +3     
  Lines       14061   14148   +87     
======================================
+ Hits        13033   13118   +85     
- Misses       1028    1030    +2     

@SeanNaren
Copy link
Contributor Author

My plan:

  1. Ensure all the tests pass
  2. Add tests for checkpoint plugin as stands
  3. Investigate if we can rely on the checkpoint plugin to run the rm that happens in the ModelCheckpoint callback, and some of the other fspec calls

@SeanNaren SeanNaren changed the title Introduce CheckpointPlugin Introduce CheckpointIOPlugin Aug 9, 2021
@awaelchli
Copy link
Contributor

@ananthsub Maybe marking it experimental in changelog + docstring of plugin class?

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

thanks @SeanNaren
looks like a great addition

tests/plugins/test_checkpoint_io_plugin.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/checkpoint.py Outdated Show resolved Hide resolved
tests/plugins/test_checkpoint_io_plugin.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Aug 12, 2021
@SeanNaren
Copy link
Contributor Author

general question: though this is brand new, how should we communicate that it's experimental and the API might change before the next release? asking for developers who work off master

as @awaelchli suggested I'll add some docstrings, however I also think this should go into the docs just like other features we have for discoverability. Would people be against this?

pytorch_lightning/plugins/checkpoint/checkpoint.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/checkpoint.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/checkpoint.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/checkpoint.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/torch.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/checkpoint/torch.py Outdated Show resolved Hide resolved
@SeanNaren SeanNaren changed the title Introduce CheckpointIOPlugin Introduce CheckpointIO Plugin Aug 13, 2021
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

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

awesome work @SeanNaren !

@SeanNaren SeanNaren enabled auto-merge (squash) August 13, 2021 14:53
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

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

@bowangbj - the collective approach for #7534 should end up looking pretty similar to this i think

Copy link
Contributor

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

Awesome!

docs/source/advanced/checkpoint_io.rst Outdated Show resolved Hide resolved
pytorch_lightning/plugins/io/torch_plugin.py Outdated Show resolved Hide resolved
@SeanNaren SeanNaren disabled auto-merge August 13, 2021 15:31
@SeanNaren SeanNaren enabled auto-merge (squash) August 13, 2021 15:33
@SeanNaren SeanNaren merged commit b2973a0 into master Aug 13, 2021
@SeanNaren SeanNaren deleted the feat/ckpt_plugin branch August 13, 2021 16:35
four4fish pushed a commit to four4fish/pytorch-lightning that referenced this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkpointing Related to checkpointing feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Checkpointing in Lightning: Create a new CheckpointAgent interface for placing checkpointing logic
8 participants