Lightning-AI / Lightning-AI/pytorch-lightning

"save_last" could not save a complete checkpoint

Open
#19,909 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug callback: model checkpoint ver: 1.9.x
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Bug description

I use save_last=True and every_n_epoch = 1 ( actually the default setting).

every_n_epoch = 1 can lead to correct checkpoint saving, everything is ok.

But the last.ckpt is incomplete, the epoch is 0 and the global is 0.

The file size of last.ckpt is around 800M while epoch*.ckpt is around 2.4g.

My pl version is 1.9.3 and torch version is 2.2.1

### What version are you seeing the problem on?

v1.9

### How to reproduce the bug

_No response_

### Error messages and logs

```
# Error messages and logs here please
```

### Environment

Current environment

```
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):
```

### More info

_No response_

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 reproducing the report on PyTorch Lightning v1.9.3 with save_last=True and every_n_epoch=1, then compare last.ckpt with the epoch*.ckpt files. Trace the checkpoint-saving path to determine why last.ckpt contains epoch and global step as 0; done means last.ckpt is complete and matches the saved checkpoint state.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.