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 support for async checkpointing #13658

Merged
merged 24 commits into from
Jul 26, 2022
Merged

Add support for async checkpointing #13658

merged 24 commits into from
Jul 26, 2022

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented Jul 14, 2022

What does this PR do?

Fixes #11561

Does your PR introduce any breaking changes? If yes, please list them.

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 minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the 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 🙃

cc @Borda @awaelchli @ananthsub @ninginthecloud @rohitgr7 @otaj @akihironitta

@rohitgr7 rohitgr7 added feature Is an improvement or enhancement checkpointing Related to checkpointing labels Jul 14, 2022
@rohitgr7 rohitgr7 added this to the pl:1.7 milestone Jul 14, 2022
@rohitgr7 rohitgr7 marked this pull request as ready for review July 15, 2022 14:46
src/pytorch_lightning/plugins/io/checkpoint_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/torch_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/torch_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/strategies/strategy.py Outdated Show resolved Hide resolved
src/pytorch_lightning/utilities/cloud_io.py Outdated Show resolved Hide resolved
@rohitgr7
Copy link
Contributor Author

after discussion with @carmocca

the design

class AsyncCheckpointIO(CheckpointIO):
    def __init__(self, checkpoint_io=None):
        self._checkpoint_io = checkpoint_io

    @setter
    def checkpoint_io(...):
        ...

    def save_checkpoint(self, checkpoint, filepath)
        async_launch(self._checkpoint_io.save_checkpoint, checkpoint, filepath)

and in the Trainer, the user can just pass

Trainer(plugins=[AsyncCheckpointIO()])

we will attach the appropriate checkpoint if not already attached. This will enable async checkpointing for existing plugins by providing async behavior without any code modification.

@rohitgr7 rohitgr7 changed the base branch from master to fix/ckpt_strat July 21, 2022 12:26
@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jul 21, 2022
@rohitgr7 rohitgr7 marked this pull request as draft July 21, 2022 13:41
@rohitgr7 rohitgr7 marked this pull request as ready for review July 21, 2022 19:42
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/async_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/checkpoint_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/async_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/wrapper.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/wrapper.py Show resolved Hide resolved
src/pytorch_lightning/plugins/io/wrapper.py Show resolved Hide resolved
@rohitgr7 rohitgr7 requested review from carmocca and removed request for SeanNaren July 25, 2022 10:38
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
docs/source-pytorch/common/checkpointing_expert.rst Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/async_plugin.py Outdated Show resolved Hide resolved
src/pytorch_lightning/plugins/io/checkpoint_plugin.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Jul 25, 2022
@rohitgr7 rohitgr7 enabled auto-merge (squash) July 25, 2022 19:30
@codecov
Copy link

codecov bot commented Jul 26, 2022

Codecov Report

Merging #13658 (c129206) into master (6a9d626) will decrease coverage by 10%.
The diff coverage is 82%.

@@            Coverage Diff            @@
##           master   #13658     +/-   ##
=========================================
- Coverage      86%      76%    -10%     
=========================================
  Files         330      332      +2     
  Lines       25973    26048     +75     
=========================================
- Hits        22266    19808   -2458     
- Misses       3707     6240   +2533     

@rohitgr7 rohitgr7 merged commit faf7ff5 into master Jul 26, 2022
@rohitgr7 rohitgr7 deleted the feat/async_ckpt branch July 26, 2022 15:43
@awaelchli
Copy link
Contributor

Great work @rohitgr7!!

@rohitgr7
Copy link
Contributor Author

Thanks @awaelchli @carmocca @otaj for great reviews and discussion.

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 pl Generic label for PyTorch Lightning package ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asynchronous checkpointing
5 participants