Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c33ba9d4
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看板
未验证
提交
c33ba9d4
编写于
5月 16, 2023
作者:
zhenhailiu
提交者:
GitHub
5月 16, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some tests for issuse 52842 (#53795)
* polish * polish
上级
69161a96
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
33 addition
and
6 deletion
+33
-6
paddle/fluid/pybind/communication.cc
paddle/fluid/pybind/communication.cc
+2
-2
python/paddle/distributed/communication/stream/reduce_scatter.py
...paddle/distributed/communication/stream/reduce_scatter.py
+1
-0
python/paddle/fluid/tests/unittests/collective/collective_allgather_api.py
...id/tests/unittests/collective/collective_allgather_api.py
+2
-0
python/paddle/fluid/tests/unittests/collective/collective_allreduce_api.py
...id/tests/unittests/collective/collective_allreduce_api.py
+1
-0
python/paddle/fluid/tests/unittests/collective/collective_broadcast_api.py
...id/tests/unittests/collective/collective_broadcast_api.py
+1
-0
python/paddle/fluid/tests/unittests/collective/collective_reduce_api.py
...fluid/tests/unittests/collective/collective_reduce_api.py
+1
-0
python/paddle/fluid/tests/unittests/collective/collective_sendrecv_api.py
...uid/tests/unittests/collective/collective_sendrecv_api.py
+2
-0
python/paddle/fluid/tests/unittests/test_collective_api_base.py
.../paddle/fluid/tests/unittests/test_collective_api_base.py
+23
-4
未找到文件。
paddle/fluid/pybind/communication.cc
浏览文件 @
c33ba9d4
...
@@ -78,8 +78,8 @@ void BindTCPStore(py::module *m) {
...
@@ -78,8 +78,8 @@ void BindTCPStore(py::module *m) {
[](
phi
::
distributed
::
Store
&
self
,
[](
phi
::
distributed
::
Store
&
self
,
const
std
::
string
&
key
)
->
py
::
bytes
{
const
std
::
string
&
key
)
->
py
::
bytes
{
auto
data
=
self
.
get
(
key
);
auto
data
=
self
.
get
(
key
);
return
py
::
bytes
(
reinterpret_cast
<
char
*>
(
data
.
data
()),
std
::
string
s
(
data
.
begin
(),
data
.
end
());
data
.
size
()
);
return
py
::
bytes
(
s
);
},
},
py
::
arg
(
"key"
),
py
::
arg
(
"key"
),
py
::
call_guard
<
py
::
gil_scoped_release
>
())
py
::
call_guard
<
py
::
gil_scoped_release
>
())
...
...
python/paddle/distributed/communication/stream/reduce_scatter.py
浏览文件 @
c33ba9d4
...
@@ -81,6 +81,7 @@ def _reduce_scatter_in_static_mode(tensor, tensor_or_tensor_list, group):
...
@@ -81,6 +81,7 @@ def _reduce_scatter_in_static_mode(tensor, tensor_or_tensor_list, group):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/collective/collective_allgather_api.py
浏览文件 @
c33ba9d4
...
@@ -43,6 +43,7 @@ def all_gather_new(tensor_list, tensor, group=None):
...
@@ -43,6 +43,7 @@ def all_gather_new(tensor_list, tensor, group=None):
'bool'
,
'bool'
,
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
@@ -58,6 +59,7 @@ def all_gather_new(tensor_list, tensor, group=None):
...
@@ -58,6 +59,7 @@ def all_gather_new(tensor_list, tensor, group=None):
'bool'
,
'bool'
,
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/collective/collective_allreduce_api.py
浏览文件 @
c33ba9d4
...
@@ -36,6 +36,7 @@ def all_reduce_new(tensor, reduce_type=str(dist.ReduceOp.SUM), group=None):
...
@@ -36,6 +36,7 @@ def all_reduce_new(tensor, reduce_type=str(dist.ReduceOp.SUM), group=None):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/collective/collective_broadcast_api.py
浏览文件 @
c33ba9d4
...
@@ -35,6 +35,7 @@ def broadcast_new(tensor, src, group=None, sync_op=True):
...
@@ -35,6 +35,7 @@ def broadcast_new(tensor, src, group=None, sync_op=True):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/collective/collective_reduce_api.py
浏览文件 @
c33ba9d4
...
@@ -36,6 +36,7 @@ def reduce_new(tensor, dst, reduce_type=str(dist.ReduceOp.SUM), group=None):
...
@@ -36,6 +36,7 @@ def reduce_new(tensor, dst, reduce_type=str(dist.ReduceOp.SUM), group=None):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/collective/collective_sendrecv_api.py
浏览文件 @
c33ba9d4
...
@@ -35,6 +35,7 @@ def send_new(tensor, dst, group=None, sync_op=True):
...
@@ -35,6 +35,7 @@ def send_new(tensor, dst, group=None, sync_op=True):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
@@ -67,6 +68,7 @@ def recv_new(tensor, src, group=None, sync_op=True, dtype='float32'):
...
@@ -67,6 +68,7 @@ def recv_new(tensor, src, group=None, sync_op=True, dtype='float32'):
'int8'
,
'int8'
,
'uint8'
,
'uint8'
,
'bool'
,
'bool'
,
'uint16'
,
],
],
op_type
,
op_type
,
)
)
...
...
python/paddle/fluid/tests/unittests/test_collective_api_base.py
浏览文件 @
c33ba9d4
...
@@ -22,7 +22,7 @@ import unittest
...
@@ -22,7 +22,7 @@ import unittest
from
contextlib
import
closing
from
contextlib
import
closing
import
numpy
as
np
import
numpy
as
np
from
paddle_bfloat
import
bfloat16
from
eager_op_test
import
convert_float_to_uint16
,
convert_uint16_to_float
import
paddle
import
paddle
import
paddle.distributed
as
dist
import
paddle.distributed
as
dist
...
@@ -45,6 +45,14 @@ def create_float_test_data(shape=None, dtype=None, seed=None):
...
@@ -45,6 +45,14 @@ def create_float_test_data(shape=None, dtype=None, seed=None):
return
data
return
data
def
create_bfloat16_test_data
(
shape
=
None
,
seed
=
None
):
if
seed
:
np
.
random
.
seed
(
seed
)
data
=
np
.
random
.
uniform
(
-
100.0
,
100.0
,
shape
).
astype
(
"float32"
)
data
=
convert_float_to_uint16
(
data
)
return
data
def
create_int_test_data
(
shape
=
None
,
dtype
=
None
,
seed
=
None
):
def
create_int_test_data
(
shape
=
None
,
dtype
=
None
,
seed
=
None
):
if
seed
:
if
seed
:
np
.
random
.
seed
(
seed
)
np
.
random
.
seed
(
seed
)
...
@@ -76,8 +84,9 @@ def create_test_data(shape=None, dtype=None, seed=None):
...
@@ -76,8 +84,9 @@ def create_test_data(shape=None, dtype=None, seed=None):
if
dtype
==
"float32"
or
dtype
==
"float16"
or
dtype
==
"float64"
:
if
dtype
==
"float32"
or
dtype
==
"float16"
or
dtype
==
"float64"
:
return
create_float_test_data
(
shape
=
shape
,
dtype
=
dtype
,
seed
=
seed
)
return
create_float_test_data
(
shape
=
shape
,
dtype
=
dtype
,
seed
=
seed
)
elif
dtype
==
"bfloat16"
:
elif
dtype
==
"bfloat16"
:
return
create_bfloat16_test_data
(
shape
=
shape
,
seed
=
seed
)
# since numpy does not support bfloat16 yet, use `paddle_bfloat` to replace
# since numpy does not support bfloat16 yet, use `paddle_bfloat` to replace
return
create_float_test_data
(
shape
=
shape
,
dtype
=
bfloat16
,
seed
=
seed
)
#
return create_float_test_data(shape=shape, dtype=bfloat16, seed=seed)
elif
dtype
==
"bool"
:
elif
dtype
==
"bool"
:
return
create_bool_test_data
(
shape
=
shape
,
seed
=
seed
)
return
create_bool_test_data
(
shape
=
shape
,
seed
=
seed
)
elif
(
elif
(
...
@@ -344,8 +353,18 @@ class TestDistBase(unittest.TestCase):
...
@@ -344,8 +353,18 @@ class TestDistBase(unittest.TestCase):
input2
=
create_test_data
(
shape
=
(
10
,
1000
),
dtype
=
dtype
,
seed
=
pid1
)
input2
=
create_test_data
(
shape
=
(
10
,
1000
),
dtype
=
dtype
,
seed
=
pid1
)
# cast bfloat16 to float32 for numeric comparison
# cast bfloat16 to float32 for numeric comparison
if
dtype
==
"bfloat16"
:
if
dtype
==
"bfloat16"
:
input1
=
input1
.
astype
(
"float32"
)
input2
=
input2
.
astype
(
"float32"
)
def
convertbf16
(
origin
):
if
origin
.
dtype
==
np
.
uint16
:
return
convert_uint16_to_float
(
origin
)
else
:
return
origin
.
astype
(
"float32"
)
input1
=
convertbf16
(
input1
)
input2
=
convertbf16
(
input2
)
tr0_out
=
[
convertbf16
(
e
)
for
e
in
tr0_out
]
tr1_out
=
[
convertbf16
(
e
)
for
e
in
tr1_out
]
if
col_type
==
"allgather"
:
if
col_type
==
"allgather"
:
need_result
=
np
.
vstack
((
input1
,
input2
))
need_result
=
np
.
vstack
((
input1
,
input2
))
tr_out0
=
np
.
vstack
((
tr0_out
[
0
],
tr0_out
[
1
]))
tr_out0
=
np
.
vstack
((
tr0_out
[
0
],
tr0_out
[
1
]))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录