quantprobe 1.22.0__tar.gz → 1.24.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.
Files changed (37) hide show
  1. {quantprobe-1.22.0/quantprobe.egg-info → quantprobe-1.24.0}/PKG-INFO +35 -1
  2. {quantprobe-1.22.0 → quantprobe-1.24.0}/README.md +34 -0
  3. {quantprobe-1.22.0 → quantprobe-1.24.0}/pyproject.toml +1 -1
  4. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/__init__.py +1 -1
  5. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/auto.py +52 -8
  6. quantprobe-1.24.0/quantprobe/branding.py +76 -0
  7. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/calibrate.py +68 -2
  8. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/cli.py +181 -176
  9. quantprobe-1.24.0/quantprobe/detect.py +277 -0
  10. quantprobe-1.24.0/quantprobe/plan.py +2119 -0
  11. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/probe.py +64 -0
  12. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/runtime.py +258 -251
  13. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/spec.py +68 -4
  14. {quantprobe-1.22.0 → quantprobe-1.24.0/quantprobe.egg-info}/PKG-INFO +35 -1
  15. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe.egg-info/SOURCES.txt +1 -0
  16. quantprobe-1.22.0/quantprobe/detect.py +0 -183
  17. quantprobe-1.22.0/quantprobe/plan.py +0 -1090
  18. {quantprobe-1.22.0 → quantprobe-1.24.0}/LICENSE +0 -0
  19. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/__main__.py +0 -0
  20. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/dashboard.py +0 -0
  21. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/fetch.py +0 -0
  22. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/optimize.py +0 -0
  23. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/recipes/mistral-7b.json +0 -0
  24. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/recipes/qwen2.5-7b.json +0 -0
  25. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/recipes/qwen3-30b.json +0 -0
  26. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/recipes/qwen3.5-35b.json +0 -0
  27. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/recipes.py +0 -0
  28. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe/target.py +0 -0
  29. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe.egg-info/dependency_links.txt +0 -0
  30. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe.egg-info/entry_points.txt +0 -0
  31. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe.egg-info/requires.txt +0 -0
  32. {quantprobe-1.22.0 → quantprobe-1.24.0}/quantprobe.egg-info/top_level.txt +0 -0
  33. {quantprobe-1.22.0 → quantprobe-1.24.0}/setup.cfg +0 -0
  34. {quantprobe-1.22.0 → quantprobe-1.24.0}/tests/test_engine.py +0 -0
  35. {quantprobe-1.22.0 → quantprobe-1.24.0}/tests/test_evaluator.py +0 -0
  36. {quantprobe-1.22.0 → quantprobe-1.24.0}/tests/test_pipeline.py +0 -0
  37. {quantprobe-1.22.0 → quantprobe-1.24.0}/tests/test_transforms.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.22.0
3
+ Version: 1.24.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,8 +16,14 @@ Requires-Dist: gguf>=0.9
16
16
  Requires-Dist: requests>=2.28
17
17
  Dynamic: license-file
18
18
 
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>
22
+
19
23
  # quantprobe
20
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
+
21
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.
22
28
 
23
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)
@@ -117,6 +123,34 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
117
123
  | Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
118
124
  | GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
119
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>
120
154
 
121
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>
122
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,5 +1,11 @@
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>
4
+
1
5
  # quantprobe
2
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
+
3
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.
4
10
 
5
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)
@@ -99,6 +105,34 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
99
105
  | Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
100
106
  | GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
101
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>
102
136
 
103
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>
104
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.22.0"
7
+ version = "1.24.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.22.0"
11
+ __version__ = "1.24.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={"User-Agent": "quantprobe-auto"})
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 os, zipfile, io
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
@@ -185,7 +206,7 @@ def run(a):
185
206
  try:
186
207
  files = list_ggufs(repo)
187
208
  except Exception as e:
188
- raise SystemExit(f"could not list {repo}: {e}")
209
+ raise SystemExit(f"could not list {repo}: {e}{gated_hint(e)}")
189
210
  if not files:
190
211
  raise SystemExit(f"no GGUF files found in {repo}")
191
212
  scored = []
@@ -240,7 +261,6 @@ def run(a):
240
261
  if not src:
241
262
  raise SystemExit("no usable high-precision source in that repo (split files unsupported)")
242
263
  sbits, ssize, spath = src
243
- import os
244
264
  dest = getattr(a, "dir", None) or "./models"
245
265
  os.makedirs(dest, exist_ok=True)
246
266
  print("\n[quantprobe auto --custom] source: " + spath + f" ({ssize/1e9:.1f} GB, {sbits:.1f}-bit)")
@@ -276,14 +296,38 @@ def run(a):
276
296
  print(f"\n[quantprobe auto] optimizer wants ~{want_bits:g}-bit; closest file in {repo}:")
277
297
  print(f" {path} ({size/1e9:.1f} GB, {bits:.2f} effective bits"
278
298
  + (f", {len(parts)} parts" if len(parts) > 1 else "") + ")")
279
- print(f" predicted on this machine: {best[1]:.1f} tok/s ({best[0]})")
299
+ # C-15: this number is computed from PRESET params + a size-derived bit-width, because the
300
+ # file is not downloaded yet - so it misses everything `plan --gguf` reads from the header:
301
+ # the gather-only embedding (#76), the format mix (#70/#77), the true always-active split.
302
+ # Measured divergence on the flagship: auto 26.2 vs plan 19.5 for the SAME file. If the file
303
+ # is already on disk, use the real thing; otherwise say plainly that it is a pre-download
304
+ # estimate and which command is authoritative.
305
+ _local = os.path.join(getattr(a, "dir", None) or "./models", os.path.basename(path))
306
+ if os.path.isfile(_local):
307
+ from . import spec as specmod
308
+ _s = specmod.from_gguf(_local)
309
+ _, _, _c = planmod.evaluate(_s["t"], _s["a"], _s["ne"], _s["moe"], _s["bits"], vc, vb,
310
+ rc, rb, db, geta, 1.0, gl, ctx=ctx, kvp=_s["kvp"],
311
+ n_layer=_s["n_layer"], true_size_gb=size / 1e9,
312
+ codebook_share=_s.get("codebook_share", 0.0))
313
+ _c = [x for x in _c if "expert cache" not in x[0]]
314
+ if _c:
315
+ _b = max(_c, key=lambda x: x[1])
316
+ print(f" predicted on this machine: {_b[1]:.1f} tok/s ({_b[0]}) [from the file's "
317
+ f"own header - already on disk]")
318
+ best = _b
319
+ else:
320
+ print(f" predicted on this machine: ~{best[1]:.1f} tok/s ({best[0]})")
321
+ print(f" NOTE: pre-download estimate from preset params - it cannot see this file's "
322
+ f"format mix or exact byte layout. After the download, `quantprobe plan --gguf "
323
+ f"<file>` reads the header and is the authoritative number (they have differed by "
324
+ f"34% on a MoE flagship).")
280
325
  if getattr(a, "dry", False):
281
326
  print(" (--dry: nothing downloaded)")
282
327
  return path
283
328
  # 3. fetch it (resumable; all parts when split), then hand off
284
329
  from . import fetch as fetchmod
285
330
  dest = getattr(a, "dir", None) or "./models"
286
- import os
287
331
  os.makedirs(dest, exist_ok=True)
288
332
  for i, part in enumerate(parts):
289
333
  if len(parts) > 1:
@@ -0,0 +1,76 @@
1
+ """The quantprobe mark: a Q that is a gauge - the dial is the Q's circle, the needle its tail.
2
+ One 12x12 pixel bitmap is the single source of truth: assets/quantprobe-icon.svg is generated
3
+ from it (python -m quantprobe.branding > assets/quantprobe-icon.svg), and the terminal banner
4
+ renders the same pixels as ANSI half-blocks. Old-style pixel art on purpose."""
5
+ import os
6
+ import sys
7
+
8
+ # '.' = background, 'o' = dial (teal), 'X' = needle/hub (white)
9
+ PIXELS = [
10
+ "...oooooo...",
11
+ "..oo....oo..",
12
+ ".oo......oo.",
13
+ ".o........o.",
14
+ "oo........oo",
15
+ "o....XX....o",
16
+ "o....XX....o",
17
+ "oo.....X....",
18
+ ".o......X...",
19
+ ".oo......X..",
20
+ "..oo......X.",
21
+ "...ooo.....X",
22
+ ]
23
+ BG, DIAL, NEEDLE = (20, 24, 31), (20, 184, 166), (230, 255, 250)
24
+
25
+
26
+ def icon_svg(px=10, pad=4):
27
+ w = len(PIXELS[0]) * px + 2 * pad
28
+ out = ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %d %d" ' % (w, w)
29
+ + 'shape-rendering="crispEdges" role="img" aria-label="quantprobe">',
30
+ ' <rect width="%d" height="%d" rx="%d" fill="#14181f"/>' % (w, w, 2 * px)]
31
+ for y, row in enumerate(PIXELS):
32
+ for x, c in enumerate(row):
33
+ if c == '.':
34
+ continue
35
+ color = "#14b8a6" if c == 'o' else "#e6fffa"
36
+ out.append(' <rect x="%d" y="%d" width="%d" height="%d" fill="%s"/>'
37
+ % (pad + x * px, pad + y * px, px, px, color))
38
+ out.append('</svg>')
39
+ return "\n".join(out) + "\n"
40
+
41
+
42
+ def _rgb(c):
43
+ return {'.': BG, 'o': DIAL, 'X': NEEDLE}[c]
44
+
45
+
46
+ def icon_ansi():
47
+ """The same pixels as truecolor half-blocks, 12 wide x 6 lines tall."""
48
+ lines = []
49
+ for y in range(0, len(PIXELS), 2):
50
+ top, bot = PIXELS[y], PIXELS[y + 1]
51
+ line = []
52
+ for t, b in zip(top, bot):
53
+ (tr, tg, tb), (br, bg_, bb) = _rgb(t), _rgb(b)
54
+ line.append("\x1b[38;2;%d;%d;%dm\x1b[48;2;%d;%d;%dm▀" % (tr, tg, tb, br, bg_, bb))
55
+ lines.append("".join(line) + "\x1b[0m")
56
+ return "\n".join(lines)
57
+
58
+
59
+ def banner(version=""):
60
+ """Icon + wordmark for the CLI header. Plain-text fallback off-tty / NO_COLOR / dumb terms."""
61
+ plain = not sys.stdout.isatty() or os.environ.get("NO_COLOR") or os.environ.get("TERM") == "dumb"
62
+ if not plain:
63
+ try: # legacy Windows consoles (cp1252) cannot encode the blocks
64
+ "▀".encode(sys.stdout.encoding or "utf-8")
65
+ except (UnicodeEncodeError, LookupError):
66
+ plain = True
67
+ if plain:
68
+ return f"quantprobe {version} - placement beats budget"
69
+ art = icon_ansi().split("\n")
70
+ text = ["", " quantprobe " + version, " placement beats budget",
71
+ " predictions before downloads", "", ""]
72
+ return "\n".join(a + t for a, t in zip(art, text))
73
+
74
+
75
+ if __name__ == "__main__":
76
+ sys.stdout.write(icon_svg())
@@ -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
- cal["disk_bw_measured"] = round(measure_disk(model), 2)
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