Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updates sorting logic to correctly compare numbers #238

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

RobotSail
Copy link
Member

@RobotSail RobotSail commented Oct 1, 2024

This PR fixes a bug currently present in the checkpoint selection logic,
where the checkpoint names are sorted by string, e.g.:

lst = ["samples_1", "samples_10","samples_19", "samples_2", "samples_9999"]
print(sorted(lst))
> ['samples_1', 'samples_10', 'samples_19', 'samples_2', 'samples_9999']

This PR fixes this issue by specifying the key parameter such that it now extracts the number at the end and uses it for comparison:

sorted(lst, key=lambda x: int(x.split("_")[-1]), reverse=True)
> ['samples_9999', 'samples_19', 'samples_10', 'samples_2', 'samples_1']

Fixes #236

Signed-off-by: Oleg S [email protected]

@RobotSail RobotSail force-pushed the fix-checkpoint-selection branch from 0aa9f1c to 0310cae Compare October 1, 2024 18:01
Copy link
Contributor

@Maxusmusti Maxusmusti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested save and loading to make sure expected ckpt was picked

@mergify mergify bot added the one-approval label Oct 1, 2024
Copy link
Contributor

@JamesKunstle JamesKunstle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM- in the future we could stat the folders and take the youngest but idk if that's really valuable.

@mergify mergify bot removed the one-approval label Oct 1, 2024
@mergify mergify bot merged commit 8e6c160 into instructlab:main Oct 1, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add checkpoint name ordering by sample count
3 participants