Skip to content
Merged
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
24 changes: 17 additions & 7 deletions src/xccl/ProcessGroupXCCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> ProcessGroupXCCL::initWork(
xpuEventCacheEnabled_.load());

if (record) {
r->trace_id_ = FlightRecorderXCCL::get()->record(
auto traceId = FlightRecorderXCCL::get()->recordWithResetEnabled(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
Expand All @@ -522,6 +522,9 @@ c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> ProcessGroupXCCL::initWork(
options_->timeout,
pgStatus_,
isP2P);

r->trace_id_ = traceId.id;
r->trace_reset_epoch_ = traceId.reset_epoch;
}
return r;
}
Expand Down Expand Up @@ -847,9 +850,11 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::collective(
c10::ListType::create(c10::TensorType::get()), devices);
work->future_->markCompleted(at::IValue(*work->outputs_));
auto id = work->trace_id_;
auto reset_epoch = work->trace_reset_epoch_;
work->future_->addCallback(
[id](at::ivalue::Future&) {
FlightRecorderXCCL::get()->retire_id(id, /*compute_duration*/ false);
[id, reset_epoch](at::ivalue::Future&) {
FlightRecorderXCCL::get()->retire_id(
id, reset_epoch, /*compute_duration*/ false);
},
/*use_future*/ false);
work->blockingWait_ = blockingWait_;
Expand Down Expand Up @@ -929,7 +934,7 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(

c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> work;
if (coalescing_state_) {
FlightRecorderXCCL::get()->record(
FlightRecorderXCCL::get()->recordWithResetEnabled(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
Expand All @@ -948,7 +953,7 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(
work->outputs_ = std::make_shared<std::vector<at::Tensor>>();
work->outputs_->push_back(tensor);

work->trace_id_ = FlightRecorderXCCL::get()->record(
auto traceId = FlightRecorderXCCL::get()->recordWithResetEnabled(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
Expand All @@ -962,6 +967,9 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(
options_->timeout,
pgStatus_,
true);

work->trace_id_ = traceId.id;
work->trace_reset_epoch_ = traceId.reset_epoch;
}

if (enableNanCheck_ && opType == OpType::SEND) {
Expand Down Expand Up @@ -999,9 +1007,11 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(
}

auto id = work->trace_id_;
auto reset_epoch = work->trace_reset_epoch_;
work->future_->addCallback(
[id](at::ivalue::Future&) {
FlightRecorderXCCL::get()->retire_id(id, /*compute_duration*/ false);
[id, reset_epoch](at::ivalue::Future&) {
FlightRecorderXCCL::get()->retire_id(
id, reset_epoch, /*compute_duration*/ false);
},
/*use_future*/ false);
setEnqueuedPgStatus(work);
Expand Down
3 changes: 2 additions & 1 deletion src/xccl/ProcessGroupXCCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class TORCH_API ProcessGroupXCCL : public Backend {
std::chrono::time_point<std::chrono::steady_clock> workStartTime_;
uint64_t seq_;
bool isP2P_;
std::optional<uint64_t> trace_id_;
std::optional<size_t> trace_id_;
std::optional<size_t> trace_reset_epoch_;
size_t numelIn_ = -1;
size_t numelOut_ = -1;

Expand Down