Skip to content

Commit 7b365a8

Browse files
committed
feat: add compare_with_vllm.py
1 parent 86d62dc commit 7b365a8

4 files changed

Lines changed: 785 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Benchmark Comparison Example
2+
3+
Compare `inference-endpoint` with vLLM's benchmarking tool using identical prompts.
4+
5+
## Prerequisites
6+
7+
1. **Running inference server** (OpenAI-compatible):
8+
9+
```bash
10+
vllm serve Qwen/Qwen2.5-0.5B-Instruct --port 8000
11+
```
12+
13+
2. **Pre-generated dataset files** (included in this directory):
14+
- `dummy_prompts_vllm.jsonl` - vLLM format: `{"prompt": "..."}`
15+
- `dummy_prompts_ie.jsonl` - inference-endpoint format: `{"text_input": "..."}`
16+
17+
## Usage
18+
19+
```bash
20+
cd examples/03_BenchmarkComparison
21+
python compare_with_vllm.py --model "Qwen/Qwen2.5-0.5B-Instruct" --endpoint http://localhost:8000
22+
```
23+
24+
### Options
25+
26+
| Option | Description | Default |
27+
| --------------------- | -------------------------------- | ----------------------- |
28+
| `--model`, `-m` | Model name (required) | - |
29+
| `--num-prompts`, `-n` | Number of prompts | 100 |
30+
| `--endpoint` | Server URL | `http://localhost:8000` |
31+
| `--max-output-tokens` | Max output tokens | 2000 |
32+
| `--timeout` | Timeout in seconds | 900 |
33+
| `--workers` | Number of workers | 1 |
34+
| `--dry` | Print commands without executing | - |
35+
36+
### Example
37+
38+
```bash
39+
python compare_with_vllm.py \
40+
--model "Qwen/Qwen2.5-0.5B-Instruct" \
41+
--num-prompts 200 \
42+
--max-output-tokens 1000
43+
```
44+
45+
## Output
46+
47+
The script runs both benchmarks and displays a comparison table:
48+
49+
```
50+
====================================================================================================
51+
Metric | Inference Endpoint | vLLM Benchmark
52+
----------------------------------------------------------------------------------------------------
53+
Test Duration (s) | 8.03 | 8.05
54+
----------------------------------------------------------------------------------------------------
55+
Throughput (req/s) | 12.45 | 12.38
56+
Output Token Throughput (tok/s) | 1234.56 | 1230.45
57+
----------------------------------------------------------------------------------------------------
58+
Mean TTFT (ms) | 45.23 | 46.12
59+
Median TTFT (ms) | 43.56 | 44.89
60+
P99 TTFT (ms) | 78.90 | 80.34
61+
----------------------------------------------------------------------------------------------------
62+
Mean TPOT (ms) | 12.34 | 12.56
63+
Median TPOT (ms) | 11.89 | 12.01
64+
P99 TPOT (ms) | 18.45 | 18.90
65+
----------------------------------------------------------------------------------------------------
66+
Mean ITL (ms) | 12.34 | 12.56
67+
Median ITL (ms) | 11.89 | 12.01
68+
P99 ITL (ms) | 18.45 | 18.90
69+
====================================================================================================
70+
```

0 commit comments

Comments
 (0)