Skip to content

Commit 4d706d1

Browse files
committed
Implement fix
1 parent 79f6824 commit 4d706d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lightning/pytorch/callbacks/model_checkpoint.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ def on_validation_end(self, trainer: "pl.Trainer", pl_module: "pl.LightningModul
332332
self._save_topk_checkpoint(trainer, monitor_candidates)
333333
self._save_last_checkpoint(trainer, monitor_candidates)
334334

335+
@override
336+
def on_train_end(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
337+
"""Ensure save_last=True is applied when training ends."""
338+
if self.save_last and not self._last_checkpoint_saved:
339+
monitor_candidates = self._monitor_candidates(trainer)
340+
self._save_last_checkpoint(trainer, monitor_candidates)
341+
335342
@override
336343
def state_dict(self) -> Dict[str, Any]:
337344
return {

0 commit comments

Comments
 (0)