Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
28b8adb1
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看板
未验证
提交
28b8adb1
编写于
8月 08, 2023
作者:
R
Ruibiao Chen
提交者:
GitHub
8月 08, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve GC for pipeline parallel (#56022)
* Improve GC for pipeline parallel * Delete print
上级
fbb3a34f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
40 deletion
+37
-40
paddle/fluid/operators/nop_op.cc
paddle/fluid/operators/nop_op.cc
+6
-1
python/paddle/distributed/passes/pass_utils.py
python/paddle/distributed/passes/pass_utils.py
+31
-39
未找到文件。
paddle/fluid/operators/nop_op.cc
浏览文件 @
28b8adb1
...
...
@@ -45,9 +45,14 @@ establish the dependency between input and output tensors.
}
};
DECLARE_NO_NEED_BUFFER_VARS_INFERER
(
NopNoNeedBufferVarsInferer
,
"X"
,
"Out"
);
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_WITHOUT_GRADIENT
(
nop
,
ops
::
NopOp
,
ops
::
NopOpMaker
);
REGISTER_OP_WITHOUT_GRADIENT
(
nop
,
ops
::
NopOp
,
ops
::
NopOpMaker
,
ops
::
NopNoNeedBufferVarsInferer
);
python/paddle/distributed/passes/pass_utils.py
浏览文件 @
28b8adb1
...
...
@@ -190,15 +190,14 @@ class OpInOutInfo:
return
for
slot_name
in
op
.
input_names
:
if
slot_name
in
self
.
_no_need_buffer_slots
:
continue
for
in_name
in
op
.
input
(
slot_name
):
self
.
_other_arg_names_set
.
add
(
in_name
)
if
slot_name
not
in
self
.
_no_need_buffer_slots
:
for
in_name
in
op
.
input
(
slot_name
):
self
.
_other_arg_names_set
.
add
(
in_name
)
for
slot_name
in
op
.
output_names
:
for
out_name
in
op
.
output
(
slot_name
):
self
.
_other_arg_names_set
.
add
(
out_name
)
if
slot_name
not
in
self
.
_no_need_buffer_slots
:
for
out_name
in
op
.
output
(
slot_name
):
self
.
_other_arg_names_set
.
add
(
out_name
)
self
.
_is_build
=
True
...
...
@@ -209,16 +208,9 @@ class OpInOutInfo:
)
def
var_can_be_deleted
(
var_name
,
program
):
var
=
program
.
global_block
().
_find_var_recursive
(
var_name
)
if
var
is
None
or
var
.
persistable
:
return
False
return
var
.
type
in
[
core
.
VarDesc
.
VarType
.
LOD_TENSOR
,
core
.
VarDesc
.
VarType
.
SELECTED_ROWS
,
core
.
VarDesc
.
VarType
.
LOD_TENSOR_ARRAY
,
]
def
var_can_be_deleted
(
var_name
,
block
):
var
=
block
.
_find_var_recursive
(
var_name
)
return
var
is
not
None
and
not
var
.
persistable
def
get_skip_gc_vars
(
program_list
:
List
[
Program
]):
...
...
@@ -231,31 +223,31 @@ def get_skip_gc_vars(program_list: List[Program]):
"""
# step1: Get all vars of every sub_program of program_list that are non-persistable and not in op's no_need_buffer.
vars_list
=
[
set
()
for
_
in
range
(
len
(
program_list
))]
for
i
p
,
program
in
enumerate
(
program_list
):
for
op
in
program
.
global_block
().
op
s
:
op_info
=
OpInOutInfo
()
for
in_name
in
op
.
input_arg_names
:
if
not
var_can_be_deleted
(
in_name
,
program
)
:
required_vars
=
[
set
()
for
_
in
range
(
len
(
program_list
))]
for
i
dx
,
program
in
enumerate
(
program_list
):
for
block
in
program
.
block
s
:
for
op
in
block
.
ops
:
# NOTE(Ruibiao): Some vars maybe be the arguements of conditional_block op but no-need-buffer in the actual subblock, should not add them to the required_vars.
if
op
.
type
==
"conditional_block"
:
continue
if
not
op_info
.
is_build
:
op_info
.
build_info
(
op
)
if
op_info
.
is_needed
(
in_name
):
vars_list
[
ip
].
add
(
in_name
)
for
out_name
in
op
.
output_arg_names
:
if
var_can_be_deleted
(
out_name
,
program
):
vars_list
[
ip
].
add
(
out_name
)
op_info
=
OpInOutInfo
()
op_info
.
build_info
(
op
)
for
arg_name
in
op
.
input_arg_names
+
op
.
output_arg_names
:
if
var_can_be_deleted
(
arg_name
,
block
)
and
op_info
.
is_needed
(
arg_name
):
required_vars
[
idx
].
add
(
arg_name
)
# step2:
g
et the `skip_gc_vars` that vars of current sub_program might be used in the later sub_program
union_set
=
set
()
# step2:
G
et the `skip_gc_vars` that vars of current sub_program might be used in the later sub_program
suffixed_required_vars
=
set
()
skip_gc_vars
=
[
set
()]
*
len
(
program_list
)
for
idx
,
vars_set
in
reversed
(
list
(
enumerate
(
vars_list
))):
if
idx
<
len
(
vars_list
)
-
1
:
union_set
=
union_set
.
union
(
vars_list
[
idx
+
1
])
skip_gc_vars
[
idx
]
=
vars_set
&
union_set
for
idx
,
vars_set
in
reversed
(
list
(
enumerate
(
required_vars
))):
if
idx
<
len
(
required_vars
)
-
1
:
suffixed_required_vars
=
suffixed_required_vars
.
union
(
required_vars
[
idx
+
1
]
)
skip_gc_vars
[
idx
]
=
vars_set
&
suffixed_required_vars
return
skip_gc_vars
...
...
@@ -279,7 +271,7 @@ def _create_param(dst_block, src_var):
stop_gradient
=
src_var
.
stop_gradient
,
is_data
=
src_var
.
is_data
,
belong_to_optimizer
=
src_var
.
belong_to_optimizer
,
**
copied_kwargs
**
copied_kwargs
,
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录