Benchmark CLI¶
本節將指導您使用 vLLM 上支援的廣泛資料集執行基準測試。
這是一個不斷更新的文件,隨著新功能和資料集的可用而更新。
Dataset Overview¶
| 資料集 | 線上 | 離線 | 資料路徑 |
|---|---|---|---|
| ShareGPT | ✅ | ✅ | wget https://huggingface.tw/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json |
| ShareGPT4V (影像) | ✅ | ✅ | wget https://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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://huggingface.tw/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 計算以正確報告吞吐量數字也已調整。
