Lightning-AI / Lightning-AI/pytorch-lightning

Create a link for the best checkpoint

Open
#19,304 0 comments 2 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

As illustrated in #19294 , since we already implement the link of `last.ckpt`, how about adding a new feature on `best.ckpt`? Although we support saving the topk checkpoints already, there is no consistent way to reference the top1 checkpoint.

Screenshot 2024-01-16 at 18 30 55

For example, in the above figure, I have to check the files under the folder `work_dirs/medclip_resnet50_iu_xray_R2GenGPT_30x/2024.01.16_17.44.40.927262/checkpoints` to determine the file name `epoch:5-val_loss:3.264.ckpt` to reference the best checkpoint if I have not created the `best.ckpt` checkpoint. It will be more convenient if we implement the hard link of `best.ckpt` also. It can be implemented with the similar code as the `last.ckpt` part.

### Pitch

Create a link for the best checkpoint when it is updated.

### 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 locating the existing `last.ckpt` link implementation and the code that updates top-k checkpoints. Trace how the top1/best checkpoint is selected, then verify that a `best.ckpt` hard link is created or updated whenever that checkpoint changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.