Skip to content

Commit fa8359d

Browse files
authored
[PIR] Fix test_tipc configs/inference/docs (#10465)
1 parent 5aa907c commit fa8359d

File tree

8 files changed

+39
-22
lines changed

8 files changed

+39
-22
lines changed

tests/test_tipc/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
## 1. 简介
44

5-
飞桨除了基本的模型训练和预测,还提供了支持多端多平台的高性能推理部署工具。本文档提供了PaddleNLP中部分模型的飞桨训推一体认证 (Training and Inference Pipeline Certification(TIPC)) 信息和测试工具,方便用户查阅每种模型的训练推理部署打通情况,并可以进行一键测试。
5+
飞桨除了基本的模型训练和预测,还提供了支持多端多平台的高性能推理部署工具。本文档提供了 PaddleNLP 中部分模型的飞桨训推一体认证 (Training and Inference Pipeline Certification(TIPC)) 信息和测试工具,方便用户查阅每种模型的训练推理部署打通情况,并可以进行一键测试。
66

77

88
## 2. 汇总信息
99

1010
打通情况汇总如下,已填写的部分表示可以使用本工具进行一键测试,未填写的表示正在支持中。
1111

1212
**字段说明:**
13-
- 基础训练预测:包括模型单机单卡训练、单机多卡训练以及Paddle Inference Python预测
13+
- 基础训练预测:包括模型单机单卡训练、单机多卡训练以及 Paddle Inference Python 预测
1414
- 更多训练方式:包括多机多卡、混合精度。
1515

16-
更详细的MKLDNN、TensorRT等预测加速相关功能的支持情况可以查看各测试工具的[更多教程](#more)
16+
更详细的 MKLDNN、TensorRT 等预测加速相关功能的支持情况可以查看各测试工具的[更多教程](#more)
1717

1818
| 模型名称 | 模型类型 | 基础<br>训练预测 | 更多<br>训练方式 | 模型压缩 |
1919
| :--- | :----: | :--------: | :---- | :---- |
@@ -55,19 +55,20 @@ test_tipc/
5555

5656
使用本工具,可以测试不同功能的支持情况,以及预测结果是否对齐,测试流程概括如下:
5757

58-
1. 运行prepare.sh准备测试所需数据和模型
59-
2. 运行要测试的功能对应的测试脚本`test_train_inference_python.sh`产出log,由log可以看到不同配置是否运行成功
60-
3.`compare_results.py`对比log中的预测结果和预存在results目录下的结果,判断预测精度是否符合预期(在误差范围内)。
58+
1. 运行 prepare.sh 准备测试所需数据和模型
59+
2. 运行要测试的功能对应的测试脚本`test_train_inference_python.sh`产出 log,由 log 可以看到不同配置是否运行成功
60+
3.`compare_results.py`对比 log 中的预测结果和预存在 results 目录下的结果,判断预测精度是否符合预期(在误差范围内)。
6161

62-
测试单项功能仅需两行命令,**如需测试不同模型/功能,替换配置文件即可**,命令格式如下:
62+
测试前需要根据[基础训练预测使用文档](docs/test_train_inference_python.md)安装依赖。
63+
测试单项功能仅需两行命令,**如需测试不同模型/功能,替换配置文件即可**,需要在 ```tests```目录下运行,命令格式如下:
6364
```shell
6465
# 功能:准备数据
6566
# 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择
66-
bash test_tipc/prepare.sh configs/[model_name]/[params_file_name] [Mode]
67+
bash ./test_tipc/prepare.sh ./test_tipc/configs/[model_name]/[params_file_name] [Mode]
6768

6869
# 功能:运行测试
6970
# 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择
70-
bash test_tipc/test_train_inference_python.sh configs/[model_name]/[params_file_name] [Mode]
71+
bash ./test_tipc/test_train_inference_python.sh ./test_tipc/configs/[model_name]/[params_file_name] [Mode]
7172
```
7273

7374
例如,测试基本训练预测功能的`lite_train_lite_infer`模式,运行:
@@ -82,5 +83,5 @@ bash test_tipc/test_train_inference_python.sh ./test_tipc/configs/bigru_crf/trai
8283

8384
<a name="more"></a>
8485
## 4. 开始测试
85-
各功能测试中涉及MKLDNN、TensorRT等多种预测相关参数配置,请点击下方相应链接了解更多细节和使用教程:
86-
- [test_train_inference_python 使用](docs/test_train_inference_python.md)测试基于Python的模型训练、推理等基本功能。
86+
各功能测试中涉及 MKLDNN、TensorRT 等多种预测相关参数配置,请点击下方相应链接了解更多细节和使用教程:
87+
- [test_train_inference_python 使用](docs/test_train_inference_python.md)测试基于 Python 的模型训练、推理等基本功能。

tests/test_tipc/bert_base_text_cls/predict.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
from paddlenlp.data import Pad, Tuple
2424
from paddlenlp.datasets import load_dataset
2525
from paddlenlp.transformers import AutoTokenizer
26+
from paddlenlp.utils.env import (
27+
PADDLE_INFERENCE_MODEL_SUFFIX,
28+
PADDLE_INFERENCE_WEIGHTS_SUFFIX,
29+
)
2630
from paddlenlp.utils.log import logger
2731

2832

@@ -95,8 +99,8 @@ def __init__(
9599
self.batch_size = batch_size
96100
self.benchmark = benchmark
97101

98-
model_file = os.path.join(model_dir, "inference.pdmodel")
99-
params_file = os.path.join(model_dir, "inference.pdiparams")
102+
model_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_MODEL_SUFFIX}")
103+
params_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_WEIGHTS_SUFFIX}")
100104
if not os.path.exists(model_file):
101105
raise ValueError("not find model file path {}".format(model_file))
102106
if not os.path.exists(params_file):

tests/test_tipc/bigru_crf/deploy/predict.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
from paddle import inference
2020

2121
from paddlenlp.data import Pad, Stack, Tuple
22+
from paddlenlp.utils.env import (
23+
PADDLE_INFERENCE_MODEL_SUFFIX,
24+
PADDLE_INFERENCE_WEIGHTS_SUFFIX,
25+
)
2226
from paddlenlp.utils.log import logger
2327

2428
parser = argparse.ArgumentParser(__doc__)
@@ -153,8 +157,8 @@ def __init__(
153157
):
154158
self.max_seq_length = max_seq_length
155159
self.batch_size = batch_size
156-
model_file = os.path.join(model_dir, "inference.pdmodel")
157-
params_file = os.path.join(model_dir, "inference.pdiparams")
160+
model_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_MODEL_SUFFIX}")
161+
params_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_WEIGHTS_SUFFIX}")
158162
if not os.path.exists(model_file):
159163
raise ValueError("not find model file path {}".format(model_file))
160164
if not os.path.exists(params_file):

