Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e3513a63
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
e3513a63
编写于
10月 19, 2020
作者:
M
MRXLT
提交者:
GitHub
10月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry pick] Fix fleet (#28067)
* fleet support paddle.optimzier * bug fix * fix fleet_base * bug fix * fix coverage
上级
e3a88eb4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
11 addition
and
22 deletion
+11
-22
python/paddle/distributed/fleet/base/fleet_base.py
python/paddle/distributed/fleet/base/fleet_base.py
+4
-16
python/paddle/fluid/incubate/fleet/base/fleet_base.py
python/paddle/fluid/incubate/fleet/base/fleet_base.py
+3
-1
python/paddle/fluid/incubate/fleet/collective/__init__.py
python/paddle/fluid/incubate/fleet/collective/__init__.py
+3
-4
python/paddle/fluid/tests/unittests/test_fleet_graph_executor.py
...paddle/fluid/tests/unittests/test_fleet_graph_executor.py
+1
-1
未找到文件。
python/paddle/distributed/fleet/base/fleet_base.py
浏览文件 @
e3513a63
...
...
@@ -1053,17 +1053,11 @@ class Fleet(object):
loss_name
=
loss
.
name
,
share_vars_from
=
None
)
loss
.
block
.
program
.
_graph
=
compiled_program
return
self
.
user_defined_optimizer
.
minimize
(
loss
,
startup_program
=
startup_program
,
parameter_list
=
parameter_list
,
no_grad_set
=
no_grad_set
)
loss
,
startup_program
,
parameter_list
,
no_grad_set
=
no_grad_set
)
if
meta_optimizer
:
optimize_ops
,
params_grads
=
meta_optimizer
.
minimize
(
loss
,
startup_program
=
startup_program
,
parameter_list
=
parameter_list
,
no_grad_set
=
no_grad_set
)
loss
,
startup_program
,
parameter_list
,
no_grad_set
=
no_grad_set
)
default_program
=
paddle
.
static
.
default_main_program
()
...
...
@@ -1072,20 +1066,14 @@ class Fleet(object):
else
:
optimize_ops
,
params_grads
=
self
.
user_defined_optimizer
.
minimize
(
loss
,
startup_program
=
startup_program
,
parameter_list
=
parameter_list
,
no_grad_set
=
no_grad_set
)
loss
,
startup_program
,
parameter_list
,
no_grad_set
=
no_grad_set
)
context
[
"program_optimize_ops"
]
=
optimize_ops
context
[
"program_params_grads"
]
=
params_grads
if
graph_optimizer
:
optimize_ops
,
params_grads
=
graph_optimizer
.
minimize
(
loss
,
startup_program
=
startup_program
,
parameter_list
=
parameter_list
,
no_grad_set
=
no_grad_set
)
loss
,
startup_program
,
parameter_list
,
no_grad_set
=
no_grad_set
)
# since we do not encourage users to use graph operations
# if a graph optimizer takes effect, mostly
# optimizers_ops and params_grads are None
...
...
python/paddle/fluid/incubate/fleet/base/fleet_base.py
浏览文件 @
e3513a63
...
...
@@ -19,6 +19,7 @@ import abc
import
paddle.fluid
as
fluid
from
paddle.fluid.executor
import
Executor
from
paddle.fluid.optimizer
import
SGD
from
paddle.optimizer
import
SGD
as
SGD_v2
from
paddle.fluid.incubate.fleet.base.mode
import
Mode
from
paddle.distributed.fleet.base.role_maker
import
RoleMakerBase
...
...
@@ -291,7 +292,8 @@ class DistributedOptimizer(object):
def
__init__
(
self
,
optimizer
,
strategy
=
None
):
if
not
isinstance
(
optimizer
,
SGD
.
__bases__
)
\
and
not
isinstance
(
optimizer
,
OptimizerWithMixedPrecision
):
and
not
isinstance
(
optimizer
,
OptimizerWithMixedPrecision
)
\
and
not
isinstance
(
optimizer
,
SGD_v2
.
__base__
):
raise
TypeError
(
"optimizer must be an instance of Optimizer"
)
self
.
_optimizer
=
optimizer
...
...
python/paddle/fluid/incubate/fleet/collective/__init__.py
浏览文件 @
e3513a63
...
...
@@ -28,6 +28,8 @@ from paddle.fluid.incubate.fleet.base.fleet_base import DistributedOptimizer
from
paddle.fluid
import
compiler
from
paddle.fluid.incubate.checkpoint.checkpoint_saver
import
PaddleModel
,
CheckpointSaver
import
paddle
import
os
import
sys
import
six
...
...
@@ -505,10 +507,7 @@ class CollectiveOptimizer(DistributedOptimizer):
self
.
_strategy
)
optimize_ops
,
param_grads
=
self
.
_optimizer
.
minimize
(
loss
,
startup_program
=
startup_program
,
parameter_list
=
parameter_list
,
no_grad_set
=
no_grad_set
)
loss
,
startup_program
,
parameter_list
,
no_grad_set
=
no_grad_set
)
fleet
.
_origin_program
=
main_program
.
clone
(
for_test
=
False
)
fleet
.
_transpiled_program
=
main_program
...
...
python/paddle/fluid/tests/unittests/test_fleet_graph_executor.py
浏览文件 @
e3513a63
...
...
@@ -60,7 +60,7 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
strategy
=
paddle
.
distributed
.
fleet
.
DistributedStrategy
()
strategy
.
nccl_comm_num
=
2
strategy
.
sync_nccl_allreduce
=
True
optimizer
=
paddle
.
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.01
)
optimizer
=
paddle
.
optimizer
.
SGD
(
learning_rate
=
0.01
)
optimizer
=
fleet
.
distributed_optimizer
(
optimizer
,
strategy
=
strategy
)
optimizer
.
minimize
(
avg_cost
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录