Skip to content

Commit 9d36604

Browse files
authored
Clarify requirements for Trainer.fit(ckpt_path="last") (#19066)
1 parent 482da0a commit 9d36604

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/source-pytorch/common/evaluation_intermediate.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ To run the test set after training completes, use this method.
4141
# run full training
4242
trainer.fit(model)
4343
44-
# (1) load the best checkpoint automatically (lightning tracks this for you)
44+
# (1) load the best checkpoint automatically (lightning tracks this for you during .fit())
4545
trainer.test(ckpt_path="best")
4646
47-
# (2) load the last available checkpoint
47+
# (2) load the last available checkpoint (only works if `ModelCheckpoint(save_last=True)`)
4848
trainer.test(ckpt_path="last")
4949
5050
# (3) test using a specific checkpoint

src/lightning/pytorch/trainer/connectors/checkpoint_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _parse_ckpt_path(
185185
# not an error so it can be set and forget before the first `fit` run
186186
rank_zero_warn(
187187
f'.{fn}(ckpt_path="last") is set, but there is no last checkpoint available.'
188-
" No checkpoint will be loaded."
188+
" No checkpoint will be loaded. HINT: Set `ModelCheckpoint(..., save_last=True)`."
189189
)
190190
return None
191191
ckpt_path = max(candidates_ts, key=candidates_ts.get) # type: ignore[arg-type]

0 commit comments

Comments
 (0)