Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
36bc5511
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看板
未验证
提交
36bc5511
编写于
7月 19, 2023
作者:
Z
zhaoyingli
提交者:
GitHub
7月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[AutoParallel] keep lr_sheduler same bewteen executor and engine (#55516)
上级
77032f0e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
7 deletion
+14
-7
python/paddle/distributed/auto_parallel/static/callbacks.py
python/paddle/distributed/auto_parallel/static/callbacks.py
+4
-4
python/paddle/distributed/auto_parallel/static/engine.py
python/paddle/distributed/auto_parallel/static/engine.py
+3
-1
python/paddle/distributed/auto_parallel/static/parallelizer_v2.py
...addle/distributed/auto_parallel/static/parallelizer_v2.py
+7
-2
未找到文件。
python/paddle/distributed/auto_parallel/static/callbacks.py
浏览文件 @
36bc5511
...
...
@@ -171,14 +171,14 @@ class LRSchedulerAuto(LRScheduler):
if
self
.
by_step
and
self
.
train_step
%
self
.
acc_step
==
0
:
if
(
self
.
model
.
_
optimizer
and
hasattr
(
self
.
model
.
_
optimizer
,
'_learning_rate'
)
self
.
model
.
optimizer
and
hasattr
(
self
.
model
.
optimizer
,
'_learning_rate'
)
and
isinstance
(
self
.
model
.
_
optimizer
.
_learning_rate
,
self
.
model
.
optimizer
.
_learning_rate
,
paddle
.
optimizer
.
lr
.
LRScheduler
,
)
):
self
.
model
.
_
optimizer
.
_learning_rate
.
step
()
self
.
model
.
optimizer
.
_learning_rate
.
step
()
class
History
(
Callback
):
...
...
python/paddle/distributed/auto_parallel/static/engine.py
浏览文件 @
36bc5511
...
...
@@ -970,7 +970,9 @@ class Engine:
save_dir
=
save_dir
,
verbose
=
verbose
,
metrics
=
self
.
_metrics_name
(),
acc_step
=
self
.
_acc_steps
,
acc_step
=
1
if
self
.
_strategy
.
pipeline
.
enable
else
self
.
_acc_steps
,
# lr update once every local batch
)
cbks
.
on_begin
(
'train'
)
...
...
python/paddle/distributed/auto_parallel/static/parallelizer_v2.py
浏览文件 @
36bc5511
...
...
@@ -223,10 +223,15 @@ class Parallelizer:
def
_generate_optimizer
(
self
,
main_program
,
startup_program
,
optimizer
,
params_grads
):
# NOTE: `apply_gradients` will add an Accumulator for a parameter only once,
# but optimizer will be called repeatedly in re-launch, so optimizer need to be copied.
# NOTE:
# 1. `apply_gradients` will add an Accumulator for a parameter only once,
# but optimizer will be called repeatedly in re-launch, so optimizer need to be copied.
# 2. lr_scheduler cannot be deepcopy, cause 'deepcopy' will lead to difference of learning_rate between executor and engine.
learning_rate
=
optimizer
.
_learning_rate
optimizer
=
copy
.
deepcopy
(
optimizer
)
self
.
_dist_context
.
_serial_optimizer
=
optimizer
self
.
_dist_context
.
_serial_optimizer
.
_learning_rate
=
learning_rate
with
program_guard
(
main_program
,
startup_program
):
with
unique_name
.
guard
(
"opt_"
):
optimizer_ops
=
optimizer
.
apply_gradients
(
params_grads
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录