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

Move loss generating token counting to the dataloader #1632

Merged
merged 19 commits into from
Nov 4, 2024

Conversation

dakinggg
Copy link
Collaborator

@dakinggg dakinggg commented Nov 2, 2024

The previous PR to count loss generating tokens caused a throughput regression because the token counting is on the critical path in the Composer trainer. This PR moves the token counting into the collator so that it can be hidden in the dataloader. It does this by counting tokens per row in the batch, using the existing token counting function (not the most efficient, but doesn't matter because this is not dataloader bottlenecked, and allows reusing the existing code).

This PR should not change token counts or loss, and will barely affect throughput for larger models, but have a significant impact for smaller models.

125m model pretraining throughput, loss, token count, before and after this PR:
Screenshot 2024-11-02 at 3 19 20 PM
Screenshot 2024-11-02 at 3 19 26 PM
Screenshot 2024-11-02 at 3 19 34 PM

llama finetune throughput, loss, token count, before and after this PR:

@dakinggg dakinggg changed the title WIP Move loss generating token counting to the dataloader Nov 2, 2024
@dakinggg dakinggg marked this pull request as ready for review November 3, 2024 00:01
@dakinggg dakinggg requested a review from a team as a code owner November 3, 2024 00:01
llmfoundry/data/utils.py Outdated Show resolved Hide resolved
llmfoundry/data/utils.py Show resolved Hide resolved
@dakinggg dakinggg merged commit ce302be into mosaicml:main Nov 4, 2024
9 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.

2 participants