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

Raise a WARNING when someone tried to load the best checkpoint when one has not been set. #12501

Closed
aprbw opened this issue Mar 29, 2022 · 3 comments
Labels
callback: model checkpoint design Includes a design discussion won't fix This will not be worked on working as intended Working as intended

Comments

@aprbw
Copy link

aprbw commented Mar 29, 2022

🚀 Feature

Raise a WARNING when someone call:
Trainer.test(ckpt_path='best')
or
Trainer.test(ckpt_path='best')
if there is no user-defined ModelCheckpoint in callbacks

Motivation

I'm frustrated when there is a deadline approaching, and I need to update my PL to the latest version, and it breaks a bunch of things, and one of thing that silently break is the model checkpointing.

If someone is calling Trainer.test(ckpt_path='best') they are expecting the best model to be loaded, not the latest model. If it is loading the latest model instead (due to user-defined ModelCheckpoint was not set), please raise a warning and not just silently load the latest model. Freaked me out real bad, I literally lost sleep over this.

Pitch

Raise a WARNING when someone call:
Trainer.test(ckpt_path='best')
or
Trainer.test(ckpt_path='best')
if there is no user-defined ModelCheckpoint in callbacks

Alternatives

None

Additional context

None

cc @tchaton @justusschock @awaelchli @Borda @ananthsub @ninginthecloud @rohitgr7 @carmocca @jjenniferdai

@aprbw aprbw added the needs triage Waiting to be triaged by maintainers label Mar 29, 2022
@ananthsub ananthsub added checkpointing Related to checkpointing callback: model checkpoint and removed needs triage Waiting to be triaged by maintainers labels Mar 29, 2022
@carmocca
Copy link
Contributor

Hi @aprbw! Sorry that you had a bad experience with this.

When you create a Trainer(), we add a instance ModelCheckpoint() internally as long as you don't set Trainer(enable_model_checkpointing=False).

This ModelCheckpoint() instance by default has monitor=None which means it doesn't track any specific logged value, instead the last model saved.
Instances with this configuration still set best_model_path, the attribute checked with test(ckpt_path='best').

Even though this was confusing to you, this is expected behavior for other users who want to set 'best' and forget without having to take into account the particular checkpointing configuration.

I am not sure we can show a warning here because this is intended.

On a similar vein: #12485

@carmocca carmocca added working as intended Working as intended design Includes a design discussion and removed checkpointing Related to checkpointing labels Mar 30, 2022
@aprbw
Copy link
Author

aprbw commented Mar 31, 2022

Sorry that you had a bad experience with this.

Sorry about my rant.

Instances with this configuration still set best_model_path, the attribute checked with test(ckpt_path='best').

I see, so there are cases where this is a desired behavior. However, I still think that this is still confusing. I'm also not sure what the correct solution should be.

@stale
Copy link

stale bot commented Apr 30, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team!

@stale stale bot added the won't fix This will not be worked on label Apr 30, 2022
@carmocca carmocca closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback: model checkpoint design Includes a design discussion won't fix This will not be worked on working as intended Working as intended
Projects
None yet
Development

No branches or pull requests

3 participants