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

Support checkpoint hooks on data module #3563

Merged
merged 22 commits into from
Sep 29, 2020

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Sep 19, 2020

What does this PR do?

Solves #3544

  • Add a new class CheckpointHooks which both the LightningModule and LightningDataModule inherit
  • Call trainer.datamodule.on_{save/load}_checkpoint inside

I'd appreciate comments as to whether the order here matters for saving/loading. Ideally the checkpoint state is independent across data and model, but if there are cases where the model depends on the data, should we prefer to call one's save/load before the other?

TODO:

  • Add tests

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 your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Sep 19, 2020

Hello @ananthsub! Thanks for updating this PR.

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

Comment last updated at 2020-09-28 23:30:16 UTC

@ananthsub ananthsub changed the title Data ckpt Support checkpoint hooks on data module Sep 19, 2020
@mergify mergify bot requested a review from a team September 19, 2020 22:22
@mergify mergify bot requested a review from a team September 19, 2020 23:56
@ananthsub ananthsub force-pushed the data-ckpt branch 3 times, most recently from b20dc2c to f1f90b5 Compare September 20, 2020 01:47
@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2020

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

@ananthsub ananthsub force-pushed the data-ckpt branch 4 times, most recently from 5bb71e2 to 0a7346d Compare September 20, 2020 02:43
@codecov
Copy link

codecov bot commented Sep 20, 2020

Codecov Report

Merging #3563 into master will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #3563   +/-   ##
======================================
- Coverage      91%     91%   -0%     
======================================
  Files         110     110           
  Lines        8206    8211    +5     
======================================
- Hits         7463    7457    -6     
- Misses        743     754   +11     

@Borda Borda added the feature Is an improvement or enhancement label Sep 20, 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.

Can we pls stop using meaningless Black formatting, e.g replacing " and ' or inconsistently splitting argument lines... this makes the PR terribly long even for minimal changes
add to you your Black config -S

@mergify mergify bot requested a review from a team September 20, 2020 08:45
@mergify mergify bot requested review from a team September 20, 2020 08:59
ananthsub added a commit to ananthsub/pytorch-lightning that referenced this pull request Sep 20, 2020
Split out changes from Lightning-AI#3563 to make that PR easier to review
ananthsub added a commit to ananthsub/pytorch-lightning that referenced this pull request Sep 20, 2020
Split out changes from Lightning-AI#3563 to make that PR easier to review. This formats the file according to the Black formatter
ananthsub added a commit to ananthsub/pytorch-lightning that referenced this pull request Sep 20, 2020
Split out changes from Lightning-AI#3563 to make that PR easier to review. This formats the file according to the Black formatter
ananthsub added a commit to ananthsub/pytorch-lightning that referenced this pull request Sep 20, 2020
…view. This formats the file according to the Black formatter
williamFalcon pushed a commit that referenced this pull request Sep 27, 2020
* Split out changes from #3563 to make that PR easier to review. This formats the file according to the Black formatter

* Store a reference to the trainer on the datamodule

Fixes #3682

* Update data_connector.py

* Update data_connector.py

* Update test_datamodules.py
williamFalcon pushed a commit that referenced this pull request Sep 28, 2020
… more storage backends (#3694)

* Split out changes from #3563 to make that PR easier to review. This formats the file according to the Black formatter

* Store a reference to the trainer on the datamodule

Fixes #3682

* Update data_connector.py

* Update data_connector.py

* Update test_datamodules.py

* Support more storage backends in trainer.test using best weights

Similar to #3692

* Update trainer.py

* Update trainer.py

use cloud_io load directly
@mergify
Copy link
Contributor

mergify bot commented Sep 28, 2020

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

Copy link
Contributor

@nateraw nateraw left a comment

Choose a reason for hiding this comment

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

wrote up some local scripts to play around with this. it works as expected.

LGTM 🚀

@awaelchli awaelchli merged commit 3dcf713 into Lightning-AI:master Sep 29, 2020
ananthsub added a commit to ananthsub/pytorch-lightning that referenced this pull request Sep 30, 2020
…view. This formats the file according to the Black formatter
rohitgr7 pushed a commit that referenced this pull request Sep 30, 2020
* Split out changes from #3563 to make that PR easier to review. This formats the file according to the Black formatter

* Store a reference to the trainer on the datamodule

Fixes #3682

* Update data_connector.py

* Update data_connector.py

* Update test_datamodules.py

* Add attribute to datamodule for trainer
Borda pushed a commit to ananthsub/pytorch-lightning that referenced this pull request Oct 2, 2020
…view. This formats the file according to the Black formatter
@Borda Borda added this to the 0.10.0 milestone Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants