Skip to content

Commit 246bca2

Browse files
committed
feat: add compare_with_vllm.py
1 parent 60644b1 commit 246bca2

4 files changed

Lines changed: 918 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Benchmark Comparison Example
2+
3+
Compare `inference-endpoint` with vLLM's benchmarking tool using identical prompts.
4+
5+
## Prerequisites
6+
7+
**Running inference server** (OpenAI-compatible):
8+
9+
```bash
10+
vllm serve Qwen/Qwen2.5-0.5B-Instruct --port 8000
11+
```
12+
13+
## Usage
14+
15+
```bash
16+
cd examples/03_BenchmarkComparison
17+
python compare_with_vllm.py --model "Qwen/Qwen2.5-0.5B-Instruct" --endpoint http://localhost:8000
18+
```
19+
20+
### Options
21+
22+
| Option | Description | Default |
23+
| --------------------- | -------------------------------- | ----------------------- |
24+
| `--model`, `-m` | Model name (required) | - |
25+
| `--num-prompts`, `-n` | Number of prompts | 100 |
26+
| `--endpoint` | Server URL | `http://localhost:8000` |
27+
| `--max-output-tokens` | Max output tokens | 2000 |
28+
| `--timeout` | Timeout in seconds | 900 |
29+
| `--workers` | Number of workers | 1 |
30+
| `--verbose`, `-v` | Show full output from each run | - |
31+
| `--dry` | Print commands without executing | - |
32+
33+
### Example
34+
35+
```bash
36+
python compare_with_vllm.py \
37+
--model "Qwen/Qwen2.5-0.5B-Instruct" \
38+
--num-prompts 200 \
39+
--max-output-tokens 1000
40+
```
41+
42+
## Output
43+
44+
The script runs both benchmarks and displays a comparison table:
45+
46+
```
47+
48+
$ python examples/03_BenchmarkComparison/compare_with_vllm.py --model Qwen/Qwen2.5-0.5B-Instruct --num-prompts 10000
49+
50+
====================================================================================================
51+
Metric | Inference Endpoint | vLLM Benchmark
52+
----------------------------------------------------------------------------------------------------
53+
----------------------------------------------------------------------------------------------------
54+
Test Duration (s) | 284.28 | 300.69
55+
----------------------------------------------------------------------------------------------------
56+
Throughput (req/s) | 35.18 | 33.26
57+
Total Generated Tokens | 4446263 | 4626060
58+
Output Token Throughput (tok/s) | 15640.65 | 15384.64
59+
----------------------------------------------------------------------------------------------------
60+
Mean TTFT (ms) | 137112.88 | 146093.86
61+
Median TTFT (ms) | 137092.46 | 145656.40
62+
P99 TTFT (ms) | 270902.92 | 281810.49
63+
----------------------------------------------------------------------------------------------------
64+
Mean TPOT (ms) | 15.85 | 15.60
65+
Median TPOT (ms) | 15.56 | 15.61
66+
P99 TPOT (ms) | 36.47 | 23.49
67+
----------------------------------------------------------------------------------------------------
68+
Mean ITL (ms) | 15.85 | 15.42
69+
Median ITL (ms) | 15.56 | 12.17
70+
P99 ITL (ms) | 36.47 | 35.96
71+
----------------------------------------------------------------------------------------------------
72+
Mean Output Length (tokens) | 444 | 462
73+
Median Output Length (tokens) | 401 | 406
74+
P99 Output Length (tokens) | 2000 | 2000
75+
====================================================================================================
76+
77+
```

0 commit comments

Comments
 (0)