Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ernie inference docs (#978) #985

Open
wants to merge 1 commit into
base: release/2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions projects/ernie/auto_export_ernie_345M_mp1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#! /bin/bash

# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


log_dir=log_auto
rm -rf $log_dir

# 345M mp1 export
python -m paddle.distributed.launch --log_dir $log_dir --devices "0" \
./tools/auto_export.py \
-c ./ppfleetx/configs/nlp/ernie/auto/finetune_ernie_345M_single_card.yaml \
-o Distributed.mp_degree=1 \
12 changes: 11 additions & 1 deletion projects/ernie/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ Learnt by ERNIE:[mask] [mask] [mask] 是黑龙江的省会,国际 [mask] [ma
```text
.
├── docs
│   └── inference.md
│   └── README.md
├── auto_export_ernie_345M_mp1.sh # 345M ernie-base模型,自动切分单卡导出
├── auto_export_ernie_345M_mp2.sh # 345M ernie-base模型,自动切分多卡导出
├── export_ernie_345M_single_card.sh # 345M ernie-base模型,单卡导出
├── finetune_ernie_345M_single_card.sh # 345M ernie-base模型,单卡finetune训练
├── inference.py # ernie推理代码
├── pretrain_ernie_base_175B_mp8_pp16.sh # 175B ernie-base模型,3D混合并行
├── pretrain_ernie_base_3D.sh # ci测试
├── pretrain_ernie_base_6.7B_sharding16.sh # 6.7B ernie-base模型,sharding16
├── pretrain_ernie_base.sh # 345M ernie-base模型,单卡
└── pretrain_ernie_large.sh # ernie-large模型,单卡
└── pretrain_ernie_large.sh # ernie-large模型,单卡
└── run_inference.sh # ernie推理运行脚本
```


Expand Down Expand Up @@ -150,3 +155,8 @@ python -m paddle.distributed.launch --log_dir $log_dir --devices "0,1,2,3,4,5,6,
-c ./ppfleetx/configs/nlp/ernie/finetune_ernie_345M_single_card.yaml \
-o Model.use_recompute=True
```
</details>

## 3. 推理部署

[推理部署](inference.md)
31 changes: 31 additions & 0 deletions projects/ernie/docs/inference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 推理部署

模型训练完成后,可使用飞桨高性能推理引擎Paddle Inference通过如下方式进行推理部署。

## 1. 模型导出

以`ERNIE(345M)`模型为例


导出单卡`ERNIE(345M)`模型:
```bash
sh projects/ernie/auto_export_ernie_345M_mp1.sh
```

导出多卡`ERNIE(345M)`模型:
```bash
sh projects/ernie/auto_export_ernie_345M_mp2.sh
```

## 2. 推理部署

模型导出后,可通过`tasks/ernie/inference.py`脚本进行推理部署。

`ERNIE(345M)` 推理
```bash
bash projects/ernie/run_inference.sh
```

## 3. Benchmark

测试中