Benchmarks测试
MTT 推理引擎性能测试
新建配置脚本perf_config.json如下:
echo \
"[
{
\"model_name\": \"$model_name\",
\"path\": \"$converted_model_dir\",
\"batchs\": [1,2,4,8],
\"prefill_token_lens\": [256,512,1024],
\"decode_token_lens\": [64]
}
]" > perf_config.json
示例文件内容:
perf_config.json
[
{
"model_name": "Qwen2.5-72B-Instruct",
"path": "/data/mtt/models_convert/Qwen2.5-72B-Instruct-converted/",
"batchs": [1,2,4,8],
"prefill_token_lens": [256,512,1024],
"decode_token_lens": [64]
}
]
然后执行以下命令开始测试:
python -m mttransformer.perf_test perf_config.json
在执行路径下,测试结果会同时打印在命令行窗口并存放在./perf_data/文件夹内的csv文件,输出示例如下图所示:
Qwen2.5-72B-Instruct perf finish
=========
Model Data_Type GPU_Num batch prefill_tokens decode_tokens prefill_latency single_batch_decode_tps total_decode_tps
0 Qwen2.5-72B-Instruct FP16 8 1 256 64 *** *** ***
1 Qwen2.5-72B-Instruct FP16 8 1 512 64 *** *** ***
2 Qwen2.5-72B-Instruct FP16 8 1 1024 64 *** *** ***
3 Qwen2.5-72B-Instruct FP16 8 2 256 64 *** *** ***
4 Qwen2.5-72B-Instruct FP16 8 2 512 64 *** *** ***
5 Qwen2.5-72B-Instruct FP16 8 2 1024 64 *** *** ***
6 Qwen2.5-72B-Instruct FP16 8 4 256 64 *** *** ***
7 Qwen2.5-72B-Instruct FP16 8 4 512 64 *** *** ***
8 Qwen2.5-72B-Instruct FP16 8 4 1024 64 *** *** ***
9 Qwen2.5-72B-Instruct FP16 8 8 256 64 *** *** ***
10 Qwen2.5-72B-Instruct FP16 8 8 512 64 *** *** ***
11 Qwen2.5-72B-Instruct FP16 8 8 1024 64 *** *** ***
可以通过-o指定输出路径。也可以通过-h查询完整的命令用法:
$ python -m mttransformer.perf_test -h
usage: perf_test.py [-h] [-o OUTPUT_PATH] config_path
mtt perf script
positional arguments:
config_path input config json file path
optional arguments:
-h, --help show this help message and exit
-o OUTPUT_PATH, --output-path OUTPUT_PATH
output file path
| 列名 | 含义 | 样例 |
|---|---|---|
| Model | 模型名 | Qwen2.5-72B-Instruct |
| Data_Type | 数据精度 | FP16 |
| GPU_Num | GPU数量 | 8 |
| batch | Batch大小 | 1 |
| prefill_tokens | 预填充长度 | 512 |
| decode_tokens | 解码长度 | 64 |
| prefill_latency | 预填充延迟/首字延迟/TTFT(ms) | 377 |
| single_batch_decode_tps | 单batch吞吐(token/s) | 30 |
| total_decode_tps | 总吞吐(token/s) | 60 |