szl-engine-bench 0.3.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.
- szl_engine_bench-0.3.0/LICENSE +201 -0
- szl_engine_bench-0.3.0/PKG-INFO +188 -0
- szl_engine_bench-0.3.0/README.md +178 -0
- szl_engine_bench-0.3.0/benchmark_manifest.py +236 -0
- szl_engine_bench-0.3.0/engine_bench.py +716 -0
- szl_engine_bench-0.3.0/pyproject.toml +17 -0
- szl_engine_bench-0.3.0/setup.cfg +4 -0
- szl_engine_bench-0.3.0/szl_engine_bench.egg-info/PKG-INFO +188 -0
- szl_engine_bench-0.3.0/szl_engine_bench.egg-info/SOURCES.txt +12 -0
- szl_engine_bench-0.3.0/szl_engine_bench.egg-info/dependency_links.txt +1 -0
- szl_engine_bench-0.3.0/szl_engine_bench.egg-info/top_level.txt +2 -0
- szl_engine_bench-0.3.0/tests/test_benchmark_manifest.py +330 -0
- szl_engine_bench-0.3.0/tests/test_bound_metric_contract.py +110 -0
- szl_engine_bench-0.3.0/tests/test_engine_bench.py +483 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 SZL Holdings
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: szl-engine-bench
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Honest inference-engine benchmark harness: TTFT, ITL, goodput-at-SLO, fairness gates, and hash-chained receipts.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# szl-engine-bench
|
|
12
|
+
|
|
13
|
+
An honest, standard-library-only benchmark client for OpenAI-compatible
|
|
14
|
+
streaming endpoints exposed by vLLM, SGLang, llama.cpp, MLX, TGI, and
|
|
15
|
+
Transformers Serve.
|
|
16
|
+
|
|
17
|
+
Version 0.3.0 reports separate distributions for time to first token/chunk
|
|
18
|
+
(TTFT), inter-chunk latency (ITL), end-to-end latency, and the fraction of
|
|
19
|
+
runs meeting a declared TTFT service-level objective. It does not collapse an
|
|
20
|
+
engine comparison into one winner.
|
|
21
|
+
|
|
22
|
+
The distinction is deliberate. SGLang's serving guide reports TTFT, TPOT,
|
|
23
|
+
ITL, and throughput as separate online-serving metrics, while vLLM Bench
|
|
24
|
+
separately exposes TTFT/ITL percentiles and SLO goodput. Cache shape, request
|
|
25
|
+
rate, concurrency, model, and hardware can all change the result; a benchmark
|
|
26
|
+
from a different workload is not evidence for this one.
|
|
27
|
+
|
|
28
|
+
- [SGLang benchmark and profiling guide (source snapshot)](https://github.com/sgl-project/sglang/blob/50ed4c011ffb37e1c16248b99deab7d4dbdde79b/docs/developer_guide/benchmark_and_profiling.md)
|
|
29
|
+
- [vLLM Bench metrics (source snapshot)](https://github.com/vllm-project/vllm-bench/blob/f3131823f167aa1e6f31a48be1ae15a18667a534/README.md#metrics)
|
|
30
|
+
|
|
31
|
+
## States and measurement semantics
|
|
32
|
+
|
|
33
|
+
- `MEASURED`: every requested run produced at least two non-empty streaming
|
|
34
|
+
response chunks and valid monotonic arrival times.
|
|
35
|
+
- `BLOCKED`: the engine endpoint was not configured, or fewer than two engines
|
|
36
|
+
produced measurements for comparison.
|
|
37
|
+
- `INVALID`: configuration, stream shape, or fairness inputs were unsuitable
|
|
38
|
+
for the requested metric.
|
|
39
|
+
- `FAILED`: the configured endpoint or streaming protocol actually failed.
|
|
40
|
+
|
|
41
|
+
ITL is measured between non-empty SSE response chunks. An SSE chunk is not
|
|
42
|
+
assumed to equal one model token. `chunks_per_s` is always labeled as such;
|
|
43
|
+
the request asks the server for streamed usage with
|
|
44
|
+
`stream_options.include_usage=true`, and `tok_per_s` is `UNAVAILABLE` unless
|
|
45
|
+
the endpoint actually supplies an integer `usage.completion_tokens` value.
|
|
46
|
+
This avoids turning packet counts into fake token throughput.
|
|
47
|
+
|
|
48
|
+
The comparison keeps the v0.1.0 fairness gates: measured engines must use the
|
|
49
|
+
same model string and run count for low-level numerical diagnostics.
|
|
50
|
+
Version 0.3.0 additionally requires the declared identity contract below for
|
|
51
|
+
CLI comparisons; the old model-name check alone is explicitly unqualified. `goodput_at_slo` is the auditable fraction of
|
|
52
|
+
runs whose TTFT is less than or equal to `--slo-ttft-ms`; the boundary is
|
|
53
|
+
inclusive. It is not claimed to be a maximum sustainable request rate.
|
|
54
|
+
|
|
55
|
+
## Install and verify
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip install -e . pytest
|
|
59
|
+
python -m pytest tests -q
|
|
60
|
+
python -m compileall -q engine_bench.py benchmark_manifest.py tests
|
|
61
|
+
python engine_bench.py --engines vllm --runs 1
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The last command is a fail-closed smoke test: without a declaration it emits
|
|
65
|
+
a `BLOCKED` result and a valid receipt, even when an endpoint is configured.
|
|
66
|
+
It issues no network request. No model or GPU is needed for the test suite.
|
|
67
|
+
|
|
68
|
+
The deterministic burst fixture from issue #2 can be reproduced without an
|
|
69
|
+
endpoint:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python -c "import engine_bench as e; print(e.run_stats([.05,.06,.07,.4,.45,.5,.55,.6], 8))"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Its TTFT is 50 ms. The inter-chunk gaps are 10, 10, 330, 50, 50, 50, and
|
|
76
|
+
50 ms, so linear interpolation yields ITL p50/p95/p99 of 50, 246, and
|
|
77
|
+
313.2 ms. This is a unit fixture, not a hardware benchmark.
|
|
78
|
+
|
|
79
|
+
## Exact experiment declarations (v0.3.0)
|
|
80
|
+
|
|
81
|
+
The default CLI requires `--manifest comparison.json` before contacting any
|
|
82
|
+
configured engine. The complete selected cohort is checked first: a missing or
|
|
83
|
+
changed endpoint, extra engine, mismatched request configuration, invalid digest,
|
|
84
|
+
or different hardware declaration cannot become a successful partial comparison.
|
|
85
|
+
|
|
86
|
+
The manifest uses the closed `szl.engine-comparison/v1` contract. Its template is
|
|
87
|
+
[`examples/comparison.synthetic.json`](examples/comparison.synthetic.json).
|
|
88
|
+
**Every identity in that file is a synthetic test fixture, not a qualified model,
|
|
89
|
+
hardware profile, or live endpoint.** Populate real operator-reviewed declarations
|
|
90
|
+
before measuring a deployment. The loader never downloads or executes a manifest
|
|
91
|
+
reference and rejects duplicate JSON keys, non-finite values, oversized inputs,
|
|
92
|
+
unknown fields, control characters, mutable revision names, and newline-suffixed
|
|
93
|
+
hashes. SHA checks use full-string matching, not permissive end anchors.
|
|
94
|
+
|
|
95
|
+
| Declaration | Meaning |
|
|
96
|
+
|---|---|
|
|
97
|
+
| Model/tokenizer revisions | Exact 40-character lowercase Git subjects; not branch names |
|
|
98
|
+
| Weights/tokenizer SHA-256 | Exact single artifact bytes, or SHA-256 of a separately retained canonical multi-file digest manifest |
|
|
99
|
+
| Template/adapter SHA-256 | Deployed template/adapter artifact identity; null adapter means explicitly none |
|
|
100
|
+
| Quantization/precision | Operator-declared configuration; no implicit conversion between engines |
|
|
101
|
+
| Suite/prompt SHA-256 | Retained suite artifact plus SHA-256 of the exact UTF-8 prompt sent by the CLI |
|
|
102
|
+
| Runs/token limit/timeout | Must match the requested invocation; timeout is the client's socket timeout, not a promised total wall-clock deadline |
|
|
103
|
+
| Sampling | Explicit temperature, top-p, and integer seed, included in every actual HTTP request |
|
|
104
|
+
| Engine build/configuration | Separate SHA-256 identities for each engine; these may differ in an engine comparison |
|
|
105
|
+
| Hardware SHA-256 | Same retained hardware-profile digest across the declared cohort |
|
|
106
|
+
| Endpoint SHA-256 | SHA-256 of the exact configured base URL after removing trailing slashes; no credentials allowed |
|
|
107
|
+
|
|
108
|
+
`benchmark_manifest.endpoint_digest()` computes the endpoint digest. File digests
|
|
109
|
+
refer to exact bytes; they are not a cryptographic demonstration that a remote
|
|
110
|
+
server loaded those bytes. Engine names must match the supported registry. The
|
|
111
|
+
client runs serially, performs no warmup/reset, and requires `concurrency: 1` and
|
|
112
|
+
`cache_state: UNCONTROLLED`; comparing cold and warm caches is not silently claimed.
|
|
113
|
+
It freezes the preflight endpoints and refuses redirects for bound requests.
|
|
114
|
+
|
|
115
|
+
Every sample commits the exact serialized request bytes. A run binding includes
|
|
116
|
+
the experiment, model/artifact subject, workload, per-engine build/configuration,
|
|
117
|
+
hardware, endpoint, and request hashes. `compare_bound()` rejects altered bindings,
|
|
118
|
+
missing samples, different wire requests, and omitted/failed cohort members.
|
|
119
|
+
No failed engine is discarded to obtain a better-looking comparison.
|
|
120
|
+
|
|
121
|
+
**Identity evidence remains `OPERATOR_DECLARED_NOT_RUNTIME_ATTESTED`.** A matching
|
|
122
|
+
manifest is not server identity attestation. Comparison reports keep
|
|
123
|
+
`runtime_identity: NOT_ATTESTED`, `quality_evaluation: NOT_PERFORMED`,
|
|
124
|
+
`production_admission: NOT_EVALUATED`, and uncontrolled cache state. They measure
|
|
125
|
+
client-observed latency only and never decide model promotion or an engine winner.
|
|
126
|
+
Different hardware should be evaluated as a separately designed system experiment,
|
|
127
|
+
not misrepresented as an engine-only improvement.
|
|
128
|
+
|
|
129
|
+
An incomplete or invalid explicit `--manifest` invocation exits 2 after emitting
|
|
130
|
+
its available receipt. The default offline smoke command retains its historical
|
|
131
|
+
zero exit. Library `run_engine()`, `compare()`, and `compare_engines()` remain
|
|
132
|
+
available for numerical diagnostics, labeled `UNBOUND_METRICS_ONLY` in comparisons.
|
|
133
|
+
The CLI requires `--unbound-diagnostics` to explicitly opt into that legacy path;
|
|
134
|
+
it cannot be combined with `--manifest` and is not release admission evidence.
|
|
135
|
+
|
|
136
|
+
## Measure configured engines
|
|
137
|
+
|
|
138
|
+
PowerShell:
|
|
139
|
+
|
|
140
|
+
```powershell
|
|
141
|
+
$env:VLLM_ENDPOINT = "http://127.0.0.1:8000"
|
|
142
|
+
$env:SGLANG_ENDPOINT = "http://127.0.0.1:30000"
|
|
143
|
+
python engine_bench.py --engines vllm sglang --model YOUR_MODEL --runs 10 --max-tokens 64 --slo-ttft-ms 200 --manifest comparison.json
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
POSIX shells:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
export VLLM_ENDPOINT=http://127.0.0.1:8000
|
|
150
|
+
export SGLANG_ENDPOINT=http://127.0.0.1:30000
|
|
151
|
+
python engine_bench.py --engines vllm sglang --model YOUR_MODEL --runs 10 --max-tokens 64 --slo-ttft-ms 200 --manifest comparison.json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Supported variables are `VLLM_ENDPOINT`, `SGLANG_ENDPOINT`,
|
|
155
|
+
`LLAMACPP_ENDPOINT`, `MLX_ENDPOINT`, `TGI_ENDPOINT`, and
|
|
156
|
+
`TRANSFORMERS_ENDPOINT`. Each must be an absolute HTTP(S) base URL without
|
|
157
|
+
embedded credentials, query parameters, fragments, or an invalid TCP port.
|
|
158
|
+
Duplicate names in `--engines` are rejected as `INVALID` before any request,
|
|
159
|
+
so receipt maps cannot silently overwrite a result. The client posts to
|
|
160
|
+
`/v1/completions`.
|
|
161
|
+
|
|
162
|
+
## Receipts
|
|
163
|
+
|
|
164
|
+
Every CLI invocation emits one canonical-JSON SHA-256 chain receipt using the
|
|
165
|
+
repository's `prev_hash` / `self_hash` schema and the all-zero genesis hash.
|
|
166
|
+
The receipt anchors:
|
|
167
|
+
|
|
168
|
+
- a canonical SHA-256 of every complete engine result;
|
|
169
|
+
- a canonical SHA-256 of each measured engine's nested ITL gap arrays;
|
|
170
|
+
- the ordered engine selection, benchmark configuration, and a prompt hash; and
|
|
171
|
+
- the comparison verdict and every engine state; and
|
|
172
|
+
- the canonical manifest digest and each exact wire-request/run binding (schema version 3).
|
|
173
|
+
|
|
174
|
+
Each run sample also includes its raw `itl_gaps_ms` array and matching
|
|
175
|
+
`itl_gaps_sha256`, so the hash can be independently recomputed.
|
|
176
|
+
`UNSIGNED_HONEST` proves integrity and order only; it does not claim signer
|
|
177
|
+
identity or external attestation.
|
|
178
|
+
|
|
179
|
+
## Verification scope
|
|
180
|
+
|
|
181
|
+
The test suite covers strict declarations, complete-cohort comparisons, actual
|
|
182
|
+
loopback HTTP request bytes/sampling fields, redirect refusal, preflight zero-
|
|
183
|
+
request behavior, endpoint freezing, bad JSON/digests, failure retention, and
|
|
184
|
+
receipt commitments, in addition to the original streaming and numerical tests.
|
|
185
|
+
Loopback test responses are fixtures: no trained model, remote production system,
|
|
186
|
+
GPU performance, energy measurement, or quality result is represented by CI.
|
|
187
|
+
|
|
188
|
+
Apache-2.0 · Doctrine v11 · SZL Holdings
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# szl-engine-bench
|
|
2
|
+
|
|
3
|
+
An honest, standard-library-only benchmark client for OpenAI-compatible
|
|
4
|
+
streaming endpoints exposed by vLLM, SGLang, llama.cpp, MLX, TGI, and
|
|
5
|
+
Transformers Serve.
|
|
6
|
+
|
|
7
|
+
Version 0.3.0 reports separate distributions for time to first token/chunk
|
|
8
|
+
(TTFT), inter-chunk latency (ITL), end-to-end latency, and the fraction of
|
|
9
|
+
runs meeting a declared TTFT service-level objective. It does not collapse an
|
|
10
|
+
engine comparison into one winner.
|
|
11
|
+
|
|
12
|
+
The distinction is deliberate. SGLang's serving guide reports TTFT, TPOT,
|
|
13
|
+
ITL, and throughput as separate online-serving metrics, while vLLM Bench
|
|
14
|
+
separately exposes TTFT/ITL percentiles and SLO goodput. Cache shape, request
|
|
15
|
+
rate, concurrency, model, and hardware can all change the result; a benchmark
|
|
16
|
+
from a different workload is not evidence for this one.
|
|
17
|
+
|
|
18
|
+
- [SGLang benchmark and profiling guide (source snapshot)](https://github.com/sgl-project/sglang/blob/50ed4c011ffb37e1c16248b99deab7d4dbdde79b/docs/developer_guide/benchmark_and_profiling.md)
|
|
19
|
+
- [vLLM Bench metrics (source snapshot)](https://github.com/vllm-project/vllm-bench/blob/f3131823f167aa1e6f31a48be1ae15a18667a534/README.md#metrics)
|
|
20
|
+
|
|
21
|
+
## States and measurement semantics
|
|
22
|
+
|
|
23
|
+
- `MEASURED`: every requested run produced at least two non-empty streaming
|
|
24
|
+
response chunks and valid monotonic arrival times.
|
|
25
|
+
- `BLOCKED`: the engine endpoint was not configured, or fewer than two engines
|
|
26
|
+
produced measurements for comparison.
|
|
27
|
+
- `INVALID`: configuration, stream shape, or fairness inputs were unsuitable
|
|
28
|
+
for the requested metric.
|
|
29
|
+
- `FAILED`: the configured endpoint or streaming protocol actually failed.
|
|
30
|
+
|
|
31
|
+
ITL is measured between non-empty SSE response chunks. An SSE chunk is not
|
|
32
|
+
assumed to equal one model token. `chunks_per_s` is always labeled as such;
|
|
33
|
+
the request asks the server for streamed usage with
|
|
34
|
+
`stream_options.include_usage=true`, and `tok_per_s` is `UNAVAILABLE` unless
|
|
35
|
+
the endpoint actually supplies an integer `usage.completion_tokens` value.
|
|
36
|
+
This avoids turning packet counts into fake token throughput.
|
|
37
|
+
|
|
38
|
+
The comparison keeps the v0.1.0 fairness gates: measured engines must use the
|
|
39
|
+
same model string and run count for low-level numerical diagnostics.
|
|
40
|
+
Version 0.3.0 additionally requires the declared identity contract below for
|
|
41
|
+
CLI comparisons; the old model-name check alone is explicitly unqualified. `goodput_at_slo` is the auditable fraction of
|
|
42
|
+
runs whose TTFT is less than or equal to `--slo-ttft-ms`; the boundary is
|
|
43
|
+
inclusive. It is not claimed to be a maximum sustainable request rate.
|
|
44
|
+
|
|
45
|
+
## Install and verify
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python -m pip install -e . pytest
|
|
49
|
+
python -m pytest tests -q
|
|
50
|
+
python -m compileall -q engine_bench.py benchmark_manifest.py tests
|
|
51
|
+
python engine_bench.py --engines vllm --runs 1
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The last command is a fail-closed smoke test: without a declaration it emits
|
|
55
|
+
a `BLOCKED` result and a valid receipt, even when an endpoint is configured.
|
|
56
|
+
It issues no network request. No model or GPU is needed for the test suite.
|
|
57
|
+
|
|
58
|
+
The deterministic burst fixture from issue #2 can be reproduced without an
|
|
59
|
+
endpoint:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
python -c "import engine_bench as e; print(e.run_stats([.05,.06,.07,.4,.45,.5,.55,.6], 8))"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Its TTFT is 50 ms. The inter-chunk gaps are 10, 10, 330, 50, 50, 50, and
|
|
66
|
+
50 ms, so linear interpolation yields ITL p50/p95/p99 of 50, 246, and
|
|
67
|
+
313.2 ms. This is a unit fixture, not a hardware benchmark.
|
|
68
|
+
|
|
69
|
+
## Exact experiment declarations (v0.3.0)
|
|
70
|
+
|
|
71
|
+
The default CLI requires `--manifest comparison.json` before contacting any
|
|
72
|
+
configured engine. The complete selected cohort is checked first: a missing or
|
|
73
|
+
changed endpoint, extra engine, mismatched request configuration, invalid digest,
|
|
74
|
+
or different hardware declaration cannot become a successful partial comparison.
|
|
75
|
+
|
|
76
|
+
The manifest uses the closed `szl.engine-comparison/v1` contract. Its template is
|
|
77
|
+
[`examples/comparison.synthetic.json`](examples/comparison.synthetic.json).
|
|
78
|
+
**Every identity in that file is a synthetic test fixture, not a qualified model,
|
|
79
|
+
hardware profile, or live endpoint.** Populate real operator-reviewed declarations
|
|
80
|
+
before measuring a deployment. The loader never downloads or executes a manifest
|
|
81
|
+
reference and rejects duplicate JSON keys, non-finite values, oversized inputs,
|
|
82
|
+
unknown fields, control characters, mutable revision names, and newline-suffixed
|
|
83
|
+
hashes. SHA checks use full-string matching, not permissive end anchors.
|
|
84
|
+
|
|
85
|
+
| Declaration | Meaning |
|
|
86
|
+
|---|---|
|
|
87
|
+
| Model/tokenizer revisions | Exact 40-character lowercase Git subjects; not branch names |
|
|
88
|
+
| Weights/tokenizer SHA-256 | Exact single artifact bytes, or SHA-256 of a separately retained canonical multi-file digest manifest |
|
|
89
|
+
| Template/adapter SHA-256 | Deployed template/adapter artifact identity; null adapter means explicitly none |
|
|
90
|
+
| Quantization/precision | Operator-declared configuration; no implicit conversion between engines |
|
|
91
|
+
| Suite/prompt SHA-256 | Retained suite artifact plus SHA-256 of the exact UTF-8 prompt sent by the CLI |
|
|
92
|
+
| Runs/token limit/timeout | Must match the requested invocation; timeout is the client's socket timeout, not a promised total wall-clock deadline |
|
|
93
|
+
| Sampling | Explicit temperature, top-p, and integer seed, included in every actual HTTP request |
|
|
94
|
+
| Engine build/configuration | Separate SHA-256 identities for each engine; these may differ in an engine comparison |
|
|
95
|
+
| Hardware SHA-256 | Same retained hardware-profile digest across the declared cohort |
|
|
96
|
+
| Endpoint SHA-256 | SHA-256 of the exact configured base URL after removing trailing slashes; no credentials allowed |
|
|
97
|
+
|
|
98
|
+
`benchmark_manifest.endpoint_digest()` computes the endpoint digest. File digests
|
|
99
|
+
refer to exact bytes; they are not a cryptographic demonstration that a remote
|
|
100
|
+
server loaded those bytes. Engine names must match the supported registry. The
|
|
101
|
+
client runs serially, performs no warmup/reset, and requires `concurrency: 1` and
|
|
102
|
+
`cache_state: UNCONTROLLED`; comparing cold and warm caches is not silently claimed.
|
|
103
|
+
It freezes the preflight endpoints and refuses redirects for bound requests.
|
|
104
|
+
|
|
105
|
+
Every sample commits the exact serialized request bytes. A run binding includes
|
|
106
|
+
the experiment, model/artifact subject, workload, per-engine build/configuration,
|
|
107
|
+
hardware, endpoint, and request hashes. `compare_bound()` rejects altered bindings,
|
|
108
|
+
missing samples, different wire requests, and omitted/failed cohort members.
|
|
109
|
+
No failed engine is discarded to obtain a better-looking comparison.
|
|
110
|
+
|
|
111
|
+
**Identity evidence remains `OPERATOR_DECLARED_NOT_RUNTIME_ATTESTED`.** A matching
|
|
112
|
+
manifest is not server identity attestation. Comparison reports keep
|
|
113
|
+
`runtime_identity: NOT_ATTESTED`, `quality_evaluation: NOT_PERFORMED`,
|
|
114
|
+
`production_admission: NOT_EVALUATED`, and uncontrolled cache state. They measure
|
|
115
|
+
client-observed latency only and never decide model promotion or an engine winner.
|
|
116
|
+
Different hardware should be evaluated as a separately designed system experiment,
|
|
117
|
+
not misrepresented as an engine-only improvement.
|
|
118
|
+
|
|
119
|
+
An incomplete or invalid explicit `--manifest` invocation exits 2 after emitting
|
|
120
|
+
its available receipt. The default offline smoke command retains its historical
|
|
121
|
+
zero exit. Library `run_engine()`, `compare()`, and `compare_engines()` remain
|
|
122
|
+
available for numerical diagnostics, labeled `UNBOUND_METRICS_ONLY` in comparisons.
|
|
123
|
+
The CLI requires `--unbound-diagnostics` to explicitly opt into that legacy path;
|
|
124
|
+
it cannot be combined with `--manifest` and is not release admission evidence.
|
|
125
|
+
|
|
126
|
+
## Measure configured engines
|
|
127
|
+
|
|
128
|
+
PowerShell:
|
|
129
|
+
|
|
130
|
+
```powershell
|
|
131
|
+
$env:VLLM_ENDPOINT = "http://127.0.0.1:8000"
|
|
132
|
+
$env:SGLANG_ENDPOINT = "http://127.0.0.1:30000"
|
|
133
|
+
python engine_bench.py --engines vllm sglang --model YOUR_MODEL --runs 10 --max-tokens 64 --slo-ttft-ms 200 --manifest comparison.json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
POSIX shells:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
export VLLM_ENDPOINT=http://127.0.0.1:8000
|
|
140
|
+
export SGLANG_ENDPOINT=http://127.0.0.1:30000
|
|
141
|
+
python engine_bench.py --engines vllm sglang --model YOUR_MODEL --runs 10 --max-tokens 64 --slo-ttft-ms 200 --manifest comparison.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Supported variables are `VLLM_ENDPOINT`, `SGLANG_ENDPOINT`,
|
|
145
|
+
`LLAMACPP_ENDPOINT`, `MLX_ENDPOINT`, `TGI_ENDPOINT`, and
|
|
146
|
+
`TRANSFORMERS_ENDPOINT`. Each must be an absolute HTTP(S) base URL without
|
|
147
|
+
embedded credentials, query parameters, fragments, or an invalid TCP port.
|
|
148
|
+
Duplicate names in `--engines` are rejected as `INVALID` before any request,
|
|
149
|
+
so receipt maps cannot silently overwrite a result. The client posts to
|
|
150
|
+
`/v1/completions`.
|
|
151
|
+
|
|
152
|
+
## Receipts
|
|
153
|
+
|
|
154
|
+
Every CLI invocation emits one canonical-JSON SHA-256 chain receipt using the
|
|
155
|
+
repository's `prev_hash` / `self_hash` schema and the all-zero genesis hash.
|
|
156
|
+
The receipt anchors:
|
|
157
|
+
|
|
158
|
+
- a canonical SHA-256 of every complete engine result;
|
|
159
|
+
- a canonical SHA-256 of each measured engine's nested ITL gap arrays;
|
|
160
|
+
- the ordered engine selection, benchmark configuration, and a prompt hash; and
|
|
161
|
+
- the comparison verdict and every engine state; and
|
|
162
|
+
- the canonical manifest digest and each exact wire-request/run binding (schema version 3).
|
|
163
|
+
|
|
164
|
+
Each run sample also includes its raw `itl_gaps_ms` array and matching
|
|
165
|
+
`itl_gaps_sha256`, so the hash can be independently recomputed.
|
|
166
|
+
`UNSIGNED_HONEST` proves integrity and order only; it does not claim signer
|
|
167
|
+
identity or external attestation.
|
|
168
|
+
|
|
169
|
+
## Verification scope
|
|
170
|
+
|
|
171
|
+
The test suite covers strict declarations, complete-cohort comparisons, actual
|
|
172
|
+
loopback HTTP request bytes/sampling fields, redirect refusal, preflight zero-
|
|
173
|
+
request behavior, endpoint freezing, bad JSON/digests, failure retention, and
|
|
174
|
+
receipt commitments, in addition to the original streaming and numerical tests.
|
|
175
|
+
Loopback test responses are fixtures: no trained model, remote production system,
|
|
176
|
+
GPU performance, energy measurement, or quality result is represented by CI.
|
|
177
|
+
|
|
178
|
+
Apache-2.0 · Doctrine v11 · SZL Holdings
|