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 save_weights_only flag in ModelCheckpoint #1780

Merged

Conversation

kepler
Copy link
Contributor

@kepler kepler commented May 11, 2020

ModelCheckpoint then passes self.save_weights_only to the save function.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Fixes #427.

PR review

Anyone in the community is free to review the PR once the tests have passed.

@mergify mergify bot requested a review from a team May 11, 2020 14:02
@kepler
Copy link
Contributor Author

kepler commented May 11, 2020

I patched the dump_checkpoint and save_checkpoint methods in TrainerIOMixin to include a weights_only flag, which defaults to False and so should be backwards compatible.

One alternative would be to read the flag from self.checkpoint_callback inside dump_checkpoint, but I find it sub-optimal (for a few reasons).

What's missing is verifying the loading side of things, regarding whether some error handling is necessary.

@Borda Borda added bug Something isn't working priority: 0 High priority task labels May 11, 2020
@Borda Borda added this to the 0.7.6 milestone May 11, 2020
@kepler kepler force-pushed the 427-fix-saving-only-model-weigths branch from 0dd2622 to 732c8ce Compare May 12, 2020 13:38
@kepler kepler marked this pull request as ready for review May 12, 2020 13:39
@kepler kepler changed the title [WIP] Fix save_weights_only flag in ModelCheckpoint Fix save_weights_only flag in ModelCheckpoint May 12, 2020
@Borda Borda modified the milestones: 0.7.6, 0.8.0 May 12, 2020
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

the GH diff is strange it makes the same code as change..

tests/trainer/test_trainer.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/training_io.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/training_io.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/training_io.py Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team May 12, 2020 21:42
@mergify
Copy link
Contributor

mergify bot commented May 13, 2020

This pull request is now in conflict... :(

kepler and others added 5 commits May 14, 2020 11:21
`ModelCheckpoint` then passes `self.save_weights_only` to the save function.
…m a weights only checkpoint

Also add a test for making sure `ModelCheckpoint.save_weights_only` works as expected.
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
@kepler kepler force-pushed the 427-fix-saving-only-model-weigths branch from 53416fb to 45b679b Compare May 14, 2020 10:25
@codecov
Copy link

codecov bot commented May 14, 2020

Codecov Report

Merging #1780 into master will increase coverage by 0%.
The diff coverage is 95%.

@@          Coverage Diff           @@
##           master   #1780   +/-   ##
======================================
  Coverage      88%     88%           
======================================
  Files          71      71           
  Lines        4458    4461    +3     
======================================
+ Hits         3915    3918    +3     
  Misses        543     543           

@Borda Borda modified the milestones: 0.8.0, 0.7.7 May 15, 2020
@williamFalcon williamFalcon added the ready PRs ready to be merged label May 17, 2020
@williamFalcon
Copy link
Contributor

@kepler thanks, this is great!

@mergify mergify bot requested a review from a team May 17, 2020 13:07
@williamFalcon williamFalcon merged commit 8c4c7b1 into Lightning-AI:master May 17, 2020
@Borda Borda modified the milestones: 0.7.7, 0.8.0 May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: 0 High priority task ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

save_weights_only parameter in ModelCheckpoint class look like doesn't work
3 participants