Skip to content

[Dist Profiling] Enable profiling for gloo send/recv - #52004

Closed
rohan-varma wants to merge 5 commits into
gh/rohan-varma/232/basefrom
gh/rohan-varma/232/head
Closed

rohan-varma wants to merge 5 commits into
gh/rohan-varma/232/basefrom
gh/rohan-varma/232/head

Conversation

@rohan-varma

@rohan-varma rohan-varma commented Feb 9, 2021 •

Copy link
Copy Markdown
Contributor

Stack from ghstack:

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: D26347164

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added cla signed oncall: distributed Add this issue/PR to distributed oncall triage queue labels Feb 9, 2021
@facebook-github-bot

facebook-github-bot commented Feb 9, 2021 •

Copy link
Copy Markdown
Contributor

💊 CI failures summary and remediations

As of commit c1e814d (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)

[ghstack-poisoned]
rohan-varma added a commit that referenced this pull request Feb 10, 2021
Pull Request resolved: #52004

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.
ghstack-source-id: 121398086

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)
@rohan-varma
rohan-varma requested a review from mrzzd February 10, 2021 00:18
Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)

[ghstack-poisoned]
Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)

[ghstack-poisoned]
-1,
OpType::UNKNOWN,
profilingTitle,
c10::optional<std::vector<at::Tensor>>({tensor})),

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.

For receive op, the output tensor does not have it's final dimension until end of the operation right? Then does it record the operator shape correctly?

@rohan-varma rohan-varma Feb 11, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think if the user does something like:

# on rank 1
dist.recv(tensor, src=0)

Then tensor is expected to be correctly sized with whatever tensor rank 0 is sending to 1. This appears to be true in all our tests in distributed_test.py and also the docs imply this: https://github.com/pytorch/pytorch/blob/master/torch/distributed/distributed_c10d.py#L819.

So we should be fine if we just record the shape of the tensor input into recv, and this seems to work with the unittests below as well.

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.

I could not understand it from the docs. If the API does not require that explicitly, could you double check that in case the output tensor is not sized prior to call, recv does not work properly?

@rohan-varma rohan-varma Feb 12, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I just re-verified this in the tests. In test_send_recv, if you change:
output_tensor = _build_tensor(recv_size, value=-1) to
output_tensor = _build_tensor(recv_size -1, value=-1) we run into the following error:

W0211 16:35:58.875078 813884 ExceptionTracer.cpp:185] Invalid trace stack for exception of type: gl
oo::EnforceNotMet
terminate called after throwing an instance of 'gloo::EnforceNotMet'
  what():  [enforce fail at gloo/transport/tcp/pair.cc:510] op.preamble.length <= op.nbytes. 4 vs 0
/data/users/rvarm1/fbsource/fbcode/buck-out/dev/gen/caffe2/test/distributed/distributed_nccl_fork#b
inary,link-tree/torch/testing/_internal/common_distributed.py:292: Caught exception:
Traceback (most recent call last):
  File "/data/users/rvarm1/fbsource/fbcode/buck-out/dev/gen/caffe2/test/distributed/distributed_ncc
l_fork#binary,link-tree/torch/testing/_internal/common_distributed.py", line 289, in wrapper
    fn()
  File "/data/users/rvarm1/fbsource/fbcode/buck-out/dev/gen/caffe2/test/distributed/distributed_ncc
l_fork#binary,link-tree/torch/testing/_internal/distributed/distributed_test.py", line 885, in test
_send_recv
    dist.recv(output_tensor, src)
  File "/data/users/rvarm1/fbsource/fbcode/buck-out/dev/gen/caffe2/test/distributed/distributed_ncc
l_fork#binary,link-tree/torch/distributed/distributed_c10d.py", line 850, in recv
    pg.recv([tensor], src, tag).wait()
RuntimeError: [gloo/transport/tcp/pair.cc:589] Read error [2401:db00:21:6045:face:0:5:0]:12722: Con
nection reset by peer
exiting process with exit code: 10
Process 0 terminated with exit code 10, terminating remaining processes.
ERROR

So it looks like tensor cannot be smaller than send tensor. However, if the recv tensor size is larger, then the recv succeeds, and we record this larger shape. However I believe that this is the desired behavior, since the larger tensor is what is input into gloo:recv buffer.

@rohan-varma
rohan-varma requested a review from mrzzd February 11, 2021 00:34
Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.

Differential Revision: [D26347164](https://our.internmc.facebook.com/intern/diff/D26347164/)

[ghstack-poisoned]

@mrzzd mrzzd left a comment

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.

Thanks Rohan!

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 7b21c6b.

@facebook-github-bot
facebook-github-bot deleted the gh/rohan-varma/232/head branch February 16, 2021 15:18
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Pull Request resolved: pytorch#52004

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.
ghstack-source-id: 121507511

Test Plan: CI

Reviewed By: mrzzd

Differential Revision: D26347164

fbshipit-source-id: f4d1c474fccf40d5776fc13c4add7a053ea08960
wubai pushed a commit to wubai/pytorch that referenced this pull request Aug 6, 2023
Summary:
Pull Request resolved: pytorch#52004

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.
ghstack-source-id: 121507511

Test Plan: CI

Reviewed By: mrzzd

Differential Revision: D26347164

fbshipit-source-id: f4d1c474fccf40d5776fc13c4add7a053ea08960
wubai pushed a commit to wubai/pytorch that referenced this pull request Aug 8, 2023
Summary:
Pull Request resolved: pytorch#52004

Enables profiling of p2p collectives for Gloo. Modified/added relevant unittests.
ghstack-source-id: 121507511

Test Plan: CI

Reviewed By: mrzzd

Differential Revision: D26347164

fbshipit-source-id: f4d1c474fccf40d5776fc13c4add7a053ea08960
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged oncall: distributed Add this issue/PR to distributed oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants