This repository was archived by the owner on Feb 21, 2026. It is now read-only.
Fix scheduler stepping logic and checkpoint state persistence in PR#11#12
Open
Fix scheduler stepping logic and checkpoint state persistence in PR#11#12
Conversation
Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review changes in pull request #11
Fix scheduler stepping logic and checkpoint state persistence in PR#11
Feb 6, 2026
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix three critical issues identified in PR#11's optimizer and scheduler factory implementation: dual counter desynchronization in LinearWarmupWrapper, missing EMA state persistence in checkpoints, and missing scheduler state persistence in checkpoints.
Changes:
- Added checkpoint persistence for scheduler and EMA state by extending save_checkpoint_bundle() and load_checkpoint_into() functions
- Reorganized initialization order to create scheduler and EMA before checkpoint resume to enable state loading
- Removed dual counter from LinearWarmupWrapper to use only the inherited last_epoch counter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| rtdetr_pose/rtdetr_pose/sched_factory.py | New scheduler factory module with LinearWarmupWrapper, build_scheduler(), and EMA class implementation |
| rtdetr_pose/tools/train_minimal.py | Added scheduler/EMA parameters to checkpoint functions, integrated factory scheduler/EMA into training loop, added CLI arguments for scheduler/EMA configuration |
| SECURITY_SUMMARY.md | Added security review summary documenting CodeQL scan results and security considerations for PR#11 |
| PR11_REVIEW_FIXES.md | Documentation describing the three issues found in PR#11 and the fixes applied |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
thinksyncs
approved these changes
Feb 6, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Code review of PR#11 revealed three critical correctness issues in the optimizer/scheduler factory implementation that would cause incorrect training behavior.
Issues Fixed
1. LinearWarmupWrapper dual counter desynchronization
The wrapper maintained both
_step_countand inheritedlast_epoch, causing warmup phase to be off by one step. Now uses onlylast_epochfrom parent_LRScheduler.Before:
After:
2. EMA shadow weights lost on checkpoint resume
EMA.state_dict()existed but was never called. Training resume would reinitialize EMA from current weights, losing accumulated shadow.schedulerandemaparameters tosave_checkpoint_bundle()andload_checkpoint_into()save_checkpoint_bundle()call sites updated3. Scheduler state not persisted
Similar to EMA - scheduler would restart from step 0 on resume, breaking learning rate schedule continuity.
Testing
Files Modified
rtdetr_pose/rtdetr_pose/sched_factory.py- Fixed LinearWarmupWrapper logicrtdetr_pose/tools/train_minimal.py- Added checkpoint persistence for scheduler/EMA stateOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.