fix: restore global_step from .states when resuming training#18112
Open
ltianyi992 wants to merge 1 commit into
Open
fix: restore global_step from .states when resuming training#18112ltianyi992 wants to merge 1 commit into
ltianyi992 wants to merge 1 commit into
Conversation
load_model() saved start_epoch from the .states file but silently dropped global_step, causing resumed training to restart the step counter at 0. This broke log timestamps, eval scheduling, VisualDL steps, and checkpoint metadata. program.train() already reads global_step from pre_best_model_dict (lines 232-234) — this patch simply populates that key in both code paths inside load_model(): - the KIE (metric.states) path - the main (.states) path Closes PaddlePaddle#18108
|
james seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
This PR fixes resume-training state propagation by restoring global_step from the checkpoint .states/metric.states files inside ppocr/utils/save_load.py, preventing tools/program.py from resetting the step counter to 0 on resume.
Changes:
- Restore
global_stepfromstates_dictintobest_model_dictin the KIE resume path (metric.states). - Restore
global_stepfromstates_dictintobest_model_dictin the standard resume path (.states).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #18108
load_model()inppocr/utils/save_load.pycorrectly restoresstart_epochfrom the.statesfile, but silently dropsglobal_step. Becauseprogram.train()initialisesglobal_stepfrompre_best_model_dict["global_step"](lines 232–234), the counter resets to 0 on every resume — corrupting log timestamps, eval scheduling, VisualDL step indices, and checkpoint metadata.Root cause
Both code paths inside
load_model()read the.statesfile and populatebest_model_dict, but neither included:Fix
Add the two-line restore to both paths:
metric.states— line ~92).states— line ~162)No other logic changed.
program.train()already has the consumer code; this patch just feeds it the correct value.Test plan
global_stepstarting at N+1 instead of 1.statesfile present)global_stepcorrectly