目录

LLM API 性能测试工具使用指南

文章提供了 Linux 和 Windows 平台上的快速开始指南,包括下载、配置和运行工具的命令示例。

本工具是用作测试 LLM API 性能,包括预填充速度、解码速度、首字延迟、延迟等。目前代码已经开源在github上,本篇主要介绍该工具如何使用。

项目地址: https://github.com/Yoosu-L/llmapibenchmark

🚀 快速开始

🐧 Linux

下载并解压

wget https://github.com/Yoosu-L/llmapibenchmark/releases/latest/download/llmapibenchmark_linux_amd64.tar.gz
tar -zxvf llmapibenchmark_linux_amd64.tar.gz 
注意

下面这条命令主要测试总解码速度(生成吞吐)可达到的最大值,适用于短输入、长输出的场景,并发数默认从1到128。

base_url 替换为你的 api 服务 url,以v1结尾。

./llmapibenchmark_linux_amd64 --base-url https://your-api-endpoint.com/v1
注意

测试总预填充速度的最大值,适用于长输入、长输出的场景,可适当改变 num-words 以及 concurrency level。

base_url 替换为你的 api 服务 url,以v1结尾。

./llmapibenchmark_linux_amd64 --base-url https://your-api-endpoint.com/v1 --num-words 6000 --concurrency 1,2,4,8,16,32

🪟 Windows

release 界面下载最新版本

解压后得到 llmapibenchmark_windows_amd64.exe

注意

下面这条命令主要测试总解码速度(生成吞吐)可达到的最大值,适用于短输入、长输出的场景,并发数默认从1到128。

base_url 替换为你的 api 服务 url,以v1结尾。

llmapibenchmark_windows_amd64.exe --base-url https://your-api-endpoint.com/v1
注意

测试总预填充速度的最大值,适用于长输入、长输出的场景,可适当改变 num-words 以及 concurrency level。

base_url 替换为你的 api 服务 url,以v1结尾。

llmapibenchmark_windows_amd64.exe --base-url https://your-api-endpoint.com/v1 --num-words 6000 --concurrency 1,2,4,8,16,32

📊 示例输出

⌨️ 终端实时输出

################################################################################################################
                                          LLM API Throughput Benchmark
                                    https://github.com/Yoosu-L/llmapibenchmark
                                         Time:2024-12-03 03:11:48 UTC+0
################################################################################################################
Input Tokens: 45
Output Tokens: 512
Test Model: qwen2.5:0.5b
Latency: 0.00 ms

| Concurrency | Generation Throughput (tokens/s) |  Prompt Throughput (tokens/s) | Min TTFT (s) | Max TTFT (s) |
|-------------|----------------------------------|-------------------------------|--------------|--------------|
|           1 |                            31.88 |                        976.60 |         0.05 |         0.05 |
|           2 |                            30.57 |                        565.40 |         0.07 |         0.16 |
|           4 |                            31.00 |                        717.96 |         0.11 |         0.25 |

📄 md文件

Input Tokens: 45
Output Tokens: 512
Test Model: Qwen2.5-7B-Instruct-AWQ
Latency: 2.20 ms
ConcurrencyGeneration Throughput (tokens/s)Prompt Throughput (tokens/s)Min TTFT (s)Max TTFT (s)
158.49846.810.050.05
2114.09989.940.080.09
4222.621193.990.110.15
8414.351479.760.110.24
16752.261543.290.130.47
32653.941625.070.140.89

📝 Json (enable with --format json)

{
    "model_name": "Qwen2.5-7B-Instruct-AWQ",
    "input_tokens": 32,
    "output_tokens": 512,
    "latency": 1,
    "results": [
        {
            "concurrency": 1,
            "generation_speed": 118.18,
            "prompt_throughput": 42.69,
            "max_ttft": 0.61,
            "min_ttft": 0.61
        },
        {
            "concurrency": 2,
            "generation_speed": 214.37,
            "prompt_throughput": 48.64,
            "max_ttft": 1.07,
            "min_ttft": 0.42
        }
    ]
}

🗒️ Yaml (enable with --format yaml)

model-name: Qwen2.5-7B-Instruct-AWQ
input-tokens: 32
output-tokens: 512
latency: 1.6
results:
    - concurrency: 1
      generation-speed: 134.28
      prompt-throughput: 59.31
      max-ttft: 0.44
      min-ttft: 0.44
    - concurrency: 2
      generation-speed: 221.23
      prompt-throughput: 51.06
      max-ttft: 1.02
      min-ttft: 0.47

⚙️ 进阶参数

Linux:

./llmapibenchmark_linux_amd64 \
  --base-url https://your-api-endpoint.com/v1 \
  --api-key YOUR_API_KEY \
  --model gpt-3.5-turbo \
  --concurrency 1,2,4,8,16 \
  --max-tokens 512 \
  --num-words 513 \
  --prompt "Your custom prompt here" \
  --format json

Windows:

llmapibenchmark_windows_amd64.exe ^
  --base-url https://your-api-endpoint.com/v1 ^
  --api-key YOUR_API_KEY ^
  --model gpt-3.5-turbo ^
  --concurrency 1,2,4,8,16 ^
  --max-tokens 512 ^
  --num-words 513 ^
  --prompt "Your custom prompt here" ^
  --format json

📋 参数解析

ParameterShortDescriptionDefaultRequired
--base-url-uBase URL for LLM API endpointEmpty (MUST be specified)Yes
--api-key-kAPI authentication keyNoneNo
--model-mSpecific AI model to testAutomatically discovers first available modelNo
--concurrency-cComma-separated concurrency levels to test1,2,4,8,16,32,64,128No
--max-tokens-tMaximum tokens to generate per request512No
--num-words-nNumber of words for random input prompt0No
--prompt-pText prompt for generating responsesA long storyNo
--format-fOutput format (json, yaml)""No
--help-hShow help messagefalseNo