Benchmark CLI¶
本节将指导您使用 vLLM 上支持的广泛数据集运行基准测试。
这是一个不断更新的文档,随着新功能和数据集的可用而更新。
Dataset Overview¶
| 数据集 | 在线 | 离线 | 数据路径 |
|---|---|---|---|
| ShareGPT | ✅ | ✅ | wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json |
| ShareGPT4V (图像) | ✅ | ✅ | wget https://hugging-face.cn/datasets/Lin-Chen/ShareGPT4V/resolve/main/sharegpt4v_instruct_gpt4-vision_cap100k.json请注意,图像需要单独下载。例如,要下载 COCO 的 2017 年训练图像 wget http://images.cocodataset.org/zips/train2017.zip |
| ShareGPT4Video (视频) | ✅ | ✅ | git clone https://hugging-face.cn/datasets/ShareGPT4Video/ShareGPT4Video |
| BurstGPT | ✅ | ✅ | wget https://github.com/HPMLL/BurstGPT/releases/download/v1.1/BurstGPT_without_fails_2.csv |
| Sonnet (已弃用) | ✅ | ✅ | 本地文件: benchmarks/sonnet.txt |
| 随机 | ✅ | ✅ | 合成 |
| RandomMultiModal (图像/视频) | 🟡 | 🚧 | 合成 |
| RandomForReranking | ✅ | ✅ | 合成 |
| 前缀重复 | ✅ | ✅ | 合成 |
| HuggingFace-VisionArena | ✅ | ✅ | lmarena-ai/VisionArena-Chat |
| HuggingFace-MMVU | ✅ | ✅ | yale-nlp/MMVU |
| HuggingFace-InstructCoder | ✅ | ✅ | likaixin/InstructCoder |
| HuggingFace-AIMO | ✅ | ✅ | AI-MO/aimo-validation-aime, AI-MO/NuminaMath-1.5, AI-MO/NuminaMath-CoT |
| HuggingFace-Other | ✅ | ✅ | lmms-lab/LLaVA-OneVision-Data, Aeala/ShareGPT_Vicuna_unfiltered |
| HuggingFace-MTBench | ✅ | ✅ | philschmid/mt-bench |
| HuggingFace-Blazedit | ✅ | ✅ | vdaita/edit_5k_char, vdaita/edit_10k_char |
| Spec Bench | ✅ | ✅ | wget https://raw.githubusercontent.com/hemingkx/Spec-Bench/refs/heads/main/data/spec_bench/question.jsonl |
| 自定义 | ✅ | ✅ | 本地文件: data.jsonl |
图例
- ✅ - 支持
- 🟡 - 部分支持
- 🚧 - 待支持
注意
HuggingFace 数据集的 dataset-name 应设置为 hf。对于本地 dataset-path,请将 hf-name 设置为其 Hugging Face ID,例如
示例¶
🚀 Online Benchmark¶
显示更多
首先启动模型服务
然后运行基准测试脚本
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--endpoint /v1/completions \
--dataset-name sharegpt \
--dataset-path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json \
--num-prompts 10
如果成功,您将看到以下输出
============ Serving Benchmark Result ============
Successful requests: 10
Benchmark duration (s): 5.78
Total input tokens: 1369
Total generated tokens: 2212
Request throughput (req/s): 1.73
Output token throughput (tok/s): 382.89
Total token throughput (tok/s): 619.85
---------------Time to First Token----------------
Mean TTFT (ms): 71.54
Median TTFT (ms): 73.88
P99 TTFT (ms): 79.49
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 7.91
Median TPOT (ms): 7.96
P99 TPOT (ms): 8.03
---------------Inter-token Latency----------------
Mean ITL (ms): 7.74
Median ITL (ms): 7.70
P99 ITL (ms): 8.39
==================================================
Custom Dataset¶
如果 vLLM 尚未支持您要基准测试的数据集,您仍然可以使用 CustomDataset 进行基准测试。您的数据需要是 .jsonl 格式,并且每条记录都需要有 "prompt" 字段,例如 data.jsonl
{"prompt": "What is the capital of India?"}
{"prompt": "What is the capital of Iran?"}
{"prompt": "What is the capital of China?"}
# run benchmarking script
vllm bench serve --port 9001 --save-result --save-detailed \
--backend vllm \
--model meta-llama/Llama-3.1-8B-Instruct \
--endpoint /v1/completions \
--dataset-name custom \
--dataset-path <path-to-your-data-jsonl> \
--custom-skip-chat-template \
--num-prompts 80 \
--max-concurrency 1 \
--temperature=0.3 \
--top-p=0.75 \
--result-dir "./log/"
如果您已经应用了聊天模板,可以使用 --custom-skip-chat-template 跳过此步骤。
VisionArena Benchmark for Vision Language Models¶
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2-VL-7B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name hf \
--dataset-path lmarena-ai/VisionArena-Chat \
--hf-split train \
--num-prompts 1000
InstructCoder Benchmark with Speculative Decoding¶
vllm serve meta-llama/Meta-Llama-3-8B-Instruct \
--speculative-config $'{"method": "ngram",
"num_speculative_tokens": 5, "prompt_lookup_max": 5,
"prompt_lookup_min": 2}'
vllm bench serve \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--dataset-name hf \
--dataset-path likaixin/InstructCoder \
--num-prompts 2048
Spec Bench Benchmark with Speculative Decoding¶
vllm serve meta-llama/Meta-Llama-3-8B-Instruct \
--speculative-config $'{"method": "ngram",
"num_speculative_tokens": 5, "prompt_lookup_max": 5,
"prompt_lookup_min": 2}'
运行所有类别
# Download the dataset using:
# wget https://raw.githubusercontent.com/hemingkx/Spec-Bench/refs/heads/main/data/spec_bench/question.jsonl
vllm bench serve \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--dataset-name spec_bench \
--dataset-path "<YOUR_DOWNLOADED_PATH>/data/spec_bench/question.jsonl" \
--num-prompts -1
可用的类别包括 [writing, roleplay, reasoning, math, coding, extraction, stem, humanities, translation, summarization, qa, math_reasoning, rag]。
仅运行特定类别,例如 "summarization"
vllm bench serve \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--dataset-name spec_bench \
--dataset-path "<YOUR_DOWNLOADED_PATH>/data/spec_bench/question.jsonl" \
--num-prompts -1
--spec-bench-category "summarization"
Other HuggingFaceDataset Examples¶
lmms-lab/LLaVA-OneVision-Data:
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2-VL-7B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name hf \
--dataset-path lmms-lab/LLaVA-OneVision-Data \
--hf-split train \
--hf-subset "chart2text(cauldron)" \
--num-prompts 10
Aeala/ShareGPT_Vicuna_unfiltered:
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2-VL-7B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name hf \
--dataset-path Aeala/ShareGPT_Vicuna_unfiltered \
--hf-split train \
--num-prompts 10
AI-MO/aimo-validation-aime:
vllm bench serve \
--model Qwen/QwQ-32B \
--dataset-name hf \
--dataset-path AI-MO/aimo-validation-aime \
--num-prompts 10 \
--seed 42
philschmid/mt-bench:
vllm bench serve \
--model Qwen/QwQ-32B \
--dataset-name hf \
--dataset-path philschmid/mt-bench \
--num-prompts 80
vdaita/edit_5k_char 或 vdaita/edit_10k_char
vllm bench serve \
--model Qwen/QwQ-32B \
--dataset-name hf \
--dataset-path vdaita/edit_5k_char \
--num-prompts 90 \
--blazedit-min-distance 0.01 \
--blazedit-max-distance 0.99
Running With Sampling Parameters¶
当使用 OpenAI 兼容的后端(如 vllm)时,可以指定可选的采样参数。示例客户端命令
vllm bench serve \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--endpoint /v1/completions \
--dataset-name sharegpt \
--dataset-path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json \
--top-k 10 \
--top-p 0.9 \
--temperature 0.5 \
--num-prompts 10
Running With Ramp-Up Request Rate¶
基准测试工具还支持在基准测试运行期间加速请求速率。这对于压力测试服务器或查找其在给定延迟预算下的最大吞吐量非常有用。
支持两种加速策略
linear:请求速率从起始值线性增加到结束值。exponential:请求速率呈指数增长。
可以使用以下参数来控制加速
--ramp-up-strategy:要使用的加速策略(linear或exponential)。--ramp-up-start-rps:基准测试开始时的请求速率。--ramp-up-end-rps:基准测试结束时的请求速率。
Load Pattern Configuration¶
vLLM 的基准测试服务脚本通过三个控制请求生成和并发行为的关键参数,提供了复杂负载模式模拟功能。
Load Pattern Control Parameters¶
--request-rate:控制目标请求生成速率(每秒请求数)。设置为inf以进行最大吞吐量测试,或设置为有限值以进行受控负载模拟。--burstiness:使用 Gamma 分布控制流量的可变性(范围:> 0)。较低的值会产生突发流量,较高的值会产生均匀流量。--max-concurrency:限制并发待处理请求。如果未提供此参数,则并发不受限制。设置一个值以模拟背压。
这些参数协同工作,创建逼真的负载模式,并具有精心选择的默认值。--request-rate 参数默认为 inf(无限),它会立即发送所有请求以进行最大吞吐量测试。当设置为有限值时,它使用泊松过程(默认 --burstiness=1.0)或 Gamma 分布进行逼真的请求计时。--burstiness 参数仅在 --request-rate 无穷大时生效——1.0 的值会产生自然的泊松流量,而较低的值(0.1-0.5)会产生突发模式,较高的值(2.0-5.0)会产生均匀间隔。--max-concurrency 参数默认为 None(无限制),但可以设置为模拟真实世界的约束,其中负载均衡器或 API 网关限制并发连接。结合使用时,这些参数允许您模拟从不受限制的压力测试(--request-rate=inf)到具有逼真到达模式和资源约束的生产场景。
--burstiness 参数在数学上使用 Gamma 分布控制请求到达模式,其中
- 形状参数:
burstiness值 - 变异系数 (CV):\(\frac{1}{\sqrt{burstiness}}\)
- 流量特征
burstiness = 0.1:高度突发流量 (CV ≈ 3.16) - 压力测试burstiness = 1.0:自然泊松流量 (CV = 1.0) - 逼真模拟burstiness = 5.0:均匀流量 (CV ≈ 0.45) - 受控负载测试
图:每个用例的负载模式示例。顶行:显示累计请求随时间变化的请求到达时间线。底行:显示流量可变性模式的到达时间间隔分布。每列代表一个不同的用例,及其特定的参数设置和由此产生的流量特征。
按用例划分的负载模式建议
| Use Case | 突发性 | 请求速率 | 最大并发数 | 描述 |
|---|---|---|---|---|
| 最大吞吐量 | 不适用 | 无限 | 有限 | 最常见:模拟具有无限用户需求的负载均衡器/网关限制 |
| 逼真测试 | 1.0 | 中等 (5-20) | 无限 | 自然泊松流量模式,用于基线性能 |
| 压力测试 | 0.1-0.5 | 高 (20-100) | 无限 | 挑战性的突发模式,用于测试弹性 |
| 延迟剖析 | 2.0-5.0 | 低 (1-10) | 无限 | 均匀负载,用于一致的时间分析 |
| 容量规划 | 1.0 | 可变 | 有限 | 使用逼真的约束测试资源限制 |
| SLA 验证 | 1.0 | 目标速率 | SLA 限制 | 生产环境般的约束,用于合规性测试 |
这些负载模式有助于评估 vLLM 部署的各个方面,从基本性能特征到在挑战性流量条件下的弹性。
最大吞吐量模式(--request-rate=inf --max-concurrency=<limit>)是生产环境基准测试中最常用的配置。这模拟了真实世界的部署架构,其中
- 用户尽可能快地发送请求(无限速率)
- 负载均衡器或 API 网关控制最大并发连接数
- 系统在其并发限制下运行,揭示真实的吞吐量能力
--burstiness无效,因为当速率无限时,请求计时不受控制
此模式有助于确定您的生产负载均衡器配置的最佳并发设置。
为了有效地配置负载模式,特别是对于容量规划和SLA 验证用例,您需要了解系统的资源限制。在启动过程中,vLLM 会报告 KV 缓存配置,这直接影响您的负载测试参数。
其中
- GPU KV 缓存大小:所有并发请求的总可缓存 token 数
- 最大并发数:对于给定的
max_model_len,理论上的最大并发请求数 - 计算:
max_concurrency = kv_cache_size / max_model_len
使用 KV 缓存指标进行负载模式配置
- 对于容量规划:将
--max-concurrency设置为报告最大值的 80-90% 以测试逼真的资源约束 - 对于 SLA 验证:使用报告的最大值作为您的 SLA 限制,以确保合规性测试与生产容量匹配
- 对于逼真测试:在接近理论极限时监控内存使用情况,以了解可持续的请求速率
- 请求速率指导:使用 KV 缓存大小来估算您特定工作负载和序列长度的可持续请求速率
📈 Offline Throughput Benchmark¶
显示更多
vllm bench throughput \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--dataset-name sonnet \
--dataset-path vllm/benchmarks/sonnet.txt \
--num-prompts 10
如果成功,您将看到以下输出
Throughput: 7.15 requests/s, 4656.00 total tokens/s, 1072.15 output tokens/s
Total num prompt tokens: 5014
Total num output tokens: 1500
VisionArena Benchmark for Vision Language Models¶
vllm bench throughput \
--model Qwen/Qwen2-VL-7B-Instruct \
--backend vllm-chat \
--dataset-name hf \
--dataset-path lmarena-ai/VisionArena-Chat \
--num-prompts 1000 \
--hf-split train
num prompt tokens 现在包括图像 token 计数
Throughput: 2.55 requests/s, 4036.92 total tokens/s, 326.90 output tokens/s
Total num prompt tokens: 14527
Total num output tokens: 1280
InstructCoder Benchmark with Speculative Decoding¶
VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm bench throughput \
--dataset-name=hf \
--dataset-path=likaixin/InstructCoder \
--model=meta-llama/Meta-Llama-3-8B-Instruct \
--input-len=1000 \
--output-len=100 \
--num-prompts=2048 \
--async-engine \
--speculative-config $'{"method": "ngram",
"num_speculative_tokens": 5, "prompt_lookup_max": 5,
"prompt_lookup_min": 2}'
Throughput: 104.77 requests/s, 23836.22 total tokens/s, 10477.10 output tokens/s
Total num prompt tokens: 261136
Total num output tokens: 204800
Other HuggingFaceDataset Examples¶
lmms-lab/LLaVA-OneVision-Data:
vllm bench throughput \
--model Qwen/Qwen2-VL-7B-Instruct \
--backend vllm-chat \
--dataset-name hf \
--dataset-path lmms-lab/LLaVA-OneVision-Data \
--hf-split train \
--hf-subset "chart2text(cauldron)" \
--num-prompts 10
Aeala/ShareGPT_Vicuna_unfiltered:
vllm bench throughput \
--model Qwen/Qwen2-VL-7B-Instruct \
--backend vllm-chat \
--dataset-name hf \
--dataset-path Aeala/ShareGPT_Vicuna_unfiltered \
--hf-split train \
--num-prompts 10
AI-MO/aimo-validation-aime:
vllm bench throughput \
--model Qwen/QwQ-32B \
--backend vllm \
--dataset-name hf \
--dataset-path AI-MO/aimo-validation-aime \
--hf-split train \
--num-prompts 10
使用 LoRA 适配器进行基准测试
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench throughput \
--model meta-llama/Llama-2-7b-hf \
--backend vllm \
--dataset_path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json \
--dataset_name sharegpt \
--num-prompts 10 \
--max-loras 2 \
--max-lora-rank 8 \
--enable-lora \
--lora-path yard1/llama-2-7b-sql-lora-test
🛠️ Structured Output Benchmark¶
显示更多
基准测试结构化输出生成(JSON、语法、正则表达式)的性能。
Server Setup¶
JSON Schema Benchmark¶
python3 benchmarks/benchmark_serving_structured_output.py \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--dataset json \
--structured-output-ratio 1.0 \
--request-rate 10 \
--num-prompts 1000
Grammar-based Generation Benchmark¶
python3 benchmarks/benchmark_serving_structured_output.py \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--dataset grammar \
--structure-type grammar \
--request-rate 10 \
--num-prompts 1000
Regex-based Generation Benchmark¶
python3 benchmarks/benchmark_serving_structured_output.py \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--dataset regex \
--request-rate 10 \
--num-prompts 1000
Choice-based Generation Benchmark¶
python3 benchmarks/benchmark_serving_structured_output.py \
--backend vllm \
--model NousResearch/Hermes-3-Llama-3.1-8B \
--dataset choice \
--request-rate 10 \
--num-prompts 1000
XGrammar Benchmark Dataset¶
📚 Long Document QA Benchmark¶
显示更多
基准测试带有前缀缓存的长文档问答性能。
Basic Long Document QA Test¶
python3 benchmarks/benchmark_long_document_qa_throughput.py \
--model meta-llama/Llama-2-7b-chat-hf \
--enable-prefix-caching \
--num-documents 16 \
--document-length 2000 \
--output-len 50 \
--repeat-count 5
Different Repeat Modes¶
# Random mode (default) - shuffle prompts randomly
python3 benchmarks/benchmark_long_document_qa_throughput.py \
--model meta-llama/Llama-2-7b-chat-hf \
--enable-prefix-caching \
--num-documents 8 \
--document-length 3000 \
--repeat-count 3 \
--repeat-mode random
# Tile mode - repeat entire prompt list in sequence
python3 benchmarks/benchmark_long_document_qa_throughput.py \
--model meta-llama/Llama-2-7b-chat-hf \
--enable-prefix-caching \
--num-documents 8 \
--document-length 3000 \
--repeat-count 3 \
--repeat-mode tile
# Interleave mode - repeat each prompt consecutively
python3 benchmarks/benchmark_long_document_qa_throughput.py \
--model meta-llama/Llama-2-7b-chat-hf \
--enable-prefix-caching \
--num-documents 8 \
--document-length 3000 \
--repeat-count 3 \
--repeat-mode interleave
🗂️ Prefix Caching Benchmark¶
显示更多
基准测试自动前缀缓存的效率。
Fixed Prompt with Prefix Caching¶
python3 benchmarks/benchmark_prefix_caching.py \
--model meta-llama/Llama-2-7b-chat-hf \
--enable-prefix-caching \
--num-prompts 1 \
--repeat-count 100 \
--input-length-range 128:256
ShareGPT Dataset with Prefix Caching¶
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
python3 benchmarks/benchmark_prefix_caching.py \
--model meta-llama/Llama-2-7b-chat-hf \
--dataset-path /path/ShareGPT_V3_unfiltered_cleaned_split.json \
--enable-prefix-caching \
--num-prompts 20 \
--repeat-count 5 \
--input-length-range 128:256
Prefix Repetition Dataset¶
🧪 Hashing Benchmarks¶
显示更多
benchmarks/ 目录中有两个辅助脚本,用于比较前缀缓存及相关实用程序使用的哈希选项。它们是独立的(不需要服务器),有助于在生产环境中启用前缀缓存之前选择哈希算法。
benchmarks/benchmark_hash.py:微基准测试,测量三种实现对代表性(bytes, tuple[int])载荷的每次调用延迟。
benchmarks/benchmark_prefix_block_hash.py:端到端块哈希基准测试,运行完整的]前缀缓存哈希管道(hash_block_tokens)在许多伪块上,并报告吞吐量。
支持的算法:sha256、sha256_cbor、xxhash、xxhash_cbor。安装可选依赖项以使用所有变体。
如果缺少某个算法的依赖项,脚本将跳过它并继续。
⚡ Request Prioritization Benchmark¶
显示更多
基准测试 vLLM 中请求优先级排序的性能。
Basic Prioritization Test¶
python3 benchmarks/benchmark_prioritization.py \
--model meta-llama/Llama-2-7b-chat-hf \
--input-len 128 \
--output-len 64 \
--num-prompts 100 \
--scheduling-policy priority
Multiple Sequences per Prompt¶
👁️ Multi-Modal Benchmark¶
显示更多
基准测试 vLLM 中多模态请求的性能。
Images (ShareGPT4V)¶
启动 vLLM
vllm serve Qwen/Qwen2.5-VL-7B-Instruct \
--dtype bfloat16 \
--limit-mm-per-prompt '{"image": 1}' \
--allowed-local-media-path /path/to/sharegpt4v/images
发送带图像的请求
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2.5-VL-7B-Instruct \
--dataset-name sharegpt \
--dataset-path /path/to/ShareGPT4V/sharegpt4v_instruct_gpt4-vision_cap100k.json \
--num-prompts 100 \
--save-result \
--result-dir ~/vllm_benchmark_results \
--save-detailed \
--endpoint /v1/chat/completions
Videos (ShareGPT4Video)¶
启动 vLLM
vllm serve Qwen/Qwen2.5-VL-7B-Instruct \
--dtype bfloat16 \
--limit-mm-per-prompt '{"video": 1}' \
--allowed-local-media-path /path/to/sharegpt4video/videos
发送带视频的请求
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2.5-VL-7B-Instruct \
--dataset-name sharegpt \
--dataset-path /path/to/ShareGPT4Video/llava_v1_5_mix665k_with_video_chatgpt72k_share4video28k.json \
--num-prompts 100 \
--save-result \
--result-dir ~/vllm_benchmark_results \
--save-detailed \
--endpoint /v1/chat/completions
Synthetic Random Images (random-mm)¶
生成合成图像输入以及随机文本提示,以在没有外部数据集的情况下对视觉模型进行压力测试。
注意事项
- 仅通过 OpenAI 后端(
--backend openai-chat)和端点/v1/chat/completions在线基准测试中有效。 - 视频采样尚未实现。
启动服务器(示例)
vllm serve Qwen/Qwen2.5-VL-3B-Instruct \
--dtype bfloat16 \
--max-model-len 16384 \
--limit-mm-per-prompt '{"image": 3, "video": 0}' \
--mm-processor-kwargs max_pixels=1003520
基准测试。建议使用标志 --ignore-eos 来模拟真实响应。您可以通过参数 random-output-len 设置输出大小。
示例 1:固定项目数量和单个图像分辨率,强制生成约 40 个 token
vllm bench serve \
--backend openai-chat \
--model Qwen/Qwen2.5-VL-3B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name random-mm \
--num-prompts 100 \
--max-concurrency 10 \
--random-prefix-len 25 \
--random-input-len 300 \
--random-output-len 40 \
--random-range-ratio 0.2 \
--random-mm-base-items-per-request 2 \
--random-mm-limit-mm-per-prompt '{"image": 3, "video": 0}' \
--random-mm-bucket-config '{(224, 224, 1): 1.0}' \
--request-rate inf \
--ignore-eos \
--seed 42
每个请求的项目数量可以通过传递多个多模态数据桶来控制
--random-mm-base-items-per-request 2 \
--random-mm-num-mm-items-range-ratio 0.5 \
--random-mm-limit-mm-per-prompt '{"image": 4, "video": 0}' \
--random-mm-bucket-config '{(256, 256, 1): 0.7, (720, 1280, 1): 0.3}' \
random-mm 特有标志
--random-mm-base-items-per-request:每个请求的基础多模态项目数。--random-mm-num-mm-items-range-ratio:在闭区间 [floor(n·(1−r)), ceil(n·(1+r))] 中均匀变化项目计数。设置为 r=0 以保持固定;r=1 允许 0 个项目。--random-mm-limit-mm-per-prompt:每个模态的硬上限,例如 '{"image": 3, "video": 0}'。--random-mm-bucket-config:将 (H, W, T) 映射到概率的字典。概率为 0 的条目将被删除;剩余的概率被重新归一化为总和为 1。图像使用 T=1。为视频设置任何 T>1(视频采样尚不支持)。
行为说明
- 如果请求的基础项目计数在提供的每个提示限制下无法满足,工具将引发错误而不是静默截断。
采样工作原理
- 通过在
--random-mm-base-items-per-request和--random-mm-num-mm-items-range-ratio定义的整数范围内均匀采样,确定每个请求的项目计数 k,然后将 k 限制在每个模态限制的总和之上。 - 对于 k 个项目中的每个项目,根据
--random-mm-bucket-config中的归一化概率对一个数据桶 (H, W, T) 进行采样,同时跟踪已添加的每种模态的项目数。 - 如果某个模态(例如图像)达到其从
--random-mm-limit-mm-per-prompt收到的限制,则该模态的所有数据桶都将被排除,并且在继续之前,剩余的数据桶概率将被重新归一化。这应被视为一种边缘情况,如果可以通过将--random-mm-limit-mm-per-prompt设置为较大的数字来避免这种情况。请注意,这可能会由于引擎配置--limit-mm-per-prompt而导致错误。 - 结果请求包含
multi_modal_data(OpenAI Chat 格式)中的合成图像数据。当random-mm与 OpenAI Chat 后端一起使用时,提示保持文本格式,并且 MM 内容通过multi_modal_data附加。
Embedding Benchmark¶
基准测试 vLLM 中嵌入请求的性能。
显示更多
Text Embeddings¶
与使用 Completions API 或 Chat Completions API 的生成模型不同,您应该设置 --backend openai-embeddings 和 --endpoint /v1/embeddings 来使用 Embeddings API。
您可以使用任何文本数据集来基准测试模型,例如 ShareGPT。
启动服务器
运行基准测试
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--model jinaai/jina-embeddings-v3 \
--backend openai-embeddings \
--endpoint /v1/embeddings \
--dataset-name sharegpt \
--dataset-path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json
Multi-modal Embeddings¶
与使用 Completions API 或 Chat Completions API 的生成模型不同,您应该设置 --endpoint /v1/embeddings 来使用 Embeddings API。要使用的后端取决于模型
- CLIP:
--backend openai-embeddings-clip - VLM2Vec:
--backend openai-embeddings-vlm2vec
对于其他模型,请在 vllm/benchmarks/lib/endpoint_request_func.py 中添加您自己的实现,以匹配预期的指令格式。
您可以使用任何文本或多模态数据集来基准测试模型,只要模型支持它即可。例如,您可以使用 ShareGPT 和 VisionArena 来基准测试视觉语言嵌入。
服务并基准测试 CLIP
# Run this in another process
vllm serve openai/clip-vit-base-patch32
# Run these one by one after the server is up
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--model openai/clip-vit-base-patch32 \
--backend openai-embeddings-clip \
--endpoint /v1/embeddings \
--dataset-name sharegpt \
--dataset-path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--model openai/clip-vit-base-patch32 \
--backend openai-embeddings-clip \
--endpoint /v1/embeddings \
--dataset-name hf \
--dataset-path lmarena-ai/VisionArena-Chat
服务并基准测试 VLM2Vec
# Run this in another process
vllm serve TIGER-Lab/VLM2Vec-Full --runner pooling \
--trust-remote-code \
--chat-template examples/template_vlm2vec_phi3v.jinja
# Run these one by one after the server is up
# download dataset
# wget https://hugging-face.cn/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--model TIGER-Lab/VLM2Vec-Full \
--backend openai-embeddings-vlm2vec \
--endpoint /v1/embeddings \
--dataset-name sharegpt \
--dataset-path <your data path>/ShareGPT_V3_unfiltered_cleaned_split.json
vllm bench serve \
--model TIGER-Lab/VLM2Vec-Full \
--backend openai-embeddings-vlm2vec \
--endpoint /v1/embeddings \
--dataset-name hf \
--dataset-path lmarena-ai/VisionArena-Chat
Reranker Benchmark¶
基准测试 vLLM 中重排序请求的性能。
显示更多
与使用 Completions API 或 Chat Completions API 的生成模型不同,您应该设置 --backend vllm-rerank 和 --endpoint /v1/rerank 来使用 Reranker API。
对于重排序,唯一支持的数据集是 --dataset-name random-rerank
启动服务器
运行基准测试
vllm bench serve \
--model BAAI/bge-reranker-v2-m3 \
--backend vllm-rerank \
--endpoint /v1/rerank \
--dataset-name random-rerank \
--tokenizer BAAI/bge-reranker-v2-m3 \
--random-input-len 512 \
--num-prompts 10 \
--random-batch-size 5
对于重排序模型,这将创建 num_prompts / random_batch_size 个请求,每个请求有 random_batch_size 个“文档”,每个文档大约有 random_input_len 个 token。在上面的示例中,这会导致 2 个重排序请求,每个请求有 5 个“文档”,每个文档大约有 512 个 token。
请注意,/v1/rerank 也支持嵌入模型。因此,如果您使用嵌入模型运行,请同时设置 --no_reranker。因为在这种情况下,查询被服务器视为单个提示,这里我们发送 random_batch_size - 1 个文档以考虑额外的查询提示。token 计算以正确报告吞吐量数字也已调整。
