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

[NCCL][Test Only] extra group #45363

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions test/test_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from functools import reduce
from operator import mul
from collections import OrderedDict
import torch.distributed as dist

import torch

Expand Down
2 changes: 2 additions & 0 deletions torch/csrc/cuda/nccl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ void broadcast(

AutoNcclGroup nccl_group_guard;
at::cuda::OptionalCUDAGuard device_guard;
ncclGroupStart();
for (size_t i = 0, num_tensors = tensors.size(); i < num_tensors; i++) {
int device = tensors[i].get_device();
device_guard.set_index(device);
Expand All @@ -427,6 +428,7 @@ void broadcast(
NCCL_CHECK(from_nccl_result(ncclBcast(
tensors[i].data_ptr(), numel, data_type, 0, *(to_nccl_comm(&comm)), stream)));
}
ncclGroupEnd();
#else
AT_ERROR("PyTorch built without NCCL support");
#endif
Expand Down
3 changes: 3 additions & 0 deletions torch/lib/c10d/ProcessGroupNCCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,8 @@ std::shared_ptr<ProcessGroup::Work> ProcessGroupNCCL::collective(
inputs[i].storage().data_ptr(), ncclStream);
}

std::cout << "extra group" << std::endl;
C10D_NCCL_CHECK(ncclGroupStart());
{
AutoNcclGroup nccl_group_guard;
for (size_t i = 0; i < inputs.size(); ++i) {
Expand All @@ -1035,6 +1037,7 @@ std::shared_ptr<ProcessGroup::Work> ProcessGroupNCCL::collective(
fn(inputs[i], outputs[i], ncclComms[i]->getNcclComm(), ncclStream));
}
}
C10D_NCCL_CHECK(ncclGroupEnd());

post(ncclStreams_[key]);

Expand Down