Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
719d96b9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
719d96b9
编写于
8月 19, 2023
作者:
Y
Yuang Liu
提交者:
GitHub
8月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
do not use fuse for sync param in dp (#56437)
上级
14393611
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
16 deletion
+26
-16
python/paddle/distributed/parallel.py
python/paddle/distributed/parallel.py
+26
-16
未找到文件。
python/paddle/distributed/parallel.py
浏览文件 @
719d96b9
...
...
@@ -145,7 +145,11 @@ def build_groups(vars, group_size):
@
imperative_base
.
no_grad
@
framework
.
dygraph_only
def
sync_params_buffers
(
model
,
comm_group
=
None
,
src_rank
=
0
,
is_model_parallel
=
False
model
,
comm_group
=
None
,
src_rank
=
0
,
is_model_parallel
=
False
,
fuse_params
=
True
,
):
model_vars
=
[]
for
_
,
param
in
model
.
_obtain_parameters_buffers
().
items
():
...
...
@@ -170,22 +174,28 @@ def sync_params_buffers(
if
len
(
model_vars
)
==
0
:
return
# group size is 128M
coalesced_vars
=
build_groups
(
model_vars
,
128
*
1024
*
1024
)
if
fuse_params
:
# group size is 128M
coalesced_vars
=
build_groups
(
model_vars
,
128
*
1024
*
1024
)
for
coalesced_var
,
_
,
_
in
coalesced_vars
:
paddle
.
distributed
.
broadcast
(
coalesced_var
,
src
=
src_rank
,
group
=
comm_group
,
sync_op
=
True
)
for
coalesced_var
,
_
,
_
in
coalesced_vars
:
paddle
.
distributed
.
broadcast
(
coalesced_var
,
src
=
src_rank
,
group
=
comm_group
,
sync_op
=
True
)
for
coalesced_var
,
origin_vars
,
var_shapes
in
coalesced_vars
:
var_len
=
[
np
.
prod
(
v_shape
)
for
v_shape
in
var_shapes
]
paddle
.
fluid
.
framework
.
_dygraph_tracer
().
trace_op
(
type
=
'split'
,
inputs
=
{
'X'
:
coalesced_var
},
outputs
=
{
'Out'
:
origin_vars
},
attrs
=
{
'sections'
:
var_len
,
'axis'
:
0
},
)
for
coalesced_var
,
origin_vars
,
var_shapes
in
coalesced_vars
:
var_len
=
[
np
.
prod
(
v_shape
)
for
v_shape
in
var_shapes
]
paddle
.
fluid
.
framework
.
_dygraph_tracer
().
trace_op
(
type
=
'split'
,
inputs
=
{
'X'
:
coalesced_var
},
outputs
=
{
'Out'
:
origin_vars
},
attrs
=
{
'sections'
:
var_len
,
'axis'
:
0
},
)
else
:
for
var
in
model_vars
:
paddle
.
distributed
.
broadcast
(
var
,
src
=
src_rank
,
group
=
comm_group
,
sync_op
=
True
)
class
DataParallel
(
layers
.
Layer
):
...
...
@@ -398,7 +408,7 @@ class DataParallel(layers.Layer):
),
"ProcessGroup must be an instance of Group in DataParallel."
# sync buffer and params
sync_params_buffers
(
self
.
_layers
)
sync_params_buffers
(
self
.
_layers
,
fuse_params
=
False
)
self
.
comm_buffer_size
=
int
(
comm_buffer_size
*
1024
*
1024
)
# NOTE(shenliang03): We can set environment variables to control
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录