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

Take gradient accumulation into account when defining samplers #15095

Merged
merged 2 commits into from
Jan 11, 2022

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Jan 10, 2022

What does this PR do?

This PR takes the gradient accumulation steps into account when defining samplers that use the batch size (like the LengthGroupedSampler) so that training with large batch size or training with smaller batch size and gradient accumulation (e.g. batch size 64 or batch size 8 and gradient accumulation steps of 8) yield the same results.

Fixes #14638

@sgugger sgugger requested a review from LysandreJik January 10, 2022 17:06
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Good for me!

@LysandreJik LysandreJik merged commit ca76618 into master Jan 11, 2022
@LysandreJik LysandreJik deleted the batch_size_grad_acc branch January 11, 2022 08:16
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.

Gradient accumulation causing different training curves
2 participants