Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b5eac52
[Benchmark] Add plot utility for parameter sweep
DarkLight1337 Oct 19, 2025
7f93c36
Update
DarkLight1337 Oct 20, 2025
d52e9b9
Add log plot
DarkLight1337 Oct 20, 2025
2f96852
Fix multifigure
DarkLight1337 Oct 20, 2025
fcf156b
Update command
DarkLight1337 Oct 20, 2025
ad14a53
Add title
DarkLight1337 Oct 20, 2025
08fab86
Support file prefix
DarkLight1337 Oct 20, 2025
bc04f30
Separate
DarkLight1337 Oct 20, 2025
1e13493
Improve separation
DarkLight1337 Oct 20, 2025
c848b10
Set by directory, not prefix
DarkLight1337 Oct 20, 2025
f7f36f2
Fix
DarkLight1337 Oct 20, 2025
c6cb78a
Plot in parallel
DarkLight1337 Oct 20, 2025
4cc5e90
Clean up
DarkLight1337 Oct 20, 2025
4af1e1a
Don't silently fail
DarkLight1337 Oct 20, 2025
7d82607
Pretty
DarkLight1337 Oct 20, 2025
8150f44
Fix nested
DarkLight1337 Oct 20, 2025
6ace5b2
Raise error if no data found
DarkLight1337 Oct 20, 2025
b3eb7cd
Show the problematic data item
DarkLight1337 Oct 20, 2025
8154e08
Convert to string first
DarkLight1337 Oct 20, 2025
d9fcb09
Be more clear
DarkLight1337 Oct 20, 2025
9c0e9fa
Use seaborn grid
DarkLight1337 Oct 20, 2025
f1810cc
Clean up
DarkLight1337 Oct 20, 2025
dac464b
Clean
DarkLight1337 Oct 20, 2025
73c911b
TODO
DarkLight1337 Oct 20, 2025
eef9c40
Clean
DarkLight1337 Oct 20, 2025
aa96151
Generalized filter and binning
DarkLight1337 Oct 20, 2025
0b98496
Remove old script
DarkLight1337 Oct 20, 2025
94c94c4
Merge branch 'main' into benchmark-sweep
DarkLight1337 Oct 20, 2025
ae9d021
Update import
DarkLight1337 Oct 20, 2025
beb3854
Clean up
DarkLight1337 Oct 20, 2025
5f36c62
Fix
DarkLight1337 Oct 20, 2025
8fbfd49
Simplify
DarkLight1337 Oct 20, 2025
daee7a8
Fix legend
DarkLight1337 Oct 20, 2025
b9e08ff
Fix
DarkLight1337 Oct 20, 2025
ad4149b
Reword
DarkLight1337 Oct 20, 2025
c5eaf78
Fix
DarkLight1337 Oct 20, 2025
c7426c2
Reword
DarkLight1337 Oct 20, 2025
49deaab
Reorder
DarkLight1337 Oct 20, 2025
0a4eb36
Informative error
DarkLight1337 Oct 20, 2025
8afa4d3
Separate out SLA tuner
DarkLight1337 Oct 21, 2025
3fa0d4c
Update
DarkLight1337 Oct 21, 2025
a3d1095
Improve error message
DarkLight1337 Oct 21, 2025
a4adbda
Allow strings
DarkLight1337 Oct 21, 2025
6357b84
Fix
DarkLight1337 Oct 21, 2025
f750fc5
Fix
DarkLight1337 Oct 21, 2025
2d856ff
Ordering
DarkLight1337 Oct 21, 2025
e6d4c72
Don't split
DarkLight1337 Oct 21, 2025
46d9f19
Remove unnecessary quotes
DarkLight1337 Oct 21, 2025
b95d706
Merge branch 'main' into benchmark-sweep
DarkLight1337 Oct 21, 2025
ceabbc8
Update with benchmark overrides as well
DarkLight1337 Oct 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions docs/contributing/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toc_depth: 4
vLLM provides comprehensive benchmarking tools for performance testing and evaluation:

