Lightning-AI / Lightning-AI/pytorch-lightning

I can not save checkpoints in checkpoints epochs

Open
#20,638 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

### Bug description

When I ran the program to train the model, I couldn't save checkpoints after a certain epoch, but instead of getting an error, the model skipped saving and continued training

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

v2.5

### How to reproduce the bug

```python
default_modelckpt_cfg = {
"target": "pytorch_lightning.callbacks.ModelCheckpoint",
"params": {
"dirpath": ckptdir,
"filename": "{epoch:04}",
"verbose": True,
"save_last": False,
"every_n_epochs": 1,
"save_top_k": -1, # save all checkpoints
}
}
modelckpt_cfg = lightning_config.modelcheckpoint
modelckpt_cfg = OmegaConf.merge(default_modelckpt_cfg, modelckpt_cfg)
default_callbacks_cfg["checkpoint_callback"] = modelckpt_cfg
if "callbacks" in lightning_config:
callbacks_cfg = lightning_config.callbacks
else:
callbacks_cfg = OmegaConf.create()
callbacks_cfg = OmegaConf.merge(default_callbacks_cfg, callbacks_cfg)

trainer_kwargs["callbacks"] = [
instantiate_from_config(callbacks_cfg[k]) for k in callbacks_cfg]
trainer = Trainer(**trainer_config, **trainer_kwargs, num_nodes=opt.num_nodes)
```

### Error messages and logs

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

### Environment

Current environment

```
#- PyTorch Lightning Version (e.g., 2.5.0):
#- PyTorch Version (e.g., 2.2.2):
#- Python version (e.g., 3.10):
#- OS (e.g., Linux):

```

### 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 reported configuration with PyTorch Lightning's ModelCheckpoint, especially every_n_epochs=1 and save_top_k=-1, using the Trainer construction shown. Inspect how the checkpoint callback handles the first skipped save and compare the configured checkpoint directory and filename pattern. Done means checkpoint saves are attempted for the expected epochs and failures are reported instead of silently allowing training to continue.

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.