quantprobe 1.8.0__tar.gz → 1.9.1__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 (31) hide show
  1. quantprobe-1.9.1/PKG-INFO +164 -0
  2. quantprobe-1.9.1/README.md +146 -0
  3. {quantprobe-1.8.0 → quantprobe-1.9.1}/pyproject.toml +1 -1
  4. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/__init__.py +1 -1
  5. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/auto.py +3 -2
  6. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/cli.py +2 -0
  7. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/plan.py +5 -1
  8. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/probe.py +89 -9
  9. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/runtime.py +8 -3
  10. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/target.py +2 -1
  11. quantprobe-1.9.1/quantprobe.egg-info/PKG-INFO +164 -0
  12. quantprobe-1.8.0/PKG-INFO +0 -151
  13. quantprobe-1.8.0/README.md +0 -133
  14. quantprobe-1.8.0/quantprobe.egg-info/PKG-INFO +0 -151
  15. {quantprobe-1.8.0 → quantprobe-1.9.1}/LICENSE +0 -0
  16. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/__main__.py +0 -0
  17. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/dashboard.py +0 -0
  18. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/detect.py +0 -0
  19. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/fetch.py +0 -0
  20. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/optimize.py +0 -0
  21. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe/spec.py +0 -0
  22. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe.egg-info/SOURCES.txt +0 -0
  23. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe.egg-info/dependency_links.txt +0 -0
  24. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe.egg-info/entry_points.txt +0 -0
  25. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe.egg-info/requires.txt +0 -0
  26. {quantprobe-1.8.0 → quantprobe-1.9.1}/quantprobe.egg-info/top_level.txt +0 -0
  27. {quantprobe-1.8.0 → quantprobe-1.9.1}/setup.cfg +0 -0
  28. {quantprobe-1.8.0 → quantprobe-1.9.1}/tests/test_engine.py +0 -0
  29. {quantprobe-1.8.0 → quantprobe-1.9.1}/tests/test_evaluator.py +0 -0
  30. {quantprobe-1.8.0 → quantprobe-1.9.1}/tests/test_pipeline.py +0 -0
  31. {quantprobe-1.8.0 → quantprobe-1.9.1}/tests/test_transforms.py +0 -0
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantprobe
3
+ Version: 1.9.1
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
+ Author: Federico Sciuca
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/FedericoTs/quantprobe
8
+ Keywords: llm,quantization,llama.cpp,gguf,inference,moe
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: gguf>=0.9
16
+ Requires-Dist: requests>=2.28
17
+ Dynamic: license-file
18
+
19
+ # quantprobe
20
+
21
+ ### How fast will this model run on *my* machine — and how do I make it faster?
22
+
23
+ **Answers both before you download anything. Then hands you the exact command.** Every number measured on one 2016 desktop (GTX 1060 6 GB · 16 GB DDR4 · SATA SSD), and every claim published as a prediction *made before the measurement*.
24
+
25
+ ![smoke](https://github.com/FedericoTs/quantprobe/actions/workflows/smoke.yml/badge.svg) ![license](https://img.shields.io/badge/license-MIT-0f766e) ![hardware](https://img.shields.io/badge/measured_on-2016_GTX_1060_6GB-d73027) ![models](https://img.shields.io/badge/validated-7B_→_744B-378add) [![x](https://img.shields.io/badge/author-@federico__sciuca-14181f)](https://x.com/federico_sciuca)
26
+
27
+ <p align="center"><img src="weights/data/hero_placement.png" width="880" alt="Placement across memory tiers: disk 2-bit cold experts, RAM 2-bit experts + probed fragile band at 4-bit, VRAM 4-bit attention — one law ties them"></p>
28
+
29
+ ---
30
+
31
+ ## Start here
32
+
33
+ ```bash
34
+ pip install quantprobe
35
+ quantprobe auto
36
+ ```
37
+
38
+ That's it — it detects your machine, asks which model you want, and gets you running. No flags to learn.
39
+
40
+ **Just want the number first?** `quantprobe plan --gguf model.gguf` prints your predicted tok/s, whether it fits, and the launch command. Downloads nothing, takes a second. There's also a [browser version](https://federicots.github.io/quantprobe/) with nothing to install.
41
+
42
+ ## The two ways to run a model
43
+
44
+ | | **Fast** — `quantprobe auto qwen3-30b` | **Custom** — `quantprobe auto qwen3-30b --custom` |
45
+ |---|---|---|
46
+ | what it does | picks the best existing quant for *your* machine, downloads it | measures which layers of *your* model break under compression, then builds a version tailored to it |
47
+ | time | minutes (mostly download) | **~50 min for a 7B, ~10 h for a 35B** — it tells you before starting |
48
+ | disk | one file | source + working files, 3–4× bigger |
49
+ | **speed** | full | **identical** — speed comes from placement, not from the build |
50
+ | **quality** | whatever the community published | **−9% perplexity at the same file size** ([measured](preregistrations/2026-07-25-recipe-upgrade-shexp-imatrix.md)) |
51
+
52
+ **Most people want Fast.** Above ~3 bits per weight, community quants are already near-lossless — so `--custom` *refuses to run* on machines that don't need it and explains why. The tool declines to sell you its own product.
53
+
54
+ **Use Custom when** you're squeezing a model that barely fits (under ~3 bits, where ordinary compression falls off a cliff), you have your own fine-tune nobody has published, or you need maximum quality at a fixed size.
55
+
56
+ ## The free speed you probably already have
57
+
58
+ Most guides put *all* of a mixture-of-experts model's experts in system RAM and leave your graphics card half empty. Keeping the first N expert layers on the GPU instead — same file, different flags — measured on the reference box:
59
+
60
+ | | all experts → RAM | **partial offload** |
61
+ |---|---|---|
62
+ | generation | 15.18 tok/s | **20.44 tok/s** (+34.7%) |
63
+ | prompt reading | 88 tok/s | **~238 tok/s** (2–3×) |
64
+
65
+ `plan` and `run` now compute the cutoff from your *free* VRAM and emit the exact flags. It costs nothing and needs no new download. ([pre-registration #13](preregistrations/2026-07-26-moe-partial-expert-offload.md) — staked before measuring, including the non-ship condition.)
66
+
67
+ ## Measured results
68
+
69
+ | result | number |
70
+ |---|---|
71
+ | Qwen3-30B-A3B on the 2016 desktop | **19.3 tok/s** — *predicted 19 before measuring* |
72
+ | Same model, partial expert offload | **20.44 tok/s**, +34.7% for free |
73
+ | Same bytes, different layers (Gemma 4 12B) | **byte-identical files, 2.25 ppl apart** |
74
+ | Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
75
+ | GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | 0.19 tok/s — inside the pre-registered 0.2–0.3 band |
76
+ | RAM overclock (XMP, 2133→3000) | dense **+52%**, pre-registered ×1.41+ |
77
+
78
+ <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>
79
+ <p align="center"><em>One frame, no cuts: Task Manager beside llama.cpp chatting Qwen3-30B-A3B at <b>20.4 tok/s</b> — above the pre-registered 19. Raw logs + GGUF SHA256: <a href="weights/data/validation_19tok/EVIDENCE.txt">EVIDENCE.txt</a>.</em></p>
80
+
81
+ ## Why you can trust the numbers
82
+
83
+ Most benchmark posts report what happened. **I write the prediction down first, publish it, then run the hardware** — and publish the misses just as loudly.
84
+
85
+ | predicted (first) | measured (after) |
86
+ |---|---|
87
+ | 110B streamed from SATA: **0.2–0.3 tok/s** | **0.19** |
88
+ | RAM overclock scales decode **×1.41+** | **×1.52** |
89
+ | 30B hybrid placement: **~19 tok/s** | **19.30 ± 0.88** |
90
+ | a day-old 118B streamed from SATA: **0.2–0.4** | **0.38 ± 0.17** |
91
+
92
+ **The misses are the point.** A few that are published in full:
93
+
94
+ - **I benchmarked my recipe against a competitor's and lost** ([#11](preregistrations/2026-07-25-apex-vs-probe-depthaware.md), +8.9% worse). It exposed two real bugs in mine. Fixed them ([#12](preregistrations/2026-07-25-recipe-upgrade-shexp-imatrix.md)), then ran a *fair* rematch on data neither side calibrated for — [predicting I'd lose again](preregistrations/2026-07-26-apex-rematch-ood-kl.md). I won: 26% better KL divergence. Two of four stakes missed **in my favour**, still recorded as misses.
95
+ - **I retracted a headline finding within the hour** when my own audit showed it was a measurement artifact — then reproduced the artifact deliberately to prove the cause ([Law 5 ledger](weights/LAW5_PROTOCOL.md)).
96
+ - **This tool told users a probe takes "30–60 minutes."** It takes 5h40m on a 35 GB model. That was my unmeasured claim, and [v1.9.0](CHANGELOG.md) replaced it with a derived estimate, a live ETA, and a confirmation prompt.
97
+
98
+ Plus a **byte-identical control** (two same-size files, 2.25 ppl apart — only placement differs), a full claim → script → log manifest, and **documented dead ends** (dynamic top-k, semantic paging, self-speculation — all measured-dead, because a law you only confirm is a law you haven't tested).
99
+
100
+ ## The four laws, in one line each
101
+
102
+ Full statements with measurements and falsifiable predictions in **[LAWS.md](LAWS.md)**.
103
+
104
+ 1. **Rotation is rank-conditional.** The standard trick behind modern quantization helps full-rank tensors and destroys low-rank bottlenecks — a ~270,000× swing.
105
+ 2. **Trained networks are dense everywhere.** No free lunch left in the weights: **2-bit is the data-free floor.**
106
+ 3. **Fragility is measurable, not predictable.** Gemma breaks late, Mistral breaks early — architectural near-twins pointing opposite ways. Only a functional probe decides.
107
+ 4. **The tiered decode law.** `tok/s = η(tier) × bandwidth ÷ active-bytes-per-token`. This is the equation that predicts your speed before you download.
108
+
109
+ <p align="center"><img src="weights/data/x_chart_E_scalinglaw.png" width="700" alt="One scaling law, 7B to 744B, predicted vs measured"></p>
110
+
111
+ ## All eleven commands
112
+
113
+ ```bash
114
+ quantprobe auto # interactive: detects, asks, decides, runs
115
+ quantprobe auto qwen3-30b --custom --run # the full custom pipeline, end to end
116
+ quantprobe hw # what the law sees on THIS machine
117
+ quantprobe plan --gguf model.gguf # predicted tok/s + placement + launch command
118
+ quantprobe optimize --tps 20 # cheapest path to a speed target, Pareto-ranked
119
+ quantprobe target --tps 5 --ladder # inverse: target -> smartest model that fits
120
+ quantprobe fetch qwen3-30b ./models # robust, resumable download
121
+ quantprobe quantize --gguf f16.gguf --out 2bit.gguf # build a depth-aware quant
122
+ quantprobe probe --gguf f16.gguf --eval wiki.test.raw # measure YOUR model's fragile band
123
+ quantprobe run --gguf 2bit.gguf # plan the placement, then launch chat
124
+ quantprobe bench --gguf 2bit.gguf --contribute # predicted vs measured; opt-in datapoint
125
+ quantprobe dashboard --gguf 2bit.gguf # the law live, every reply scored vs prediction
126
+ ```
127
+
128
+ `hw`/`plan`/`target`/`optimize` need nothing but Python. The weight-touching commands drive stock [llama.cpp](https://github.com/ggml-org/llama.cpp/releases) — point at it with `--llama-dir`, `QUANTPROBE_LLAMA_DIR`, or `PATH`, and preview anything with `--dry`. 16 machine presets ship in (`--machine`); multi-GPU and RAID aggregate with comma lists (`--vram 24,24`).
129
+
130
+ > **Windows: `'quantprobe' is not recognized`?** pip put it in a folder that isn't on your PATH. Use `python -m quantprobe ...` — identical, always works.
131
+
132
+ ## Help grow the law
133
+
134
+ `quantprobe bench --contribute` prints exactly what would be shared plus a pre-filled issue link — **you review and submit; nothing is ever sent automatically.** Points that land *outside* the predicted bands are the most valuable ones. Open predictions anyone can settle: [preregistrations/](preregistrations/).
135
+
136
+ ## Deep dives
137
+
138
+ | | |
139
+ |---|---|
140
+ | [QUICKSTART.md](QUICKSTART.md) | get running, three levels; recipes for fine-tunes, coding agents, hardware buying |
141
+ | [LAWS.md](LAWS.md) | the four laws — statements, measurements, falsifiable predictions |
142
+ | [docs/EXAMPLES.md](docs/EXAMPLES.md) | worked examples with real output, including the ×5.4 optimizer A/B |
143
+ | [docs/HARDWARE.md](docs/HARDWARE.md) | the 2016 box: exact specs, measured bandwidths, what the next euro buys |
144
+ | [preregistrations/](preregistrations/) | every staked prediction with its verdict — hits **and** misses |
145
+ | [weights/LAW5_PROTOCOL.md](weights/LAW5_PROTOCOL.md) | the live Law-5 research ledger, including the retraction |
146
+ | [CHANGELOG.md](CHANGELOG.md) | every release |
147
+
148
+ ## Honest limitations
149
+
150
+ - Perplexity and KL divergence are my metrics; I haven't run task-level evals (MMLU/HellaSwag) yet.
151
+ - The fragility atlas covers four model families — enough to *disprove* universality, not to chart every architecture.
152
+ - 0.19 tok/s for a 110B is a **capacity demonstration, not usable inference.**
153
+ - Speed numbers are single-stream decode on one machine (±25% across environments); the η values are fitted, not derived.
154
+ - No custom runtime: everything rides stock llama.cpp.
155
+
156
+ ## Credits
157
+
158
+ [colibri](https://github.com/JustVugg/colibri) (744B on 25 GB, pure C) inspired the tier-streaming exploration. The quantization stack builds on [llama.cpp](https://github.com/ggml-org/llama.cpp) and the QTIP/QuIP# incoherence codecs — whose central tool our first law bounds. Independent research by Federico Sciuca, AI-supported, on one desktop.
159
+
160
+ Two community contributions changed the tool measurably: **u/RogerAI--fyi** (Reddit) observed that the Law 4 formulation omitted per-token KV reads — measured, confirmed, shipped within a day. **u/MoneroApe** pointed me at [apex-quant](https://github.com/localai-org/apex-quant) and TurboQuant, and testing against **mudler's APEX** exposed two real gaps in my recipe: unprotected always-active tensors (their kurtosis argument, adopted here) and no importance-matrix calibration at all. The head-to-head and its scope limits are published in full, loss first.
161
+
162
+ ## License
163
+
164
+ MIT — see [LICENSE](LICENSE). © 2026 Federico Sciuca.
@@ -0,0 +1,146 @@
1
+ # quantprobe
2
+
3
+ ### How fast will this model run on *my* machine — and how do I make it faster?
4
+
5
+ **Answers both before you download anything. Then hands you the exact command.** Every number measured on one 2016 desktop (GTX 1060 6 GB · 16 GB DDR4 · SATA SSD), and every claim published as a prediction *made before the measurement*.
6
+
7
+ ![smoke](https://github.com/FedericoTs/quantprobe/actions/workflows/smoke.yml/badge.svg) ![license](https://img.shields.io/badge/license-MIT-0f766e) ![hardware](https://img.shields.io/badge/measured_on-2016_GTX_1060_6GB-d73027) ![models](https://img.shields.io/badge/validated-7B_→_744B-378add) [![x](https://img.shields.io/badge/author-@federico__sciuca-14181f)](https://x.com/federico_sciuca)
8
+
9
+ <p align="center"><img src="weights/data/hero_placement.png" width="880" alt="Placement across memory tiers: disk 2-bit cold experts, RAM 2-bit experts + probed fragile band at 4-bit, VRAM 4-bit attention — one law ties them"></p>
10
+
11
+ ---
12
+
13
+ ## Start here
14
+
15
+ ```bash
16
+ pip install quantprobe
17
+ quantprobe auto
18
+ ```
19
+
20
+ That's it — it detects your machine, asks which model you want, and gets you running. No flags to learn.
21
+
22
+ **Just want the number first?** `quantprobe plan --gguf model.gguf` prints your predicted tok/s, whether it fits, and the launch command. Downloads nothing, takes a second. There's also a [browser version](https://federicots.github.io/quantprobe/) with nothing to install.
23
+
24
+ ## The two ways to run a model
25
+
26
+ | | **Fast** — `quantprobe auto qwen3-30b` | **Custom** — `quantprobe auto qwen3-30b --custom` |
27
+ |---|---|---|
28
+ | what it does | picks the best existing quant for *your* machine, downloads it | measures which layers of *your* model break under compression, then builds a version tailored to it |
29
+ | time | minutes (mostly download) | **~50 min for a 7B, ~10 h for a 35B** — it tells you before starting |
30
+ | disk | one file | source + working files, 3–4× bigger |
31
+ | **speed** | full | **identical** — speed comes from placement, not from the build |
32
+ | **quality** | whatever the community published | **−9% perplexity at the same file size** ([measured](preregistrations/2026-07-25-recipe-upgrade-shexp-imatrix.md)) |
33
+
34
+ **Most people want Fast.** Above ~3 bits per weight, community quants are already near-lossless — so `--custom` *refuses to run* on machines that don't need it and explains why. The tool declines to sell you its own product.
35
+
36
+ **Use Custom when** you're squeezing a model that barely fits (under ~3 bits, where ordinary compression falls off a cliff), you have your own fine-tune nobody has published, or you need maximum quality at a fixed size.
37
+
38
+ ## The free speed you probably already have
39
+
40
+ Most guides put *all* of a mixture-of-experts model's experts in system RAM and leave your graphics card half empty. Keeping the first N expert layers on the GPU instead — same file, different flags — measured on the reference box:
41
+
42
+ | | all experts → RAM | **partial offload** |
43
+ |---|---|---|
44
+ | generation | 15.18 tok/s | **20.44 tok/s** (+34.7%) |
45
+ | prompt reading | 88 tok/s | **~238 tok/s** (2–3×) |
46
+
47
+ `plan` and `run` now compute the cutoff from your *free* VRAM and emit the exact flags. It costs nothing and needs no new download. ([pre-registration #13](preregistrations/2026-07-26-moe-partial-expert-offload.md) — staked before measuring, including the non-ship condition.)
48
+
49
+ ## Measured results
50
+
51
+ | result | number |
52
+ |---|---|
53
+ | Qwen3-30B-A3B on the 2016 desktop | **19.3 tok/s** — *predicted 19 before measuring* |
54
+ | Same model, partial expert offload | **20.44 tok/s**, +34.7% for free |
55
+ | Same bytes, different layers (Gemma 4 12B) | **byte-identical files, 2.25 ppl apart** |
56
+ | Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
57
+ | GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | 0.19 tok/s — inside the pre-registered 0.2–0.3 band |
58
+ | RAM overclock (XMP, 2133→3000) | dense **+52%**, pre-registered ×1.41+ |
59
+
60
+ <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>
61
+ <p align="center"><em>One frame, no cuts: Task Manager beside llama.cpp chatting Qwen3-30B-A3B at <b>20.4 tok/s</b> — above the pre-registered 19. Raw logs + GGUF SHA256: <a href="weights/data/validation_19tok/EVIDENCE.txt">EVIDENCE.txt</a>.</em></p>
62
+
63
+ ## Why you can trust the numbers
64
+
65
+ Most benchmark posts report what happened. **I write the prediction down first, publish it, then run the hardware** — and publish the misses just as loudly.
66
+
67
+ | predicted (first) | measured (after) |
68
+ |---|---|
69
+ | 110B streamed from SATA: **0.2–0.3 tok/s** | **0.19** |
70
+ | RAM overclock scales decode **×1.41+** | **×1.52** |
71
+ | 30B hybrid placement: **~19 tok/s** | **19.30 ± 0.88** |
72
+ | a day-old 118B streamed from SATA: **0.2–0.4** | **0.38 ± 0.17** |
73
+
74
+ **The misses are the point.** A few that are published in full:
75
+
76
+ - **I benchmarked my recipe against a competitor's and lost** ([#11](preregistrations/2026-07-25-apex-vs-probe-depthaware.md), +8.9% worse). It exposed two real bugs in mine. Fixed them ([#12](preregistrations/2026-07-25-recipe-upgrade-shexp-imatrix.md)), then ran a *fair* rematch on data neither side calibrated for — [predicting I'd lose again](preregistrations/2026-07-26-apex-rematch-ood-kl.md). I won: 26% better KL divergence. Two of four stakes missed **in my favour**, still recorded as misses.
77
+ - **I retracted a headline finding within the hour** when my own audit showed it was a measurement artifact — then reproduced the artifact deliberately to prove the cause ([Law 5 ledger](weights/LAW5_PROTOCOL.md)).
78
+ - **This tool told users a probe takes "30–60 minutes."** It takes 5h40m on a 35 GB model. That was my unmeasured claim, and [v1.9.0](CHANGELOG.md) replaced it with a derived estimate, a live ETA, and a confirmation prompt.
79
+
80
+ Plus a **byte-identical control** (two same-size files, 2.25 ppl apart — only placement differs), a full claim → script → log manifest, and **documented dead ends** (dynamic top-k, semantic paging, self-speculation — all measured-dead, because a law you only confirm is a law you haven't tested).
81
+
82
+ ## The four laws, in one line each
83
+
84
+ Full statements with measurements and falsifiable predictions in **[LAWS.md](LAWS.md)**.
85
+
86
+ 1. **Rotation is rank-conditional.** The standard trick behind modern quantization helps full-rank tensors and destroys low-rank bottlenecks — a ~270,000× swing.
87
+ 2. **Trained networks are dense everywhere.** No free lunch left in the weights: **2-bit is the data-free floor.**
88
+ 3. **Fragility is measurable, not predictable.** Gemma breaks late, Mistral breaks early — architectural near-twins pointing opposite ways. Only a functional probe decides.
89
+ 4. **The tiered decode law.** `tok/s = η(tier) × bandwidth ÷ active-bytes-per-token`. This is the equation that predicts your speed before you download.
90
+
91
+ <p align="center"><img src="weights/data/x_chart_E_scalinglaw.png" width="700" alt="One scaling law, 7B to 744B, predicted vs measured"></p>
92
+
93
+ ## All eleven commands
94
+
95
+ ```bash
96
+ quantprobe auto # interactive: detects, asks, decides, runs
97
+ quantprobe auto qwen3-30b --custom --run # the full custom pipeline, end to end
98
+ quantprobe hw # what the law sees on THIS machine
99
+ quantprobe plan --gguf model.gguf # predicted tok/s + placement + launch command
100
+ quantprobe optimize --tps 20 # cheapest path to a speed target, Pareto-ranked
101
+ quantprobe target --tps 5 --ladder # inverse: target -> smartest model that fits
102
+ quantprobe fetch qwen3-30b ./models # robust, resumable download
103
+ quantprobe quantize --gguf f16.gguf --out 2bit.gguf # build a depth-aware quant
104
+ quantprobe probe --gguf f16.gguf --eval wiki.test.raw # measure YOUR model's fragile band
105
+ quantprobe run --gguf 2bit.gguf # plan the placement, then launch chat
106
+ quantprobe bench --gguf 2bit.gguf --contribute # predicted vs measured; opt-in datapoint
107
+ quantprobe dashboard --gguf 2bit.gguf # the law live, every reply scored vs prediction
108
+ ```
109
+
110
+ `hw`/`plan`/`target`/`optimize` need nothing but Python. The weight-touching commands drive stock [llama.cpp](https://github.com/ggml-org/llama.cpp/releases) — point at it with `--llama-dir`, `QUANTPROBE_LLAMA_DIR`, or `PATH`, and preview anything with `--dry`. 16 machine presets ship in (`--machine`); multi-GPU and RAID aggregate with comma lists (`--vram 24,24`).
111
+
112
+ > **Windows: `'quantprobe' is not recognized`?** pip put it in a folder that isn't on your PATH. Use `python -m quantprobe ...` — identical, always works.
113
+
114
+ ## Help grow the law
115
+
116
+ `quantprobe bench --contribute` prints exactly what would be shared plus a pre-filled issue link — **you review and submit; nothing is ever sent automatically.** Points that land *outside* the predicted bands are the most valuable ones. Open predictions anyone can settle: [preregistrations/](preregistrations/).
117
+
118
+ ## Deep dives
119
+
120
+ | | |
121
+ |---|---|
122
+ | [QUICKSTART.md](QUICKSTART.md) | get running, three levels; recipes for fine-tunes, coding agents, hardware buying |
123
+ | [LAWS.md](LAWS.md) | the four laws — statements, measurements, falsifiable predictions |
124
+ | [docs/EXAMPLES.md](docs/EXAMPLES.md) | worked examples with real output, including the ×5.4 optimizer A/B |
125
+ | [docs/HARDWARE.md](docs/HARDWARE.md) | the 2016 box: exact specs, measured bandwidths, what the next euro buys |
126
+ | [preregistrations/](preregistrations/) | every staked prediction with its verdict — hits **and** misses |
127
+ | [weights/LAW5_PROTOCOL.md](weights/LAW5_PROTOCOL.md) | the live Law-5 research ledger, including the retraction |
128
+ | [CHANGELOG.md](CHANGELOG.md) | every release |
129
+
130
+ ## Honest limitations
131
+
132
+ - Perplexity and KL divergence are my metrics; I haven't run task-level evals (MMLU/HellaSwag) yet.
133
+ - The fragility atlas covers four model families — enough to *disprove* universality, not to chart every architecture.
134
+ - 0.19 tok/s for a 110B is a **capacity demonstration, not usable inference.**
135
+ - Speed numbers are single-stream decode on one machine (±25% across environments); the η values are fitted, not derived.
136
+ - No custom runtime: everything rides stock llama.cpp.
137
+
138
+ ## Credits
139
+
140
+ [colibri](https://github.com/JustVugg/colibri) (744B on 25 GB, pure C) inspired the tier-streaming exploration. The quantization stack builds on [llama.cpp](https://github.com/ggml-org/llama.cpp) and the QTIP/QuIP# incoherence codecs — whose central tool our first law bounds. Independent research by Federico Sciuca, AI-supported, on one desktop.
141
+
142
+ Two community contributions changed the tool measurably: **u/RogerAI--fyi** (Reddit) observed that the Law 4 formulation omitted per-token KV reads — measured, confirmed, shipped within a day. **u/MoneroApe** pointed me at [apex-quant](https://github.com/localai-org/apex-quant) and TurboQuant, and testing against **mudler's APEX** exposed two real gaps in my recipe: unprotected always-active tensors (their kurtosis argument, adopted here) and no importance-matrix calibration at all. The head-to-head and its scope limits are published in full, loss first.
143
+
144
+ ## License
145
+
146
+ MIT — see [LICENSE](LICENSE). © 2026 Federico Sciuca.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quantprobe"
7
- version = "1.8.0"
7
+ version = "1.9.1"
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.8.0"
11
+ __version__ = "1.9.1"
@@ -200,8 +200,9 @@ def run(a):
200
200
  os.makedirs(dest, exist_ok=True)
201
201
  print("\n[quantprobe auto --custom] source: " + spath + f" ({ssize/1e9:.1f} GB, {sbits:.1f}-bit)")
202
202
  cal = "skipped (--no-imatrix)" if getattr(a, "no_imatrix", False) else "calibrate (importance matrix)"
203
- print(f" pipeline: fetch source -> probe the fragile band (~30-60 min) -> {cal} -> build")
204
- print(" the depth-aware GGUF. Interrupt anytime; the fetch resumes.")
203
+ print(f" pipeline: fetch source -> probe the fragile band -> {cal} -> build the")
204
+ print(" depth-aware GGUF. Each stage prints its own time estimate before it starts;")
205
+ print(" on a large source this is HOURS, not minutes. Interrupt anytime; fetch resumes.")
205
206
  if getattr(a, "dry", False):
206
207
  print(" (--dry: nothing downloaded)")
207
208
  return spath
@@ -29,6 +29,7 @@ def main():
29
29
  p.add_argument("--out", default=None, help="output path for --apply (default: <model>-depthaware.gguf)")
30
30
  p.add_argument("--imatrix", default=None, help="importance-matrix file for --apply, or 'auto' to generate one first (measured -8.5%% ppl at ~3 bits, free in size and speed)")
31
31
  p.add_argument("--imatrix-chunks", type=int, default=100, help="calibration chunks when --imatrix auto (default 100)")
32
+ p.add_argument("--yes", "-y", action="store_true", help="skip the time-commitment confirmation for long runs")
32
33
  p.add_argument("--dry-run", action="store_true")
33
34
 
34
35
  q = sub.add_parser("plan", help="evaluate every bit/tier placement, predict tok/s (Law 4)")
@@ -104,6 +105,7 @@ def main():
104
105
  au.add_argument("--max-quality", type=float, default=None)
105
106
  au.add_argument("--allow-prune", action="store_true"); au.add_argument("--any-runtime", action="store_true")
106
107
  au.add_argument("--custom", action="store_true", help="THE PRODUCT: fetch a high-precision source, probe YOUR model (~30-60 min), build a depth-aware GGUF personalized to it (machine-gated: skipped with an explanation when this box doesn't need sub-3-bit surgery)")
108
+ au.add_argument("--yes", "-y", action="store_true", help="skip time-commitment confirmations")
107
109
  au.add_argument("--no-imatrix", action="store_true", help="skip importance-matrix calibration in --custom (faster build, measurably worse quality)")
108
110
  au.add_argument("--force-custom", action="store_true", help="build the depth-aware GGUF even when the optimizer says this machine doesn't need it")
109
111
  au.add_argument("--serve", action="store_true", help="with --run: llama-server instead of chat")
@@ -88,7 +88,11 @@ def moe_split_flags(frac, n_layer):
88
88
  if not n_layer or frac <= 0:
89
89
  return None
90
90
  k = max(1, min(n_layer - 1, int(frac * n_layer)))
91
- return '-ngl 99 -ot "blk\\.(%s)\\.ffn_.*_exps\\.=CPU"' % "|".join(str(i) for i in range(k, n_layer))
91
+ # --no-mmap for the same reason the all-experts row carries it: llama.cpp itself warns that
92
+ # tensor overrides to CPU with mmap enabled cost performance. Measured 2026-07-26 on this
93
+ # split placement: 16.45 tok/s with mmap vs 18.70 without (+13.7%).
94
+ return ('-ngl 99 -ot "blk\\.(%s)\\.ffn_.*_exps\\.=CPU" --no-mmap'
95
+ % "|".join(str(i) for i in range(k, n_layer)))
92
96
 
93
97
 
94
98
  def evaluate(t, a, ne, moe, bits, vc, vb, rc, rb, db, geta, act_scale=1.0, gl=None, ctx=0, kvp=0.0,
@@ -20,6 +20,51 @@ def exe(name):
20
20
  return name + (".exe" if os.name == "nt" else "")
21
21
 
22
22
 
23
+ # Throughput constants MEASURED on the reference box (i5-7600K, 8 threads, 16 GB DDR4-3000,
24
+ # GTX 1060 6 GB), 2026-07-25/26. They are the basis of the up-front time estimate and are
25
+ # refined from the user's OWN elapsed time after the first step - see _Progress.
26
+ QUANT_GB_PER_MIN = 2.8 # 35 GB source -> 12.6 min per pass, five passes measured
27
+ PPL_MIN_PER_GB_FITS = 0.55 # intermediate fits memory: 13 GB model -> ~7 min / 32 chunks
28
+ PPL_MIN_PER_GB_SPILLS = 2.4
29
+ IMATRIX_MIN_PER_GB = 7.7 # 35 GB source, 100 chunks -> 270 min measured # intermediate exceeds RAM: 23 GB -> ~55 min (page thrashing)
30
+
31
+
32
+ def fmt_dur(minutes):
33
+ if minutes < 90:
34
+ return f"{minutes:.0f} min"
35
+ return f"{minutes/60:.1f} h"
36
+
37
+
38
+ def estimate_probe_minutes(src_gb, bands, ram_gb=16.0, vram_gb=0.0):
39
+ """Honest up-front cost of a probe. Returns (minutes, spills) - `spills` flags the case
40
+ where the Q6_K intermediate exceeds memory, which is what turns an hour into most of a day."""
41
+ passes = bands + 1 # one reference + one per band
42
+ inter_gb = src_gb * 0.66 # Q6_K intermediate of the source
43
+ spills = inter_gb > max(ram_gb - 4, 1) + vram_gb * 0.9
44
+ rate = PPL_MIN_PER_GB_SPILLS if spills else PPL_MIN_PER_GB_FITS
45
+ return passes * (src_gb / QUANT_GB_PER_MIN + inter_gb * rate), spills
46
+
47
+
48
+ class _Progress:
49
+ """Step counter + ETA refined from the user's own measured pace, not our constants."""
50
+
51
+ def __init__(self, total_steps, est_minutes):
52
+ import time
53
+ self.t0 = time.time(); self.total = total_steps; self.done = 0; self.est = est_minutes
54
+
55
+ def step(self, label):
56
+ import time
57
+ self.done += 1
58
+ el = (time.time() - self.t0) / 60
59
+ if self.done > 1: # refine from real pace once we have one data point
60
+ remain = el / (self.done - 1) * (self.total - self.done + 1)
61
+ eta = f", ~{fmt_dur(remain)} left (measured pace)"
62
+ else:
63
+ eta = f", ~{fmt_dur(max(self.est - el, 0))} left (estimated)"
64
+ print(f"\n[quantprobe] step {self.done}/{self.total}: {label} "
65
+ f"[elapsed {fmt_dur(el)}{eta}]", flush=True)
66
+
67
+
23
68
  def n_layers(gguf_path):
24
69
  from gguf import GGUFReader
25
70
  r = GGUFReader(gguf_path)
@@ -77,11 +122,41 @@ def run(a):
77
122
  L = n_layers(a.gguf)
78
123
  step = (L + a.bands - 1) // a.bands
79
124
  bands = [(i, min(i + step - 1, L - 1)) for i in range(0, L, step)]
80
- print(f"quant-probe: {os.path.basename(a.gguf)} | {L} layers -> {len(bands)} bands {bands}\n", flush=True)
125
+ print(f"quant-probe: {os.path.basename(a.gguf)} | {L} layers -> {len(bands)} bands {bands}", flush=True)
126
+
127
+ # Up-front honesty about cost. A 35 GB source took 5h40m on the reference box - telling
128
+ # people "30-60 min" (as this tool used to) is wrong by an order of magnitude on big models.
129
+ src_gb = os.path.getsize(a.gguf) / 1e9
130
+ ram_gb, vram_gb = 16.0, 0.0
131
+ try:
132
+ from . import detect as detmod
133
+ d, _ = detmod.detect()
134
+ ram_gb, vram_gb = float(d.get("ram", 16)), float(d.get("vram", 0))
135
+ except Exception:
136
+ pass
137
+ est, spills = estimate_probe_minutes(src_gb, len(bands), ram_gb, vram_gb)
138
+ print(f"\n ESTIMATED TIME: ~{fmt_dur(est)} ({len(bands)+1} quantize passes + "
139
+ f"{len(bands)+1} perplexity runs on a {src_gb:.0f} GB source)", flush=True)
140
+ if spills:
141
+ print(f" WARNING: the {src_gb*0.66:.0f} GB working file exceeds your memory, so every\n"
142
+ f" perplexity run pages from disk - that is what makes this slow. A smaller source\n"
143
+ f" (or more RAM) changes this from hours to minutes.", flush=True)
144
+ print(" (measured on the reference box; refined from YOUR pace after step 1. "
145
+ "Ctrl-C is safe between steps.)", flush=True)
146
+ if est > 120 and not getattr(a, "yes", False) and not a.dry_run:
147
+ try:
148
+ if input(f"\n This will take about {fmt_dur(est)}. Continue? [y/N]: ").strip().lower() != "y":
149
+ raise SystemExit("aborted - nothing was built. Re-run with --yes to skip this prompt.")
150
+ except EOFError:
151
+ raise SystemExit(f"this probe needs ~{fmt_dur(est)} and there is no terminal to confirm.\n"
152
+ " Re-run with --yes if you intend to commit that time.")
153
+ prog = _Progress(2 * (len(bands) + 1), est)
154
+ print("", flush=True)
81
155
 
82
156
  ref = os.path.join(wd, "_probe_ref_q6k.gguf")
83
- print("[1/3] reference Q6_K", flush=True)
157
+ prog.step("building the Q6_K reference")
84
158
  sh([quant, "--allow-requantize", a.gguf, ref, "Q6_K", "8"], a.dry_run)
159
+ prog.step("scoring the reference")
85
160
  p_ref = ppl(perp, ref, a.eval, a.chunks, a.ngl, a.dry_run)
86
161
  print(f" ref PPL = {p_ref}\n", flush=True)
87
162
 
@@ -89,7 +164,9 @@ def run(a):
89
164
  deltas = []
90
165
  for lo, hi in bands:
91
166
  out = os.path.join(wd, f"_probe_b{lo}_{hi}.gguf")
167
+ prog.step(f"building band {lo}-{hi}")
92
168
  sh([quant, "--allow-requantize", "--tensor-type", f"{band_regex(lo, hi)}=q2_k", a.gguf, out, "Q6_K", "8"], a.dry_run)
169
+ prog.step(f"scoring band {lo}-{hi}")
93
170
  p = ppl(perp, out, a.eval, a.chunks, a.ngl, a.dry_run)
94
171
  d = None if (p is None or p_ref is None) else p - p_ref
95
172
  deltas.append(d)
@@ -105,13 +182,12 @@ def run(a):
105
182
  return
106
183
  worst = max(range(len(bands)), key=lambda i: deltas[i])
107
184
  lo, hi = bands[worst]
108
- others = [f"{band_regex(b[0], b[1])}=q2_k" for i, b in enumerate(bands) if i != worst]
109
185
  print(f" fragile band: layers {lo}-{hi} (delta +{deltas[worst]:.2f} vs "
110
186
  f"median {sorted(deltas)[len(deltas)//2]:.2f}) -> protect at Q4_K:\n", flush=True)
111
- flags = " ".join(f'--tensor-type "{o}"' for o in others)
112
- print(f' llama-quantize {flags} --tensor-type "{band_regex(lo, hi)}=q4_k" '
113
- f'--tensor-type "attn_.*=q4_k" --token-embedding-type q4_k \\\n'
114
- f' {os.path.basename(a.gguf)} out-depthaware.gguf Q2_K 8', flush=True)
187
+ # ONE source of truth for the recipe: print exactly what --apply would run. Hand-writing this
188
+ # string separately let it silently go stale (it predated the SSM and shared-expert
189
+ # protections, so anyone copying it built the OLD, worse recipe) - found in the 2026-07-26 audit.
190
+ build_depthaware(a.llama_dir, a.gguf, "out-depthaware.gguf", lo, hi, bands[-1][1] + 1, dry=True)
115
191
  if getattr(a, "apply", False):
116
192
  out = a.out or os.path.splitext(a.gguf)[0] + "-depthaware.gguf"
117
193
  imat = getattr(a, "imatrix", None)
@@ -175,8 +251,12 @@ def make_imatrix(llama_dir, src, eval_file, out=None, chunks=100, ngl=99, dry=Fa
175
251
  return out
176
252
  im = exe("llama-imatrix") if dry else os.path.join(find_llama(llama_dir), exe("llama-imatrix"))
177
253
  cmd = [im, "-m", src, "-f", eval_file, "-o", out, "--chunks", str(chunks), "-ngl", str(ngl), "-c", "512"]
178
- print(f"[quantprobe] building importance matrix over {chunks} chunks "
179
- f"(one pass; slow on big models, but worth ~8% quality for free)")
254
+ src_gb = os.path.getsize(src) / 1e9 if os.path.isfile(src) else 0
255
+ im_est = src_gb * IMATRIX_MIN_PER_GB * (chunks / 100.0)
256
+ print(f"[quantprobe] building importance matrix over {chunks} chunks on a {src_gb:.0f} GB source")
257
+ print(f" ESTIMATED TIME: ~{fmt_dur(im_est)} (measured 4.5 h for a 35 GB source at 100 chunks).")
258
+ print(f" Worth ~8% quality at zero size/speed cost - but it is a real time commitment.")
259
+ print(f" Skip it with --no-imatrix; reduce it with --imatrix-chunks (quality scales down too).")
180
260
  print(" $ " + " ".join(cmd))
181
261
  if dry:
182
262
  return out
@@ -115,9 +115,6 @@ def bench(a):
115
115
  bflags += ["-ngl", flags[i + 1]]
116
116
  if f == "-ot":
117
117
  bflags += ["-ot", flags[i + 1]]
118
- if flags and flags[0].startswith("-ngl") is False and "-ngl" not in flags:
119
- pass
120
- # normalize: flags like ['-ngl','99','-ot','exps=CPU','--no-mmap']
121
118
  cmd = [binp, "-m", a.gguf, "-n", "32", "-p", "0", "-r", str(a.reps)] + bflags
122
119
  if getattr(a, "depth", None):
123
120
  cmd += ["-d", str(a.depth)]
@@ -136,6 +133,14 @@ def bench(a):
136
133
  delta = (meas / best[1] - 1) * 100 if best[1] else 0
137
134
  print(f"\n[quantprobe] measured: {meas:.2f} +/- {err:.2f} tok/s "
138
135
  f"(predicted {best[1]:.1f}, {delta:+.0f}%)")
136
+ # A run whose own error bar is huge is not a measurement - saying so beats letting
137
+ # someone quote a cold-cache artifact. (Seen 2026-07-26: 4.01 +/- 2.16 on a first
138
+ # read from disk, where the warm number was 18.7.)
139
+ if err > meas * 0.15:
140
+ print(f"[quantprobe] WARNING: +/-{err/meas*100:.0f}% spread - this number is not "
141
+ f"reliable. Usually a cold file cache on the first read.\n"
142
+ f" Re-run it: the second run reads from RAM and is the real number.")
143
+ return
139
144
  if getattr(a, "contribute", False):
140
145
  _emit_contribution(a, best, meas, err, delta)
141
146
  else:
@@ -39,7 +39,8 @@ def feasible(a, tps_target):
39
39
  for bits in BITS_LADDER:
40
40
  size, act, cfgs = planmod.evaluate(m["t"], m["a"], m["ne"], m["moe"],
41
41
  bits, vc, vb, rc, rb, db, geta, 1.0, gl,
42
- ctx=ctx, kvp=m.get("kvp", planmod.DEFAULT_KVP))
42
+ ctx=ctx, kvp=m.get("kvp", planmod.DEFAULT_KVP),
43
+ n_layer=m.get("nl"))
43
44
  best = cfgs[0]
44
45
  if best[1] >= tps_target:
45
46
  q = planmod.qual_of(m["moe"], bits)