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
17 changes: 11 additions & 6 deletions src/xccl/ProcessGroupXCCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ bool ProcessGroupXCCL::WorkXCCL::wait(std::chrono::milliseconds timeout) {
return true;
}

ProcessGroupXCCL::Options::Options() : Backend::Options(XCCL_BACKEND_NAME) {}
ProcessGroupXCCL::Options::Options(bool is_high_priority_stream)
: Backend::Options(XCCL_BACKEND_NAME),
is_high_priority_stream(is_high_priority_stream) {}

static std::atomic<size_t> process_group_id = 0;

Expand Down Expand Up @@ -351,7 +353,7 @@ const std::string& ProcessGroupXCCL::logPrefix() const {
}

ProcessGroupXCCL::ProcessGroupXCCL(
const c10::intrusive_ptr<Store>& store,
c10::intrusive_ptr<Store> store,
int rank,
int size,
c10::intrusive_ptr<Options> options)
Expand All @@ -377,7 +379,10 @@ ProcessGroupXCCL::ProcessGroupXCCL(
std::string torch_distributed_debug =
getCvarString({"TORCH_DISTRIBUTED_DEBUG"}, OFF.c_str());
LOG(INFO) << logPrefix() << "ProcessGroupXCCL initialization options: "
<< "size: " << size << ", global rank: " << rank_;
<< "size: " << size << ", global rank: " << rank_
<< ", USE_HIGH_PRIORITY_STREAM: "
<< options_->is_high_priority_stream
<< ", PG Name: " << options_->group_name;

LOG(INFO) << logPrefix() << "ProcessGroupXCCL environments: "
<< "XCCL version: " << XcclVersion
Expand Down Expand Up @@ -534,9 +539,9 @@ std::shared_ptr<xcclComm_t> ProcessGroupXCCL::getXCCLComm(
rank = p2pRank;
}

c10::impl::VirtualGuardImpl impl(device.type());
c10::Stream stream =
impl.getStreamFromGlobalPool(device, /*isHighPriority=*/false);
bool force_high = getCvarBool(TORCH_XCCL_HIGH_PRIORITY, false);
c10::Stream stream = at::xpu::getStreamFromPool(
options_->is_high_priority_stream || force_high);
sycl::queue& q = c10::xpu::XPUStream(stream).queue();

auto ctx = ccl::create_context(q.get_context());
Expand Down
23 changes: 16 additions & 7 deletions src/xccl/ProcessGroupXCCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <xccl/ProcessGroupXCCLMonitor.hpp>
namespace c10d {

static std::vector<std::string> TORCH_XCCL_HIGH_PRIORITY = {
"TORCH_XCCL_HIGH_PRIORITY"};

static std::vector<std::string> TORCH_XCCL_BLOCKING_WAIT = {
"TORCH_XCCL_BLOCKING_WAIT",
"XCCL_BLOCKING_WAIT"};
Expand Down Expand Up @@ -118,18 +121,19 @@ class TORCH_API ProcessGroupXCCL : public Backend {
};

struct Options : public Backend::Options {
explicit Options();
explicit Options(bool is_high_priority_stream = false);

static c10::intrusive_ptr<Options> create() {
return c10::make_intrusive<Options>();
static c10::intrusive_ptr<Options> create(
bool is_high_priority_stream = false) {
return c10::make_intrusive<Options>(is_high_priority_stream);
}

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

ProcessGroupXCCL(
const c10::intrusive_ptr<Store>& store,
c10::intrusive_ptr<Store> store,
int rank,
int size,
c10::intrusive_ptr<Options> options = Options::create());
Expand All @@ -138,11 +142,16 @@ class TORCH_API ProcessGroupXCCL : public Backend {
const c10::intrusive_ptr<Store>& store,
int rank,
int size,
const std::string& groupName)
: ProcessGroupXCCL(store, rank, size) {}
const std::string& groupName,
c10::intrusive_ptr<Options> options = Options::create())
: ProcessGroupXCCL(store, rank, size, std::move(options)) {}

~ProcessGroupXCCL() override;

c10::intrusive_ptr<Options> getOptions() {
return options_;
}

const std::string getBackendName() const override {
return std::string(XCCL_BACKEND_NAME);
}
Expand Down