profile_throughput.md 1.78 KB
Newer Older
zhouxiang's avatar
zhouxiang committed
1
# 请求吞吐量性能测试
Lyu Han's avatar
Lyu Han committed
2
3
4
5
6

在真实应用中,用户输入的 prompt 长度以及模型回复的 token 数量是动态变化的。而静态推理能力不足以反映推理引擎对动态输入输出的处理能力。

所以需要使用真实对话数据,评测推理引擎的动态推理能力。本文将介绍如何在 localhost 上测试 LMDeploy 的动态推理性能。

zhouxiang's avatar
zhouxiang committed
7
测试脚本是 `profile_throughput.py`。测试之前,请安装 lmdeploy 预编译包,并下载评测脚本和测试数据集。
Lyu Han's avatar
Lyu Han committed
8
9

```shell
zhouxiang's avatar
zhouxiang committed
10
pip install lmdeploy
Lyu Han's avatar
Lyu Han committed
11
git clone --depth=1 https://github.com/InternLM/lmdeploy
zhouxiang's avatar
zhouxiang committed
12
cd lmdeploy/benchmark
Lyu Han's avatar
Lyu Han committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
wget https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
```

## 测量指标

LMDeploy 统计首token延时(first_token_latency)、token吞吐量(tokens/s)和请求吞吐量(RPM)。

`first_token_latency` 只有在流式推理的情况下才会输出。

token吞吐量的计算公式为:

$$
token吞吐量 = 生成的token数量 / 总时间
$$

请求吞吐量的计算公式为:

$$
吞吐量 = 请求数量 / 总时间
$$

总时间包括 prefill 时间

zhouxiang's avatar
zhouxiang committed
36
## 测量方法
Lyu Han's avatar
Lyu Han committed
37

zhouxiang's avatar
zhouxiang committed
38
我们以 [internlm/internlm-7b](https://huggingface.co/internlm/internlm-7b) 为例,分别介绍测试 LMDeploy 两个推理引擎 turbomind 和 pytorch 的离线请求处理速度
Lyu Han's avatar
Lyu Han committed
39

zhouxiang's avatar
zhouxiang committed
40
### Turbomind 引擎
Lyu Han's avatar
Lyu Han committed
41

zhouxiang's avatar
zhouxiang committed
42
43
```shell
python3 profile_throughput.py ./ShareGPT_V3_unfiltered_cleaned_split.json internlm/internlm-7b
Lyu Han's avatar
Lyu Han committed
44
45
```

zhouxiang's avatar
zhouxiang committed
46
### PyTorch 引擎
Lyu Han's avatar
Lyu Han committed
47
48

```shell
zhouxiang's avatar
zhouxiang committed
49
python3 profile_throughput.py ./ShareGPT_V3_unfiltered_cleaned_split.json internlm/internlm-7b  --backend pytorch
Lyu Han's avatar
Lyu Han committed
50
51
```

zhouxiang's avatar
zhouxiang committed
52
有关 profile_throughput.py 的详细参数,比如并发数、采样参数、k/v内存分配比例等等,请执行 `python3 profile_throughput.py -h` 查阅