Lightning-AI / Lightning-AI/pytorch-lightning

Saving the Latest best checkpoint

Open
#17,240 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

callback: model checkpoint feature
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Description & Motivation

I am working with Graph Neural Networks and training models to learn graph structures and test their expressiveness. In such a case, acc=100% happens.

I adopted a randomized approach, where once in a while, due to variance, the validation score gets 100% high during the early stage of training, while the average validation ACC across epochs is low. The validation results get more stable and also reach 100% sometimes in the later stage of training, and I want to save these checkpoints, but the earlier 100% score prevents the ModelCheckpoint from saving them, and I can only save the latest checkpoint, which might not be optimal.

Is it interesting to add save_latest_best_checkpoint mode to ModelCheckpoint, so we break ties in favor of later epochs?

### Pitch

Add save_latest_best_checkpoint mode to ModelCheckpoint

### Alternatives

_No response_

### Additional context

_No response_

cc @borda @carmocca @awaelchli

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ModelCheckpoint implementation and its validation-score comparison behavior. Determine how an equal best score is handled, then add coverage showing that the proposed mode retains the checkpoint from the later epoch; done means later ties are saved without changing existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.