Skip to content

Fix zero-1 bug related to stitching reduced grads across comm partitions - #318

Merged
jeffra merged 1 commit into
masterfrom
jeffra/zero-1-fix
Sep 15, 2020
Merged

Fix zero-1 bug related to stitching reduced grads across comm partitions#318
jeffra merged 1 commit into
masterfrom
jeffra/zero-1-fix

Conversation

@jeffra

@jeffra jeffra commented Aug 14, 2020

Copy link
Copy Markdown
Collaborator

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.

@jeffra jeffra added the bug Something isn't working label Aug 14, 2020
@jeffra
jeffra requested review from samyam and tjruwase August 19, 2020 16:17
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])):

@samyam samyam Aug 20, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
jeffra merged commit 55ed105 into master Sep 15, 2020
@jeffra
jeffra deleted the jeffra/zero-1-fix branch November 13, 2020 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants