quantprobe 1.23.0__tar.gz → 1.25.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.
- {quantprobe-1.23.0/quantprobe.egg-info → quantprobe-1.25.0}/PKG-INFO +34 -2
- {quantprobe-1.23.0 → quantprobe-1.25.0}/README.md +33 -1
- {quantprobe-1.23.0 → quantprobe-1.25.0}/pyproject.toml +1 -1
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/__init__.py +1 -1
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/auto.py +101 -8
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/calibrate.py +68 -2
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/cli.py +190 -181
- quantprobe-1.25.0/quantprobe/detect.py +277 -0
- quantprobe-1.25.0/quantprobe/ollama.py +314 -0
- quantprobe-1.25.0/quantprobe/plan.py +2138 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/probe.py +64 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/runtime.py +9 -2
- quantprobe-1.25.0/quantprobe/smoke.py +2507 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/spec.py +68 -4
- {quantprobe-1.23.0 → quantprobe-1.25.0/quantprobe.egg-info}/PKG-INFO +34 -2
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe.egg-info/SOURCES.txt +2 -0
- quantprobe-1.23.0/quantprobe/detect.py +0 -183
- quantprobe-1.23.0/quantprobe/plan.py +0 -1124
- {quantprobe-1.23.0 → quantprobe-1.25.0}/LICENSE +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/__main__.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/branding.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/fetch.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/optimize.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/recipes/mistral-7b.json +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/recipes/qwen2.5-7b.json +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/recipes/qwen3-30b.json +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/recipes/qwen3.5-35b.json +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/recipes.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe/target.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/setup.cfg +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/tests/test_engine.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/tests/test_evaluator.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/tests/test_pipeline.py +0 -0
- {quantprobe-1.23.0 → quantprobe-1.25.0}/tests/test_transforms.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.25.0
|
|
4
4
|
Summary: Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes.
|
|
5
5
|
Author: Federico Sciuca
|
|
6
6
|
License: MIT
|
|
@@ -16,10 +16,14 @@ Requires-Dist: gguf>=0.9
|
|
|
16
16
|
Requires-Dist: requests>=2.28
|
|
17
17
|
Dynamic: license-file
|
|
18
18
|
|
|
19
|
-
<
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="assets/quantprobe-wordmark.svg" width="360" alt="quantprobe — the q and p share one bar, coloured VRAM to RAM to disk">
|
|
21
|
+
</p>
|
|
20
22
|
|
|
21
23
|
# quantprobe
|
|
22
24
|
|
|
25
|
+
<p align="center"><em>the bar is the probe: one column through the memory tiers it prices — VRAM, RAM, disk.</em></p>
|
|
26
|
+
|
|
23
27
|
Predicts how fast an LLM will run on your machine — **before you download it** — then hands you the exact llama.cpp command. If nothing fits well enough, it builds a quantization tuned to your specific model and hardware.
|
|
24
28
|
|
|
25
29
|
[**Quickstart**](#quickstart) · [**Browser version**](https://federicots.github.io/quantprobe/) · [**Commands**](#commands) · [**The laws**](LAWS.md) · [**When it won't help**](#when-quantprobe-wont-help-you)
|
|
@@ -119,6 +123,34 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
119
123
|
| Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
|
|
120
124
|
| GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
|
|
121
125
|
| RAM overclock (XMP, 2133→3000) | dense **+52%** |
|
|
126
|
+
| 14-row ladder, median absolute error | **8.4%** (2026-08-01, clean conditions) |
|
|
127
|
+
| Disk-tier row, 117B MoE streamed from SATA | predicted 0.332, **measured 0.476 tok/s — we were 30% pessimistic** |
|
|
128
|
+
|
|
129
|
+
<details>
|
|
130
|
+
<summary><b>What "clean conditions" means, and why we say it</b></summary>
|
|
131
|
+
|
|
132
|
+
The 8.4% ladder above was measured on a **deliberately quiesced machine**: no browser, no coding
|
|
133
|
+
agent, background services stopped, verified by gate before each phase at **CPU 0.7% mean / 2.0%
|
|
134
|
+
max** with 14.1 GB RAM free. One `cal_id` throughout, benches strictly serial.
|
|
135
|
+
|
|
136
|
+
That is not your machine on a normal day, and we will not pretend otherwise:
|
|
137
|
+
|
|
138
|
+
- **All 14 rows measured faster than the previous pass** — not 13, all of them. Median **+4.6%**,
|
|
139
|
+
up to +27.5%. The scrubbed box is a **ceiling**, not a typical result.
|
|
140
|
+
- Because of that, **the published headline speeds above are unchanged.** Qwen3-30B-A3B measured
|
|
141
|
+
**22.94 tok/s** on this pass, above the 20.4–22.2 we quote. We did not raise it. A number you
|
|
142
|
+
can only get by stopping services is not a number you can reproduce, and reproducibility is the
|
|
143
|
+
only thing that makes these figures worth reading.
|
|
144
|
+
- The median moved 9.0% → 8.4%, which is **inside our own ±1 point noise floor**, so we report it
|
|
145
|
+
as *unchanged* rather than improved — even though the smaller number is the flattering one.
|
|
146
|
+
- One row is flagged untrustworthy: **gemma4-12B** has returned 13.23, 12.25 and 15.62 tok/s across
|
|
147
|
+
three passes, a 27% spread. It is not measuring a stable quantity.
|
|
148
|
+
|
|
149
|
+
The disk-tier row is the first disk-tier measurement this project has ever taken, and **it failed
|
|
150
|
+
its own staked band.** We publish it at the same size as the wins. Details, including the two
|
|
151
|
+
mechanisms we tested and the one that survived: [CHANGELOG](CHANGELOG.md).
|
|
152
|
+
|
|
153
|
+
</details>
|
|
122
154
|
|
|
123
155
|
<p align="center"><img src="weights/data/validation_19tok/live_run_20tps.png" width="880" alt="One frame: Task Manager showing 16 GB DDR4-3000 and the GTX 1060 6GB beside llama.cpp chatting Qwen3-30B-A3B live at 20.4 tok/s generation"></p>
|
|
124
156
|
<p align="center"><em>One frame, no cuts: Qwen3-30B-A3B at <b>20.4 tok/s</b> on a 2016 desktop — GTX 1060 6 GB · 16 GB DDR4 · SATA SSD. Raw logs + GGUF SHA256: <a href="weights/data/validation_19tok/EVIDENCE.txt">EVIDENCE.txt</a>.</em></p>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
<
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/quantprobe-wordmark.svg" width="360" alt="quantprobe — the q and p share one bar, coloured VRAM to RAM to disk">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
# quantprobe
|
|
4
6
|
|
|
7
|
+
<p align="center"><em>the bar is the probe: one column through the memory tiers it prices — VRAM, RAM, disk.</em></p>
|
|
8
|
+
|
|
5
9
|
Predicts how fast an LLM will run on your machine — **before you download it** — then hands you the exact llama.cpp command. If nothing fits well enough, it builds a quantization tuned to your specific model and hardware.
|
|
6
10
|
|
|
7
11
|
[**Quickstart**](#quickstart) · [**Browser version**](https://federicots.github.io/quantprobe/) · [**Commands**](#commands) · [**The laws**](LAWS.md) · [**When it won't help**](#when-quantprobe-wont-help-you)
|
|
@@ -101,6 +105,34 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
101
105
|
| Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
|
|
102
106
|
| GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
|
|
103
107
|
| RAM overclock (XMP, 2133→3000) | dense **+52%** |
|
|
108
|
+
| 14-row ladder, median absolute error | **8.4%** (2026-08-01, clean conditions) |
|
|
109
|
+
| Disk-tier row, 117B MoE streamed from SATA | predicted 0.332, **measured 0.476 tok/s — we were 30% pessimistic** |
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><b>What "clean conditions" means, and why we say it</b></summary>
|
|
113
|
+
|
|
114
|
+
The 8.4% ladder above was measured on a **deliberately quiesced machine**: no browser, no coding
|
|
115
|
+
agent, background services stopped, verified by gate before each phase at **CPU 0.7% mean / 2.0%
|
|
116
|
+
max** with 14.1 GB RAM free. One `cal_id` throughout, benches strictly serial.
|
|
117
|
+
|
|
118
|
+
That is not your machine on a normal day, and we will not pretend otherwise:
|
|
119
|
+
|
|
120
|
+
- **All 14 rows measured faster than the previous pass** — not 13, all of them. Median **+4.6%**,
|
|
121
|
+
up to +27.5%. The scrubbed box is a **ceiling**, not a typical result.
|
|
122
|
+
- Because of that, **the published headline speeds above are unchanged.** Qwen3-30B-A3B measured
|
|
123
|
+
**22.94 tok/s** on this pass, above the 20.4–22.2 we quote. We did not raise it. A number you
|
|
124
|
+
can only get by stopping services is not a number you can reproduce, and reproducibility is the
|
|
125
|
+
only thing that makes these figures worth reading.
|
|
126
|
+
- The median moved 9.0% → 8.4%, which is **inside our own ±1 point noise floor**, so we report it
|
|
127
|
+
as *unchanged* rather than improved — even though the smaller number is the flattering one.
|
|
128
|
+
- One row is flagged untrustworthy: **gemma4-12B** has returned 13.23, 12.25 and 15.62 tok/s across
|
|
129
|
+
three passes, a 27% spread. It is not measuring a stable quantity.
|
|
130
|
+
|
|
131
|
+
The disk-tier row is the first disk-tier measurement this project has ever taken, and **it failed
|
|
132
|
+
its own staked band.** We publish it at the same size as the wins. Details, including the two
|
|
133
|
+
mechanisms we tested and the one that survived: [CHANGELOG](CHANGELOG.md).
|
|
134
|
+
|
|
135
|
+
</details>
|
|
104
136
|
|
|
105
137
|
<p align="center"><img src="weights/data/validation_19tok/live_run_20tps.png" width="880" alt="One frame: Task Manager showing 16 GB DDR4-3000 and the GTX 1060 6GB beside llama.cpp chatting Qwen3-30B-A3B live at 20.4 tok/s generation"></p>
|
|
106
138
|
<p align="center"><em>One frame, no cuts: Qwen3-30B-A3B at <b>20.4 tok/s</b> on a 2016 desktop — GTX 1060 6 GB · 16 GB DDR4 · SATA SSD. Raw logs + GGUF SHA256: <a href="weights/data/validation_19tok/EVIDENCE.txt">EVIDENCE.txt</a>.</em></p>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantprobe"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.25.0"
|
|
8
8
|
description = "Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -8,4 +8,4 @@ Three commands, all grounded in measured laws (see LAWS.md in the repo):
|
|
|
8
8
|
Every constant in `plan` is fitted from measurements published in the repo, including two
|
|
9
9
|
pre-registered hardware predictions confirmed within 8%.
|
|
10
10
|
"""
|
|
11
|
-
__version__ = "1.
|
|
11
|
+
__version__ = "1.25.0"
|
|
@@ -11,7 +11,7 @@ The two-speed design:
|
|
|
11
11
|
depth-aware GGUF at the same bits - better quality at the same bytes. `probe --apply` does it.
|
|
12
12
|
"""
|
|
13
13
|
from __future__ import annotations
|
|
14
|
-
import json, urllib.request
|
|
14
|
+
import json, os, urllib.request
|
|
15
15
|
from collections import namedtuple
|
|
16
16
|
|
|
17
17
|
from . import plan as planmod
|
|
@@ -38,10 +38,20 @@ MODEL_REPOS = {
|
|
|
38
38
|
def list_ggufs(repo):
|
|
39
39
|
"""[(path, size_bytes)] for a HF repo, via the public tree API (recursive: big repos
|
|
40
40
|
keep quants in subfolders). Split multi-part files (-00001-of-000NN) are grouped into
|
|
41
|
-
ONE logical entry: path = first part, size = sum of parts - so effective-bits stays honest.
|
|
41
|
+
ONE logical entry: path = first part, size = sum of parts - so effective-bits stays honest.
|
|
42
|
+
|
|
43
|
+
Sends the same HF token `fetch` sends: this listing used to be anonymous-only, so a GATED
|
|
44
|
+
repo 401'd `auto` even for a user whose token would have downloaded the files fine one step
|
|
45
|
+
later (caught live when unsloth gated their Mistral repo: `auto mistral-7b` died on the
|
|
46
|
+
listing while `fetch` would have succeeded)."""
|
|
42
47
|
import re
|
|
48
|
+
from . import fetch as fetchmod
|
|
49
|
+
headers = {"User-Agent": "quantprobe-auto"}
|
|
50
|
+
tok = fetchmod.token()
|
|
51
|
+
if tok:
|
|
52
|
+
headers["Authorization"] = f"Bearer {tok}"
|
|
43
53
|
req = urllib.request.Request(f"https://huggingface.co/api/models/{repo}/tree/main?recursive=true",
|
|
44
|
-
headers=
|
|
54
|
+
headers=headers)
|
|
45
55
|
with urllib.request.urlopen(req, timeout=30) as r:
|
|
46
56
|
raw = [(f["path"], f.get("size", 0)) for f in json.load(r)
|
|
47
57
|
if f["path"].endswith(".gguf") and f.get("size", 0) > 1e8
|
|
@@ -62,6 +72,17 @@ def list_ggufs(repo):
|
|
|
62
72
|
return singles
|
|
63
73
|
|
|
64
74
|
|
|
75
|
+
def gated_hint(e):
|
|
76
|
+
"""Actionable suffix for a 401/403 from the HF tree API - a bare 'Unauthorized' on a repo the
|
|
77
|
+
user can see in a browser reads like a quantprobe bug, when it is a gated repo waiting for a
|
|
78
|
+
token (or for the access request the repo page gates downloads behind)."""
|
|
79
|
+
if any(code in str(e) for code in ("401", "403")):
|
|
80
|
+
return ("\n That repo is gated or private on Hugging Face. Request access on its page if "
|
|
81
|
+
"you have not,\n then authenticate: set HF_TOKEN, or `huggingface-cli login` "
|
|
82
|
+
"(quantprobe reads the same\n cached token). Or pick another preset/repo.")
|
|
83
|
+
return ""
|
|
84
|
+
|
|
85
|
+
|
|
65
86
|
def split_parts(first_part):
|
|
66
87
|
"""All part paths of a split file, derived from the -00001-of-000NN first part."""
|
|
67
88
|
import re
|
|
@@ -77,7 +98,7 @@ WIKI_URL = "https://huggingface.co/datasets/ggml-org/ci/resolve/main/wikitext-2-
|
|
|
77
98
|
|
|
78
99
|
def ensure_eval(dest_dir):
|
|
79
100
|
"""The held-out corpus for probing, fetched once (1.3 MB)."""
|
|
80
|
-
import
|
|
101
|
+
import zipfile, io
|
|
81
102
|
path = os.path.join(dest_dir, "wiki.test.raw")
|
|
82
103
|
if os.path.isfile(path):
|
|
83
104
|
return path
|
|
@@ -168,6 +189,45 @@ def apply_to(spec, a):
|
|
|
168
189
|
return spec
|
|
169
190
|
|
|
170
191
|
|
|
192
|
+
|
|
193
|
+
def local_spec_or_none(local, expected_size, n_parts):
|
|
194
|
+
"""Read a downloaded GGUF's header - but ONLY if the file is actually complete.
|
|
195
|
+
|
|
196
|
+
Returns (spec_or_None, note_or_None). Split out of `run` so the decision is testable
|
|
197
|
+
against a real truncated file rather than asserted on by reading source text - the first
|
|
198
|
+
guard written for this was a source-inspection test, and disabling the size check left it
|
|
199
|
+
green, which is the decorative-test pattern this suite exists to catch.
|
|
200
|
+
|
|
201
|
+
"Already on disk" is not "complete". An interrupted `fetch` leaves a partial GGUF at exactly
|
|
202
|
+
the path `auto` probes, and there are two failure modes:
|
|
203
|
+
|
|
204
|
+
LOUD from_gguf RAISES. Reproduced: a 200 KB slice of a 531 MB GGUF gives ValueError out
|
|
205
|
+
of the tensor-shape reader. Unguarded, that killed the whole `auto` command with a
|
|
206
|
+
traceback instead of falling back to the estimate it had already computed.
|
|
207
|
+
QUIET from_gguf SUCCEEDS on a truncated file and returns a plausible-but-wrong spec, so
|
|
208
|
+
`auto` prints a confident number for a model that is not there. This is the worse
|
|
209
|
+
one, and only the size check catches it. A crash is recoverable; a confident wrong
|
|
210
|
+
answer is the defect class this project exists to remove.
|
|
211
|
+
"""
|
|
212
|
+
if not os.path.isfile(local):
|
|
213
|
+
return None, None
|
|
214
|
+
have = os.path.getsize(local)
|
|
215
|
+
# multi-part repos: `expected_size` is the total while `local` is one shard, so the
|
|
216
|
+
# comparison does not apply and is skipped rather than made to look meaningful.
|
|
217
|
+
if n_parts == 1 and expected_size and have != expected_size:
|
|
218
|
+
return None, (f"{os.path.basename(local)} is on disk but INCOMPLETE - {have/1e9:.2f} GB "
|
|
219
|
+
f"of {expected_size/1e9:.2f} GB ({have/expected_size*100:.1f}%). Its header "
|
|
220
|
+
f"is not trusted; using the pre-download estimate instead. Finish it with "
|
|
221
|
+
f"`quantprobe fetch --force` before quoting a number from this file.")
|
|
222
|
+
from . import spec as specmod
|
|
223
|
+
try:
|
|
224
|
+
return specmod.from_gguf(local), None
|
|
225
|
+
except Exception as e:
|
|
226
|
+
return None, (f"{os.path.basename(local)} is on disk but its header could not be read "
|
|
227
|
+
f"({type(e).__name__}). Falling back to the pre-download estimate. If the "
|
|
228
|
+
f"download was interrupted, `quantprobe fetch --force` will replace it.")
|
|
229
|
+
|
|
230
|
+
|
|
171
231
|
def run(a):
|
|
172
232
|
if a.target is None:
|
|
173
233
|
_wizard(a)
|
|
@@ -185,7 +245,7 @@ def run(a):
|
|
|
185
245
|
try:
|
|
186
246
|
files = list_ggufs(repo)
|
|
187
247
|
except Exception as e:
|
|
188
|
-
raise SystemExit(f"could not list {repo}: {e}")
|
|
248
|
+
raise SystemExit(f"could not list {repo}: {e}{gated_hint(e)}")
|
|
189
249
|
if not files:
|
|
190
250
|
raise SystemExit(f"no GGUF files found in {repo}")
|
|
191
251
|
scored = []
|
|
@@ -240,7 +300,6 @@ def run(a):
|
|
|
240
300
|
if not src:
|
|
241
301
|
raise SystemExit("no usable high-precision source in that repo (split files unsupported)")
|
|
242
302
|
sbits, ssize, spath = src
|
|
243
|
-
import os
|
|
244
303
|
dest = getattr(a, "dir", None) or "./models"
|
|
245
304
|
os.makedirs(dest, exist_ok=True)
|
|
246
305
|
print("\n[quantprobe auto --custom] source: " + spath + f" ({ssize/1e9:.1f} GB, {sbits:.1f}-bit)")
|
|
@@ -276,14 +335,48 @@ def run(a):
|
|
|
276
335
|
print(f"\n[quantprobe auto] optimizer wants ~{want_bits:g}-bit; closest file in {repo}:")
|
|
277
336
|
print(f" {path} ({size/1e9:.1f} GB, {bits:.2f} effective bits"
|
|
278
337
|
+ (f", {len(parts)} parts" if len(parts) > 1 else "") + ")")
|
|
279
|
-
|
|
338
|
+
# C-15: this number is computed from PRESET params + a size-derived bit-width, because the
|
|
339
|
+
# file is not downloaded yet - so it misses everything `plan --gguf` reads from the header:
|
|
340
|
+
# the gather-only embedding (#76), the format mix (#70/#77), the true always-active split.
|
|
341
|
+
# Measured divergence on the flagship: auto 26.2 vs plan 19.5 for the SAME file. If the file
|
|
342
|
+
# is already on disk, use the real thing; otherwise say plainly that it is a pre-download
|
|
343
|
+
# estimate and which command is authoritative.
|
|
344
|
+
# "already on disk" is not the same as "complete". An interrupted `fetch` leaves a partial
|
|
345
|
+
# file at exactly this path, and there are TWO failure modes, the quieter one being worse:
|
|
346
|
+
# (a) from_gguf RAISES - reproduced on a 200 KB slice of a 531 MB GGUF, ValueError out of
|
|
347
|
+
# the tensor-shape reader. Unguarded, that killed the whole `auto` command with a
|
|
348
|
+
# traceback instead of falling back to the estimate it had already computed.
|
|
349
|
+
# (b) from_gguf SUCCEEDS on a truncated file and returns a plausible-but-wrong spec, so
|
|
350
|
+
# `auto` confidently prints a number derived from a model that is not there. A crash
|
|
351
|
+
# is recoverable; a confident wrong answer is the defect class this project exists to
|
|
352
|
+
# remove. The size check below is what catches (b), and it is the more important half.
|
|
353
|
+
_local = os.path.join(getattr(a, "dir", None) or "./models", os.path.basename(path))
|
|
354
|
+
_s, _why = local_spec_or_none(_local, size, len(parts))
|
|
355
|
+
if _why:
|
|
356
|
+
print(" NOTE: " + _why)
|
|
357
|
+
if _s:
|
|
358
|
+
_, _, _c = planmod.evaluate(_s["t"], _s["a"], _s["ne"], _s["moe"], _s["bits"], vc, vb,
|
|
359
|
+
rc, rb, db, geta, 1.0, gl, ctx=ctx, kvp=_s["kvp"],
|
|
360
|
+
n_layer=_s["n_layer"], true_size_gb=size / 1e9,
|
|
361
|
+
codebook_share=_s.get("codebook_share", 0.0))
|
|
362
|
+
_c = [x for x in _c if "expert cache" not in x[0]]
|
|
363
|
+
if _c:
|
|
364
|
+
_b = max(_c, key=lambda x: x[1])
|
|
365
|
+
print(f" predicted on this machine: {_b[1]:.1f} tok/s ({_b[0]}) [from the file's "
|
|
366
|
+
f"own header - already on disk]")
|
|
367
|
+
best = _b
|
|
368
|
+
else:
|
|
369
|
+
print(f" predicted on this machine: ~{best[1]:.1f} tok/s ({best[0]})")
|
|
370
|
+
print(f" NOTE: pre-download estimate from preset params - it cannot see this file's "
|
|
371
|
+
f"format mix or exact byte layout. After the download, `quantprobe plan --gguf "
|
|
372
|
+
f"<file>` reads the header and is the authoritative number (they have differed by "
|
|
373
|
+
f"34% on a MoE flagship).")
|
|
280
374
|
if getattr(a, "dry", False):
|
|
281
375
|
print(" (--dry: nothing downloaded)")
|
|
282
376
|
return path
|
|
283
377
|
# 3. fetch it (resumable; all parts when split), then hand off
|
|
284
378
|
from . import fetch as fetchmod
|
|
285
379
|
dest = getattr(a, "dir", None) or "./models"
|
|
286
|
-
import os
|
|
287
380
|
os.makedirs(dest, exist_ok=True)
|
|
288
381
|
for i, part in enumerate(parts):
|
|
289
382
|
if len(parts) > 1:
|
|
@@ -187,6 +187,41 @@ def gpu_anchor(model_path, vram_gb, llama_dir=None):
|
|
|
187
187
|
return _bench_anchor(model_path, 99, 128, llama_dir)
|
|
188
188
|
|
|
189
189
|
|
|
190
|
+
def cal_id(cal):
|
|
191
|
+
"""A short, stable fingerprint of the MEASURED machine state (C-14).
|
|
192
|
+
|
|
193
|
+
Two calibrations of the same idle box hours apart measured RAM 23.21 -> 21.66 GB/s, the CPU
|
|
194
|
+
anchor 6.72 -> 6.24 tok/s and the GPU ratio 0.75 -> 1.03. Predictions from one state scored
|
|
195
|
+
against measurements from the other moved every arm of the model ladder by 5-12 points -
|
|
196
|
+
more than most of the effects being tested. A predicted-vs-measured number is only meaningful
|
|
197
|
+
when both sides come from the same state, so every state gets a name and every measurement
|
|
198
|
+
records which one it was taken under.
|
|
199
|
+
"""
|
|
200
|
+
import hashlib
|
|
201
|
+
if not cal:
|
|
202
|
+
return None
|
|
203
|
+
parts = [f"{cal.get('ram_bw_measured')}", f"{cal.get('disk_bw_measured')}"]
|
|
204
|
+
for a in cal.get("anchors") or []:
|
|
205
|
+
parts.append(f"{a.get('placement')}:{a.get('tok_s')}:{a.get('sustained_sm')}")
|
|
206
|
+
return hashlib.sha1("|".join(parts).encode()).hexdigest()[:8]
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def drift_vs(prev, cur, tol=0.03):
|
|
210
|
+
"""[(field, old, new, pct)] for measured values that moved more than tol between states."""
|
|
211
|
+
out = []
|
|
212
|
+
def cmp(name, a, b):
|
|
213
|
+
if a and b and abs(b - a) / a > tol:
|
|
214
|
+
out.append((name, a, b, (b - a) / a * 100))
|
|
215
|
+
cmp("ram_bw", prev.get("ram_bw_measured"), cur.get("ram_bw_measured"))
|
|
216
|
+
cmp("disk_bw", prev.get("disk_bw_measured"), cur.get("disk_bw_measured"))
|
|
217
|
+
pa = {a.get("placement"): a for a in (prev.get("anchors") or [])}
|
|
218
|
+
for a in cur.get("anchors") or []:
|
|
219
|
+
p = pa.get(a.get("placement"))
|
|
220
|
+
if p:
|
|
221
|
+
cmp(f"anchor {a.get('placement')}", p.get("tok_s"), a.get("tok_s"))
|
|
222
|
+
return out
|
|
223
|
+
|
|
224
|
+
|
|
190
225
|
def load():
|
|
191
226
|
"""Return (calibration dict, age_days) or (None, None). Used by plan."""
|
|
192
227
|
try:
|
|
@@ -221,8 +256,22 @@ def run(a):
|
|
|
221
256
|
model = getattr(a, "model", None)
|
|
222
257
|
if model and os.path.isfile(model):
|
|
223
258
|
from .detect import measure_disk
|
|
224
|
-
|
|
259
|
+
bw, info = measure_disk(model, detail=True)
|
|
260
|
+
cal["disk_bw_measured"] = round(bw, 2)
|
|
261
|
+
cal["disk_probe"] = info
|
|
225
262
|
print(f" disk: {cal['disk_bw_measured']:.2f} GB/s sequential on your file [measured]")
|
|
263
|
+
# prereg #97: no longer one sample, and no longer your job to spot the warm one. The
|
|
264
|
+
# minimum over disjoint regions is the estimate, because nothing reads faster than the
|
|
265
|
+
# device except cache. Measured: 6 of 8 single draws on a 73%-warm file returned
|
|
266
|
+
# >1.5 GB/s (max 2.854, a 6.3x error) while the minimum stayed correct.
|
|
267
|
+
print(f" (minimum of {info['samples']} probes at random offsets: "
|
|
268
|
+
f"{info['draws']})")
|
|
269
|
+
if info["warm_draws"]:
|
|
270
|
+
print(f" {info['warm_draws']} of {info['samples']} draws came back >2x the "
|
|
271
|
+
f"minimum - those regions were served from page cache,\n not disk. The "
|
|
272
|
+
f"minimum above is used and is the right number; this line is only telling you "
|
|
273
|
+
f"why\n the draws disagree. A single-sample probe could have shipped "
|
|
274
|
+
f"one of the fast ones. (C-17/#97)")
|
|
226
275
|
if not getattr(a, "skip_bench", False):
|
|
227
276
|
cal["anchors"] = []
|
|
228
277
|
print(" anchor: running llama-bench -ngl 0 tg32 on your file (1-10 min on big models)...")
|
|
@@ -257,10 +306,27 @@ def run(a):
|
|
|
257
306
|
else:
|
|
258
307
|
print(" (pass --model your.gguf to also measure disk + a real decode anchor)")
|
|
259
308
|
|
|
309
|
+
# C-14: name this machine state, and say out loud how far it drifted from the last one.
|
|
310
|
+
# Silent drift is what made a day of predicted-vs-measured numbers partly fiction.
|
|
311
|
+
prev, _ = load()
|
|
312
|
+
cal["cal_id"] = cal_id(cal)
|
|
313
|
+
if prev:
|
|
314
|
+
moved = drift_vs(prev, cal)
|
|
315
|
+
if moved:
|
|
316
|
+
print(f"\n DRIFT since the last calibration ({prev.get('date')}, "
|
|
317
|
+
f"id {prev.get('cal_id', '?')}):")
|
|
318
|
+
for name, a, b, pct in moved:
|
|
319
|
+
print(f" {name}: {a} -> {b} ({pct:+.1f}%)")
|
|
320
|
+
print(" Measurements taken under the OLD state cannot be scored against "
|
|
321
|
+
"predictions from this one - that comparison moved every arm of our own model "
|
|
322
|
+
"ladder by 5-12 points, more than most real effects (C-14). Re-measure, or "
|
|
323
|
+
"compare only within one state.")
|
|
324
|
+
else:
|
|
325
|
+
print(f"\n no drift since {prev.get('date')} (same machine state)")
|
|
260
326
|
os.makedirs(CAL_DIR, exist_ok=True)
|
|
261
327
|
with open(CAL_PATH, "w", encoding="utf-8") as f:
|
|
262
328
|
json.dump(cal, f, indent=1)
|
|
263
|
-
print(f"\n saved: {CAL_PATH}")
|
|
329
|
+
print(f"\n saved: {CAL_PATH} [state id {cal['cal_id']}]")
|
|
264
330
|
print(" plan/optimize/auto now use the measured values automatically (tagged [calibrated]).")
|
|
265
331
|
print(" Delete the file to return to auto-detection. Re-run after RAM/driver changes.")
|
|
266
332
|
return cal
|