Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
56fd25b8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
56fd25b8
编写于
6月 08, 2023
作者:
L
Leo Chen
提交者:
GitHub
6月 08, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eager call all2all to avoid p2p hang in lazy init (#54431)
* eager call all2all to avoid p2p hang in lazy init * update
上级
2a2af7d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
9 deletion
+36
-9
python/paddle/distributed/auto_parallel/static/process_group.py
.../paddle/distributed/auto_parallel/static/process_group.py
+21
-3
python/paddle/distributed/auto_parallel/static/reshard.py
python/paddle/distributed/auto_parallel/static/reshard.py
+15
-6
未找到文件。
python/paddle/distributed/auto_parallel/static/process_group.py
浏览文件 @
56fd25b8
...
...
@@ -55,7 +55,9 @@ def remove_process_group(ring_id):
_g_process_group_map
.
pop
(
ring_id
)
def
new_process_group
(
ranks
,
group_id
=
None
,
force_new_group
=
False
):
def
new_process_group
(
ranks
,
group_id
=
None
,
force_new_group
=
False
,
group_type
=
None
):
global
_g_process_group_map
if
not
force_new_group
:
...
...
@@ -72,8 +74,9 @@ def new_process_group(ranks, group_id=None, force_new_group=False):
if
group_id
is
None
:
group_id
=
_new_ring_id
()
+
num_groups
+
1
new_pg
=
ProcessGroup
(
group_id
,
ranks
)
new_pg
=
ProcessGroup
(
group_id
,
ranks
,
group_type
)
_g_process_group_map
[
group_id
]
=
new_pg
return
new_pg
...
...
@@ -84,7 +87,7 @@ def new_process_group(ranks, group_id=None, force_new_group=False):
# the instantiation process in a more general way. In the future, the process group may
# handle the communication implementation choice.
class
ProcessGroup
:
def
__init__
(
self
,
group_id
,
ranks
):
def
__init__
(
self
,
group_id
,
ranks
,
group_type
=
None
):
if
group_id
==
0
and
get_process_group
(
0
)
is
not
None
:
assert
(
group_id
!=
0
...
...
@@ -96,6 +99,7 @@ class ProcessGroup:
global
_g_process_group_map
_g_process_group_map
[
0
].
add_ranks
(
ranks
)
self
.
_is_instantiate
=
False
self
.
_group_type
=
group_type
@
property
def
id
(
self
):
...
...
@@ -109,6 +113,10 @@ class ProcessGroup:
def
nranks
(
self
):
return
len
(
self
.
_ranks
)
@
property
def
group_type
(
self
):
return
self
.
_group_type
def
add_ranks
(
self
,
new_ranks
):
if
set
(
new_ranks
)
<=
set
(
self
.
ranks
):
return
...
...
@@ -192,6 +200,16 @@ class ProcessGroup:
barrier_tensor
,
barrier_tensor
,
'ring_id'
,
ring_id
)
# NOTE(zhiqiu): to avoid send/recv hang in lazy init
if
self
.
_group_type
==
'p2p'
:
alltoall_tmp
=
paddle
.
empty
(
shape
=
[
self
.
nranks
,
self
.
nranks
],
dtype
=
"int32"
)
paddle
.
_legacy_C_ops
.
alltoall
(
alltoall_tmp
,
'use_calc_stream'
,
True
,
'ring_id'
,
ring_id
)
paddle
.
device
.
cuda
.
synchronize
()
if
self
.
nranks
>
1
:
barrier_tensor
=
paddle
.
full
([
1
],
1
,
dtype
=
"int32"
)
paddle
.
_legacy_C_ops
.
barrier
(
...
...
python/paddle/distributed/auto_parallel/static/reshard.py
浏览文件 @
56fd25b8
...
...
@@ -337,7 +337,7 @@ class Inserter:
"""Insert send op into block at the given index."""
op_type
=
'send_v2'
# use pair comm group
process_group
=
new_process_group
([
src
,
dst
])
process_group
=
new_process_group
([
src
,
dst
]
,
group_type
=
'p2p'
)
send_op
=
block
.
_insert_op
(
idx
,
type
=
op_type
,
...
...
@@ -357,7 +357,7 @@ class Inserter:
"""Insert recv op into block at the given index."""
op_type
=
'recv_v2'
# use pair group
process_group
=
new_process_group
([
src
,
dst
])
process_group
=
new_process_group
([
src
,
dst
]
,
group_type
=
'p2p'
)
recv_op
=
block
.
_insert_op
(
idx
,
type
=
op_type
,
...
...
@@ -1794,9 +1794,13 @@ class Resharder:
elif
isinstance
(
op_desc
,
AllGatherConcatOpDesc
):
new_process_group
(
op_desc
.
group
)
elif
isinstance
(
op_desc
,
SendOpDesc
):
new_process_group
([
op_desc
.
src
,
op_desc
.
dst
])
new_process_group
(
[
op_desc
.
src
,
op_desc
.
dst
],
group_type
=
'p2p'
)
elif
isinstance
(
op_desc
,
RecvOpDesc
):
new_process_group
([
op_desc
.
src
,
op_desc
.
dst
])
new_process_group
(
[
op_desc
.
src
,
op_desc
.
dst
],
group_type
=
'p2p'
)
tensor_list
=
[]
partition_tensor_list
=
[]
...
...
@@ -2721,7 +2725,10 @@ class Resharder:
# Ensure every rank has a global view of communicator groups for entire cluters.
# When initialize communicators for pipeline parallel, every rank could
# conduct a correct global synchronization.
new_process_group
([
item
,
recv_rank
])
new_process_group
(
[
item
,
recv_rank
],
group_type
=
'p2p'
,
)
else
:
for
index
,
tensor_process
in
enumerate
(
tensor_processes
...
...
@@ -2748,7 +2755,9 @@ class Resharder:
# Ensure every rank has a global view of communicator groups for entire cluters.
# When initialize communicators for pipeline parallel, every rank could
# conduct a correct global synchronization.
new_process_group
([
item
,
recv_rank
])
new_process_group
(
[
item
,
recv_rank
],
group_type
=
'p2p'
)
cur_op_count
=
len
(
block
.
ops
)
idx_offset
=
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录