Fix zero-1 bug related to stitching reduced grads across comm partitions - #318
Merged
Conversation
samyam
reviewed
Aug 20, 2020
| flat_all_grads = torch.cat(flat_comm_grads) | ||
|
|
||
| # copy back reduced gradients but only those needed for this local rank | ||
| for param, updated_grad in zip(self.fp16_groups[i], _unflatten_dense_tensors(flat_all_grads, self.fp16_groups[i])): |
Contributor
There was a problem hiding this comment.
By flattening the gradients aren't we creating an extra copy of the gradients? At this point are we going to have 3 copies of the gradients? i) in param.grad, ii) in all_comm_partitions, iii) flattented gradients
We should probably release all param.grad before flattening, then delete all_comm_partitions after flattening. That way we will have at most one copy of the gradients alive at any given time?
jeffra
requested review from
RezaYazdaniAminabadi,
ShadenSmith,
arashashari,
awan-10,
cli99,
conglongli,
eltonzheng,
minjiaz and
niumanar
as code owners
August 31, 2020 18:45
jeffra
force-pushed
the
jeffra/zero-1-fix
branch
from
September 15, 2020 17:30
55284a2 to
eb287dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Has been confirmed from 1p user to have fixed their issue. Also our original repro of the diverged loss shows the issue has fixed as well.
I believe the issue was related to the old copy gradients code was not stitching the sub-partitions together correctly. After simplifying this part of the code substantially this issue appears to be fixed.