Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b8bce682
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b8bce682
编写于
2月 26, 2021
作者:
W
WangXi
提交者:
GitHub
2月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xpu support fuse allreduce (#31104)
上级
59b00e8c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
8 deletion
+26
-8
paddle/fluid/framework/details/fused_all_reduce_op_handle.cc
paddle/fluid/framework/details/fused_all_reduce_op_handle.cc
+3
-7
paddle/fluid/operators/coalesce_tensor_op.cc
paddle/fluid/operators/coalesce_tensor_op.cc
+10
-0
paddle/fluid/platform/device_memory_aligment.cc
paddle/fluid/platform/device_memory_aligment.cc
+3
-0
python/paddle/fluid/tests/unittests/parallel_executor_test_base.py
...ddle/fluid/tests/unittests/parallel_executor_test_base.py
+0
-1
python/paddle/fluid/tests/unittests/test_fuse_all_reduce_pass.py
...paddle/fluid/tests/unittests/test_fuse_all_reduce_pass.py
+10
-0
未找到文件。
paddle/fluid/framework/details/fused_all_reduce_op_handle.cc
浏览文件 @
b8bce682
...
...
@@ -76,14 +76,10 @@ void FusedAllReduceOpHandle::RunImpl() {
"handles is %d, and the number of output variable handles is %d."
,
in_var_handles
.
size
(),
out_var_handles
.
size
()));
// Note: some gradient op doesn't have CUDAKernel, so the gradients of
// those op are in CPUPlace, in this case, the all reduce should not be fused.
#if defined(PADDLE_WITH_XPU_BKCL)
// TODO(liuyuhui): XPU don't support fuse all reduce for now
if
(
InputIsInDifferentPlace
(
in_var_handles
)
||
true
)
{
#else
// Note: some gradient op doesn't have CUDAKernel or XPUKernel, so the
// gradients of those op are in CPUPlace, in this case, the all reduce
// should not be fused.
if
(
InputIsInDifferentPlace
(
in_var_handles
))
{
#endif
for
(
size_t
j
=
0
;
j
<
num_of_all_reduce_
;
++
j
)
{
std
::
vector
<
VarHandle
*>
dev_inputs
;
std
::
vector
<
VarHandle
*>
dev_outputs
;
...
...
paddle/fluid/operators/coalesce_tensor_op.cc
浏览文件 @
b8bce682
...
...
@@ -299,6 +299,16 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
CoalesceTensorOpKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
);
#endif
#ifdef PADDLE_WITH_XPU
REGISTER_OP_XPU_KERNEL
(
coalesce_tensor
,
ops
::
CoalesceTensorOpKernel
<
paddle
::
platform
::
XPUDeviceContext
,
plat
::
float16
>
,
ops
::
CoalesceTensorOpKernel
<
paddle
::
platform
::
XPUDeviceContext
,
int
>
,
ops
::
CoalesceTensorOpKernel
<
paddle
::
platform
::
XPUDeviceContext
,
float
>
,
ops
::
CoalesceTensorOpKernel
<
paddle
::
platform
::
XPUDeviceContext
,
double
>
);
#endif
REGISTER_OP_VERSION
(
coalesce_tensor
)
.
AddCheckpoint
(
R"ROC(
...
...
paddle/fluid/platform/device_memory_aligment.cc
浏览文件 @
b8bce682
...
...
@@ -23,6 +23,9 @@ size_t Alignment(size_t size, const platform::Place &place) {
}
else
{
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
alignment
=
GpuMinChunkSize
();
#elif defined(PADDLE_WITH_XPU)
// TODO(wangxi): add XpuMinChunkSize
alignment
=
alignment
;
#else
PADDLE_THROW
(
platform
::
errors
::
PreconditionNotMet
(
"Fluid is not compiled with CUDA."
));
...
...
python/paddle/fluid/tests/unittests/parallel_executor_test_base.py
浏览文件 @
b8bce682
...
...
@@ -192,7 +192,6 @@ class TestParallelExecutorBase(unittest.TestCase):
build_strategy
.
fuse_elewise_add_act_ops
=
False
build_strategy
.
fuse_relu_depthwise_conv
=
False
build_strategy
.
fuse_all_optimizer_ops
=
False
build_strategy
.
fuse_all_reduce_ops
=
False
build_strategy
.
memory_optimize
=
False
build_strategy
.
enable_inplace
=
False
build_strategy
.
enable_sequential_execution
=
False
...
...
python/paddle/fluid/tests/unittests/test_fuse_all_reduce_pass.py
浏览文件 @
b8bce682
...
...
@@ -22,6 +22,8 @@ import paddle
import
unittest
import
os
paddle
.
enable_static
()
class
TestFuseAllReduceOpsBase
(
TestParallelExecutorBase
):
@
classmethod
...
...
@@ -37,6 +39,8 @@ class TestFuseAllReduceOpsBase(TestParallelExecutorBase):
fuse_all_optimizer_ops
=
False
):
if
use_device
==
DeviceType
.
CUDA
and
not
core
.
is_compiled_with_cuda
():
return
if
use_device
==
DeviceType
.
XPU
and
not
core
.
is_compiled_with_xpu
():
return
feed_dict_data
=
None
if
init_feed_dict
is
not
None
:
...
...
@@ -83,11 +87,15 @@ class TestFuseAllReduceOps(TestFuseAllReduceOpsBase):
def
test_simple_fc_with_fuse_all_reduce
(
self
):
self
.
_decorate_compare_fused_all_reduce
(
simple_fc_net
,
DeviceType
.
CUDA
)
self
.
_decorate_compare_fused_all_reduce
(
simple_fc_net
,
DeviceType
.
XPU
)
self
.
_decorate_compare_fused_all_reduce
(
simple_fc_net
,
DeviceType
.
CPU
)
def
test_batchnorm_fc_with_fuse_all_reduce
(
self
):
self
.
_decorate_compare_fused_all_reduce
(
fc_with_batchnorm
,
DeviceType
.
CUDA
)
# TODO(wangxi): xpu batch_norm op only support dim = 4
# self._decorate_compare_fused_all_reduce(fc_with_batchnorm,
# DeviceType.XPU)
self
.
_decorate_compare_fused_all_reduce
(
fc_with_batchnorm
,
DeviceType
.
CPU
)
...
...
@@ -127,6 +135,8 @@ class TestFuseAllReduceOpsWithSparseGrad(TestFuseAllReduceOpsBase):
def
test_simple_bow_net_with_fuse_all_reduce
(
self
):
model
=
partial
(
bow_net
,
dict_dim
=
self
.
word_dict_len
,
is_sparse
=
True
)
self
.
_decorate_compare_fused_all_reduce
(
model
,
DeviceType
.
CUDA
)
# TODO(wangxi): xpu sum op only support LodTensor for now
# self._decorate_compare_fused_all_reduce(model, DeviceType.XPU)
self
.
_decorate_compare_fused_all_reduce
(
model
,
DeviceType
.
CPU
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录