Skip to content

[c10d] Make send/recv as custom ops#79779

Closed
alanwaketan wants to merge 5 commits intogh/alanwaketan/42/basefrom
gh/alanwaketan/42/head
Closed

[c10d] Make send/recv as custom ops#79779
alanwaketan wants to merge 5 commits intogh/alanwaketan/42/basefrom
gh/alanwaketan/42/head

Conversation

@alanwaketan
Copy link
Copy Markdown
Collaborator

@alanwaketan alanwaketan commented Jun 17, 2022

Stack from ghstack (oldest at bottom):

Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

[ghstack-poisoned]
@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Jun 17, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

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

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

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

Click here to manually regenerate this comment.

alanwaketan pushed a commit that referenced this pull request Jun 17, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

ghstack-source-id: d0536fb
Pull Request resolved: #79779
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

[ghstack-poisoned]
alanwaketan pushed a commit that referenced this pull request Jun 17, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

ghstack-source-id: c627df1
Pull Request resolved: #79779
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

[ghstack-poisoned]
alanwaketan pushed a commit that referenced this pull request Jun 22, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

ghstack-source-id: b5cad84
Pull Request resolved: #79779
@alanwaketan alanwaketan requested a review from wanchaol June 22, 2022 23:45
@mrshenli mrshenli added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 24, 2022
}

c10::intrusive_ptr<ProcessGroup::Work> send(
at::TensorList tensors,
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.

same comment on TensorList vs std::vector<Tensor>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it's a convention to use TensorList to represent const std::vectorat::Tensor&.

I only use const std::vectorat::Tensor& if there is a const std::vectorstd::vectorat::Tensor& in the signature to keep consistency on that function. Let me know which way you like.

BarrierOptions{device_ids, std::chrono::milliseconds(timeout)});
}

c10::intrusive_ptr<ProcessGroup::Work> send(
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.

trailing underscore?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Send is not a in-place op. So there is no needs to have a trailing _.

Copy link
Copy Markdown
Collaborator

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

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

lgtm, have some questions.

int64_t dstRank,
int64_t tag) {
static auto op = c10::Dispatcher::singleton()
.findSchemaOrThrow("c10d::send", "")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hmm would we not find the schema by any chance?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Why would you have such concern? Do you happen to know another op called "c10d::send" as well?

return op.call(tensors, process_group, dstRank, tag);
}

c10::intrusive_ptr<ProcessGroup::Work> recv(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just noticed we have this recv and recv_ two separate APIs (above), what's the difference between these two and should we merge?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The above recv_ is the implementation of the function schema. This one is the C++ API for users to call the op. recv_ follows aten ops's conventions while recv follows c10d's conventions.

Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

[ghstack-poisoned]
alanwaketan pushed a commit that referenced this pull request Jun 27, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

ghstack-source-id: 07f0d10
Pull Request resolved: #79779
@alanwaketan
Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge --green

@alanwaketan
Copy link
Copy Markdown
Collaborator Author

Thanks for approving this pull request, Shen and Wanchao.

@pytorchmergebot

This comment was marked as outdated.

@pytorchmergebot

This comment was marked as outdated.

Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

[ghstack-poisoned]
alanwaketan pushed a commit that referenced this pull request Jun 27, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Test Plan:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

ghstack-source-id: b1c39c2
Pull Request resolved: #79779
@alanwaketan
Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge --green

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Copy Markdown
Contributor

Hey @alanwaketan.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Jun 30, 2022
Summary:
This patch makes send/recv as custom ops such that it's dispatcher
passable. It's one part of the effort to route comm ops to the dispatcher
such that tracing mechanisms that relies on the dispatcher can trace them,
e.g., LazyTensor and AOTAutograd.

Pull Request resolved: #79779
Approved by: https://github.com/mrshenli, https://github.com/wanchaol

Test Plan:
contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/79c2dfcd8ef3ab2ca14a942109242ae7440dd6b1

Test plan from GitHub:
python test/distributed/test_c10d_nccl.py -k test_send_recv
...and other existing distributed tests.

Reviewed By: b0noI

Differential Revision: D37509682

Pulled By: alanwaketan

fbshipit-source-id: a3a698f85b64b256618b8af95dd29aade4b50d74
@facebook-github-bot facebook-github-bot deleted the gh/alanwaketan/42/head branch July 1, 2022 14:18
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 cla signed Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (c10d) release notes category topic: new features topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants