KEMBAR78
[distributed] add PG APIs and general doc cleanups by d4l3k · Pull Request #140853 · pytorch/pytorch · GitHub
Skip to content

Conversation

@d4l3k
Copy link
Member

@d4l3k d4l3k commented Nov 15, 2024

Doc updates:

  • This adds documentation for the object oriented ProcessGroup APIs that are being used in torchft as well as RFC-0042-torch-distributed-redesign rfcs#71 .
  • It also does some general cleanups to simplify the distributed.rst by using :methods.
  • It adds __init__ definitions for the Stores
  • I've reordered things so the collective APIs are before the Store/PG apis

Test plan:

lintrunner -a
cd docs && sphinx-autobuild source build/ -j auto -WT --keep-going

cc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @c-p-i-o

@d4l3k d4l3k requested a review from wconstab November 15, 2024 22:01
@pytorch-bot pytorch-bot bot added oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (c10d) release notes category labels Nov 15, 2024
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 15, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/140853

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 8662b64 with merge base 48a276c (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@d4l3k d4l3k requested review from c-p-i-o and fduwjj November 15, 2024 22:24

There are some notable differences:

* These APIs are always asynchronous and require you to manually synchronize the returned :class:`~torch.distributed.Work` objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't users still manually create a PG and then call dist.all_reduce(group=pg) and get the same thing, but without skipping our validation layers that are only present in the upper layer?

I'm still wondering in what cases it would be good to call pg.all_reduce instead. (Granted, my other PRs for adding 'group_src'/'group_dst' are needed for this statement to hold.)

Also, I haven't looked at it carefully but I am worried about manual PG creation skipping our UUID logic. I think that ends up not mattering if you use a prefix store for each pg, but if you use the same prefix store for 2 PGs by accident you'd be in trouble right? Should we actually encourage users to use ProcessGroup ctor? or should we improve our new_group type APIs to let the PGs be created without a harmful tie to the world?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I talked with vllm in one of their PRs.
A potential thing we can do is to improve the new_group API so that it does not require init_process_group (world creation) first.
vllm-project/vllm#10216 (review)

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed, removed this documentation in favor of your other PRs

&::c10d::ProcessGroupNCCL::abort,
py::call_guard<py::gil_scoped_release>())
py::call_guard<py::gil_scoped_release>(),
R"(Abort the process group.)")
Copy link
Contributor

Choose a reason for hiding this comment

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

note to check; do we have proper docs about this API in our c10d layer? iirc it is a new/experimental api

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we have any docs on abort

@wconstab
Copy link
Contributor

was going to stamp anyway, despite my question above, since the overall changes are good. But there is some problem, it looks like the doc build is failing. I noticed when I tried to click on the py docs build link and it didn't open.

2024-11-15T22:44:31.1428247Z WARNING: autodoc: failed to import class 'ProcessGroupNCCL' from module 'torch.distributed'; the following exception was raised:
2024-11-15T22:44:31.1428955Z Traceback (most recent call last):
2024-11-15T22:44:31.1429559Z   File "/opt/conda/envs/py_3.9/lib/python3.9/site-packages/sphinx/util/inspect.py", line 376, in safe_getattr
2024-11-15T22:44:31.1430177Z     return getattr(obj, name, *defargs)
2024-11-15T22:44:31.1430672Z AttributeError: module 'torch.distributed' has no attribute 'ProcessGroupNCCL'
2024-11-15T22:44:31.1431074Z 
2024-11-15T22:44:31.1431292Z The above exception was the direct cause of the following exception:

Copy link
Contributor

@kwen2501 kwen2501 left a comment

Choose a reason for hiding this comment

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

Overall looks good.
I left a couple comments inline. Would appreciate it if we could "de-emphasize" the support before merge.

Comment on lines 533 to 534
APIs but if you need more control over the process groups (i.e. dynamic world
sizes) you can directly instantiate them.
Copy link
Contributor

@kwen2501 kwen2501 Nov 17, 2024

Choose a reason for hiding this comment

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

Sorry, what does the "dynamic world size" feature refer to?

I am a little bit unsure about suggesting direct instantiation of ProcessGroupNCCL or ProcessGroupGloo in our documentation. The main reason is that it may go against device generalization. As in, if other device backends follow, they may also request a pybind of their backend classes to dist and an exposure in doc.

For power users, such usage would be per their choice (after digging into our code) and that's okay.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed


There are some notable differences:

* These APIs are always asynchronous and require you to manually synchronize the returned :class:`~torch.distributed.Work` objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I talked with vllm in one of their PRs.
A potential thing we can do is to improve the new_group API so that it does not require init_process_group (world creation) first.
vllm-project/vllm#10216 (review)

Comment on lines 529 to 530
Object Oriented Process Groups
------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

The title sounds like we support member method calling on these ProcessGroup objects? I am not sure we have signed up to support that?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, upon further discussion I think it's best to not recommend users use this

@d4l3k
Copy link
Member Author

d4l3k commented Nov 18, 2024

I updated this to remove documenting the PG API and just keeping the doc cleanups.

After discussion I think it's better to improve new_group api in combination with the changes @wconstab is doing to use group ranks

@d4l3k
Copy link
Member Author

d4l3k commented Nov 18, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 18, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@d4l3k d4l3k deleted the d4l3k/dist_docs branch November 19, 2024 18:20
@d4l3k d4l3k restored the d4l3k/dist_docs branch November 19, 2024 18:24
Ryo-not-rio pushed a commit to Ryo-not-rio/pytorch that referenced this pull request Dec 2, 2024
Doc updates:

* This adds documentation for the object oriented ProcessGroup APIs that are being used in torchft as well as pytorch/rfcs#71 .
* It also does some general cleanups to simplify the distributed.rst by using `:methods`.
* It adds `__init__` definitions for the Stores
* I've reordered things so the collective APIs are before the Store/PG apis

Test plan:

```
lintrunner -a
cd docs && sphinx-autobuild source build/ -j auto -WT --keep-going
```

Pull Request resolved: pytorch#140853
Approved by: https://github.com/kwen2501
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
Doc updates:

* This adds documentation for the object oriented ProcessGroup APIs that are being used in torchft as well as pytorch/rfcs#71 .
* It also does some general cleanups to simplify the distributed.rst by using `:methods`.
* It adds `__init__` definitions for the Stores
* I've reordered things so the collective APIs are before the Store/PG apis

Test plan:

```
lintrunner -a
cd docs && sphinx-autobuild source build/ -j auto -WT --keep-going
```

Pull Request resolved: pytorch#140853
Approved by: https://github.com/kwen2501
@github-actions github-actions bot deleted the d4l3k/dist_docs branch December 20, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (c10d) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants