fix iterator overflow when gradient accumulation is 1 #35960
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
In the original part of the code:
if we assume
args.gradient_accumulation_steps
is1
and the length of the iterator/num_examples
is say10
, thenN % 1
is alwaysremainder = 0
.which then sets the
remainder
to an additional step.Then for total updates, we know that it's
10 steps // 1 ga + 1
, sototal_updates = 11
, which is one more than the actual number of row in the dataset/dataloader.then when the loop calls
self.get_batch_samples(epoch_iterator, num_batches)
on theremainder
there is no data left, which I believe is causing a segmentation fault for me.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@muellerzr or @SunMarc
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.