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
25 changes: 17 additions & 8 deletions src/xccl/ProcessGroupXCCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ c10::intrusive_ptr<ProcessGroupXCCL::WorkXCCL> ProcessGroupXCCL::initWork(
: std::nullopt);

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

r->trace_id_ = traceId.id;
Copy link
Contributor

@zhangxiaoli73 zhangxiaoli73 Nov 5, 2025

Choose a reason for hiding this comment

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

This change depends on PyTorch PR pytorch/pytorch#166970, and 166970 also depends on this PR for merging, creating a circular dependency. Could you please add a check to see if traceId is of type uint64_t? If it is, assign trace_id_ directly to r->trace_id_; otherwise, parse it using traceId.id.

r->trace_reset_epoch_ = traceId.reset_epoch;
}
return r;
}
Expand Down Expand Up @@ -803,9 +806,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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let’s not pass it for now to maintain compatibility with both before and after the 166970 merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
id, reset_epoch, /*compute_duration*/ false);
id, /*compute_duration*/ false);

},
/*use_future*/ false);
work->blockingWait_ = blockingWait_;
Expand Down Expand Up @@ -891,7 +896,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()->record(
local_id_,
std::make_tuple(pg_uid_, pg_desc_), // PG name tuple
seqCollective_,
Expand All @@ -905,6 +910,8 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(
options_->timeout,
pgStatus_,
true);
work->trace_id_ = traceId.id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Could you please add a check to see if traceId is of type uint64_t? If it is, assign trace_id_ directly to r->trace_id_; otherwise, parse it using traceId.id.

work->trace_reset_epoch_ = traceId.reset_epoch;

c10::OptionalDeviceGuard gpuGuard(device);

Expand All @@ -922,9 +929,11 @@ c10::intrusive_ptr<Work> ProcessGroupXCCL::pointToPoint(
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);

Expand Down Expand Up @@ -2059,8 +2068,8 @@ c10::DeviceIndex ProcessGroupXCCL::guessDeviceId() const {
} else if (!usedDeviceIdxs_.empty()) {
return *usedDeviceIdxs_.begin();
}
int devIdx =
static_cast<int16_t>(globalRank() % at::detail::getXPUHooks().getNumGPUs());
int devIdx = static_cast<int16_t>(
globalRank() % at::detail::getXPUHooks().getNumGPUs());
LOG(WARNING)
<< logPrefix()
<< c10::str(
Expand Down
1 change: 1 addition & 0 deletions src/xccl/ProcessGroupXCCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class TORCH_API ProcessGroupXCCL : public Backend {
uint64_t seq_;
bool isP2P_;
std::optional<uint64_t> trace_id_;
std::optional<uint64_t> trace_reset_epoch_;
size_t numelIn_ = -1;
size_t numelOut_ = -1;

Expand Down