Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • 合并请求
  • !25793

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • 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看板

enable original optimizer !25793

  • Report abuse
!25793 已关闭 7月 29, 2020 由 saxon_zh@saxon_zh 创建
#<User:0x00007f0e50f5d128>
  • 概览 1
  • 提交 1
  • 变更 1

Created by: mapingshuo

PR types

Bug fixes

PR changes

APIs

Describe

When using the Fleet API (version2.0), I found that my program lacks the 'backward' and 'optimize' operators, which means the optimize.minimize() did not work correctly.

test code

# limitations under the License.
import os

os.environ['FLAGS_enable_parallel_graph'] = "0"
os.environ['FLAGS_fraction_of_gpu_memory_to_use'] = "0.98"
os.environ['FLAGS_sync_nccl_allreduce'] = "1"
os.environ['FLAGS_eager_delete_tensor_gb'] = "0"
os.environ['FLAGS_fuse_parameter_memory_size'] = "32"
os.environ['FLAGS_fuse_parameter_groups_size'] = "50"

import numpy as np
import fleet_lightning as lighting
import paddle.fluid as fluid
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
import time
import paddle.fleet as fleet
import paddle

# lightning help users to focus more on learning to train a large scale model
# if you want to learn how to write a model, lightning is not for you
# focus more on engineering staff in fleet-lightning

configs = lighting.parse_train_configs()
role = role_maker.PaddleCloudRoleMaker(is_collective=True)
fleet.init(role)
# load Bert_large / Bert_base model
model = lighting.applications.Bert_large()
#model = lighting.applications.Bert_base()

data_loader = model.load_digital_dataset_from_file(
    data_dir='train/',
    vocab_path='vocab.txt',
    max_seq_len=512,
    batch_size=14,
)

place = fluid.CUDAPlace(int(os.environ.get('FLAGS_selected_gpus', 0)))
exec_strategy = fluid.ExecutionStrategy()
exec_strategy.num_threads = 2
exec_strategy.num_iteration_per_drop_scope = 1
dist_strategy = fleet.DistributedStrategy()
dist_strategy.exec_strategy = exec_strategy
dist_strategy.nccl_comm_num = 3

optimizer = fluid.optimizer.Adam(learning_rate=configs.lr)
optimizer = fleet.distributed_optimizer(optimizer, dist_strategy)
optimizer.minimize(model.loss)

print(optimizer)
print("after minimize")
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())

with open("main_program.txt", 'w') as f:
    f.write(str(paddle.default_main_program()))

scope = fluid.global_scope()
total_time = 0
for i, data in enumerate(data_loader()):
    if i >= 10:
        start_time = time.time()
    cost_val = exe.run(paddle.default_main_program(),
                       feed=data,
                       fetch_list=[model.loss.name])
    if i >= 10:
        end_time = time.time()
        total_time += (end_time - start_time)
        print(
            "worker_index: %d, step%d cost = %f, total time cost = %f, step per second: %f, speed: %f"
            % (fleet.worker_index(), i, cost_val[0], total_time,
               (i - 9) / total_time, 1 / (end_time - start_time)))
    print("step: %d, encoder_layer_16_ffn_fc_1.w_0: %s" % (
         i, scope.var("encoder_layer_16_ffn_fc_1.w_0").get_tensor().__array__()))
python -m paddle.distributed.launch  --selected_gpus=2,3 no-backward.py

Result:

The dumped main_program.txt contains no backward and optimize ops, such as adam. This PR fixed this.

指派人
分配到
审核者
Request review from
无
里程碑
无
分配里程碑
工时统计
标识: paddlepaddle/Paddle!25793
Source branch: github/fork/mapingshuo/origin_optimizer
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7