Skip to content

Temp fix for bug in scale-out profiling by adding env variable to disable profiler around allreduce #1697

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
12 changes: 12 additions & 0 deletions src/xccl/Register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
#include <c10/util/intrusive_ptr.h>
#include <torch/csrc/distributed/c10d/ProcessGroup.hpp>
#include <torch/csrc/distributed/c10d/Types.hpp>
#include <torch/csrc/autograd/profiler.h>
#include <torch/library.h>

static std::vector<std::string> TORCH_XCCL_DISABLE_ALLREDUCE_PROFILER = {
"TORCH_XCCL_DISABLE_ALLREDUCE_PROFILER",
"XCCL_DISABLE_ALLREDUCE_PROFILER"};

namespace c10d {
namespace ops {
namespace {
Expand Down Expand Up @@ -84,13 +89,20 @@ std::tuple<std::vector<at::Tensor>, c10::intrusive_ptr<Work>> allreduce_XPU(
bool asyncOp,
int64_t timeout) {
auto tensor_vec = tensors.vec();
// Due to bug in PTI, profiling needs to be skipped for allreduce between multiple nodes
// TODO: Remove this when PTI is fixed
bool disableAllreduceProfiler = getCvarBool(TORCH_XCCL_DISABLE_ALLREDUCE_PROFILER) && torch::autograd::profiler::profilerEnabled();
if (disableAllreduceProfiler)
torch::autograd::profiler::toggleCollectionDynamic(false, {torch::autograd::profiler::ActivityType::XPU});
auto work = process_group->getBackend(c10::DeviceType::XPU)
->allreduce(
tensor_vec,
AllreduceOptions{
*reduce_op.get(),
std::chrono::milliseconds(timeout),
asyncOp});
if (disableAllreduceProfiler)
torch::autograd::profiler::toggleCollectionDynamic(true, {torch::autograd::profiler::ActivityType::XPU});
return std::tuple<std::vector<at::Tensor>, c10::intrusive_ptr<Work>>(
std::move(tensor_vec), work);
}
Expand Down