Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2922985a
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看板
未验证
提交
2922985a
编写于
6月 07, 2022
作者:
H
Haohongxiang
提交者:
GitHub
6月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Dygraph] Fix bugs of EagerReducer for complex control flows (#43252)
* fix bugs of reducer * update * update
上级
42dd0f1b
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
21 addition
and
7 deletion
+21
-7
paddle/fluid/distributed/collective/reducer.cc
paddle/fluid/distributed/collective/reducer.cc
+7
-0
python/paddle/distributed/fleet/utils/hybrid_parallel_util.py
...on/paddle/distributed/fleet/utils/hybrid_parallel_util.py
+6
-5
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+1
-1
python/paddle/fluid/tests/unittests/test_parallel_dygraph_dataparallel.py
...uid/tests/unittests/test_parallel_dygraph_dataparallel.py
+3
-1
python/paddle/fluid/tests/unittests/test_parallel_dygraph_no_sync_gradient_check.py
...unittests/test_parallel_dygraph_no_sync_gradient_check.py
+4
-0
未找到文件。
paddle/fluid/distributed/collective/reducer.cc
浏览文件 @
2922985a
...
...
@@ -775,6 +775,13 @@ void EagerReducer::ProcessUnusedDenseVars() {
continue
;
}
// NOTE(haohongxiang): Calling SetFakeEmpty here is to make sure that
// gradient accumulation can continue normally after clear_gradients()
// especiall in cases including complex control flow.
std
::
static_pointer_cast
<
egr
::
GradNodeAccumulation
>
(
GetGradNodeFromTensor
(
&
tensors_
[
var_index
]))
->
SetFakeEmpty
(
false
);
Tensor
grad_value
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
src_tensor
));
auto
dest_var_base
=
tensors_
[
var_index
];
...
...
python/paddle/distributed/fleet/utils/hybrid_parallel_util.py
浏览文件 @
2922985a
...
...
@@ -43,12 +43,11 @@ def _apply_collective_grads(parameters, comm_group):
coalesced_grads_and_vars
=
build_groups
(
grad_vars
,
128
*
1024
*
1024
)
for
coalesced_grad
,
_
,
_
in
coalesced_grads_and_vars
:
# need to div nranks
nranks
=
paddle
.
distributed
.
get_world_size
(
)
if
comm_group
is
None
else
comm_group
.
nranks
for
coalesced_grad
,
_
,
_
in
coalesced_grads_and_vars
:
# need to div nranks
div_factor
=
paddle
.
to_tensor
(
nranks
,
dtype
=
coalesced_grad
.
dtype
)
paddle
.
distributed
.
all_reduce
(
coalesced_grad
,
group
=
comm_group
)
paddle
.
fluid
.
framework
.
_dygraph_tracer
().
trace_op
(
type
=
"elementwise_div"
,
inputs
=
{
...
...
@@ -57,6 +56,7 @@ def _apply_collective_grads(parameters, comm_group):
},
outputs
=
{
'Out'
:
coalesced_grad
},
attrs
=
{
'axis'
:
-
1
})
paddle
.
distributed
.
all_reduce
(
coalesced_grad
,
group
=
comm_group
)
_split_tensors
(
coalesced_grads_and_vars
)
...
...
@@ -76,10 +76,11 @@ def _apply_collective_grads_eager(parameters, comm_group):
coalesced_grads_and_vars
=
build_groups
(
grad_vars
,
128
*
1024
*
1024
)
div_factor
=
1.0
/
comm_group
.
nranks
nranks
=
paddle
.
distributed
.
get_world_size
(
)
if
comm_group
is
None
else
comm_group
.
nranks
for
coalesced_grad
,
_
,
_
in
coalesced_grads_and_vars
:
# need to div nranks
coalesced_grad
.
scale_
(
div_factor
)
coalesced_grad
.
scale_
(
1.0
/
nranks
)
paddle
.
distributed
.
all_reduce
(
coalesced_grad
,
group
=
comm_group
)
_split_tensors
(
coalesced_grads_and_vars
)
...
...
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
2922985a
...
...
@@ -1507,7 +1507,7 @@ if(WITH_DISTRIBUTE
350
)
set_tests_properties
(
test_parallel_dygraph_no_sync PROPERTIES TIMEOUT 300
)
set_tests_properties
(
test_parallel_dygraph_no_sync_gradient_check
PROPERTIES TIMEOUT
3
0
)
PROPERTIES TIMEOUT
6
0
)
set_tests_properties
(
test_parallel_dygraph_pipeline_parallel
PROPERTIES TIMEOUT 500
)
set_tests_properties
(
test_parallel_dygraph_tensor_parallel PROPERTIES TIMEOUT
...
...
python/paddle/fluid/tests/unittests/test_parallel_dygraph_dataparallel.py
浏览文件 @
2922985a
...
...
@@ -200,7 +200,8 @@ class TestMultipleWithGloo(unittest.TestCase):
class
TestDataParallelGradientCheck
(
TestMultipleGpus
):
def
test_multiple_gpus_dynamic
(
self
):
self
.
run_mnist_2gpu
(
'parallel_dygraph_gradient_check.py'
)
self
.
run_mnist_2gpu
(
'parallel_dygraph_gradient_check.py'
,
eager_mode
=
False
)
class
TestDataParallelWithPyLayer
(
TestMultipleGpus
):
...
...
@@ -218,4 +219,5 @@ class TestGradientCheckInEagerMode(TestMultipleGpus):
if
__name__
==
"__main__"
:
os
.
environ
[
"FLAGS_enable_eager_mode"
]
=
"1"
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_parallel_dygraph_no_sync_gradient_check.py
浏览文件 @
2922985a
...
...
@@ -14,6 +14,7 @@
from
__future__
import
print_function
import
os
import
unittest
import
paddle.fluid
as
fluid
...
...
@@ -24,7 +25,10 @@ class TestDataParallelLayer(TestMultipleGpus):
def
test_parallel_dygraph_dataparallel_no_sync
(
self
):
self
.
run_mnist_2gpu
(
'parallel_dygraph_no_sync_gradient_check.py'
)
self
.
run_mnist_2gpu
(
'parallel_dygraph_no_sync_gradient_check.py'
,
eager_mode
=
False
)
if
__name__
==
"__main__"
:
os
.
environ
[
"FLAGS_enable_eager_mode"
]
=
"1"
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录