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 should_rank_save_checkpoint property to Training Plugins #7684

Merged
merged 10 commits into from
May 25, 2021

Conversation

kaushikb11
Copy link
Contributor

@kaushikb11 kaushikb11 commented May 24, 2021

What does this PR do?

Fixes #7678
Related to link

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 update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
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 🙃

@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #7684 (54f331b) into master (8b01497) will decrease coverage by 5%.
The diff coverage is 94%.

@@           Coverage Diff           @@
##           master   #7684    +/-   ##
=======================================
- Coverage      93%     88%    -5%     
=======================================
  Files         199     199            
  Lines       12957   12960     +3     
=======================================
- Hits        11991   11371   -620     
- Misses        966    1589   +623     

@pep8speaks
Copy link

pep8speaks commented May 24, 2021

Hello @kaushikb11! Thanks for updating this PR.

Line 722:13: W503 line break before binary operator

Comment last updated at 2021-05-24 21:11:39 UTC

@kaushikb11 kaushikb11 self-assigned this May 24, 2021
@kaushikb11 kaushikb11 added design Includes a design discussion checkpointing Related to checkpointing refactor labels May 24, 2021
@kaushikb11 kaushikb11 marked this pull request as ready for review May 24, 2021 18:30
@awaelchli awaelchli added this to the v1.4 milestone May 24, 2021
@ananthsub
Copy link
Contributor

thanks for following up on this @kaushikb11 ! I requested changes because of possible inconsistencies that emerge from @rank_zero_only decorator usage in the callback vs using trainer.should_rank_save_checkpoint

@kaushikb11 kaushikb11 changed the title Add should_save_checkpoint property to Training Plugins Add should_rank_save_checkpoint property to Training Plugins May 24, 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.

@SeanNaren @shuyingsunshine21 i think this will also help with FSDP saving sharded state

pytorch_lightning/callbacks/model_checkpoint.py Outdated Show resolved Hide resolved
Comment on lines +100 to +103
@property
def should_rank_save_checkpoint(self) -> bool:
return self.accelerator.training_type_plugin.should_rank_save_checkpoint

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure it's okay adding a convenience function in the trainer for it?

Do you expect/allow users to use/rely on it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't expect it to be used by users, but for internal use.

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is that if it is for internal use, the property should be prepended by _.

It's ugly accessing an underscore attribute but we need a mechanism to avoid having to deprecate later.

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@kaushikb11 kaushikb11 merged commit e7057d5 into Lightning-AI:master May 25, 2021
@kaushikb11 kaushikb11 deleted the rank/modelcheckpoint branch May 25, 2021 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkpointing Related to checkpointing design Includes a design discussion refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove TPU training related logic from ModelCheckpointCallback
6 participants