8000 fix: updates sorting logic to correctly compare numbers by RobotSail · Pull Request #238 · instructlab/training · GitHub
[go: up one dir, main page]

Skip to content

fix: updates sorting logic to correctly compare numbers - #238

Merged
mergify[bot] merged 1 commit into
instructlab:mainfrom
RobotSail:fix-checkpoint-selection
Oct 1, 2024
Merged

mergify[bot] merged 1 commit into
instructlab:mainfrom
RobotSail:fix-checkpoint-selection

Conversation

@RobotSail
@RobotSail RobotSail commented Oct 1, 2024 •
Copy link
Copy Markdown
Member

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 97077423+RobotSail@users.noreply.github.com

Signed-off-by: Oleg S <97077423+RobotSail@users.noreply.github.com>
@RobotSail
RobotSail force-pushed the fix-checkpoint-selection branch from 0aa9f1c to 0310cae Compare October 1, 2024 18:01
@Maxusmusti Maxusmusti left a comment
Copy link
Copy Markdown
Collaborator

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
@JamesKunstle JamesKunstle left a comment
Copy link
Copy Markdown
Contributor

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
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
39D1

3 participants

0