profile_triton_server.md 1.95 KB
Newer Older
zhouxiang's avatar
zhouxiang committed
1
# Triton Inference Server 性能测试
Lyu Han's avatar
Lyu Han committed
2
3
4
5
6
7
8
9
10
11

Triton Inference Server(TIS) 是 LMDeploy 支持的除了 api_server 之外的另一种 serving 方式。它的性能测试方式和测试指标和 [api_server](./profile_api_server.md) 的测试方式类似。

```{note}
LMDeploy 尚未实现 Triton Inference Server 的 ensemble 推理模式,所以推理性能要比 api_server 弱。对于追求性能的用户,我们推荐使用 api_server 部署服务。
```

TIS 性能测试脚本是 `profile_serving.py`。测试之前,请安装 lmdeploy 预编译包,并下载评测脚本和测试数据集。

```shell
zhouxiang's avatar
zhouxiang committed
12
pip install 'lmdeploy[serve]'
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
36
git clone --depth=1 https://github.com/InternLM/lmdeploy
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数量 / 总时间
$$

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

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

总时间包括 prefill 时间

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

zhouxiang's avatar
zhouxiang committed
39
我们以 [internlm/internlm-7b](https://huggingface.co/internlm/internlm-7b) 为例,展示 triton inference server 的性能测试流程
Lyu Han's avatar
Lyu Han committed
40

zhouxiang's avatar
zhouxiang committed
41
### 启动服务
Lyu Han's avatar
Lyu Han committed
42

zhouxiang's avatar
zhouxiang committed
43
启动服务之前,必须先把模型转换为 turbomind 模型格式:
Lyu Han's avatar
Lyu Han committed
44

zhouxiang's avatar
zhouxiang committed
45
46
```shell
lmdeploy convert internlm internlm/internlm-7b --dst-path ./internlm-7b
Lyu Han's avatar
Lyu Han committed
47
48
```

zhouxiang's avatar
zhouxiang committed
49
然后,执行如下命令,启动服务:
Lyu Han's avatar
Lyu Han committed
50
51

```shell
zhouxiang's avatar
zhouxiang committed
52
bash ./internlm-7b/service_docker_up.sh
Lyu Han's avatar
Lyu Han committed
53
54
```

zhouxiang's avatar
zhouxiang committed
55
### 测速
Lyu Han's avatar
Lyu Han committed
56

zhouxiang's avatar
zhouxiang committed
57
58
59
```shell
python3 profile_serving.py 0.0.0.0:33337 ./internlm-7b/triton_models/tokenizer ./ShareGPT_V3_unfiltered_cleaned_split.json
```
Lyu Han's avatar
Lyu Han committed
60

zhouxiang's avatar
zhouxiang committed
61
关于 `profile_serving.py` 脚本中的参数,比如请求并发数、采样参数等等,可以通过运行命令 `python3 profile_serving.py -h` 查阅。