Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ff806111
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
ff806111
编写于
6月 16, 2023
作者:
L
LiYuRio
提交者:
GitHub
6月 16, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate four directions p2p communication to a new file (#54664)
上级
aac91e82
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
931 addition
and
4 deletion
+931
-4
python/paddle/distributed/fleet/base/topology.py
python/paddle/distributed/fleet/base/topology.py
+54
-3
python/paddle/distributed/fleet/meta_parallel/pipeline_parallel.py
...ddle/distributed/fleet/meta_parallel/pipeline_parallel.py
+11
-1
python/paddle/distributed/fleet/meta_parallel/pp_utils/four_directions_p2p_communication.py
...ta_parallel/pp_utils/four_directions_p2p_communication.py
+866
-0
未找到文件。
python/paddle/distributed/fleet/base/topology.py
浏览文件 @
ff806111
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
collections
import
os
from
functools
import
reduce
from
itertools
import
product
...
...
@@ -24,6 +25,9 @@ from ..utils.log_util import logger
__all__
=
[
'CommunicateTopology'
,
'HybridCommunicateGroup'
]
_HYBRID_PARALLEL_GROUP
=
None
_use_four_directions
=
os
.
environ
.
get
(
'PADDLE_USE_FOUR_DIRECTIONS_P2P'
,
paddle
.
fluid
.
core
.
is_compiled_with_xpu
()
)
class
ParallelMode
:
...
...
@@ -191,7 +195,9 @@ class HybridCommunicateGroup:
if
self
.
_pp_degree
>
1
:
if
paddle
.
framework
.
core
.
is_compiled_with_nccl
():
check_nccl_version_for_p2p
()
self
.
_set_p2p_group
()
self
.
_set_p2p_prev_next
()
if
_use_four_directions
:
self
.
_set_four_directions_p2p_group
()
debug_str
=
(
"HybridParallelInfo: rank_id: %d, mp_degree: %d, "
...
...
@@ -291,7 +297,7 @@ class HybridCommunicateGroup:
assert
hasattr
(
self
,
'prev_rank'
),
"prev_rank has not been inited"
return
self
.
prev_rank
def
_set_p2p_
group
(
self
):
def
_set_p2p_
prev_next
(
self
):
comm_lists
=
self
.
_topo
.
get_comm_list
(
'pipe'
)
for
comm_ranks
in
comm_lists
:
...
...
@@ -305,6 +311,43 @@ class HybridCommunicateGroup:
self
.
next_rank
=
next_rank
self
.
prev_rank
=
prev_rank
def
_set_four_directions_p2p_group
(
self
):
comm_lists
=
self
.
_topo
.
get_comm_list
(
'pipe'
)
self
.
send_next_group
=
None
self
.
send_prev_group
=
None
self
.
recv_next_group
=
None
self
.
recv_prev_group
=
None
for
comm_ranks
in
comm_lists
:
assert
len
(
comm_ranks
)
==
self
.
_pp_degree
for
idx
,
rank
in
enumerate
(
comm_ranks
):
curr_rank
=
rank
next_rank
=
comm_ranks
[(
idx
+
1
)
%
self
.
_pp_degree
]
prev_rank
=
comm_ranks
[(
idx
-
1
)
%
self
.
_pp_degree
]
next_group
=
paddle
.
distributed
.
new_group
(
ranks
=
[
curr_rank
,
next_rank
]
)
if
self
.
global_rank
==
curr_rank
:
self
.
send_next_group
=
next_group
elif
self
.
global_rank
==
next_rank
:
self
.
recv_prev_group
=
next_group
prev_group
=
paddle
.
distributed
.
new_group
(
ranks
=
[
prev_rank
,
curr_rank
]
)
if
self
.
global_rank
==
curr_rank
:
self
.
send_prev_group
=
prev_group
elif
self
.
global_rank
==
prev_rank
:
self
.
recv_next_group
=
prev_group
assert
self
.
send_next_group
is
not
None
assert
self
.
send_prev_group
is
not
None
assert
self
.
recv_next_group
is
not
None
assert
self
.
recv_prev_group
is
not
None
def
topology
(
self
):
return
self
.
_topo
...
...
@@ -357,7 +400,15 @@ class HybridCommunicateGroup:
return
self
.
_pp_comm_group
def
get_p2p_groups
(
self
):
return
None
assert
(
_use_four_directions
),
"If you want to use four directions p2p group, set the environment variable PADDLE_USE_FOUR_DIRECTIONS_P2P to True."
return
(
self
.
send_next_group
,
self
.
send_prev_group
,
self
.
recv_next_group
,
self
.
recv_prev_group
,
)
# sharding parallel message:
def
_get_sharding_parallel_id
(
self
):
...
...
python/paddle/distributed/fleet/meta_parallel/pipeline_parallel.py
浏览文件 @
ff806111
...
...
@@ -13,6 +13,8 @@
import
time
import
warnings
import
os
import
paddle
from
paddle
import
framework
...
...
@@ -26,7 +28,15 @@ from ..utils.hybrid_parallel_util import (
from
..utils.log_util
import
logger
from
.meta_parallel_base
import
MetaParallelBase
from
.parallel_layers.pp_layers
import
PipelineLayer
from
.pp_utils
import
p2p_communication
as
p2p
_use_four_directions
=
os
.
environ
.
get
(
'PADDLE_USE_FOUR_DIRECTIONS_P2P'
,
paddle
.
fluid
.
core
.
is_compiled_with_xpu
()
)
if
_use_four_directions
:
from
.pp_utils
import
four_directions_p2p_communication
as
p2p
else
:
from
.pp_utils
import
p2p_communication
as
p2p
from
.pp_utils.utils
import
HOOK_ACTION
,
FusedCommBuffer
,
assign_group_by_size
__all__
=
[]
...
...
python/paddle/distributed/fleet/meta_parallel/pp_utils/four_directions_p2p_communication.py
0 → 100644
浏览文件 @
ff806111
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录