- **[Benchmark CLI](#benchmark-cli)**: `vllm bench` CLI tools and specialized benchmark scripts for interactive performance testing
- **[Batch Scripts](#batch-scripts)**: Run `vllm bench` against multiple configurations conveniently
- **[Parameter sweeps](#parameter-sweeps)**: Automate `vllm bench` runs for multiple configurations
- **[Performance benchmarks](#performance-benchmarks)**: Automated CI benchmarks for development
- **[Nightly benchmarks](#nightly-benchmarks)**: Comparative benchmarks against alternatives

Expand Down Expand Up @@ -925,11 +925,11 @@ throughput numbers correctly is also adjusted.

</details>

## Batch Scripts
## Parameter Sweeps

### Batch Serving Script
### Online Benchmark

[`vllm/benchmarks/serve_multi.py`](../../vllm/benchmarks/serve_multi.py) automatically starts `vllm serve` and runs `vllm bench serve` over multiple configurations.
[`vllm/benchmarks/sweep/serve.py`](../../vllm/benchmarks/sweep/serve.py) automatically starts `vllm serve` and runs `vllm bench serve` over multiple configurations.

#### Batch Mode

Expand Down Expand Up @@ -996,7 +996,7 @@ The basic purpose of this script is to evaluate vLLM under different settings. F
Example command:

```bash
python vllm/benchmarks/serve_multi.py \
python -m vllm.benchmarks.sweep.serve \
--serve-cmd 'vllm serve meta-llama/Llama-2-7b-chat-hf' \
--bench-cmd 'vllm bench serve --model meta-llama/Llama-2-7b-chat-hf --backend vllm --endpoint /v1/completions --dataset-name sharegpt --dataset-path benchmarks/ShareGPT_V3_unfiltered_cleaned_split.json' \
--serve-params benchmarks/serve_hparams.json \
Expand Down Expand Up @@ -1044,7 +1044,7 @@ For example, to ensure E2E latency within different target values for 99% of req
Example command:

```bash
python vllm/benchmarks/serve_multi.py \
python -m vllm.benchmarks.sweep.serve \
--serve-cmd 'vllm serve meta-llama/Llama-2-7b-chat-hf' \
Copy link
Contributor

@lengrongfu lengrongfu Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use a vllm serve api address, we should how to config?

Maybe we should add a --serve-host param, user can set a vllm online server, then this --serve-params param can be invalid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set the server's host via --serve-cmd. And for resetting the server cache after each benchmark run, you can use --after-bench-cmd.

Copy link
Member Author

@DarkLight1337 DarkLight1337 Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean that the benchmark should not be responsible for launching the server, you can just use a dummy command that sleeps infinitely and adjust --bench-cmd to access the real server. Of course, you should also set --after-bench-cmd in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, maybe i not need set --serve-cmd param, use --bench-cmd param to set vllm bench serve --model meta-llama/Llama-2-7b-chat-hf --backend openai is enough.

--bench-cmd 'vllm bench serve --model meta-llama/Llama-2-7b-chat-hf --backend vllm --endpoint /v1/completions --dataset-name sharegpt --dataset-path benchmarks/ShareGPT_V3_unfiltered_cleaned_split.json' \
--serve-params benchmarks/serve_hparams.json \
Expand All @@ -1066,6 +1066,24 @@ The algorithm for adjusting the SLA variable is as follows:

For a given combination of `--serve-params` and `--bench-params`, we share the benchmark results across `--sla-params` to avoid rerunning benchmarks with the same SLA variable value.

### Visualizer

[`vllm/benchmarks/sweep/plot.py`](../../vllm/benchmarks/sweep/plot.py) can be used to plot performance curves from parameter sweep results.

Example command:

```bash
python -m vllm.benchmarks.sweep.plot benchmarks/results/<timestamp> \
--var-x max_concurrency \
--curve-by api_server_count,max_num_batched_tokens \
--row-by random_input_len \
--col-by random_output_len \
--filter-by 'max_concurrency<=1024'
```

!!! tip
You can use `--dry-run` to preview the commands to be run.

## Performance Benchmarks

The performance benchmarks are used for development to confirm whether new changes improve performance under various workloads. They are triggered on every commit with both the `perf-benchmarks` and `ready` labels, and when a PR is merged into vLLM.
Expand Down
Empty file.
91 changes: 91 additions & 0 deletions vllm/benchmarks/sweep/param_sweep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import json
import os
from typing import Any


class ParameterSweep(list["ParameterSweepItem"]):
@classmethod
def read_json(cls, filepath: os.PathLike):
with open(filepath, "rb") as f:
records = json.load(f)

return cls.from_records(records)

@classmethod
def from_records(cls, records: list[dict[str, object]]):
if not isinstance(records, list):
raise TypeError(
f"The parameter sweep should be a list of dictionaries, "
f"but found type: {type(records)}"
)

return cls(ParameterSweepItem.from_record(record) for record in records)


class ParameterSweepItem(dict[str, object]):
@classmethod
def from_record(cls, record: dict[str, object]):
if not isinstance(record, dict):
raise TypeError(
f"Each item in the parameter sweep should be a dictionary, "
f"but found type: {type(record)}"
)

return cls(record)

def __or__(self, other: dict[str, Any]):
return type(self)(super().__or__(other))

# In JSON, we prefer "_"
def _iter_param_key_candidates(self, param_key: str):
# Inner config arguments are not converted by the CLI
if "." in param_key:
prefix, rest = param_key.split(".", 1)
for prefix_candidate in self._iter_param_key_candidates(prefix):
yield prefix_candidate + "." + rest

return

yield param_key
yield param_key.replace("-", "_")
yield param_key.replace("_", "-")

# In CLI, we prefer "-"
def _iter_cmd_key_candidates(self, param_key: str):
for k in reversed(tuple(self._iter_param_key_candidates(param_key))):
yield "--" + k

def _normalize_cmd_key(self, param_key: str):
return next(self._iter_cmd_key_candidates(param_key))

def has_param(self, param_key: str) -> bool:
return any(k in self for k in self._iter_param_key_candidates(param_key))

def apply_to_cmd(self, cmd: list[str]) -> list[str]:
cmd = list(cmd)

for k, v in self.items():
for k_candidate in self._iter_cmd_key_candidates(k):
try:
k_idx = cmd.index(k_candidate)

if isinstance(v, bool):
cmd[k_idx] = self._normalize_cmd_key(k if v else "no-" + k)
else:
cmd[k_idx + 1] = str(v)

break
except ValueError:
continue
else:
if isinstance(v, bool):
cmd.append(self._normalize_cmd_key(k if v else "no-" + k))
else:
cmd.extend([self._normalize_cmd_key(k), str(v)])

return cmd

def as_text(self, sep: str = ", ") -> str:
return sep.join(f"{k}={v}" for k, v in self.items())
Loading