Repository navigation
fix(checkpoint): break metric ties by recency in get_best_checkpoint_path - #3071
Conversation
…path get_best_checkpoint_path sorted only on the metric value, so when multiple checkpoints tied for the best value the returned checkpoint depended on unordered glob() ordering and could be an older one. Sort by (metric, step) preferring the most recent, matching the tie-breaking already used by remove_old_checkpoints. Add a regression test that fails on the previous behavior. Fixes NVIDIA-NeMo#3067. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Tianyi Zhang <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
LGTM, thanks for catching this and the fix!
|
/ok to test 0ab3647 |
|
/ok to test e8d9e95 |
|
thanks @tianyi-zhang-02 . retriggeed the CI since the merge in from main invalidates the CI |
|
/ok to test f6137ab |
The PR branch pinned 3rdparty/Gym-workspace/Gym at an older commit than main, failing the submodule fast-forward check. Point it at main's Gym commit (d67ad66) so the gitlink is a fast-forward. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Tianyi Zhang <[email protected]>
Head branch was pushed to by a user without write access
|
Update — current tip is Heads up on merge state: the pushes dismissed the prior approval and disabled auto-merge (author push without base-repo write access). @yuki-97 could you re-approve and re-enable auto-merge, and |
|
/ok to test fff014d |
|
thanks @tianyi-zhang-02 , re-approved and enqueued, also retriggeed the CI. |
|
Sorry — accidentally hit "Update branch" again, so the tip is now |
|
/ok to test 886f5e1 |
|
hi @tianyi-zhang-02 , no worry and retriggered. |
What does this PR do ?
CheckpointManager.get_best_checkpoint_path()sorted candidate checkpoints on the metric value alone. Because_load_checkpoint_historybuilds its list from an unorderedglob.glob(...)and Python's sort is stable, when two or more checkpoints tie for the best metric value the returned one was whicheverglobhappened to list first — often an older checkpoint.This PR sorts by
(metric, step)so the most recent checkpoint wins on ties, matching the tie-breaking already used byremove_old_checkpoints()(pinned bytest_remove_old_checkpoints_topk_bias_recent_if_equal). It also adds a regression test.This is a user-facing, documented selection API (no internal caller; six algorithm configs point users to it for final checkpoint export/eval), so the fix affects which checkpoint a user gets when exporting the "best" model on a metric tie.
Issues
Closes #3067.
Usage
Before your PR is "Ready for review"
Pre checks:
test_get_best_checkpoint_path_bias_recent_if_equal, which fails on the previous behavior and passes with this fix.tests/unit/utils/test_checkpoint.pylogic locally; the added test forces the adversarial (older-first) history order viamonkeypatchso it is deterministic regardless of filesystemglobordering.Additional Information
higher_is_better=Trueandhigher_is_better=False.