Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions src/xccl/ProcessGroupXCCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> ProcessGroupXCCL::initWork(
bool isP2P,
const char* profilingTitle,
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
const std::vector<at::Tensor>& outputs,
bool record) {
auto r = c10::make_intrusive<ProcessGroupXCCL::WorkXCCL>(
device,
rank,
Expand All @@ -466,20 +467,22 @@ c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> ProcessGroupXCCL::initWork(
profilingTitle != nullptr ? std::optional<std::vector<at::Tensor>>(inputs)
: std::nullopt);

r->trace_id_ = FlightRecorderXCCL::get()->record(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
seqP2P_,
op_id_,
profilingTitle ? profilingTitle : "",
inputs,
outputs,
nullptr,
r->xcclEndEvent_.get(),
options_->timeout,
pgStatus_,
isP2P);
if (record) {
r->trace_id_ = FlightRecorderXCCL::get()->record(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
seqP2P_,
op_id_,
profilingTitle ? profilingTitle : "",
inputs,
outputs,
nullptr,
r->xcclEndEvent_.get(),
options_->timeout,
pgStatus_,
isP2P);
}
return r;
}

Expand Down Expand Up @@ -660,16 +663,19 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::collective(
const char* profilingTitle,
bool nanCheck) {
nanCheck &= enableNanCheck_;
seqCollective_++;
auto device = inputs[0].device();
const auto key = std::to_string(device.index());
auto comm = getXCCLComm(key, device, opType);

if (!coalescing_state_) {
seqCollective_++;
}
op_id_++;

if (coalescing_state_ & CoalActive) {
if ((coalescing_state_ & CoalColl) == 0) {
seqCollective_++;
}
op_id_++;
coalescing_state_ |= CoalColl;
if (coalescedDevice_.index() < 0) {
coalescedDevice_ = device;
Expand Down Expand Up @@ -710,8 +716,15 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::collective(
}

c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> work;
work =
initWork(device, rank_, opType, false, profilingTitle, inputs, outputs);
work = initWork(
device,
rank_,
opType,
false,
profilingTitle,
inputs,
outputs,
!coalescing_state_);
if (coalescing_state_) {
FlightRecorderXCCL::get()->record(
local_id_,
Expand Down
6 changes: 2 additions & 4 deletions src/xccl/ProcessGroupXCCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ class TORCH_API ProcessGroupXCCL : public Backend {
static c10::intrusive_ptr<Options> create() {
return c10::make_intrusive<Options>();
}

std::vector<uint64_t> global_ranks_in_group;
std::string group_name;
};

ProcessGroupXCCL(
Expand Down Expand Up @@ -171,7 +168,8 @@ class TORCH_API ProcessGroupXCCL : public Backend {
bool isP2P,
const char* profilingTitle = nullptr,
const std::vector<at::Tensor>& inputs = {},
const std::vector<at::Tensor>& outputs = {});
const std::vector<at::Tensor>& outputs = {},
bool record = false);

Choose a reason for hiding this comment

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

Does it follow the same logic like NCCL backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, NCCL uses the same logic. Sometimes initWork needs to be recorded, but in other cases it causes improper access in FlightRecorder.


template <typename Fn>
c10::intrusive_ptr<Work> collective(
Expand Down
Loading
Loading