速度基准测试#
若想进行速度测试,得到类似Qwen官方报告的速度基准,如下所示:
可以使用 --dataset [speed_benchmark|speed_benchmark_long]
来指定速度测试的数据集:
speed_benchmark
: 测试[1, 6144, 14336, 30720]长度的prompt,固定输出2048个token。speed_benchmark_long
: 测试[63488, 129024]长度的prompt,固定输出2048个token。
在线API推理#
备注
速度测试--url
需要使用/v1/completions
端点,而不是/v1/chat/completions
,避免chat template的额外处理对输入长度有影响。
evalscope perf \
--rate 1 \
--url http://127.0.0.1:8000/v1/completions \
--model qwen2.5 \
--log-every-n-query 5 \
--connect-timeout 6000 \
--read-timeout 6000 \
--max-tokens 2048 \
--min-tokens 2048 \
--api openai \
--dataset speed_benchmark \
--debug
本地Transformer推理#
CUDA_VISIBLE_DEVICES=0 evalscope perf \
--rate 1 \
--model Qwen/Qwen2.5-0.5B-Instruct \
--attn-implementation flash_attention_2 \
--log-every-n-query 5 \
--connect-timeout 6000 \
--read-timeout 6000 \
--max-tokens 2048 \
--min-tokens 2048 \
--api local \
--dataset speed_benchmark \
--debug
输出示例:
Speed Benchmark Results:
+---------------+-----------------+----------------+
| Prompt Tokens | Speed(tokens/s) | GPU Memory(GB) |
+---------------+-----------------+----------------+
| 1 | 50.69 | 0.97 |
| 6144 | 51.36 | 1.23 |
| 14336 | 49.93 | 1.59 |
| 30720 | 49.56 | 2.34 |
+---------------+-----------------+----------------+
本地vLLM推理#
CUDA_VISIBLE_DEVICES=0 evalscope perf \
--rate 1 \
--model Qwen/Qwen2.5-0.5B-Instruct \
--log-every-n-query 5 \
--connect-timeout 6000 \
--read-timeout 6000 \
--max-tokens 2048 \
--min-tokens 2048 \
--api local_vllm \
--dataset speed_benchmark
输出示例:
小技巧
vLLM会预分配显存,因此此处不展示GPU使用情况。
Speed Benchmark Results:
+---------------+-----------------+----------------+
| Prompt Tokens | Speed(tokens/s) | GPU Memory(GB) |
+---------------+-----------------+----------------+
| 1 | 343.08 | 0.0 |
| 6144 | 334.71 | 0.0 |
| 14336 | 318.88 | 0.0 |
| 30720 | 292.86 | 0.0 |
+---------------+-----------------+----------------+