Skip to content

updated ModelCheckpoint to add the facility of retaining periodic checkpoints #20547

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arijit-hub
Copy link

@arijit-hub arijit-hub commented Jan 14, 2025

… checkpoints

What does this PR do?

This decouples the save_top_k from saving intermediate checkpoints when setting every_n_epochs or every_n_steps to some value. This is a direct solution to close #20539 and further motivation can be gathered from the thread's discussion.

  • [x]Was this discussed/agreed via a GitHub issue? (not for typos and docs) : Yes. See top_k parameter of ModelCheckpoint default value #20539
  • 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): NO. It just add a new condition and seems to work.
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

@Borda @lantiga

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jan 14, 2025
@lantiga
Copy link
Collaborator

lantiga commented Feb 3, 2025

Thank you @arijit-hub, we do need a test that goes with it.
The test should verify that we remove previous checkpoints on given conditions, and that backward compatibility is guaranteed.

Take a look here as a starting point:
https://github.com/Lightning-AI/pytorch-lightning/blob/master/tests/tests_pytorch/checkpointing/test_model_checkpoint.py
https://github.com/Lightning-AI/pytorch-lightning/blob/master/tests/tests_pytorch/checkpointing/test_checkpoint_callback_frequency.py

I'd be great if you could give it a shot, if not please let me know. Thanks for your contribution!

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79%. Comparing base (a944e77) to head (3bc6e9f).
Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (a944e77) and HEAD (3bc6e9f). Click for more details.

HEAD has 5427 uploads less than BASE
Flag BASE (a944e77) HEAD (3bc6e9f)
cpu 1228 24
lightning 922 18
pytest 601 0
python3.9 308 6
lightning_fabric 151 0
python3.10 153 3
python3.11 309 6
python3.12.7 458 9
gpu 2 0
pytorch2.1 236 9
pytest-full 629 24
pytorch_lightning 157 6
pytorch2.2.2 79 3
pytorch2.3 80 3
pytorch2.4.1 78 3
pytorch2.5.1 156 6
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20547     +/-   ##
=========================================
- Coverage      88%      79%     -9%     
=========================================
  Files         267      264      -3     
  Lines       23380    23326     -54     
=========================================
- Hits        20481    18367   -2114     
- Misses       2899     4959   +2060     

@Borda Borda changed the title updated model_checkpoint.py to add the facility of retaining periodic checkpoints updated ModelCheckpoint to add the facility of retaining periodic checkpoints Mar 14, 2025
Copy link

stale bot commented Apr 16, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need further help see our docs: https://lightning.ai/docs/pytorch/latest/generated/CONTRIBUTING.html#pull-request or ask the assistance of a core contributor here or on Discord. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Apr 16, 2025
@Borda Borda marked this pull request as draft April 17, 2025 17:47
@stale stale bot removed the won't fix This will not be worked on label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pl Generic label for PyTorch Lightning package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

top_k parameter of ModelCheckpoint default value
2 participants