[Bug] Match checkpoint directory names exactly - #4292
Open
taking-lying-flat wants to merge 1 commit into
Open
Conversation
taking-lying-flat
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
August 23, 2026 00:13
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.
Problem
Checkpoint discovery and stale-checkpoint purging independently parse directory names with re.search using the step-(digits) pattern. Because re.search accepts a match anywhere in the string, names such as step-100.backup and foo-step-100 are treated as checkpoint step 100 even though they are outside the canonical step-N namespace.
This creates two distinct failure modes:
The root cause is substring matching combined with duplicated checkpoint-name parsing in discovery and purge.
Fix
Add one _parse_checkpoint_step helper using re.fullmatch with the step-(digits) pattern, and use it for both latest-checkpoint discovery and stale-checkpoint purging. Only a complete canonical directory name can now produce a step number. Latest loading already consumes the result of _find_load_step and reconstructs the same canonical step-N name, so parsing and path construction now agree.
The parser returns None for invalid names and uses explicit None checks so step-0 remains valid.