kvfit 0.2.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.
- kvfit-0.2.0/.gitignore +9 -0
- kvfit-0.2.0/LICENSE +21 -0
- kvfit-0.2.0/PKG-INFO +447 -0
- kvfit-0.2.0/README.md +428 -0
- kvfit-0.2.0/examples/calibration-dgx-spark.toml +31 -0
- kvfit-0.2.0/examples/calibration-dual-spark.toml +32 -0
- kvfit-0.2.0/examples/dgx-long-horizon.toml +54 -0
- kvfit-0.2.0/examples/enterprise-frontier-2026.toml +262 -0
- kvfit-0.2.0/examples/inkling-b200.toml +10 -0
- kvfit-0.2.0/pyproject.toml +50 -0
- kvfit-0.2.0/src/kvfit/__init__.py +7 -0
- kvfit-0.2.0/src/kvfit/__main__.py +3 -0
- kvfit-0.2.0/src/kvfit/_engine_probe.py +748 -0
- kvfit-0.2.0/src/kvfit/architectures.py +1157 -0
- kvfit-0.2.0/src/kvfit/audit.py +1021 -0
- kvfit-0.2.0/src/kvfit/calibrate.py +1186 -0
- kvfit-0.2.0/src/kvfit/calibration_config.py +272 -0
- kvfit-0.2.0/src/kvfit/cli.py +820 -0
- kvfit-0.2.0/src/kvfit/engines.py +397 -0
- kvfit-0.2.0/src/kvfit/hardware.py +211 -0
- kvfit-0.2.0/src/kvfit/hf.py +548 -0
- kvfit-0.2.0/src/kvfit/models.py +120 -0
- kvfit-0.2.0/src/kvfit/oracle.py +241 -0
- kvfit-0.2.0/src/kvfit/planner.py +208 -0
- kvfit-0.2.0/src/kvfit/systems.py +153 -0
- kvfit-0.2.0/src/kvfit/toml_config.py +278 -0
- kvfit-0.2.0/tests/test_architectures.py +443 -0
- kvfit-0.2.0/tests/test_audit.py +149 -0
- kvfit-0.2.0/tests/test_calibrate.py +352 -0
- kvfit-0.2.0/tests/test_cli.py +483 -0
- kvfit-0.2.0/tests/test_engines.py +422 -0
- kvfit-0.2.0/tests/test_hf.py +208 -0
- kvfit-0.2.0/tests/test_planner.py +163 -0
- kvfit-0.2.0/tests/test_systems.py +20 -0
- kvfit-0.2.0/uv.lock +108 -0
kvfit-0.2.0/.gitignore
ADDED
kvfit-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Teïlo Millet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
kvfit-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kvfit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Fail-closed KV-cache and inference-memory planning from Hugging Face model metadata
|
|
5
|
+
Author: Teïlo Millet
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: gpu,huggingface,inference,kv-cache,llm,vllm
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# kvfit
|
|
21
|
+
|
|
22
|
+
`kvfit` answers a narrow deployment question before you download or start a model:
|
|
23
|
+
|
|
24
|
+
> Given this exact Hugging Face model revision, context length, cache precision,
|
|
25
|
+
> hardware, and GPU topology, how much logical cache state does one active
|
|
26
|
+
> sequence need, and how many full-context sequences fit in memory?
|
|
27
|
+
|
|
28
|
+
The tool fails closed on cache architectures it does not understand. It does not
|
|
29
|
+
silently apply the standard Transformer KV formula to a new hybrid, recurrent,
|
|
30
|
+
compressed, or sparse-attention model.
|
|
31
|
+
|
|
32
|
+
## Start locally
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv sync
|
|
36
|
+
uv run kvfit Qwen/Qwen3-32B \
|
|
37
|
+
--hardware h100-80 \
|
|
38
|
+
--gpus 8 \
|
|
39
|
+
--context 128k \
|
|
40
|
+
--kv-dtype fp8
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
DeepSeek V4 keeps its sparse indexer at a different precision in common vLLM
|
|
44
|
+
deployments, so state that explicitly:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv run kvfit https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash \
|
|
48
|
+
--hardware b200-180 \
|
|
49
|
+
--gpus 4 \
|
|
50
|
+
--context 1m \
|
|
51
|
+
--kv-dtype fp8 \
|
|
52
|
+
--index-dtype fp4
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Use `--json` for scripts and agents. Use `--list-hardware` to see built-in
|
|
56
|
+
presets; `--hardware custom:96` handles an accelerator with 96 GiB.
|
|
57
|
+
Contexts beyond the checkpoint's declared maximum are rejected unless you add
|
|
58
|
+
`--allow-context-overflow`, which labels the result as hypothetical.
|
|
59
|
+
|
|
60
|
+
For complete DGX systems, specify systems rather than manually multiplying GPU
|
|
61
|
+
counts. This preserves the scale-up boundary and reports a memory-only
|
|
62
|
+
concurrent-user ceiling:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv run kvfit openai/gpt-oss-120b \
|
|
66
|
+
--system dgx-h100 \
|
|
67
|
+
--nodes 2 \
|
|
68
|
+
--context 90000 \
|
|
69
|
+
--active-sequences-per-user 1
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`context = 90000` means exactly 90,000 tokens; the shorthand `90k` means 92,160
|
|
73
|
+
tokens because suffixes use powers of 1024. One concurrent user means one
|
|
74
|
+
resident full-context sequence by default. Set `--active-sequences-per-user 2`
|
|
75
|
+
for an agent that may keep two branches resident; the reported user count is
|
|
76
|
+
then divided by two. This remains an OOM capacity ceiling, not a throughput or
|
|
77
|
+
latency SLO.
|
|
78
|
+
|
|
79
|
+
Built-in systems include DGX Spark, DGX H100, H200, B200, B300, and the DGX
|
|
80
|
+
GB200 NVL72 rack. `--list-systems` prints their accelerator counts and
|
|
81
|
+
scale-up/scale-out boundaries. `--nodes` multiplies complete systems; TP within
|
|
82
|
+
a system's NVLink domain is labeled node-local, while larger TP is explicitly
|
|
83
|
+
reported as cross-domain and unqualified until tested on the target fabric.
|
|
84
|
+
|
|
85
|
+
## Reusable TOML presets
|
|
86
|
+
|
|
87
|
+
Pass a TOML file as the positional argument, or use `--config`. Command-line
|
|
88
|
+
values override the file, so the preset can hold the stable deployment while a
|
|
89
|
+
single run changes one dimension:
|
|
90
|
+
|
|
91
|
+
```toml
|
|
92
|
+
# inkling-b200.toml
|
|
93
|
+
model = "thinkingmachines/Inkling-NVFP4"
|
|
94
|
+
hardware = "b200-180"
|
|
95
|
+
gpus = 8
|
|
96
|
+
context = "1m"
|
|
97
|
+
kv_dtype = "bf16"
|
|
98
|
+
utilization = 0.90
|
|
99
|
+
tp = 8
|
|
100
|
+
|
|
101
|
+
[engine]
|
|
102
|
+
check = ["vllm"]
|
|
103
|
+
python = ".engine-envs/vllm/bin/python"
|
|
104
|
+
probe = "config"
|
|
105
|
+
tp = 8
|
|
106
|
+
timeout = 300
|
|
107
|
+
require_pass = false
|
|
108
|
+
|
|
109
|
+
[output]
|
|
110
|
+
json = true
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
uv run kvfit inkling-b200.toml
|
|
115
|
+
uv run kvfit --config inkling-b200.toml --context 256k --gpus 4 --tp 4
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Supported root keys are `model`, `revision`, `context`, `kv_dtype`,
|
|
119
|
+
`index_dtype`, `weight_gib`, `allow_context_overflow`, `hardware`, `gpus`,
|
|
120
|
+
`system`, `nodes`, `active_sequences_per_user`, `utilization`, `tp`, and the
|
|
121
|
+
Hugging Face request `timeout`. Use either `hardware` plus `gpus`, or `system`
|
|
122
|
+
plus `nodes`; the strict parser rejects a mixture. The `[engine]`
|
|
123
|
+
table accepts `check`, `python`, `probe`, `tp`, `timeout`, and `require_pass`;
|
|
124
|
+
`[output]` currently accepts `json`. A relative `engine.python` path is resolved
|
|
125
|
+
from the preset's directory. Unknown keys, invalid enum values, malformed TOML,
|
|
126
|
+
and wrong value types are errors rather than ignored settings. JSON reports
|
|
127
|
+
include the resolved `input_config` path.
|
|
128
|
+
|
|
129
|
+
## Calibrate on the target serving host
|
|
130
|
+
|
|
131
|
+
The memory result is a hypothesis until the installed engine serves the real
|
|
132
|
+
checkpoint. Add a strict `[calibration]` table and run the target-host sweep:
|
|
133
|
+
|
|
134
|
+
```toml
|
|
135
|
+
model = "openai/gpt-oss-120b"
|
|
136
|
+
system = "dgx-spark"
|
|
137
|
+
nodes = 1
|
|
138
|
+
context = 90000
|
|
139
|
+
kv_dtype = "bf16"
|
|
140
|
+
tp = 1
|
|
141
|
+
|
|
142
|
+
[engine]
|
|
143
|
+
check = "vllm"
|
|
144
|
+
python = "/opt/vllm/bin/python"
|
|
145
|
+
probe = "config"
|
|
146
|
+
|
|
147
|
+
[calibration]
|
|
148
|
+
engine = "vllm"
|
|
149
|
+
mode = "launch"
|
|
150
|
+
python = "/opt/vllm/bin/python"
|
|
151
|
+
output_tokens = 1
|
|
152
|
+
max_concurrency = 32
|
|
153
|
+
requests_per_concurrency = 1
|
|
154
|
+
startup_timeout = 1800
|
|
155
|
+
request_timeout = 7200
|
|
156
|
+
metrics_interval = 1.0
|
|
157
|
+
stop_on_failure = true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
uv run kvfit calibrate deployment.toml --dry-run
|
|
162
|
+
uv run kvfit calibrate deployment.toml --output calibration.json
|
|
163
|
+
# Equivalent standalone entry point:
|
|
164
|
+
uv run kvfit-calibrate deployment.toml --output calibration.json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`launch` first runs the installed-version config preflight, rejects a default
|
|
168
|
+
managed launch without a CUDA accelerator, records the exact server command,
|
|
169
|
+
waits for readiness, and then runs the engine project's own serving benchmark.
|
|
170
|
+
For each concurrency point, the random workload uses exactly
|
|
171
|
+
`context - output_tokens` input tokens, zero length variation, and the requested
|
|
172
|
+
output length. The report verifies the aggregate input-token count when the
|
|
173
|
+
benchmark exports it.
|
|
174
|
+
|
|
175
|
+
The sweep samples `/metrics` concurrently. It understands current and legacy
|
|
176
|
+
vLLM running/waiting/KV-use names plus SGLang's running, queue, and token-use
|
|
177
|
+
gauges. The result keeps offered concurrency, measured resident requests,
|
|
178
|
+
queueing, successful completions, SLO qualification, and direct OOM evidence as
|
|
179
|
+
separate facts. A scheduler queue is never labeled an OOM.
|
|
180
|
+
|
|
181
|
+
By default, the sweep tests powers of two and the predicted boundary, capped by
|
|
182
|
+
`max_concurrency`. Set `concurrency = [1, 2, 4, 8]` for exact points. One request
|
|
183
|
+
per point is an intentionally cheap long-context capacity boundary. Set
|
|
184
|
+
`requests_per_concurrency = 5` or more for a steady-state run; this follows the
|
|
185
|
+
SGLang serving-benchmark guidance and can be very expensive at 90k+ tokens.
|
|
186
|
+
Optional `max_ttft_ms`, `max_tpot_ms`, and `max_e2e_ms` produce a separate
|
|
187
|
+
SLO-qualified ceiling.
|
|
188
|
+
|
|
189
|
+
For one host, the generated vLLM/SGLang command preserves the selected TP and
|
|
190
|
+
DP layout. For two Sparks or multiple DGX systems, `kvfit` refuses to pretend it
|
|
191
|
+
can provision the remote workers and router. Use `mode = "attach"` with the
|
|
192
|
+
cluster's OpenAI-compatible endpoint, or provide a version-specific
|
|
193
|
+
`server_command` array. `examples/calibration-dual-spark.toml` shows two
|
|
194
|
+
GPT-OSS replicas behind one dual-Spark endpoint (`tp = 1`, planner DP = 2). For
|
|
195
|
+
a model sharded across both Sparks, select `tp = 2` and attach to that TP=2
|
|
196
|
+
deployment instead.
|
|
197
|
+
|
|
198
|
+
Custom `server_command` and `benchmark_command` arrays support placeholders:
|
|
199
|
+
`{python}`, `{engine}`, `{base_url}`, `{host}`, `{port}`, `{model}`,
|
|
200
|
+
`{served_model}`, `{tokenizer}`, `{revision}`, `{context}`, `{input_tokens}`,
|
|
201
|
+
`{output_tokens}`, `{concurrency}`, `{num_prompts}`, `{result_file}`, `{seed}`,
|
|
202
|
+
`{tensor_parallel}`, `{data_parallel}`, `{utilization}`, and
|
|
203
|
+
`{max_concurrency}`. This is the escape hatch for Ray, Slurm, SSH, containers,
|
|
204
|
+
SGLang Model Gateway, or an engine CLI whose installed version differs from the
|
|
205
|
+
checked defaults.
|
|
206
|
+
|
|
207
|
+
The complete `[calibration]` schema also accepts `base_url`, `host`, `port`,
|
|
208
|
+
`server_args`, `startup_timeout`, `request_timeout`, `api_key_env`,
|
|
209
|
+
`stop_on_failure`, `keep_server`, and `allow_cpu`. Secrets are read from the
|
|
210
|
+
named environment variable and redacted from reports. `allow_cpu` exists for
|
|
211
|
+
deliberate tests, not production qualification. Attach mode records endpoint
|
|
212
|
+
metadata when exposed, but labels cache precision and topology unverified when
|
|
213
|
+
the server cannot report them. Exit code 4 means the sweep ran but did not fully
|
|
214
|
+
calibrate; configuration and launch errors use exit code 2.
|
|
215
|
+
|
|
216
|
+
Weight quantization still comes from the exact checkpoint and is independently
|
|
217
|
+
checked against the installed engine. Managed launch separately passes the
|
|
218
|
+
resolved KV-cache dtype using that engine's spelling. For DeepSeek V4 with an
|
|
219
|
+
FP4 sparse-index cache, current vLLM receives
|
|
220
|
+
`--attention-config '{"use_fp4_indexer_cache": true}'`. No equivalent SGLang
|
|
221
|
+
flag is assumed: use an explicitly checked `server_args`/`server_command` or
|
|
222
|
+
attach to a qualified server when the installed SGLang version supports that
|
|
223
|
+
path.
|
|
224
|
+
|
|
225
|
+
For a fleet/model decision rather than one deployment, use the strict audit
|
|
226
|
+
schema. The bundled frontier has 28 checkpoint/quantization variants from 13
|
|
227
|
+
families, 13 named accelerator presets, two context points per checkpoint, and
|
|
228
|
+
50 one-/multi-device fleet shapes:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
uv run kvfit-audit examples/enterprise-frontier-2026.toml
|
|
232
|
+
uv run kvfit-audit examples/enterprise-frontier-2026.toml --json
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The audit fetches each model live, records its resolved Hugging Face commit,
|
|
236
|
+
runs every model/context against every hardware/count, and exits 1 when the TOML
|
|
237
|
+
coverage thresholds are missed. A family counts as supported only when every
|
|
238
|
+
required variant and context succeeds. Every cache result must also match a
|
|
239
|
+
separate formula implementation; topology arithmetic and monotonicity across
|
|
240
|
+
context, dtype width, and accelerator memory are checked over the final matrix.
|
|
241
|
+
The reported percentage is equal-weight coverage of the explicitly named TOML
|
|
242
|
+
frontier, not an unsupported market-share claim.
|
|
243
|
+
|
|
244
|
+
Add `[[engines]]` tables to the same audit TOML to check an installed vLLM or
|
|
245
|
+
SGLang version for every successful model scenario. The fields are `name`,
|
|
246
|
+
`python`, `probe`, `timeout`, and `required`. Relative Python paths resolve from
|
|
247
|
+
the TOML directory. Keep `required = false` when surveying an old or
|
|
248
|
+
platform-incomplete environment; set it to true for a deployment gate.
|
|
249
|
+
|
|
250
|
+
The audit schema also accepts `[[systems]]` with `preset` and `node_counts`.
|
|
251
|
+
For example, `examples/dgx-long-horizon.toml` evaluates exact 90,000- and
|
|
252
|
+
131,072-token contexts across one, two, and eight complete DGX systems. Each
|
|
253
|
+
row includes `concurrency.recommended`, `best_scale_up_local`, and
|
|
254
|
+
`best_any_fabric`, so a cross-node arithmetic result cannot masquerade as a
|
|
255
|
+
validated local layout.
|
|
256
|
+
|
|
257
|
+
## Check the installed serving engine
|
|
258
|
+
|
|
259
|
+
`kvfit` can ask the exact vLLM or SGLang installation in a Python environment
|
|
260
|
+
whether it recognizes the checkpoint architecture, weight quantization, and
|
|
261
|
+
requested KV/index-cache formats on the local hardware backend:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
uv run kvfit openai/gpt-oss-120b \
|
|
265
|
+
--check-engine all \
|
|
266
|
+
--engine-python /path/to/serving-env/bin/python \
|
|
267
|
+
--context 128k
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
No `--hardware` is needed for an engine-only check. Add it when you want the
|
|
271
|
+
engine result and memory layouts in the same report:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
uv run kvfit openai/gpt-oss-120b \
|
|
275
|
+
--check-engine vllm \
|
|
276
|
+
--engine-python /path/to/vllm-env/bin/python \
|
|
277
|
+
--hardware h100-80 \
|
|
278
|
+
--gpus 2 \
|
|
279
|
+
--context 128k
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The default `--engine-probe config` has two levels. It first reads the installed
|
|
283
|
+
package's own model and quantization registries, then asks that version to parse
|
|
284
|
+
the model config and resolve its implementation. It sets
|
|
285
|
+
`trust_remote_code=False`, does not download weight shards, does not allocate the
|
|
286
|
+
model, and does not generate a token. Therefore `preflight-pass` means
|
|
287
|
+
**config-compatible on the detected backend**, not load-tested.
|
|
288
|
+
|
|
289
|
+
The probe also reads that installed version's cache-dtype choices. The report
|
|
290
|
+
shows both the portable spelling requested from `kvfit` and the exact engine
|
|
291
|
+
spelling (for example, BF16 becomes `bfloat16`, SGLang MXFP4 KV becomes
|
|
292
|
+
`fp4_e2m1`, and vLLM NVFP4 KV remains `nvfp4`). Prefer the explicit `mxfp4` or
|
|
293
|
+
`nvfp4` choices over generic `fp4`: the two formats are not interchangeable.
|
|
294
|
+
Config/registry mode proves that the option exists, while `load` passes it into
|
|
295
|
+
the engine and is the only mode that exercises the model-specific kernel path.
|
|
296
|
+
|
|
297
|
+
When you are on the target GPU host and want actual proof, opt into the
|
|
298
|
+
destructive smoke test:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
uv run kvfit openai/gpt-oss-120b \
|
|
302
|
+
--check-engine vllm \
|
|
303
|
+
--engine-python /path/to/vllm-env/bin/python \
|
|
304
|
+
--engine-probe load \
|
|
305
|
+
--engine-tp 2 \
|
|
306
|
+
--engine-timeout 1800 \
|
|
307
|
+
--context 128k
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`load` downloads missing weights, initializes the engine at the requested
|
|
311
|
+
context and tensor-parallel size, and requests one generated token. A
|
|
312
|
+
`smoke-pass` is therefore much stronger than `preflight-pass`. It can consume
|
|
313
|
+
the full accelerator allocation and should not be run beside production work.
|
|
314
|
+
The default tensor parallelism is `--engine-tp`, then an explicit `--tp`, then
|
|
315
|
+
`--gpus`.
|
|
316
|
+
|
|
317
|
+
Use `--engine-probe registry` for a faster offline-ish check that does not ask
|
|
318
|
+
the engine to fetch and parse the config again. This weaker mode can return
|
|
319
|
+
`unknown` when an engine advertises a generic Transformers fallback. For CI,
|
|
320
|
+
`--require-engine-pass` exits with status 3 unless every requested engine gets
|
|
321
|
+
`preflight-pass`; ordinary reporting still exits successfully for unsupported or
|
|
322
|
+
missing engines.
|
|
323
|
+
|
|
324
|
+
vLLM and SGLang are commonly installed in separate environments. Run the command
|
|
325
|
+
once per `--engine-python` in that case; `--check-engine all` checks both packages
|
|
326
|
+
only inside the one selected interpreter.
|
|
327
|
+
|
|
328
|
+
GPT-OSS weight quantization and KV precision are separate. `--kv-dtype auto`
|
|
329
|
+
(the default) keeps the official MXFP4 checkpoints at BF16 KV, but detects an
|
|
330
|
+
explicit KVFP8 declaration when a checkpoint provides one. Override it only
|
|
331
|
+
when the serving backend is configured differently.
|
|
332
|
+
|
|
333
|
+
Standalone `hf_quant_config.json` files are read when a repository publishes
|
|
334
|
+
one. This matters for `thinkingmachines/Inkling-NVFP4`: only routed experts are
|
|
335
|
+
NVFP4, hundreds of excluded module patterns remain BF16, and
|
|
336
|
+
`kv_cache_quant_algo: none` leaves the attention cache at the model dtype. The
|
|
337
|
+
JSON report exposes the weight algorithm, mixed scope, exclusion count, config
|
|
338
|
+
source, and independent KV-cache declaration instead of calling the checkpoint
|
|
339
|
+
simply BF16.
|
|
340
|
+
|
|
341
|
+
For a repository with multiple GGUF quantizations, pass the exact Hugging Face
|
|
342
|
+
blob URL. Split GGUF variants are summed automatically:
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
uv run kvfit \
|
|
346
|
+
https://huggingface.co/unsloth/gpt-oss-120b-GGUF/blob/main/Q4_K_M/gpt-oss-120b-Q4_K_M-00001-of-00002.gguf \
|
|
347
|
+
--hardware h100-80 \
|
|
348
|
+
--context 128k
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## What is supported now
|
|
352
|
+
|
|
353
|
+
- Standard MHA, GQA, and MQA.
|
|
354
|
+
- Explicit full/sliding-window layer schedules.
|
|
355
|
+
- DeepSeek V2/V3 MLA.
|
|
356
|
+
- DeepSeek V3.2 DSA: MLA plus Lightning Indexer state.
|
|
357
|
+
- DeepSeek V4: shared K=V, local sliding state, C4 compressed sparse state,
|
|
358
|
+
C128 heavily compressed state, and the C4 indexer.
|
|
359
|
+
- GPT-OSS 20B and 120B: checked alternating 128-token sliding/full GQA schedule.
|
|
360
|
+
- Thinking Machines Inkling BF16 and NVFP4: 11 full-attention layers, 55
|
|
361
|
+
512-token sliding layers, and all four short-convolution history streams.
|
|
362
|
+
- Qwen3-Next and Qwen3.6: full-attention KV plus gated-delta short-convolution
|
|
363
|
+
and FP32 recurrent matrices.
|
|
364
|
+
- Nemotron-H / Nemotron 3: explicit attention/Mamba-2/expert schedule, attention
|
|
365
|
+
KV, Mamba convolution history, and FP32 temporal state.
|
|
366
|
+
- Gemma 4: distinct global/local KV head counts and head dimensions, sliding
|
|
367
|
+
windows, and cross-layer KV sharing when declared.
|
|
368
|
+
- GLM DSA: latent MLA state plus its index-key cache.
|
|
369
|
+
- MiniMax M3: full GQA history plus the sparse-attention index-key side cache;
|
|
370
|
+
sparse selection does not imply KV eviction.
|
|
371
|
+
- Replicated tensor-parallel groups on identical accelerators.
|
|
372
|
+
|
|
373
|
+
Unadapted hybrid/recurrent state such as generic Mamba or Jamba is detected but
|
|
374
|
+
rejected until its exact state shapes and schedule are checked.
|
|
375
|
+
|
|
376
|
+
Unknown model types and configs that require custom remote model code are also
|
|
377
|
+
rejected by default. This is intentional: a new architecture can expose familiar
|
|
378
|
+
field names while storing very different inference state.
|
|
379
|
+
|
|
380
|
+
## What the number means
|
|
381
|
+
|
|
382
|
+
`kvfit` reports **memory capacity**, not production concurrency. A result of
|
|
383
|
+
"four full-context sequences fit" does not promise that four simultaneous
|
|
384
|
+
requests satisfy a latency or throughput objective.
|
|
385
|
+
|
|
386
|
+
Multi-GPU estimates currently assume ideal weight sharding inside each
|
|
387
|
+
tensor-parallel group and full model replication across data-parallel groups.
|
|
388
|
+
Cache components shard independently when an architecture has different global
|
|
389
|
+
and local KV-head counts (Inkling uses 8 and 16 respectively). Inkling's sconv
|
|
390
|
+
history stays BF16 even when its attention cache is explicitly sized at a lower
|
|
391
|
+
precision.
|
|
392
|
+
Qwen gated-delta and Nemotron-H recurrent matrices stay FP32 in the checked
|
|
393
|
+
reference configurations. The capacity estimate counts one live recurrent
|
|
394
|
+
state per sequence. Engine prefix caching can retain additional recurrent-state
|
|
395
|
+
checkpoints per cache block; that engine mode is not inferred and must be
|
|
396
|
+
measured on the serving host.
|
|
397
|
+
Expert parallelism, pipeline parallelism, context parallelism, offload, runtime
|
|
398
|
+
allocator page rounding, CUDA graphs, and framework-specific workspaces are not
|
|
399
|
+
silently inferred. The chosen `--utilization` is the explicit budget for those
|
|
400
|
+
unmodeled costs.
|
|
401
|
+
|
|
402
|
+
The installed-engine preflight is deliberately separate from this topology
|
|
403
|
+
arithmetic. An engine can accept an architecture and quantization while still
|
|
404
|
+
OOMing during weight load, lacking a required kernel at runtime, or failing a
|
|
405
|
+
real request. `--engine-probe load` closes that launch-time gap on the target GPU
|
|
406
|
+
host, but one successful token still does not validate production throughput,
|
|
407
|
+
latency, long-context accuracy, or stability under concurrency.
|
|
408
|
+
|
|
409
|
+
Repository artifact sizes are used as a weight-footprint proxy unless
|
|
410
|
+
`--weight-gib` is supplied. Runtime packing can differ, especially for
|
|
411
|
+
quantized checkpoints.
|
|
412
|
+
|
|
413
|
+
For GPT-OSS, the planner converts OpenAI's approximate decimal-GB runtime
|
|
414
|
+
guidance into conservative binary planning floors: 16 GiB for compact 20B
|
|
415
|
+
checkpoints, 48 GiB for a 20B BF16 checkpoint, and 60 GiB for compact 120B
|
|
416
|
+
checkpoints. These are planning floors, not measured guarantees. Safetensors
|
|
417
|
+
GPT-OSS checkpoints are rejected when their index does not cover every declared
|
|
418
|
+
layer. GGUF tensor coverage is not yet parsed, so that limitation is shown as a
|
|
419
|
+
warning.
|
|
420
|
+
|
|
421
|
+
## References used as test oracles
|
|
422
|
+
|
|
423
|
+
- [Hugging Face cache documentation](https://huggingface.co/docs/transformers/kv_cache)
|
|
424
|
+
- [Hugging Face DeepSeek V4 architecture](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/deepseek_v4.md)
|
|
425
|
+
- [vLLM DeepSeek V4 cache arithmetic](https://vllm.ai/blog/2026/04/24/deepseek-v4.html#the-math-behind-deepseek-v4s-attention-mechanism)
|
|
426
|
+
- [OpenAI GPT-OSS reference implementation](https://github.com/openai/gpt-oss/blob/main/gpt_oss/torch/model.py)
|
|
427
|
+
- [OpenAI GPT-OSS runtime memory guidance](https://developers.openai.com/cookbook/articles/gpt-oss/run-transformers#pick-your-model)
|
|
428
|
+
- [vLLM Inkling architecture and sconv cache design](https://vllm.ai/blog/2026/07/15/inkling)
|
|
429
|
+
- [vLLM Inkling sconv cache implementation](https://github.com/vllm-project/vllm/blob/main/vllm/models/inkling/nvidia/sconv_swa_attn.py)
|
|
430
|
+
- [vLLM serving benchmark CLI](https://docs.vllm.ai/en/latest/cli/bench/serve/)
|
|
431
|
+
- [vLLM production metrics](https://docs.vllm.ai/en/stable/usage/metrics/)
|
|
432
|
+
- [SGLang serving benchmark](https://github.com/sgl-project/sglang/blob/main/docs/developer_guide/bench_serving.md)
|
|
433
|
+
- [SGLang server arguments](https://github.com/sgl-project/sglang/blob/main/docs/advanced_features/server_arguments.md)
|
|
434
|
+
- [Thinking Machines Inkling release](https://thinkingmachines.ai/news/introducing-inkling/)
|
|
435
|
+
- [vLLM recurrent and gated-delta state shapes](https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/mamba/mamba_utils.py)
|
|
436
|
+
- [vLLM Nemotron-H state integration](https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/nemotron_h.py)
|
|
437
|
+
- [Transformers Gemma 4 cache geometry](https://github.com/huggingface/transformers/blob/main/src/transformers/models/gemma4/modeling_gemma4.py)
|
|
438
|
+
- [vLLM MiniMax M3 indexed cache](https://github.com/vllm-project/vllm/blob/main/vllm/models/minimax_m3/nvidia/model.py)
|
|
439
|
+
- [NVIDIA DGX Spark specifications](https://docs.nvidia.com/dgx/dgx-spark/hardware.html)
|
|
440
|
+
- [NVIDIA connecting two DGX Sparks](https://build.nvidia.com/spark/connect-two-sparks)
|
|
441
|
+
- [NVIDIA vLLM on two DGX Sparks](https://build.nvidia.com/spark/vllm/stacked-sparks)
|
|
442
|
+
- [NVIDIA H100 specifications](https://www.nvidia.com/en-us/data-center/h100/)
|
|
443
|
+
- [NVIDIA H200 specifications](https://www.nvidia.com/en-us/data-center/h200/)
|
|
444
|
+
- [NVIDIA accelerator memory table](https://docs.nvidia.com/datacenter/tesla/mig-user-guide/supported-gpus.html)
|
|
445
|
+
- [NVIDIA HGX H200/B200/B300 memory](https://docs.nvidia.com/enterprise-reference-architectures/hgx-ai-factory/latest/components.html)
|
|
446
|
+
- [AMD Instinct MI300/MI325 memory](https://www.amd.com/en/products/accelerators/instinct/mi300.html)
|
|
447
|
+
- [AMD Instinct MI350/MI355 memory](https://www.amd.com/en/products/accelerators/instinct/mi350.html)
|