-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[2/n] Thread PG: add class _World to distributed_c10d.py (#781) #88471
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/88471
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit a47a15c: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D40236769 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D40236769 |
1d972b7 to
322f94d
Compare
gnadathur
left a comment
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.
LGTM.
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.
nit: typo, "mechanism"
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.
Are these vars only used by class _World? Why not put them under that class. You can define them as attributes, then also you dont need to call global abc each time you access.
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.
They are used in some other projects. So we have to keep them. Let me ping you some examples.
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.
Hey I randomly browsed into this piece of code. I am wondering why we need to keep them? I know it's being used in other projects, but I feel since we make all those variables be private variables, shouldn't that mean we are free to change this to whatever we like without worrying about BC?
If it's internal change related, maybe we can just refactor it directly.
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.
FYI I have a PR to refactor some of this code since this and the if statements below are basically repeated, #88351. Feel free to land yours first if you are ready though
rohan-varma
left a comment
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.
Stamp to unblock, but please address @H-Huang's comments
Summary: Pull Request resolved: pytorch#88471 X-link: meta-pytorch/torchrec#781 Move a bunch of globals to instance methods and replace all use to them. We move all PG related globals under World and use a singleton instance under _world. This creates an undocumented extension point to inject full control of how how c10d state behaves. One simple hack is to change _world to an implementation that uses a threadlocal and enable per-thread PGs. It almost get DDP working and the PG is missing an implementation of all_reduce. This enables notebook usage of PTD, which is a big deal for learning it: https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68 This change ensures BC by keeping the global variables around and have the default _World wrap it. I have relinked this diff to a new github PR, so that I can update it. The original PR is > Pull Request resolved: pytorch#86348 Reviewed By: gnadathur Differential Revision: D40236769 Pulled By: yhcharles fbshipit-source-id: efeaa7990e26a58987769a93cedf7318d5cae445
Summary: X-link: pytorch/pytorch#88471 Pull Request resolved: meta-pytorch#781 Move a bunch of globals to instance methods and replace all use to them. We move all PG related globals under World and use a singleton instance under _world. This creates an undocumented extension point to inject full control of how how c10d state behaves. One simple hack is to change _world to an implementation that uses a threadlocal and enable per-thread PGs. It almost get DDP working and the PG is missing an implementation of all_reduce. This enables notebook usage of PTD, which is a big deal for learning it: https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68 This change ensures BC by keeping the global variables around and have the default _World wrap it. I have relinked this diff to a new github PR, so that I can update it. The original PR is > Pull Request resolved: pytorch/pytorch#86348 Reviewed By: gnadathur Differential Revision: D40236769 Pulled By: yhcharles fbshipit-source-id: ebd6080e4923da549800a048f089fa0bb69eb331
322f94d to
a47a15c
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40236769 |
Summary: X-link: pytorch/pytorch#88471 Pull Request resolved: #781 Move a bunch of globals to instance methods and replace all use to them. We move all PG related globals under World and use a singleton instance under _world. This creates an undocumented extension point to inject full control of how how c10d state behaves. One simple hack is to change _world to an implementation that uses a threadlocal and enable per-thread PGs. It almost get DDP working and the PG is missing an implementation of all_reduce. This enables notebook usage of PTD, which is a big deal for learning it: https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68 This change ensures BC by keeping the global variables around and have the default _World wrap it. I have relinked this diff to a new github PR, so that I can update it. The original PR is > Pull Request resolved: pytorch/pytorch#86348 Reviewed By: gnadathur Differential Revision: D40236769 Pulled By: yhcharles fbshipit-source-id: c6aecff5b0801938713f867827d0d3b4b5c906e6
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary: X-link: pytorch/pytorch#88471 Pull Request resolved: meta-pytorch#781 Move a bunch of globals to instance methods and replace all use to them. We move all PG related globals under World and use a singleton instance under _world. This creates an undocumented extension point to inject full control of how how c10d state behaves. One simple hack is to change _world to an implementation that uses a threadlocal and enable per-thread PGs. It almost get DDP working and the PG is missing an implementation of all_reduce. This enables notebook usage of PTD, which is a big deal for learning it: https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68 This change ensures BC by keeping the global variables around and have the default _World wrap it. I have relinked this diff to a new github PR, so that I can update it. The original PR is > Pull Request resolved: pytorch/pytorch#86348 Reviewed By: gnadathur Differential Revision: D40236769 Pulled By: yhcharles fbshipit-source-id: c6aecff5b0801938713f867827d0d3b4b5c906e6
pytorch#88471) Summary: X-link: meta-pytorch/torchrec#781 Move a bunch of globals to instance methods and replace all use to them. We move all PG related globals under World and use a singleton instance under _world. This creates an undocumented extension point to inject full control of how how c10d state behaves. One simple hack is to change _world to an implementation that uses a threadlocal and enable per-thread PGs. It almost get DDP working and the PG is missing an implementation of all_reduce. This enables notebook usage of PTD, which is a big deal for learning it: https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68 This change ensures BC by keeping the global variables around and have the default _World wrap it. I have relinked this diff to a new github PR, so that I can update it. The original PR is > Pull Request resolved: pytorch#86348 Differential Revision: D40236769 Pulled By: yhcharles Pull Request resolved: pytorch#88471 Approved by: https://github.com/gnadathur, https://github.com/rohan-varma
Summary:
X-link: meta-pytorch/torchrec#781
Move a bunch of globals to instance methods and replace all use to them.
We move all PG related globals under World and use a singleton instance under _world.
This creates an undocumented extension point to inject full control of how how c10d
state behaves.
One simple hack is to change _world to an implementation that uses a threadlocal
and enable per-thread PGs.
It almost get DDP working and the PG is missing an implementation of all_reduce.
This enables notebook usage of PTD, which is a big deal for learning it:
https://gist.github.com/kumpera/32cb051fa26b8cad8bdf671f968dcd68
This change ensures BC by keeping the global variables around and have the default _World wrap it.
I have relinked this diff to a new github PR, so that I can update it. The original PR is
Differential Revision: D40236769
Pulled By: yhcharles