Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6786c012
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
未验证
提交
6786c012
编写于
2月 27, 2023
作者:
J
jameszhang
提交者:
GitHub
2月 27, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[kunlun] support reduce_scatter (#50792)
* [kunlun] support reduce_scatter * uncomment unittest * update xccl to 1.0.10
上级
2eeaaa7d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
1 deletion
+64
-1
cmake/external/xpu.cmake
cmake/external/xpu.cmake
+1
-1
paddle/fluid/distributed/collective/process_group_bkcl.cc
paddle/fluid/distributed/collective/process_group_bkcl.cc
+28
-0
paddle/fluid/distributed/collective/process_group_bkcl.h
paddle/fluid/distributed/collective/process_group_bkcl.h
+7
-0
python/paddle/fluid/tests/unittests/xpu/process_group_bkcl.py
...on/paddle/fluid/tests/unittests/xpu/process_group_bkcl.py
+28
-0
未找到文件。
cmake/external/xpu.cmake
浏览文件 @
6786c012
...
...
@@ -8,7 +8,7 @@ set(XPU_API_LIB_NAME "libxpuapi.so")
set
(
XPU_RT_LIB_NAME
"libxpurt.so"
)
set
(
XPU_BASE_DATE
"20230220"
)
set
(
XPU_XCCL_BASE_VERSION
"1.0.
9
"
)
set
(
XPU_XCCL_BASE_VERSION
"1.0.
10
"
)
if
(
NOT DEFINED XPU_BASE_URL
)
set
(
XPU_BASE_URL_WITHOUT_DATE
...
...
paddle/fluid/distributed/collective/process_group_bkcl.cc
浏览文件 @
6786c012
...
...
@@ -367,6 +367,34 @@ std::shared_ptr<ProcessGroup::Task> ProcessGroupBKCL::Reduce(
use_calc_stream
);
}
std
::
shared_ptr
<
ProcessGroup
::
Task
>
ProcessGroupBKCL
::
ReduceScatter
(
phi
::
DenseTensor
*
out_tensor
,
const
phi
::
DenseTensor
&
in_tensor
,
const
ReduceScatterOptions
&
opts
,
bool
sync_op
,
bool
use_calc_stream
)
{
return
Collective
(
out_tensor
,
in_tensor
,
[
&
](
phi
::
DenseTensor
*
output
,
const
phi
::
DenseTensor
&
input
,
BKCLContext_t
comm
,
const
XPUStream
&
stream
)
{
return
bkcl_reduce_scatter
(
comm
,
input
.
data
(),
output
->
data
(),
output
->
numel
(),
platform
::
ToBKCLDataType
(
framework
::
TransToProtoVarType
(
input
.
type
())),
ToBKCLRedType
(
opts
.
reduce_op
),
stream
);
},
CommType
::
REDUCE_SCATTER
,
sync_op
,
use_calc_stream
);
}
std
::
shared_ptr
<
ProcessGroup
::
Task
>
ProcessGroupBKCL
::
Barrier
(
const
BarrierOptions
&
opts
)
{
PADDLE_ENFORCE_GE
(
opts
.
device_id
,
...
...
paddle/fluid/distributed/collective/process_group_bkcl.h
浏览文件 @
6786c012
...
...
@@ -115,6 +115,13 @@ class ProcessGroupBKCL : public ProcessGroupWithStream {
bool
sync_op
,
bool
use_calc_stream
)
override
;
std
::
shared_ptr
<
ProcessGroup
::
Task
>
ReduceScatter
(
phi
::
DenseTensor
*
out_tensor
,
const
phi
::
DenseTensor
&
in_tensor
,
const
ReduceScatterOptions
&
opts
,
bool
sync_op
,
bool
use_calc_stream
)
override
;
std
::
shared_ptr
<
ProcessGroup
::
Task
>
Recv
(
phi
::
DenseTensor
*
tensor
,
int
src_rank
,
int64_t
offset
,
...
...
python/paddle/fluid/tests/unittests/xpu/process_group_bkcl.py
浏览文件 @
6786c012
...
...
@@ -175,6 +175,34 @@ class TestProcessGroupFp32(unittest.TestCase):
assert
np
.
array_equal
(
tensor_y
,
old_tensor_y
)
sys
.
stdout
.
write
(
"rank {}: test reduce sum api ok
\n
"
.
format
(
pg
.
rank
()))
# test reduce_scatter
in_shape
=
list
(
self
.
shape
)
in_shape
[
0
]
*=
2
x
=
np
.
random
.
random
(
in_shape
).
astype
(
self
.
dtype
)
y
=
np
.
random
.
random
(
in_shape
).
astype
(
self
.
dtype
)
tensor_x
=
paddle
.
to_tensor
(
x
)
tensor_y
=
paddle
.
to_tensor
(
y
)
need_result
=
tensor_x
+
tensor_y
need_result0
=
paddle
.
slice
(
need_result
,
[
0
],
[
0
],
[
self
.
shape
[
0
]])
need_result1
=
paddle
.
slice
(
need_result
,
[
0
],
[
self
.
shape
[
0
]],
[
in_shape
[
0
]]
)
out
=
np
.
random
.
random
(
self
.
shape
).
astype
(
self
.
dtype
)
tensor_out
=
paddle
.
to_tensor
(
out
)
if
pg
.
rank
()
==
0
:
task
=
dist
.
reduce_scatter
(
tensor_out
,
tensor_x
,
sync_op
=
True
)
else
:
task
=
dist
.
reduce_scatter
(
tensor_out
,
tensor_y
,
sync_op
=
False
)
task
.
wait
()
paddle
.
device
.
xpu
.
synchronize
()
if
pg
.
rank
()
==
0
:
assert
np
.
array_equal
(
need_result0
,
tensor_out
)
else
:
assert
np
.
array_equal
(
need_result1
,
tensor_out
)
sys
.
stdout
.
write
(
"rank {}: test reduce_scatter sum api ok
\n
"
.
format
(
pg
.
rank
())
)
# test send async api
# rank 0
x
=
np
.
random
.
random
(
self
.
shape
).
astype
(
self
.
dtype
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录