-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
scale gradient accumulation steps with train batch size to keep effective batch size about the same #33281
base: main
Are you sure you want to change the base?
scale gradient accumulation steps with train batch size to keep effective batch size about the same #33281
Conversation
…tive batch size about the same
ab90906
to
56cbbba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start!
def reduce_batch_size_fn_wrapper(train_batch_size, args): | ||
effective_batch_size = args.gradient_accumulation_steps * train_batch_size | ||
def reduce_batch_size_fn(): | ||
nonlocal train_batch_size | ||
train_batch_size = train_batch_size // 2 | ||
args.gradient_accumulation_steps = effective_batch_size // train_batch_size | ||
return train_batch_size | ||
return reduce_batch_size_fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this in trainer_utils
I think since that's where we have find_executable_batch_size
defined.
args.gradient_accumulation_steps = effective_batch_size // train_batch_size | ||
return train_batch_size | ||
return reduce_batch_size_fn | ||
|
||
inner_training_loop = find_executable_batch_size( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trainer_utils
's find_executable_batch_size
will then also need changing.
Also need to be careful about versioning inside that func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be set as >=0.34.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I forgot to commit a file. should be there now
What does this PR do?
goes with huggingface/accelerate#3071
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.