Skip to content

Commit 5e313ee

Browse files
committed
Fix validation on restart
1 parent acd8aa1 commit 5e313ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lightning/pytorch/loops/training_epoch_loop.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ def advance(self, data_fetcher: _DataFetcher) -> None:
208208
StopIteration: When the epoch is canceled by the user returning -1
209209
210210
"""
211+
if (
212+
self.restarting
213+
and self._should_check_val_fx(data_fetcher)
214+
and self.val_loop.batch_progress.total.started > self.val_loop.batch_progress.total.completed
215+
):
216+
# skip training and run validation in `on_advance_end`
217+
return
211218
# we are going to train first so the val loop does not need to restart
212219
self.val_loop.restarting = False
213220

0 commit comments

Comments
 (0)