Skip to content

Not saving checkpoint when monitor is None and save_top_k is -1 #6096

@ruotianluo

Description

@ruotianluo

🐛 Bug

When monitor is None, current will be None here
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc4490d01aed21c2d52f884d4afbeaa24a47ca0/pytorch_lightning/callbacks/model_checkpoint.py#L553

And check_monitor_top_k will return False because of that:
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc4490d01aed21c2d52f884d4afbeaa24a47ca0/pytorch_lightning/callbacks/model_checkpoint.py#L340

_update_best_and_save also doesn't take None current. raise error here: https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc4490d01aed21c2d52f884d4afbeaa24a47ca0/pytorch_lightning/callbacks/model_checkpoint.py#L605

Currently, checkpointing is associated with validation, which is not necessarily always the case. I just want to save the checkpoint every k iterations.

Please reproduce using the BoringModel

Sorry, no time to reproduce for now.

To Reproduce

Use following BoringModel and post here

Expected behavior

Should save the checkpoint always if save_top_k == -1.

Environment

Note: Bugs with code are solved faster ! Colab Notebook should be made public !

You can get the script and run it with:

wget https://raw.githubusercontent.com/PyTorchLightning/pytorch-lightning/master/tests/collect_env_details.py
# For security purposes, please check the contents of collect_env_details.py before running it.
python collect_env_details.py
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcheckpointingRelated to checkpointinghelp wantedOpen to be worked onpriority: 0High priority task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions