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

Code explanation in gather.py #33

Open
littleredxh opened this issue Jun 15, 2021 · 1 comment
Open

Code explanation in gather.py #33

littleredxh opened this issue Jun 15, 2021 · 1 comment

Comments

@littleredxh
Copy link

Hi, Janne

The GatherLayer module in gather.py is smart and efficient. I really appreciate this module.

I almost understand most of the functions of the codes but still confuse at one point.

line 19 of SimCLR/simclr/modules/gather.py

    grad_out[:] = grads[dist.get_rank()]

Would you mind explaining it in more detail?

@ivallesp
Copy link

Basically, the gradients in each device would be the local gradients. Look at this blog post: https://amsword.medium.com/gradient-backpropagation-with-torch-distributed-all-gather-9f3941a381f8

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

No branches or pull requests

2 participants