vllm-headroom 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vllm_headroom-0.1.0/LICENSE +202 -0
- vllm_headroom-0.1.0/PKG-INFO +195 -0
- vllm_headroom-0.1.0/README.md +164 -0
- vllm_headroom-0.1.0/pyproject.toml +48 -0
- vllm_headroom-0.1.0/setup.cfg +4 -0
- vllm_headroom-0.1.0/src/vllm_headroom/__init__.py +3 -0
- vllm_headroom-0.1.0/src/vllm_headroom/analysis.py +196 -0
- vllm_headroom-0.1.0/src/vllm_headroom/cli.py +222 -0
- vllm_headroom-0.1.0/src/vllm_headroom/fit.py +134 -0
- vllm_headroom-0.1.0/src/vllm_headroom/mock_server.py +185 -0
- vllm_headroom-0.1.0/src/vllm_headroom/profiler.py +382 -0
- vllm_headroom-0.1.0/src/vllm_headroom/report.py +257 -0
- vllm_headroom-0.1.0/src/vllm_headroom/sim.py +325 -0
- vllm_headroom-0.1.0/src/vllm_headroom/workload.py +80 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/PKG-INFO +195 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/SOURCES.txt +21 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/dependency_links.txt +1 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/entry_points.txt +2 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/requires.txt +5 -0
- vllm_headroom-0.1.0/src/vllm_headroom.egg-info/top_level.txt +1 -0
- vllm_headroom-0.1.0/tests/test_end_to_end.py +53 -0
- vllm_headroom-0.1.0/tests/test_fit_and_analysis.py +74 -0
- vllm_headroom-0.1.0/tests/test_sim.py +123 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vllm-headroom
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Estimate how much more load a vLLM deployment can take before it breaks its latency SLO
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/haochen2049/vllm-headroom
|
|
7
|
+
Project-URL: Source, https://github.com/haochen2049/vllm-headroom
|
|
8
|
+
Project-URL: Issues, https://github.com/haochen2049/vllm-headroom/issues
|
|
9
|
+
Project-URL: Example report, https://haochen2049.github.io/vllm-headroom/
|
|
10
|
+
Keywords: vllm,llm,inference,capacity-planning,slo,queueing,simulation
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: System :: Benchmark
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.24
|
|
27
|
+
Requires-Dist: httpx>=0.25
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# vllm-headroom
|
|
33
|
+
|
|
34
|
+
English | [中文](https://github.com/haochen2049/vllm-headroom/blob/main/README.zh-CN.md)
|
|
35
|
+
|
|
36
|
+
**How much more traffic can your vLLM server take before it breaks its latency SLO?**
|
|
37
|
+
|
|
38
|
+
`vllm-headroom` profiles a running vLLM server for about three minutes, fits a model of how long each
|
|
39
|
+
engine step takes, and simulates continuous batching to predict p95/p99 latency at any load. It
|
|
40
|
+
reports the highest request rate that still meets your SLO, with an uncertainty range, and checks its
|
|
41
|
+
own predictions against load it measured but did not fit on.
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
$ vllm-headroom analyze profile.json --slo ttft_p95=1 --slo tpot_p95=0.05 --current-rate 10 \
|
|
45
|
+
--whatif max_num_seqs=128 --whatif replicas=2
|
|
46
|
+
saturation: 21.589 req/s
|
|
47
|
+
max load meeting SLO: 20.827 req/s (10-90%: 19.948-21.538; binding: ttft_p95)
|
|
48
|
+
headroom vs current: +108% (10-90%: +99% to +115%)
|
|
49
|
+
what-if max_num_seqs=128: max 27.745 req/s (saturation)
|
|
50
|
+
what-if replicas=2: max 42.475 req/s (saturation)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
It writes a self-contained HTML report with latency-versus-load curves, the backtest and the fitted
|
|
54
|
+
model. Nothing leaves your machine. [See the full example report](https://haochen2049.github.io/vllm-headroom/) from a real 7B deployment.
|
|
55
|
+
|
|
56
|
+
[](https://haochen2049.github.io/vllm-headroom/)
|
|
57
|
+
|
|
58
|
+
> Status: alpha (0.1). Tested against vLLM 0.31 on one GPU type; see [Validation](#validation).
|
|
59
|
+
> Not affiliated with the vLLM project.
|
|
60
|
+
|
|
61
|
+
## Why
|
|
62
|
+
|
|
63
|
+
Dashboards show what already happened, and forecasting tools extrapolate it. Neither tells you what
|
|
64
|
+
happens after you change something, such as more traffic, a different `--max-num-seqs`, one fewer
|
|
65
|
+
replica or a longer prompt mix, or how close you are to the point where latency falls off a cliff.
|
|
66
|
+
Load testing every option is slow. A model fitted to *your* server answers these questions in seconds.
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install vllm-headroom
|
|
72
|
+
|
|
73
|
+
# no GPU? profile a bundled simulated server and open the sample report (about 2-3 minutes)
|
|
74
|
+
vllm-headroom demo -o demo_report.html
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Against a real server, ideally an idle replica or a staging copy:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 1. profile (about 3-4 minutes); pass the server's own settings if you know them
|
|
81
|
+
vllm-headroom profile --url http://localhost:8000 \
|
|
82
|
+
--max-num-seqs 256 --max-num-batched-tokens 8192 -o profile.json
|
|
83
|
+
|
|
84
|
+
# 2. analyse against your SLO and current traffic
|
|
85
|
+
vllm-headroom analyze profile.json --slo ttft_p95=2 --slo tpot_p95=0.1 \
|
|
86
|
+
--current-rate 12 --workload my_requests.jsonl -o headroom.html
|
|
87
|
+
|
|
88
|
+
# 3. compare configurations quickly
|
|
89
|
+
vllm-headroom whatif profile.json --slo ttft_p95=2 \
|
|
90
|
+
--change max_num_seqs=512 --change replicas=3 --change kv_scale=0.5
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`--workload` is a JSONL file with one request per line, `{"prompt_tokens": 812, "output_tokens": 230}`
|
|
94
|
+
(OpenAI `usage` objects also work). Without it, `--prompt-mean/--output-mean` give a log-normal mix,
|
|
95
|
+
and the default is the mix used during profiling. SLO metrics are `ttft` (time to first token),
|
|
96
|
+
`tpot` (time per output token after the first) and `e2e` (end-to-end), each with any percentile:
|
|
97
|
+
`ttft_p95=2`, `e2e_p99=30`, `tpot_p50=0.05`.
|
|
98
|
+
|
|
99
|
+
## How it works
|
|
100
|
+
|
|
101
|
+
**1. Profile.** Four phases against the OpenAI-compatible endpoint:
|
|
102
|
+
|
|
103
|
+
| phase | what is sent | what it identifies |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| prefill sweep | single requests, prompts from 128 to 8192 tokens, idle server | prefill cost per token and fixed overhead |
|
|
106
|
+
| decode waves | `c` identical requests at once, `c` = 1, 2, 4 ... 256, short and long prompts | step time versus batch size and context length |
|
|
107
|
+
| admission probes | short requests sent while a wave decodes | how many steps a new request waits before it is scheduled |
|
|
108
|
+
| validation | open-loop Poisson load at 30, 50 and 70% of predicted saturation | nothing: held out for the backtest |
|
|
109
|
+
|
|
110
|
+
Prompts are random token ids, so prefix caching cannot shorten prefill and lengths are exact;
|
|
111
|
+
`ignore_eos` fixes output lengths. Streaming chunk timestamps give inter-token gaps; only gaps with no
|
|
112
|
+
prefill from another request are used for decode fitting. KV capacity is read from `/metrics`, and
|
|
113
|
+
`max_num_seqs` is inferred from the waves if you do not pass it.
|
|
114
|
+
|
|
115
|
+
**2. Fit.** Engine step time is modelled as
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
step = b0 + b_dec·(decoding sequences) + b_ctx·(their context tokens)
|
|
119
|
+
+ b_pf·(prefill tokens) + b_pfatt·(prefill attention term)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
fitted with robust least squares, plus a client-visible `overhead` and an `admit_lag` (vLLM V1 plans
|
|
123
|
+
the next step while the current one runs, so a new request waits about one to two extra steps).
|
|
124
|
+
A bootstrap over profiling requests gives parameter uncertainty.
|
|
125
|
+
|
|
126
|
+
**3. Simulate.** A discrete-event simulator of vLLM-style continuous batching: chunked prefill under
|
|
127
|
+
`max_num_batched_tokens`, `max_num_seqs`, KV capacity with recompute preemption, several replicas
|
|
128
|
+
behind a least-loaded or round-robin router. Decode-only stretches are advanced in closed form, so a
|
|
129
|
+
1,500-request run takes well under a second.
|
|
130
|
+
|
|
131
|
+
**4. Report.** The maximum Poisson rate meeting every SLO (bisection), the saturation rate, latency
|
|
132
|
+
curves with a 10–90% range across bootstrap refits, what-if comparisons and a backtest against the
|
|
133
|
+
held-out validation load.
|
|
134
|
+
|
|
135
|
+
## Validation
|
|
136
|
+
|
|
137
|
+
One run so far: Qwen2.5-7B-Instruct on vLLM 0.31.0, one NVIDIA RTX PRO 6000 Blackwell (96 GB),
|
|
138
|
+
`--max-num-seqs 64 --max-num-batched-tokens 4096 --gpu-memory-utilization 0.5`. The profile, report
|
|
139
|
+
and check script are in [`examples/qwen2.5-7b-vllm0.31`](https://github.com/haochen2049/vllm-headroom/tree/main/examples/qwen2.5-7b-vllm0.31). The workload
|
|
140
|
+
is the default log-normal mix (prompt mean 505, output mean 130 tokens). `max_num_seqs` was not passed
|
|
141
|
+
and was inferred correctly (64).
|
|
142
|
+
|
|
143
|
+
**Backtest** (held-out validation load from the same profiling run, never used for fitting):
|
|
144
|
+
|
|
145
|
+
| load (of predicted saturation) | requests | TTFT p50 | TTFT p95 | E2E p50 | E2E p95 |
|
|
146
|
+
|---|---|---|---|---|---|
|
|
147
|
+
| 30% (6.5 req/s) | 161 | +8% | +7% | +2% | +2% |
|
|
148
|
+
| 50% (10.8 req/s) | 268 | +9% | +12% | +2% | +2% |
|
|
149
|
+
| 70% (15.1 req/s) | 376 | +8% | +14% | +3% | +4% |
|
|
150
|
+
|
|
151
|
+
**Near saturation** (a separate later run against the same server with the fit frozen,
|
|
152
|
+
`near_saturation_check.py`):
|
|
153
|
+
|
|
154
|
+
| load | requests | TTFT p50 | TTFT p95 | E2E p50 | E2E p95 |
|
|
155
|
+
|---|---|---|---|---|---|
|
|
156
|
+
| 85% (18.5 req/s) | 833 | +7% | +5% | +3% | +5% |
|
|
157
|
+
| 95% (20.7 req/s) | 931 | 0% | −19% | −3% | 0% |
|
|
158
|
+
|
|
159
|
+
Entries are prediction error relative to measurement (positive = predicted slower). End-to-end
|
|
160
|
+
latency is within 5% everywhere. TTFT is predicted somewhat pessimistically up to 85% load. At 95%
|
|
161
|
+
load the TTFT tail is under-predicted by 19%, because close to saturation a small error in the rate
|
|
162
|
+
moves the tail a lot. Treat the last few percent before saturation as unreliable and keep a margin.
|
|
163
|
+
This is one model, one GPU and one workload; results on other setups may differ. If you run it on
|
|
164
|
+
other hardware, please [share your backtest](https://github.com/haochen2049/vllm-headroom/issues/new?template=backtest.yml): it is the most useful contribution right now.
|
|
165
|
+
|
|
166
|
+
The unit tests also check the simulator against a plain step-by-step reference implementation
|
|
167
|
+
(identical results), recover known parameters from synthetic data, and run the full
|
|
168
|
+
profile → fit → report pipeline over HTTP against the bundled simulated server.
|
|
169
|
+
|
|
170
|
+
## Limits
|
|
171
|
+
|
|
172
|
+
- One replica is profiled; multiple replicas are modelled as identical copies.
|
|
173
|
+
- Arrivals are Poisson at a constant rate. Bursty traffic needs more headroom than reported.
|
|
174
|
+
- Not modelled: prefix-cache hits, speculative decoding, LoRA adapter switching, multi-model serving,
|
|
175
|
+
disaggregated prefill/decode, pipeline-parallel bubbles, network between client and router.
|
|
176
|
+
- Batch sizes and prompt lengths beyond what was profiled are extrapolated.
|
|
177
|
+
- The uncertainty range reflects profiling noise, not every way production can differ.
|
|
178
|
+
- Profiling sends real load. Run it on a replica that is not serving users.
|
|
179
|
+
|
|
180
|
+
## Output files
|
|
181
|
+
|
|
182
|
+
`profile` writes raw timings (no prompt or output text). `analyze` writes `headroom.html` and
|
|
183
|
+
`headroom.json` with the fitted parameters, curves, headroom, backtest and what-if results.
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install -e ".[dev]"
|
|
189
|
+
pytest -q
|
|
190
|
+
vllm-headroom mock-server --port 8001 # a simulated OpenAI-compatible server for experiments
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# vllm-headroom
|
|
2
|
+
|
|
3
|
+
English | [中文](https://github.com/haochen2049/vllm-headroom/blob/main/README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
**How much more traffic can your vLLM server take before it breaks its latency SLO?**
|
|
6
|
+
|
|
7
|
+
`vllm-headroom` profiles a running vLLM server for about three minutes, fits a model of how long each
|
|
8
|
+
engine step takes, and simulates continuous batching to predict p95/p99 latency at any load. It
|
|
9
|
+
reports the highest request rate that still meets your SLO, with an uncertainty range, and checks its
|
|
10
|
+
own predictions against load it measured but did not fit on.
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
$ vllm-headroom analyze profile.json --slo ttft_p95=1 --slo tpot_p95=0.05 --current-rate 10 \
|
|
14
|
+
--whatif max_num_seqs=128 --whatif replicas=2
|
|
15
|
+
saturation: 21.589 req/s
|
|
16
|
+
max load meeting SLO: 20.827 req/s (10-90%: 19.948-21.538; binding: ttft_p95)
|
|
17
|
+
headroom vs current: +108% (10-90%: +99% to +115%)
|
|
18
|
+
what-if max_num_seqs=128: max 27.745 req/s (saturation)
|
|
19
|
+
what-if replicas=2: max 42.475 req/s (saturation)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
It writes a self-contained HTML report with latency-versus-load curves, the backtest and the fitted
|
|
23
|
+
model. Nothing leaves your machine. [See the full example report](https://haochen2049.github.io/vllm-headroom/) from a real 7B deployment.
|
|
24
|
+
|
|
25
|
+
[](https://haochen2049.github.io/vllm-headroom/)
|
|
26
|
+
|
|
27
|
+
> Status: alpha (0.1). Tested against vLLM 0.31 on one GPU type; see [Validation](#validation).
|
|
28
|
+
> Not affiliated with the vLLM project.
|
|
29
|
+
|
|
30
|
+
## Why
|
|
31
|
+
|
|
32
|
+
Dashboards show what already happened, and forecasting tools extrapolate it. Neither tells you what
|
|
33
|
+
happens after you change something, such as more traffic, a different `--max-num-seqs`, one fewer
|
|
34
|
+
replica or a longer prompt mix, or how close you are to the point where latency falls off a cliff.
|
|
35
|
+
Load testing every option is slow. A model fitted to *your* server answers these questions in seconds.
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install vllm-headroom
|
|
41
|
+
|
|
42
|
+
# no GPU? profile a bundled simulated server and open the sample report (about 2-3 minutes)
|
|
43
|
+
vllm-headroom demo -o demo_report.html
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Against a real server, ideally an idle replica or a staging copy:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# 1. profile (about 3-4 minutes); pass the server's own settings if you know them
|
|
50
|
+
vllm-headroom profile --url http://localhost:8000 \
|
|
51
|
+
--max-num-seqs 256 --max-num-batched-tokens 8192 -o profile.json
|
|
52
|
+
|
|
53
|
+
# 2. analyse against your SLO and current traffic
|
|
54
|
+
vllm-headroom analyze profile.json --slo ttft_p95=2 --slo tpot_p95=0.1 \
|
|
55
|
+
--current-rate 12 --workload my_requests.jsonl -o headroom.html
|
|
56
|
+
|
|
57
|
+
# 3. compare configurations quickly
|
|
58
|
+
vllm-headroom whatif profile.json --slo ttft_p95=2 \
|
|
59
|
+
--change max_num_seqs=512 --change replicas=3 --change kv_scale=0.5
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`--workload` is a JSONL file with one request per line, `{"prompt_tokens": 812, "output_tokens": 230}`
|
|
63
|
+
(OpenAI `usage` objects also work). Without it, `--prompt-mean/--output-mean` give a log-normal mix,
|
|
64
|
+
and the default is the mix used during profiling. SLO metrics are `ttft` (time to first token),
|
|
65
|
+
`tpot` (time per output token after the first) and `e2e` (end-to-end), each with any percentile:
|
|
66
|
+
`ttft_p95=2`, `e2e_p99=30`, `tpot_p50=0.05`.
|
|
67
|
+
|
|
68
|
+
## How it works
|
|
69
|
+
|
|
70
|
+
**1. Profile.** Four phases against the OpenAI-compatible endpoint:
|
|
71
|
+
|
|
72
|
+
| phase | what is sent | what it identifies |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| prefill sweep | single requests, prompts from 128 to 8192 tokens, idle server | prefill cost per token and fixed overhead |
|
|
75
|
+
| decode waves | `c` identical requests at once, `c` = 1, 2, 4 ... 256, short and long prompts | step time versus batch size and context length |
|
|
76
|
+
| admission probes | short requests sent while a wave decodes | how many steps a new request waits before it is scheduled |
|
|
77
|
+
| validation | open-loop Poisson load at 30, 50 and 70% of predicted saturation | nothing: held out for the backtest |
|
|
78
|
+
|
|
79
|
+
Prompts are random token ids, so prefix caching cannot shorten prefill and lengths are exact;
|
|
80
|
+
`ignore_eos` fixes output lengths. Streaming chunk timestamps give inter-token gaps; only gaps with no
|
|
81
|
+
prefill from another request are used for decode fitting. KV capacity is read from `/metrics`, and
|
|
82
|
+
`max_num_seqs` is inferred from the waves if you do not pass it.
|
|
83
|
+
|
|
84
|
+
**2. Fit.** Engine step time is modelled as
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
step = b0 + b_dec·(decoding sequences) + b_ctx·(their context tokens)
|
|
88
|
+
+ b_pf·(prefill tokens) + b_pfatt·(prefill attention term)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
fitted with robust least squares, plus a client-visible `overhead` and an `admit_lag` (vLLM V1 plans
|
|
92
|
+
the next step while the current one runs, so a new request waits about one to two extra steps).
|
|
93
|
+
A bootstrap over profiling requests gives parameter uncertainty.
|
|
94
|
+
|
|
95
|
+
**3. Simulate.** A discrete-event simulator of vLLM-style continuous batching: chunked prefill under
|
|
96
|
+
`max_num_batched_tokens`, `max_num_seqs`, KV capacity with recompute preemption, several replicas
|
|
97
|
+
behind a least-loaded or round-robin router. Decode-only stretches are advanced in closed form, so a
|
|
98
|
+
1,500-request run takes well under a second.
|
|
99
|
+
|
|
100
|
+
**4. Report.** The maximum Poisson rate meeting every SLO (bisection), the saturation rate, latency
|
|
101
|
+
curves with a 10–90% range across bootstrap refits, what-if comparisons and a backtest against the
|
|
102
|
+
held-out validation load.
|
|
103
|
+
|
|
104
|
+
## Validation
|
|
105
|
+
|
|
106
|
+
One run so far: Qwen2.5-7B-Instruct on vLLM 0.31.0, one NVIDIA RTX PRO 6000 Blackwell (96 GB),
|
|
107
|
+
`--max-num-seqs 64 --max-num-batched-tokens 4096 --gpu-memory-utilization 0.5`. The profile, report
|
|
108
|
+
and check script are in [`examples/qwen2.5-7b-vllm0.31`](https://github.com/haochen2049/vllm-headroom/tree/main/examples/qwen2.5-7b-vllm0.31). The workload
|
|
109
|
+
is the default log-normal mix (prompt mean 505, output mean 130 tokens). `max_num_seqs` was not passed
|
|
110
|
+
and was inferred correctly (64).
|
|
111
|
+
|
|
112
|
+
**Backtest** (held-out validation load from the same profiling run, never used for fitting):
|
|
113
|
+
|
|
114
|
+
| load (of predicted saturation) | requests | TTFT p50 | TTFT p95 | E2E p50 | E2E p95 |
|
|
115
|
+
|---|---|---|---|---|---|
|
|
116
|
+
| 30% (6.5 req/s) | 161 | +8% | +7% | +2% | +2% |
|
|
117
|
+
| 50% (10.8 req/s) | 268 | +9% | +12% | +2% | +2% |
|
|
118
|
+
| 70% (15.1 req/s) | 376 | +8% | +14% | +3% | +4% |
|
|
119
|
+
|
|
120
|
+
**Near saturation** (a separate later run against the same server with the fit frozen,
|
|
121
|
+
`near_saturation_check.py`):
|
|
122
|
+
|
|
123
|
+
| load | requests | TTFT p50 | TTFT p95 | E2E p50 | E2E p95 |
|
|
124
|
+
|---|---|---|---|---|---|
|
|
125
|
+
| 85% (18.5 req/s) | 833 | +7% | +5% | +3% | +5% |
|
|
126
|
+
| 95% (20.7 req/s) | 931 | 0% | −19% | −3% | 0% |
|
|
127
|
+
|
|
128
|
+
Entries are prediction error relative to measurement (positive = predicted slower). End-to-end
|
|
129
|
+
latency is within 5% everywhere. TTFT is predicted somewhat pessimistically up to 85% load. At 95%
|
|
130
|
+
load the TTFT tail is under-predicted by 19%, because close to saturation a small error in the rate
|
|
131
|
+
moves the tail a lot. Treat the last few percent before saturation as unreliable and keep a margin.
|
|
132
|
+
This is one model, one GPU and one workload; results on other setups may differ. If you run it on
|
|
133
|
+
other hardware, please [share your backtest](https://github.com/haochen2049/vllm-headroom/issues/new?template=backtest.yml): it is the most useful contribution right now.
|
|
134
|
+
|
|
135
|
+
The unit tests also check the simulator against a plain step-by-step reference implementation
|
|
136
|
+
(identical results), recover known parameters from synthetic data, and run the full
|
|
137
|
+
profile → fit → report pipeline over HTTP against the bundled simulated server.
|
|
138
|
+
|
|
139
|
+
## Limits
|
|
140
|
+
|
|
141
|
+
- One replica is profiled; multiple replicas are modelled as identical copies.
|
|
142
|
+
- Arrivals are Poisson at a constant rate. Bursty traffic needs more headroom than reported.
|
|
143
|
+
- Not modelled: prefix-cache hits, speculative decoding, LoRA adapter switching, multi-model serving,
|
|
144
|
+
disaggregated prefill/decode, pipeline-parallel bubbles, network between client and router.
|
|
145
|
+
- Batch sizes and prompt lengths beyond what was profiled are extrapolated.
|
|
146
|
+
- The uncertainty range reflects profiling noise, not every way production can differ.
|
|
147
|
+
- Profiling sends real load. Run it on a replica that is not serving users.
|
|
148
|
+
|
|
149
|
+
## Output files
|
|
150
|
+
|
|
151
|
+
`profile` writes raw timings (no prompt or output text). `analyze` writes `headroom.html` and
|
|
152
|
+
`headroom.json` with the fitted parameters, curves, headroom, backtest and what-if results.
|
|
153
|
+
|
|
154
|
+
## Development
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pip install -e ".[dev]"
|
|
158
|
+
pytest -q
|
|
159
|
+
vllm-headroom mock-server --port 8001 # a simulated OpenAI-compatible server for experiments
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
Apache-2.0
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vllm-headroom"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Estimate how much more load a vLLM deployment can take before it breaks its latency SLO"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "Apache-2.0"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = ["numpy>=1.24", "httpx>=0.25"]
|
|
13
|
+
keywords = ["vllm", "llm", "inference", "capacity-planning", "slo", "queueing", "simulation"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: System Administrators",
|
|
19
|
+
"License :: OSI Approved :: Apache Software License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
"Topic :: System :: Benchmark",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/haochen2049/vllm-headroom"
|
|
31
|
+
Source = "https://github.com/haochen2049/vllm-headroom"
|
|
32
|
+
Issues = "https://github.com/haochen2049/vllm-headroom/issues"
|
|
33
|
+
"Example report" = "https://haochen2049.github.io/vllm-headroom/"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = ["pytest>=7"]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
vllm-headroom = "vllm_headroom.cli:main"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.dynamic]
|
|
42
|
+
version = {attr = "vllm_headroom.__version__"}
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
where = ["src"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|