Skip to content
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

Bugfix for Collective Default Stream #48308

4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/alltoall_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class AllToAllOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/barrier_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class BarrierOpCUDAKernel : public framework::OpKernel<T> {

int rid = ctx.Attr<int>("ring_id");
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
auto stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
auto stream = ctx.cuda_device_context().stream();
ncclRedOp_t nccl_red_type = ncclSum;
PADDLE_ENFORCE_GPU_SUCCESS(platform::dynload::ncclAllReduce(
sendbuff, recvbuff, numel, dtype, nccl_red_type, comm->comm(), stream));
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_allgather_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class CAllGatherOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
6 changes: 4 additions & 2 deletions paddle/fluid/operators/collective/c_allreduce_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ class CAllReduceOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should not use global ctx for calc stream.
// auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
// stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_broadcast_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class CBroadcastOpCUDAKernel : public framework::OpKernel<T> {
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_concat_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class CConcatOpCUDAKernel : public framework::OpKernel<T> {
const T* send_buff = x->data<T>();
T* recv_buff = temp_out.data<T>();
gpuStream_t stream = nullptr;
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();

PADDLE_ENFORCE_GPU_SUCCESS(
platform::dynload::ncclAllGather(send_buff,
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_reduce_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ class CReduceOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_reducescatter_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class CReduceScatterOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_scatter_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class CScatterOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/global_gather_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct GlobalGatherFunctor<phi::GPUContext, T> {
auto comm = platform::NCCLCommContext::Instance().Get(ring_id, place);
gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/global_scatter_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ struct GlobalScatterFunctor<phi::GPUContext, T> {
auto comm = platform::NCCLCommContext::Instance().Get(ring_id, place);
gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/partial_allgather_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class PartialAllGatherOpCUDAKernel : public framework::OpKernel<T> {

gpuStream_t stream = nullptr;
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/partial_recv_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class PartialRecvOpCUDAKernel : public framework::OpKernel<T> {
gpuStream_t stream = nullptr;
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext *>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/partial_send_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class PartialSendCUDAKernel : public framework::OpKernel<T> {
auto place = ctx.GetPlace();
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/recv_v2_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class RecvOpV2CUDAKernel : public framework::OpKernel<T> {
}
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext *>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/send_v2_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ class SendOpV2CUDAKernel : public framework::OpKernel<T> {
auto place = ctx.GetPlace();
auto comm = platform::NCCLCommContext::Instance().Get(rid, place);
if (ctx.Attr<bool>("use_calc_stream")) {
auto dev_ctx = platform::DeviceContextPool::Instance().Get(place);
stream = static_cast<phi::GPUContext*>(dev_ctx)->stream();
// should ExecutionContext for calc stream.
stream = ctx.cuda_device_context().stream();
} else {
stream = comm->stream();
}
Expand Down