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

[warning] Add a warning with missing callback with resume_from_checkpoint #7254

Merged
merged 5 commits into from
Apr 29, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Apr 28, 2021

What does this PR do?

Add a warning with missing callback with resume_from_checkpoint

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 🙃

@pep8speaks
Copy link

pep8speaks commented Apr 28, 2021

Hello @tchaton! Thanks for updating this PR.

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

Comment last updated at 2021-04-29 12:13:09 UTC

@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #7254 (5d91654) into master (e272bea) will increase coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #7254    +/-   ##
=======================================
+ Coverage      87%     91%    +4%     
=======================================
  Files         199     199            
  Lines       12799   12802     +3     
=======================================
+ Hits        11170   11683   +513     
+ Misses       1629    1119   -510     

@tchaton tchaton added the bug Something isn't working label Apr 28, 2021
@tchaton tchaton enabled auto-merge (squash) April 28, 2021 15:42
Comment on lines +307 to +309
"Be aware that when using ``resume_from_checkpoint``, "
"callbacks used to create the checkpoint need to be provided. "
f"Please, add the following callbacks: {list(difference)}. ", UserWarning
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Be aware that when using ``resume_from_checkpoint``, "
"callbacks used to create the checkpoint need to be provided. "
f"Please, add the following callbacks: {list(difference)}. ", UserWarning
"Be aware that when using ``resume_from_checkpoint``,"
" callbacks used to create the checkpoint need to be provided."
f" Please add the following callbacks: {list(difference)}. ", UserWarning

Copy link
Contributor

Choose a reason for hiding this comment

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

is this warning always needed? For example, i may have saved a checkpoint dict which contained callback states from the model checkpoint. But when I resume from checkpoint, I might not set a new model checkpoint callback on the trainer

is there an issue/question which prompted the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR checks the AU~B between save_callback_state and current_callback_state.
Basically, if you trained with a CustomCallback and you don't provide it back when resuming,
we won't be able to reload the state as this callback isn't provided.
Therefore we should provide a warning that resume might not have the expected behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resume_from_checkpoint is bringing lot of confusion as we expect exactly the same arguments to the Trainer as provided when training before.

tests/trainer/test_trainer.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the has conflicts label Apr 29, 2021
Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM 😃 maybe just do set(callback_states.keys()) for readability

pytorch_lightning/trainer/callback_hook.py Outdated Show resolved Hide resolved
@carmocca carmocca added the ready PRs ready to be merged label Apr 29, 2021
@tchaton tchaton merged commit 848288c into master Apr 29, 2021
@tchaton tchaton deleted the add_warning_missing_callback branch April 29, 2021 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants