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 packing + streaming + resumption #1277

Merged
merged 20 commits into from
Jun 14, 2024

Conversation

dakinggg
Copy link
Collaborator

@dakinggg dakinggg commented Jun 13, 2024

There was a long standing bug when resuming a streaming, finetuning dataset with packing enabled. The issue would only occur if you resumed not on an epoch boundary. The issue would be fairly significant, in that resumption would resume at an earlier sample than it should have, so data would be unexpectedly repeated. The root cause of the issue is that, when packing, the num samples recorded for streaming resumption needed to be multiplied by the packing ratio.

Manual test, with PR, resumption is deterministic:
Screenshot 2024-06-14 at 2 42 55 AM

Before this PR (note, loss is lower upon resumption because its repeating samples, and then it reverts to the same general loss curve once its through the repeats):
Screenshot 2024-06-14 at 11 24 59 AM

The above plots were with num_workers=0, when setting num_workers=8, we discovered a second deterministic resumption bug, where the wrong batch size was passed to streaming. This has now also been fixed, and here is a manual test with num_workers=8.

Screenshot 2024-06-14 at 2 33 17 PM

Note: There will still be some non determinism if max_leftover_bins_to_keep is not set to zero, because we don't save the reservoir. This will just be slight non determinism, as opposed to the current bug which would repeat samples.

@dakinggg dakinggg changed the title attempt Fix packing + streaming + resumption Jun 13, 2024
@dakinggg dakinggg marked this pull request as ready for review June 14, 2024 18:26
@dakinggg dakinggg requested a review from a team as a code owner June 14, 2024 18:26
@dakinggg dakinggg requested a review from snarayan21 June 14, 2024 18:26
Copy link
Contributor

@snarayan21 snarayan21 left a comment

Choose a reason for hiding this comment

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

thanks for addressing this! minor nit but otherwise lgtm

llmfoundry/data/finetuning/tasks.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mvpatel2000 mvpatel2000 left a comment

Choose a reason for hiding this comment

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

Thanks for hunting this down!

@dakinggg dakinggg merged commit dbd798e into mosaicml:main Jun 14, 2024
10 of 11 checks passed
@dakinggg dakinggg deleted the packing-resumption branch June 22, 2024 20:45
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.

None yet

3 participants