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

[1 / 3] improvements to saving and loading callback state #6886

Merged
merged 44 commits into from
Jul 28, 2021

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Apr 8, 2021

What does this PR do?

Initial PR for an improved state saving and loading for Callbacks.

  1. This is a bugfix, since pickling with the keys type(callback) would pickle the callback class source, and this prevents loading the checkpoint outside of PL (when PL not installed).

  2. Feature: With a state identifier, we will be able to produce a (more) unique key for the callbacks. It allows us to save more than one of the same type of callback since we can now disambiguate. This PR does not yet add unique identifiers. This will come in a follow up part.

This change is fully backward compatible (old checkpoints can still be loaded the same way).

Part of #6467

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?

I made sure I had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Apr 8, 2021

Hello @awaelchli! 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-07-28 21:31:21 UTC

@awaelchli awaelchli added bug Something isn't working callback feature Is an improvement or enhancement labels Apr 8, 2021
@codecov
Copy link

codecov bot commented Apr 8, 2021

Codecov Report

Merging #6886 (302e724) into master (aadd2a9) will increase coverage by 0%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #6886    +/-   ##
=======================================
  Coverage      92%     93%            
=======================================
  Files         218     169    -49     
  Lines       14407   13959   -448     
=======================================
- Hits        13305   12917   -388     
+ Misses       1102    1042    -60     

@awaelchli awaelchli changed the title improvements to saving and loading callback state [1 / N] improvements to saving and loading callback state Apr 21, 2021
@awaelchli awaelchli marked this pull request as ready for review April 21, 2021 09:45
@mergify mergify bot removed the has conflicts label Jul 26, 2021
@awaelchli awaelchli marked this pull request as draft July 26, 2021 12:08
@awaelchli awaelchli marked this pull request as ready for review July 27, 2021 17:24
@awaelchli awaelchli requested a review from carmocca July 27, 2021 17:24
pytorch_lightning/callbacks/base.py Show resolved Hide resolved
pytorch_lightning/callbacks/base.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/callback_hook.py Show resolved Hide resolved
tests/callbacks/test_early_stopping.py Show resolved Hide resolved
tests/checkpointing/test_legacy_checkpoints.py Outdated Show resolved Hide resolved
tests/checkpointing/test_model_checkpoint.py Outdated Show resolved Hide resolved
tests/trainer/logging_/test_logger_connector.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the has conflicts label Jul 28, 2021
@awaelchli awaelchli enabled auto-merge (squash) July 28, 2021 21:31
@awaelchli awaelchli merged commit 8c27fa7 into master Jul 28, 2021
@awaelchli awaelchli deleted the bugfix/callback-state branch July 28, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working callback 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.

6 participants