Fix batch progress state misalignment when resuming from mid-epoch checkpoints #21411
+208
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix BatchProgress Inconsistency When Resuming From Mid-Epoch Checkpoint (Fixes #19367)
What does this PR do?
This PR fixes incorrect synchronization of
batch_progresswhen resuming training from a mid-epoch checkpoint, as described in issue #19367.Before this fix, resuming from a checkpoint saved before completing an epoch caused:
batch_progress.total_readyandtotal_completedto desynchronize from the restoredglobal_stepcurrent_ready/current_completedto become inconsistent or invalidSummary of the Fix
The PR modifies
CheckpointConnector.resume_start()to:batch_progress.total_readyandtotal_completedto be at least the restoredglobal_stepcurrent_readyandcurrent_completedusingglobal_step % limit_train_batcheswhen availableA new test verifies correct behavior and prevents regressions.
Tests Added
A new file:
tests/test_resume_batch_progress.pyThis test:
batch_progressexists in the expected formtotal_completed≥global_stepcurrent_completed≤total_completedThe test failed before the fix and passes after it.
Fixes #19367
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--21411.org.readthedocs.build/en/21411/