tests/test_tipc/configs/bigru_crf/train_infer_python.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
===========================train_params===========================
22
model_name:bigru_crf
3-
python:python3.7
3+
python:python
44
gpu_list:0|0,1
55
--device:gpu|gpu
66
null:null

tests/test_tipc/configs/bigru_crf/train_mac_cpu_normal_normal_infer_python_mac_cpu.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
===========================train_params===========================
22
model_name:bigru_crf
3-
python:python3.7
3+
python:python
44
gpu_list:-1
55
--device:cpu
66
Global.auto_cast:null

tests/test_tipc/configs/bigru_crf/train_windows_gpu_normal_normal_infer_python_windows_cpu_gpu.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
===========================train_params===========================
22
model_name:bigru_crf
3-
python:python3.7
3+
python:python
44
gpu_list:0
55
--device:gpu
66
Global.auto_cast:null

tests/test_tipc/ernie_information_extraction/predict.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
from paddlenlp.data import Pad, Stack, Tuple
2323
from paddlenlp.datasets import load_dataset
2424
from paddlenlp.transformers import ErnieTokenizer
25+
from paddlenlp.utils.env import (
26+
PADDLE_INFERENCE_MODEL_SUFFIX,
27+
PADDLE_INFERENCE_WEIGHTS_SUFFIX,
28+
)
2529
from paddlenlp.utils.log import logger
2630

2731

@@ -128,8 +132,8 @@ def __init__(
128132
self.batch_size = batch_size
129133
self.benchmark = benchmark
130134

131-
model_file = os.path.join(model_dir, "inference.pdmodel")
132-
params_file = os.path.join(model_dir, "inference.pdiparams")
135+
model_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_MODEL_SUFFIX}")
136+
params_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_WEIGHTS_SUFFIX}")
133137
if not os.path.exists(model_file):
134138
raise ValueError("not find model file path {}".format(model_file))
135139
if not os.path.exists(params_file):

tests/test_tipc/ernie_text_cls/predict.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
from paddlenlp.data import Pad, Tuple
2424
from paddlenlp.datasets import load_dataset
2525
from paddlenlp.transformers import AutoTokenizer
26+
from paddlenlp.utils.env import (
27+
PADDLE_INFERENCE_MODEL_SUFFIX,
28+
PADDLE_INFERENCE_WEIGHTS_SUFFIX,
29+
)
2630
from paddlenlp.utils.log import logger
2731

2832

@@ -95,8 +99,8 @@ def __init__(
9599
self.batch_size = batch_size
96100
self.benchmark = benchmark
97101

98-
model_file = os.path.join(model_dir, "inference.pdmodel")
99-
params_file = os.path.join(model_dir, "inference.pdiparams")
102+
model_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_MODEL_SUFFIX}")
103+
params_file = os.path.join(model_dir, f"inference{PADDLE_INFERENCE_WEIGHTS_SUFFIX}")
100104
if not os.path.exists(model_file):
101105
raise ValueError("not find model file path {}".format(model_file))
102106
if not os.path.exists(params_file):

0 commit comments

Comments
 (0)