quantprobe 1.14.0__tar.gz → 1.15.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.14.0/quantprobe.egg-info → quantprobe-1.15.0}/PKG-INFO +2 -2
- {quantprobe-1.14.0 → quantprobe-1.15.0}/README.md +163 -163
- {quantprobe-1.14.0 → quantprobe-1.15.0}/pyproject.toml +31 -31
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/__init__.py +11 -11
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/optimize.py +156 -154
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/plan.py +142 -26
- {quantprobe-1.14.0 → quantprobe-1.15.0/quantprobe.egg-info}/PKG-INFO +2 -2
- {quantprobe-1.14.0 → quantprobe-1.15.0}/LICENSE +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/__main__.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/auto.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/cli.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/detect.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/fetch.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/probe.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/recipes/mistral-7b.json +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/recipes/qwen2.5-7b.json +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/recipes/qwen3-30b.json +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/recipes/qwen3.5-35b.json +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/recipes.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/runtime.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/spec.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe/target.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe.egg-info/SOURCES.txt +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/setup.cfg +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/tests/test_engine.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/tests/test_evaluator.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.0}/tests/test_pipeline.py +0 -0
- {quantprobe-1.14.0 → quantprobe-1.15.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.15.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
|
|
@@ -118,7 +118,7 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
118
118
|
## When quantprobe won't help you
|
|
119
119
|
|
|
120
120
|
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
121
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well
|
|
121
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. Across 8 models and 13 benchmarks, real speed landed between **0.91× and 1.84× the prediction** — usually faster, so read that row as a floor. One model came in *slower* (gemma4-12b, −9%), so it is a floor with one measured exception rather than a guarantee. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
122
122
|
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
123
123
|
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
124
124
|
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
# quantprobe
|
|
2
|
-
|
|
3
|
-
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
|
-
|
|
5
|
-
[**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)
|
|
6
|
-
|
|
7
|
-
    [](https://x.com/federico_sciuca)
|
|
8
|
-
|
|
9
|
-
## Quickstart
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
pip install quantprobe
|
|
13
|
-
quantprobe plan --model qwen3-30b --bits 2.95
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
[quantprobe] no hardware flags: auto-detected this machine (vram 6GB@192 | ram 16GB@48 | disk 0.5 GB/s).
|
|
18
|
-
|
|
19
|
-
quantprobe plan - Qwen3-30B-A3B @ 2.95-bit on THIS machine [auto-detected]
|
|
20
|
-
model 12.4 GB | active 1.67 GB/token | est. quality cost x1.05 (depth-aware recipe)
|
|
21
|
-
|
|
22
|
-
* 18.9 tok/s split experts: 21%->VRAM, rest->RAM
|
|
23
|
-
18.4 tok/s stream from disk (VRAM+RAM expert cache) [needs an expert-caching runtime]
|
|
24
|
-
16.6 tok/s hybrid: attention->VRAM, experts->RAM [RAM boundary - needs --no-mmap]
|
|
25
|
-
3.0 tok/s stream from disk (cold experts) [exceeds RAM - capacity demo]
|
|
26
|
-
|
|
27
|
-
run it: llama-server -m model.gguf -ngl 99 -ot "blk\.(10|11|…|47)\.ffn_.*_exps\.=CPU" --no-mmap
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Downloads nothing. Takes a second.** No hardware flags needed — it reads your machine. `--model` and `--bits` just say what you're considering; point it at a file you already have with `--gguf model.gguf` instead.
|
|
31
|
-
|
|
32
|
-
Want it to do the whole thing for you?
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
quantprobe auto
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Detects your machine, asks which model you want, picks the best quant for it, downloads it, and launches. No flags to learn.
|
|
39
|
-
|
|
40
|
-
## What it does
|
|
41
|
-
|
|
42
|
-
- **Predicts tok/s before you download** — across every placement (all-VRAM, hybrid, expert-split, CPU, disk-stream) and picks the winner.
|
|
43
|
-
- **Emits the exact command**, including the `-ot` regex most guides get wrong.
|
|
44
|
-
- **Finds free speed in what you already have** — [partial expert offload](#free-speed-you-probably-already-have) and [prompt-lookup speculation](#free-speed-part-two-if-you-write-code) need no new download.
|
|
45
|
-
- **Measures which layers of *your* model break** under compression, then builds a quant that protects them.
|
|
46
|
-
- **Tells you when to stop** — it declines the expensive path on machines that don't need it.
|
|
47
|
-
- Runs on stock [llama.cpp](https://github.com/ggml-org/llama.cpp). No custom runtime, nothing to build.
|
|
48
|
-
|
|
49
|
-
## Fast vs Custom
|
|
50
|
-
|
|
51
|
-
| | **Fast** — `quantprobe auto qwen3-30b` | **Custom** — `quantprobe auto qwen3-30b --custom` |
|
|
52
|
-
|---|---|---|
|
|
53
|
-
| 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 |
|
|
54
|
-
| time | minutes (mostly download) | **~50 min for a 7B, ~10 h for a 35B** — it tells you before starting |
|
|
55
|
-
| disk | one file | source + working files, 3–4× bigger |
|
|
56
|
-
| **speed** | full | **identical** — speed comes from placement, not from the build |
|
|
57
|
-
| **quality** | whatever the community published | **−9% perplexity at the same file size** |
|
|
58
|
-
|
|
59
|
-
**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 says why. Reach for Custom when you're squeezing a model that barely fits (under ~3 bits, where ordinary compression falls off a cliff), when you have a fine-tune nobody has published, or when you need maximum quality at a fixed size.
|
|
60
|
-
|
|
61
|
-
## Free speed you probably already have
|
|
62
|
-
|
|
63
|
-
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:
|
|
64
|
-
|
|
65
|
-
| | all experts → RAM | **partial offload** |
|
|
66
|
-
|---|---|---|
|
|
67
|
-
| generation | 18.35 tok/s | **20.62 tok/s** (+12.4%) |
|
|
68
|
-
| prompt reading | 88 tok/s | **~238 tok/s** (2–3×) |
|
|
69
|
-
|
|
70
|
-
`plan` and `run` compute the cutoff from your *free* VRAM and emit the flags.
|
|
71
|
-
|
|
72
|
-
## Free speed, part two: if you write code
|
|
73
|
-
|
|
74
|
-
`--spec-type ngram-simple` drafts tokens by finding repeated spans in your own context, then verifies them — output is **identical**, it's one flag, nothing is downloaded.
|
|
75
|
-
|
|
76
|
-
| workload | off | ngram on | effect |
|
|
77
|
-
|---|---|---|---|
|
|
78
|
-
| **code** (edit a file, answer restates its input) | 17.72 | **37.17** | **2.10× — decode doubles** |
|
|
79
|
-
| prose (open-ended continuation) | 18.46 | 18.56 | 1.01× — nothing |
|
|
80
|
-
| code, but **MoE with experts in RAM** | 18.18 | 18.81 | 1.03× — the union tax eats it |
|
|
81
|
-
|
|
82
|
-
Copyability is the whole mechanism: code answers repeat their input, prose invents. Turn it on for coding work on a **dense** model; skip it otherwise.
|
|
83
|
-
|
|
84
|
-
## Measured results
|
|
85
|
-
|
|
86
|
-
| result | number |
|
|
87
|
-
|---|---|
|
|
88
|
-
| Qwen3-30B-A3B on a 2016 desktop | **19.3 tok/s** |
|
|
89
|
-
| Same model, partial expert offload | **20.62 tok/s** (+12.4%, free) |
|
|
90
|
-
| Same bytes, different layers protected (Gemma 4 12B) | **byte-identical files, 2.25 ppl apart** |
|
|
91
|
-
| Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
|
|
92
|
-
| GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
|
|
93
|
-
| RAM overclock (XMP, 2133→3000) | dense **+52%** |
|
|
94
|
-
|
|
95
|
-
<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>
|
|
96
|
-
<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>
|
|
97
|
-
|
|
98
|
-
**Every number above was written down as a prediction, published, and only then measured** — including the ones that missed. [All predictions and their verdicts →](preregistrations/) · [the four laws behind them →](LAWS.md)
|
|
99
|
-
|
|
100
|
-
## When quantprobe won't help you
|
|
101
|
-
|
|
102
|
-
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
103
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well
|
|
104
|
-
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
105
|
-
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
106
|
-
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
107
|
-
- **You're on a Mac or a 50-series card.** Those presets are extrapolated, not measured. `quantprobe bench --contribute` turns one into a datapoint.
|
|
108
|
-
- **You need throughput numbers.** Everything here is single-stream decode on one machine; expect ±25% across environments.
|
|
109
|
-
|
|
110
|
-
## Commands
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
quantprobe auto # interactive: detects, asks, decides, runs
|
|
114
|
-
quantprobe plan --gguf model.gguf # predicted tok/s + placement + launch command
|
|
115
|
-
quantprobe hw # what the law sees on THIS machine
|
|
116
|
-
quantprobe run --gguf model.gguf # plan the placement, then launch chat
|
|
117
|
-
quantprobe bench --gguf model.gguf --contribute # predicted vs measured; opt-in datapoint
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
<details>
|
|
121
|
-
<summary>Six more: optimize, target, fetch, quantize, probe, dashboard</summary>
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
quantprobe optimize --tps 20 # cheapest path to a speed target, Pareto-ranked
|
|
125
|
-
quantprobe target --tps 5 --ladder # inverse: target -> smartest model that fits
|
|
126
|
-
quantprobe fetch qwen3-30b ./models # robust, resumable download
|
|
127
|
-
quantprobe quantize --gguf f16.gguf --out 2bit.gguf # build a depth-aware quant
|
|
128
|
-
quantprobe probe --gguf f16.gguf --eval wiki.test.raw # measure YOUR model's fragile band
|
|
129
|
-
quantprobe dashboard --gguf 2bit.gguf # the law live, every reply scored vs prediction
|
|
130
|
-
```
|
|
131
|
-
</details>
|
|
132
|
-
|
|
133
|
-
`hw`/`plan`/`target`/`optimize` need nothing but Python. The weight-touching commands drive stock llama.cpp — point at it with `--llama-dir`, `QUANTPROBE_LLAMA_DIR`, or `PATH`, and preview anything with `--dry`. 17 machine presets ship in (`--machine`); multi-GPU and RAID aggregate with comma lists (`--vram 24,24`).
|
|
134
|
-
|
|
135
|
-
> **Windows: `'quantprobe' is not recognized`?** pip put it in a folder that isn't on your PATH. Use `python -m quantprobe ...` — identical, always works.
|
|
136
|
-
|
|
137
|
-
## Contributing
|
|
138
|
-
|
|
139
|
-
`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, and there are [open predictions](preregistrations/) anyone can settle.
|
|
140
|
-
|
|
141
|
-
## Docs
|
|
142
|
-
|
|
143
|
-
| | |
|
|
144
|
-
|---|---|
|
|
145
|
-
| [QUICKSTART.md](QUICKSTART.md) | get running, three levels; recipes for fine-tunes, coding agents, hardware buying |
|
|
146
|
-
| [LAWS.md](LAWS.md) | the four laws — statements, measurements, falsifiable predictions |
|
|
147
|
-
| [docs/EXAMPLES.md](docs/EXAMPLES.md) | worked examples with real output, including the ×5.4 optimizer A/B |
|
|
148
|
-
| [docs/HARDWARE.md](docs/HARDWARE.md) | the 2016 box: exact specs, measured bandwidths, what the next euro buys |
|
|
149
|
-
| [preregistrations/](preregistrations/) | every staked prediction with its verdict — hits **and** misses |
|
|
150
|
-
| [CONTRIBUTING.md](CONTRIBUTING.md) | the method: stake, measure, score *and wire*, audit |
|
|
151
|
-
| [docs/DEEP-DIVE.md](docs/DEEP-DIVE.md) | what's new vs. built-on, parity tables, and the repository map |
|
|
152
|
-
| [papers/arxiv/](papers/arxiv/) | the paper (submission-ready LaTeX) |
|
|
153
|
-
| [CHANGELOG.md](CHANGELOG.md) | every release, including corrections to numbers published here |
|
|
154
|
-
|
|
155
|
-
## Credits
|
|
156
|
-
|
|
157
|
-
[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.
|
|
158
|
-
|
|
159
|
-
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.
|
|
160
|
-
|
|
161
|
-
## License
|
|
162
|
-
|
|
163
|
-
MIT — see [LICENSE](LICENSE). © 2026 Federico Sciuca.
|
|
1
|
+
# quantprobe
|
|
2
|
+
|
|
3
|
+
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
|
+
|
|
5
|
+
[**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)
|
|
6
|
+
|
|
7
|
+
    [](https://x.com/federico_sciuca)
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install quantprobe
|
|
13
|
+
quantprobe plan --model qwen3-30b --bits 2.95
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
[quantprobe] no hardware flags: auto-detected this machine (vram 6GB@192 | ram 16GB@48 | disk 0.5 GB/s).
|
|
18
|
+
|
|
19
|
+
quantprobe plan - Qwen3-30B-A3B @ 2.95-bit on THIS machine [auto-detected]
|
|
20
|
+
model 12.4 GB | active 1.67 GB/token | est. quality cost x1.05 (depth-aware recipe)
|
|
21
|
+
|
|
22
|
+
* 18.9 tok/s split experts: 21%->VRAM, rest->RAM
|
|
23
|
+
18.4 tok/s stream from disk (VRAM+RAM expert cache) [needs an expert-caching runtime]
|
|
24
|
+
16.6 tok/s hybrid: attention->VRAM, experts->RAM [RAM boundary - needs --no-mmap]
|
|
25
|
+
3.0 tok/s stream from disk (cold experts) [exceeds RAM - capacity demo]
|
|
26
|
+
|
|
27
|
+
run it: llama-server -m model.gguf -ngl 99 -ot "blk\.(10|11|…|47)\.ffn_.*_exps\.=CPU" --no-mmap
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Downloads nothing. Takes a second.** No hardware flags needed — it reads your machine. `--model` and `--bits` just say what you're considering; point it at a file you already have with `--gguf model.gguf` instead.
|
|
31
|
+
|
|
32
|
+
Want it to do the whole thing for you?
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
quantprobe auto
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Detects your machine, asks which model you want, picks the best quant for it, downloads it, and launches. No flags to learn.
|
|
39
|
+
|
|
40
|
+
## What it does
|
|
41
|
+
|
|
42
|
+
- **Predicts tok/s before you download** — across every placement (all-VRAM, hybrid, expert-split, CPU, disk-stream) and picks the winner.
|
|
43
|
+
- **Emits the exact command**, including the `-ot` regex most guides get wrong.
|
|
44
|
+
- **Finds free speed in what you already have** — [partial expert offload](#free-speed-you-probably-already-have) and [prompt-lookup speculation](#free-speed-part-two-if-you-write-code) need no new download.
|
|
45
|
+
- **Measures which layers of *your* model break** under compression, then builds a quant that protects them.
|
|
46
|
+
- **Tells you when to stop** — it declines the expensive path on machines that don't need it.
|
|
47
|
+
- Runs on stock [llama.cpp](https://github.com/ggml-org/llama.cpp). No custom runtime, nothing to build.
|
|
48
|
+
|
|
49
|
+
## Fast vs Custom
|
|
50
|
+
|
|
51
|
+
| | **Fast** — `quantprobe auto qwen3-30b` | **Custom** — `quantprobe auto qwen3-30b --custom` |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| 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 |
|
|
54
|
+
| time | minutes (mostly download) | **~50 min for a 7B, ~10 h for a 35B** — it tells you before starting |
|
|
55
|
+
| disk | one file | source + working files, 3–4× bigger |
|
|
56
|
+
| **speed** | full | **identical** — speed comes from placement, not from the build |
|
|
57
|
+
| **quality** | whatever the community published | **−9% perplexity at the same file size** |
|
|
58
|
+
|
|
59
|
+
**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 says why. Reach for Custom when you're squeezing a model that barely fits (under ~3 bits, where ordinary compression falls off a cliff), when you have a fine-tune nobody has published, or when you need maximum quality at a fixed size.
|
|
60
|
+
|
|
61
|
+
## Free speed you probably already have
|
|
62
|
+
|
|
63
|
+
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:
|
|
64
|
+
|
|
65
|
+
| | all experts → RAM | **partial offload** |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| generation | 18.35 tok/s | **20.62 tok/s** (+12.4%) |
|
|
68
|
+
| prompt reading | 88 tok/s | **~238 tok/s** (2–3×) |
|
|
69
|
+
|
|
70
|
+
`plan` and `run` compute the cutoff from your *free* VRAM and emit the flags.
|
|
71
|
+
|
|
72
|
+
## Free speed, part two: if you write code
|
|
73
|
+
|
|
74
|
+
`--spec-type ngram-simple` drafts tokens by finding repeated spans in your own context, then verifies them — output is **identical**, it's one flag, nothing is downloaded.
|
|
75
|
+
|
|
76
|
+
| workload | off | ngram on | effect |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| **code** (edit a file, answer restates its input) | 17.72 | **37.17** | **2.10× — decode doubles** |
|
|
79
|
+
| prose (open-ended continuation) | 18.46 | 18.56 | 1.01× — nothing |
|
|
80
|
+
| code, but **MoE with experts in RAM** | 18.18 | 18.81 | 1.03× — the union tax eats it |
|
|
81
|
+
|
|
82
|
+
Copyability is the whole mechanism: code answers repeat their input, prose invents. Turn it on for coding work on a **dense** model; skip it otherwise.
|
|
83
|
+
|
|
84
|
+
## Measured results
|
|
85
|
+
|
|
86
|
+
| result | number |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Qwen3-30B-A3B on a 2016 desktop | **19.3 tok/s** |
|
|
89
|
+
| Same model, partial expert offload | **20.62 tok/s** (+12.4%, free) |
|
|
90
|
+
| Same bytes, different layers protected (Gemma 4 12B) | **byte-identical files, 2.25 ppl apart** |
|
|
91
|
+
| Gemma 4 12B depth-aware 2-bit | 1.91× → **1.45×** quality cost, ~4.5 GB resident |
|
|
92
|
+
| GLM-4.5-Air **110B** from a SATA drive, 16 GB RAM | **0.19 tok/s** (capacity demo, not usable inference) |
|
|
93
|
+
| RAM overclock (XMP, 2133→3000) | dense **+52%** |
|
|
94
|
+
|
|
95
|
+
<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>
|
|
96
|
+
<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>
|
|
97
|
+
|
|
98
|
+
**Every number above was written down as a prediction, published, and only then measured** — including the ones that missed. [All predictions and their verdicts →](preregistrations/) · [the four laws behind them →](LAWS.md)
|
|
99
|
+
|
|
100
|
+
## When quantprobe won't help you
|
|
101
|
+
|
|
102
|
+
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
103
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. Across 8 models and 13 benchmarks, real speed landed between **0.91× and 1.84× the prediction** — usually faster, so read that row as a floor. One model came in *slower* (gemma4-12b, −9%), so it is a floor with one measured exception rather than a guarantee. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
104
|
+
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
105
|
+
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
106
|
+
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
107
|
+
- **You're on a Mac or a 50-series card.** Those presets are extrapolated, not measured. `quantprobe bench --contribute` turns one into a datapoint.
|
|
108
|
+
- **You need throughput numbers.** Everything here is single-stream decode on one machine; expect ±25% across environments.
|
|
109
|
+
|
|
110
|
+
## Commands
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
quantprobe auto # interactive: detects, asks, decides, runs
|
|
114
|
+
quantprobe plan --gguf model.gguf # predicted tok/s + placement + launch command
|
|
115
|
+
quantprobe hw # what the law sees on THIS machine
|
|
116
|
+
quantprobe run --gguf model.gguf # plan the placement, then launch chat
|
|
117
|
+
quantprobe bench --gguf model.gguf --contribute # predicted vs measured; opt-in datapoint
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
<details>
|
|
121
|
+
<summary>Six more: optimize, target, fetch, quantize, probe, dashboard</summary>
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
quantprobe optimize --tps 20 # cheapest path to a speed target, Pareto-ranked
|
|
125
|
+
quantprobe target --tps 5 --ladder # inverse: target -> smartest model that fits
|
|
126
|
+
quantprobe fetch qwen3-30b ./models # robust, resumable download
|
|
127
|
+
quantprobe quantize --gguf f16.gguf --out 2bit.gguf # build a depth-aware quant
|
|
128
|
+
quantprobe probe --gguf f16.gguf --eval wiki.test.raw # measure YOUR model's fragile band
|
|
129
|
+
quantprobe dashboard --gguf 2bit.gguf # the law live, every reply scored vs prediction
|
|
130
|
+
```
|
|
131
|
+
</details>
|
|
132
|
+
|
|
133
|
+
`hw`/`plan`/`target`/`optimize` need nothing but Python. The weight-touching commands drive stock llama.cpp — point at it with `--llama-dir`, `QUANTPROBE_LLAMA_DIR`, or `PATH`, and preview anything with `--dry`. 17 machine presets ship in (`--machine`); multi-GPU and RAID aggregate with comma lists (`--vram 24,24`).
|
|
134
|
+
|
|
135
|
+
> **Windows: `'quantprobe' is not recognized`?** pip put it in a folder that isn't on your PATH. Use `python -m quantprobe ...` — identical, always works.
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
`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, and there are [open predictions](preregistrations/) anyone can settle.
|
|
140
|
+
|
|
141
|
+
## Docs
|
|
142
|
+
|
|
143
|
+
| | |
|
|
144
|
+
|---|---|
|
|
145
|
+
| [QUICKSTART.md](QUICKSTART.md) | get running, three levels; recipes for fine-tunes, coding agents, hardware buying |
|
|
146
|
+
| [LAWS.md](LAWS.md) | the four laws — statements, measurements, falsifiable predictions |
|
|
147
|
+
| [docs/EXAMPLES.md](docs/EXAMPLES.md) | worked examples with real output, including the ×5.4 optimizer A/B |
|
|
148
|
+
| [docs/HARDWARE.md](docs/HARDWARE.md) | the 2016 box: exact specs, measured bandwidths, what the next euro buys |
|
|
149
|
+
| [preregistrations/](preregistrations/) | every staked prediction with its verdict — hits **and** misses |
|
|
150
|
+
| [CONTRIBUTING.md](CONTRIBUTING.md) | the method: stake, measure, score *and wire*, audit |
|
|
151
|
+
| [docs/DEEP-DIVE.md](docs/DEEP-DIVE.md) | what's new vs. built-on, parity tables, and the repository map |
|
|
152
|
+
| [papers/arxiv/](papers/arxiv/) | the paper (submission-ready LaTeX) |
|
|
153
|
+
| [CHANGELOG.md](CHANGELOG.md) | every release, including corrections to numbers published here |
|
|
154
|
+
|
|
155
|
+
## Credits
|
|
156
|
+
|
|
157
|
+
[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.
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT — see [LICENSE](LICENSE). © 2026 Federico Sciuca.
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "quantprobe"
|
|
7
|
-
version = "1.
|
|
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
|
-
readme = "README.md"
|
|
10
|
-
license = { text = "MIT" }
|
|
11
|
-
authors = [{ name = "Federico Sciuca" }]
|
|
12
|
-
requires-python = ">=3.9"
|
|
13
|
-
dependencies = ["gguf>=0.9", "requests>=2.28"]
|
|
14
|
-
keywords = ["llm", "quantization", "llama.cpp", "gguf", "inference", "moe"]
|
|
15
|
-
classifiers = [
|
|
16
|
-
"License :: OSI Approved :: MIT License",
|
|
17
|
-
"Programming Language :: Python :: 3",
|
|
18
|
-
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
[project.urls]
|
|
22
|
-
Homepage = "https://github.com/FedericoTs/quantprobe"
|
|
23
|
-
|
|
24
|
-
[project.scripts]
|
|
25
|
-
quantprobe = "quantprobe.cli:main"
|
|
26
|
-
|
|
27
|
-
[tool.setuptools]
|
|
28
|
-
packages = ["quantprobe"]
|
|
29
|
-
|
|
30
|
-
[tool.setuptools.package-data]
|
|
31
|
-
quantprobe = ["recipes/*.json"]
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quantprobe"
|
|
7
|
+
version = "1.15.0"
|
|
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
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "Federico Sciuca" }]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = ["gguf>=0.9", "requests>=2.28"]
|
|
14
|
+
keywords = ["llm", "quantization", "llama.cpp", "gguf", "inference", "moe"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/FedericoTs/quantprobe"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
quantprobe = "quantprobe.cli:main"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools]
|
|
28
|
+
packages = ["quantprobe"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-data]
|
|
31
|
+
quantprobe = ["recipes/*.json"]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""quantprobe - probe-then-quantize for LLMs on commodity hardware.
|
|
2
|
-
|
|
3
|
-
Three commands, all grounded in measured laws (see LAWS.md in the repo):
|
|
4
|
-
quantprobe probe - measure a GGUF's depth-fragility curve, emit the depth-aware recipe (Law 3)
|
|
5
|
-
quantprobe plan - evaluate every bit/tier placement for a model on your machine, predict tok/s (Law 4)
|
|
6
|
-
quantprobe fetch - robust HuggingFace downloader (Range-resume, retry)
|
|
7
|
-
|
|
8
|
-
Every constant in `plan` is fitted from measurements published in the repo, including two
|
|
9
|
-
pre-registered hardware predictions confirmed within 8%.
|
|
10
|
-
"""
|
|
11
|
-
__version__ = "1.
|
|
1
|
+
"""quantprobe - probe-then-quantize for LLMs on commodity hardware.
|
|
2
|
+
|
|
3
|
+
Three commands, all grounded in measured laws (see LAWS.md in the repo):
|
|
4
|
+
quantprobe probe - measure a GGUF's depth-fragility curve, emit the depth-aware recipe (Law 3)
|
|
5
|
+
quantprobe plan - evaluate every bit/tier placement for a model on your machine, predict tok/s (Law 4)
|
|
6
|
+
quantprobe fetch - robust HuggingFace downloader (Range-resume, retry)
|
|
7
|
+
|
|
8
|
+
Every constant in `plan` is fitted from measurements published in the repo, including two
|
|
9
|
+
pre-registered hardware predictions confirmed within 8%.
|
|
10
|
+
"""
|
|
11
|
+
__version__ = "1.15.0"
|
|
@@ -1,154 +1,156 @@
|
|
|
1
|
-
"""quantprobe optimize - the cheapest path to a target speed.
|
|
2
|
-
|
|
3
|
-
A pure SEARCH LAYER over the frozen decode law: enumerate lever combinations, price each with
|
|
4
|
-
plan.evaluate(), rank by (meets target, quality cost, euros, speed). The law is never modified -
|
|
5
|
-
the optimizer only reads it, so every published anchor is untouchable by construction.
|
|
6
|
-
|
|
7
|
-
Levers and their measured gates:
|
|
8
|
-
bits effective bits/weight ladder, priced with the DEPTH-AWARE quality curve (measured;
|
|
9
|
-
uniform quantization costs ~1.3x more quality at <=2.5 bits - Gemma 1.91x vs 1.45x)
|
|
10
|
-
kv-q8 quantized K-cache (kvp x0.75). GATED OFF on weak-decode GPUs: measured -83%
|
|
11
|
-
at 16k depth on Pascal (2026-07-24, no flash attention -> per-token dequant tax).
|
|
12
|
-
Offered [est] only where geta >= 0.5; verify with `bench --depth`.
|
|
13
|
-
prune REAP-class 50% expert pruning (total x0.82, file shrinks, active bytes UNCHANGED).
|
|
14
|
-
Measured +39% out-of-domain perplexity (pre-registration #8) - domain-specialized,
|
|
15
|
-
never ranked first without --allow-prune.
|
|
16
|
-
hardware upgrade deltas from the projections table: XMP (free), +16GB RAM, NVMe. Ranked by
|
|
17
|
-
relative cost internally; no currency figures are shown (region- and time-dependent).
|
|
18
|
-
"""
|
|
19
|
-
from __future__ import annotations
|
|
20
|
-
from . import plan as planmod
|
|
21
|
-
|
|
22
|
-
BITS_LADDER = [2.0, 2.5, 3.0, 3.5, 4.5]
|
|
23
|
-
REALIZE = {
|
|
24
|
-
2.0: 'quantize --gguf <f16> --protect-late 8 (base Q2_K, narrow probed band)',
|
|
25
|
-
2.5: 'quantize --gguf <f16> --protect-late 12 (base Q2_K - the validated default)',
|
|
26
|
-
3.0: 'quantize --gguf <f16> --protect-late 20 (or base Q3_K_S)',
|
|
27
|
-
3.5: 'fetch a Q3_K_M and probe --apply',
|
|
28
|
-
4.5: 'fetch a Q4_K_M (straight; no probe needed at 4-bit)',
|
|
29
|
-
}
|
|
30
|
-
HW_DELTAS = [
|
|
31
|
-
("as-is", 0, {}),
|
|
32
|
-
("+16GB RAM (used)", 40, {"rc": +16}),
|
|
33
|
-
("NVMe SSD", 100, {"db_min": 3.5}),
|
|
34
|
-
("+RAM & NVMe", 140, {"rc": +16, "db_min": 3.5}),
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def resolve(a):
|
|
39
|
-
planmod.check_presets(a)
|
|
40
|
-
"""Model + machine resolution, same semantics as plan.run (autospec + autodetect included)."""
|
|
41
|
-
from . import spec as specmod
|
|
42
|
-
specmod.apply(a, quiet=True)
|
|
43
|
-
if getattr(a, "bits", None) is None:
|
|
44
|
-
a.bits = 2.5
|
|
45
|
-
m = dict(planmod.MODELS[a.model]) if getattr(a, "model", None) in planmod.MODELS else {}
|
|
46
|
-
t = a.total or m.get("t") or 13.0
|
|
47
|
-
ac = a.active or m.get("a") or t
|
|
48
|
-
ne = a.always_active or m.get("ne") or (ac if ac >= t * 0.9 else ac * 0.35)
|
|
49
|
-
moe = m.get("moe", ac < t * 0.9)
|
|
50
|
-
hw = dict(planmod.MACHINES[a.machine]) if getattr(a, "machine", None) in planmod.MACHINES else {}
|
|
51
|
-
if not hw and all(getattr(a, k, None) is None for k in ("vram", "vram_bw", "ram", "ram_bw", "disk_bw")):
|
|
52
|
-
from . import detect as detmod
|
|
53
|
-
auto, _ = detmod.detect()
|
|
54
|
-
hw = dict(vc=auto["vram"], vb=auto["vram_bw"], rc=auto["ram"], rb=auto["ram_bw"],
|
|
55
|
-
db=auto["disk_bw"], geta=auto.get("geta", 0.45), gl=auto.get("gl"),
|
|
56
|
-
hint="THIS machine [auto-detected]")
|
|
57
|
-
print("[quantprobe] hardware auto-detected (pass --machine/flags to optimize another box)")
|
|
58
|
-
vc = planmod.agg_cap(a.vram) if a.vram is not None else hw.get("vc", 0)
|
|
59
|
-
vb = planmod.agg_bw(a.vram_bw, 0.85) if a.vram_bw is not None else hw.get("vb", 0)
|
|
60
|
-
rc = a.ram if a.ram is not None else hw.get("rc", 16)
|
|
61
|
-
rb = a.ram_bw if a.ram_bw is not None else hw.get("rb", 40)
|
|
62
|
-
db = planmod.agg_bw(a.disk_bw, 0.75) if a.disk_bw is not None else hw.get("db", 0.5)
|
|
63
|
-
geta = hw.get("geta", 0.45); gl = hw.get("gl")
|
|
64
|
-
ctx = getattr(a, "ctx", 0) or 0
|
|
65
|
-
kvp = (a.kv_per_pos * 1024 if getattr(a, "kv_per_pos", None) else m.get("kvp", planmod.DEFAULT_KVP))
|
|
66
|
-
return m, t, ac, ne, moe, (vc or 0, vb or 0, rc or 16, rb or 40, db or 0.5, geta, gl), ctx, kvp
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def run(a):
|
|
70
|
-
m, t, ac, ne, moe, (vc, vb, rc, rb, db, geta, gl), ctx, kvp = resolve(a)
|
|
71
|
-
tgt = getattr(a, "tps", None)
|
|
72
|
-
maxq = getattr(a, "max_quality", None) or 1.12
|
|
73
|
-
allow_prune = getattr(a, "allow_prune", False)
|
|
74
|
-
kvq_ok = geta >= 0.5 # measured gate: Pascal-class collapses (-83% @16k)
|
|
75
|
-
rows = []
|
|
76
|
-
for hw_name, euro, delta in HW_DELTAS:
|
|
77
|
-
rc2 = rc + delta.get("rc", 0)
|
|
78
|
-
db2 = max(db, delta.get("db_min", db))
|
|
79
|
-
if euro and rc2 == rc and db2 == db:
|
|
80
|
-
continue # delta changes nothing on this box
|
|
81
|
-
for bits in BITS_LADDER:
|
|
82
|
-
for prune, pf in ((False, 1.0),) + (((True, 0.82),) if allow_prune and moe else ()):
|
|
83
|
-
for kvq, kf in ((False, 1.0),) + (((True, 0.75),) if kvq_ok and ctx > 0 else ()):
|
|
84
|
-
q = planmod.qual_of(moe, bits) * (1.0 if not prune else 1.0) # in-domain qual; OOD flagged in text
|
|
85
|
-
if q > maxq:
|
|
86
|
-
continue
|
|
87
|
-
_, _, cfgs = planmod.evaluate(t * pf, ac, ne, moe, bits, vc, vb, rc2, rb, db2,
|
|
88
|
-
geta, 1.0, gl, ctx=ctx, kvp=kvp * kf,
|
|
89
|
-
n_layer=planmod.effective_n_layer(a, m))
|
|
90
|
-
if not cfgs:
|
|
91
|
-
continue
|
|
92
|
-
if not getattr(a, "any_runtime", False):
|
|
93
|
-
cfgs = [c for c in cfgs if "expert cache" not in c[0]] or cfgs
|
|
94
|
-
name, tps, warn, flags = cfgs[0]
|
|
95
|
-
desc = f"{bits:g}-bit depth-aware + {name}"
|
|
96
|
-
tags = []
|
|
97
|
-
if prune:
|
|
98
|
-
tags.append("PRUNED: +39% out-of-domain ppl measured - domain use only")
|
|
99
|
-
if kvq:
|
|
100
|
-
tags.append("KV q8 [est - needs FA; measured trap on Pascal-class]")
|
|
101
|
-
if hw_name != "as-is":
|
|
102
|
-
desc += f" + {hw_name}"
|
|
103
|
-
rows.append(dict(tps=tps, q=q, euro=euro, bits=bits, desc=desc,
|
|
104
|
-
tags=tags, flags=flags, warn=warn))
|
|
105
|
-
# Pareto: drop rows beaten on every axis
|
|
106
|
-
keep = []
|
|
107
|
-
for r in sorted(rows, key=lambda x: (-x["tps"], x["q"], x["euro"])):
|
|
108
|
-
if not any(k["tps"] >= r["tps"] and k["q"] <= r["q"] and k["euro"] <= r["euro"]
|
|
109
|
-
and (k["tps"], k["q"], k["euro"]) != (r["tps"], r["q"], r["euro"]) for k in keep):
|
|
110
|
-
keep.append(r)
|
|
111
|
-
if tgt:
|
|
112
|
-
meeting = [r for r in keep if r["tps"] >= tgt]
|
|
113
|
-
ranked = (sorted(meeting, key=lambda x: (x["q"], x["euro"], -x["tps"])) or
|
|
114
|
-
sorted(keep, key=lambda x: -x["tps"])[:1])
|
|
115
|
-
headline = "cheapest configuration meeting the target" if meeting else \
|
|
116
|
-
"TARGET NOT REACHABLE on this hardware - fastest available:"
|
|
117
|
-
else:
|
|
118
|
-
ranked = sorted(keep, key=lambda x: (-x["tps"], x["q"], x["euro"]))
|
|
119
|
-
headline = "speed frontier (quality ceiling x%.2f)" % maxq
|
|
120
|
-
print(f"\nquantprobe optimize - {m.get('hint', 'custom model')} on "
|
|
121
|
-
f"{'this machine' if not getattr(a, 'machine', None) else a.machine}"
|
|
122
|
-
+ (f" | target {tgt:g} tok/s" if tgt else "") + (f" | ctx {ctx}" if ctx else ""))
|
|
123
|
-
print(f" {headline}\n")
|
|
124
|
-
for i, r in enumerate(ranked[:6]):
|
|
125
|
-
star = "*" if i == 0 else " "
|
|
126
|
-
euro = "free" if r["euro"] == 0 else "hw upgrade"
|
|
127
|
-
print(f" {star} {r['tps']:6.1f} tok/s quality x{r['q']:.2f} {euro:>7s} {r['desc']}")
|
|
128
|
-
for tag in r["tags"]:
|
|
129
|
-
print(f" [{tag}]")
|
|
130
|
-
best = ranked[0]
|
|
131
|
-
# This ranking is at its most misleading exactly here. It orders by a bandwidth model, so when
|
|
132
|
-
# everything fits in VRAM it puts 2-bit above 4.5-bit (305 vs 197 tok/s on a 24 GB card).
|
|
133
|
-
# Measured, that gap does not exist: same 7B, all in VRAM, Q2_K vs Q4_K_M is 36% smaller and
|
|
134
|
-
# 4% SLOWER (pre-registration #16). `plan` already says so; `optimize` is the command that
|
|
135
|
-
# actually does the ranking, so it has to say so too - a warning only one of two commands
|
|
136
|
-
# gives is the inconsistency class that cost us the plan-vs-bench correction.
|
|
137
|
-
roomier = next((r for r in ranked if r["bits"] >= 4.5 and "all in VRAM" in r["desc"]), None)
|
|
138
|
-
if "all in VRAM" in best["desc"]:
|
|
139
|
-
print(f"\n note: all-in-VRAM is the placement our law knows least well
|
|
140
|
-
print(f"
|
|
141
|
-
print(f"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
print(f"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
print(f"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
print(f"
|
|
152
|
-
print("
|
|
153
|
-
print("
|
|
154
|
-
|
|
1
|
+
"""quantprobe optimize - the cheapest path to a target speed.
|
|
2
|
+
|
|
3
|
+
A pure SEARCH LAYER over the frozen decode law: enumerate lever combinations, price each with
|
|
4
|
+
plan.evaluate(), rank by (meets target, quality cost, euros, speed). The law is never modified -
|
|
5
|
+
the optimizer only reads it, so every published anchor is untouchable by construction.
|
|
6
|
+
|
|
7
|
+
Levers and their measured gates:
|
|
8
|
+
bits effective bits/weight ladder, priced with the DEPTH-AWARE quality curve (measured;
|
|
9
|
+
uniform quantization costs ~1.3x more quality at <=2.5 bits - Gemma 1.91x vs 1.45x)
|
|
10
|
+
kv-q8 quantized K-cache (kvp x0.75). GATED OFF on weak-decode GPUs: measured -83%
|
|
11
|
+
at 16k depth on Pascal (2026-07-24, no flash attention -> per-token dequant tax).
|
|
12
|
+
Offered [est] only where geta >= 0.5; verify with `bench --depth`.
|
|
13
|
+
prune REAP-class 50% expert pruning (total x0.82, file shrinks, active bytes UNCHANGED).
|
|
14
|
+
Measured +39% out-of-domain perplexity (pre-registration #8) - domain-specialized,
|
|
15
|
+
never ranked first without --allow-prune.
|
|
16
|
+
hardware upgrade deltas from the projections table: XMP (free), +16GB RAM, NVMe. Ranked by
|
|
17
|
+
relative cost internally; no currency figures are shown (region- and time-dependent).
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
from . import plan as planmod
|
|
21
|
+
|
|
22
|
+
BITS_LADDER = [2.0, 2.5, 3.0, 3.5, 4.5]
|
|
23
|
+
REALIZE = {
|
|
24
|
+
2.0: 'quantize --gguf <f16> --protect-late 8 (base Q2_K, narrow probed band)',
|
|
25
|
+
2.5: 'quantize --gguf <f16> --protect-late 12 (base Q2_K - the validated default)',
|
|
26
|
+
3.0: 'quantize --gguf <f16> --protect-late 20 (or base Q3_K_S)',
|
|
27
|
+
3.5: 'fetch a Q3_K_M and probe --apply',
|
|
28
|
+
4.5: 'fetch a Q4_K_M (straight; no probe needed at 4-bit)',
|
|
29
|
+
}
|
|
30
|
+
HW_DELTAS = [
|
|
31
|
+
("as-is", 0, {}),
|
|
32
|
+
("+16GB RAM (used)", 40, {"rc": +16}),
|
|
33
|
+
("NVMe SSD", 100, {"db_min": 3.5}),
|
|
34
|
+
("+RAM & NVMe", 140, {"rc": +16, "db_min": 3.5}),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def resolve(a):
|
|
39
|
+
planmod.check_presets(a)
|
|
40
|
+
"""Model + machine resolution, same semantics as plan.run (autospec + autodetect included)."""
|
|
41
|
+
from . import spec as specmod
|
|
42
|
+
specmod.apply(a, quiet=True)
|
|
43
|
+
if getattr(a, "bits", None) is None:
|
|
44
|
+
a.bits = 2.5
|
|
45
|
+
m = dict(planmod.MODELS[a.model]) if getattr(a, "model", None) in planmod.MODELS else {}
|
|
46
|
+
t = a.total or m.get("t") or 13.0
|
|
47
|
+
ac = a.active or m.get("a") or t
|
|
48
|
+
ne = a.always_active or m.get("ne") or (ac if ac >= t * 0.9 else ac * 0.35)
|
|
49
|
+
moe = m.get("moe", ac < t * 0.9)
|
|
50
|
+
hw = dict(planmod.MACHINES[a.machine]) if getattr(a, "machine", None) in planmod.MACHINES else {}
|
|
51
|
+
if not hw and all(getattr(a, k, None) is None for k in ("vram", "vram_bw", "ram", "ram_bw", "disk_bw")):
|
|
52
|
+
from . import detect as detmod
|
|
53
|
+
auto, _ = detmod.detect()
|
|
54
|
+
hw = dict(vc=auto["vram"], vb=auto["vram_bw"], rc=auto["ram"], rb=auto["ram_bw"],
|
|
55
|
+
db=auto["disk_bw"], geta=auto.get("geta", 0.45), gl=auto.get("gl"),
|
|
56
|
+
hint="THIS machine [auto-detected]")
|
|
57
|
+
print("[quantprobe] hardware auto-detected (pass --machine/flags to optimize another box)")
|
|
58
|
+
vc = planmod.agg_cap(a.vram) if a.vram is not None else hw.get("vc", 0)
|
|
59
|
+
vb = planmod.agg_bw(a.vram_bw, 0.85) if a.vram_bw is not None else hw.get("vb", 0)
|
|
60
|
+
rc = a.ram if a.ram is not None else hw.get("rc", 16)
|
|
61
|
+
rb = a.ram_bw if a.ram_bw is not None else hw.get("rb", 40)
|
|
62
|
+
db = planmod.agg_bw(a.disk_bw, 0.75) if a.disk_bw is not None else hw.get("db", 0.5)
|
|
63
|
+
geta = hw.get("geta", 0.45); gl = hw.get("gl")
|
|
64
|
+
ctx = getattr(a, "ctx", 0) or 0
|
|
65
|
+
kvp = (a.kv_per_pos * 1024 if getattr(a, "kv_per_pos", None) else m.get("kvp", planmod.DEFAULT_KVP))
|
|
66
|
+
return m, t, ac, ne, moe, (vc or 0, vb or 0, rc or 16, rb or 40, db or 0.5, geta, gl), ctx, kvp
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def run(a):
|
|
70
|
+
m, t, ac, ne, moe, (vc, vb, rc, rb, db, geta, gl), ctx, kvp = resolve(a)
|
|
71
|
+
tgt = getattr(a, "tps", None)
|
|
72
|
+
maxq = getattr(a, "max_quality", None) or 1.12
|
|
73
|
+
allow_prune = getattr(a, "allow_prune", False)
|
|
74
|
+
kvq_ok = geta >= 0.5 # measured gate: Pascal-class collapses (-83% @16k)
|
|
75
|
+
rows = []
|
|
76
|
+
for hw_name, euro, delta in HW_DELTAS:
|
|
77
|
+
rc2 = rc + delta.get("rc", 0)
|
|
78
|
+
db2 = max(db, delta.get("db_min", db))
|
|
79
|
+
if euro and rc2 == rc and db2 == db:
|
|
80
|
+
continue # delta changes nothing on this box
|
|
81
|
+
for bits in BITS_LADDER:
|
|
82
|
+
for prune, pf in ((False, 1.0),) + (((True, 0.82),) if allow_prune and moe else ()):
|
|
83
|
+
for kvq, kf in ((False, 1.0),) + (((True, 0.75),) if kvq_ok and ctx > 0 else ()):
|
|
84
|
+
q = planmod.qual_of(moe, bits) * (1.0 if not prune else 1.0) # in-domain qual; OOD flagged in text
|
|
85
|
+
if q > maxq:
|
|
86
|
+
continue
|
|
87
|
+
_, _, cfgs = planmod.evaluate(t * pf, ac, ne, moe, bits, vc, vb, rc2, rb, db2,
|
|
88
|
+
geta, 1.0, gl, ctx=ctx, kvp=kvp * kf,
|
|
89
|
+
n_layer=planmod.effective_n_layer(a, m))
|
|
90
|
+
if not cfgs:
|
|
91
|
+
continue
|
|
92
|
+
if not getattr(a, "any_runtime", False):
|
|
93
|
+
cfgs = [c for c in cfgs if "expert cache" not in c[0]] or cfgs
|
|
94
|
+
name, tps, warn, flags = cfgs[0]
|
|
95
|
+
desc = f"{bits:g}-bit depth-aware + {name}"
|
|
96
|
+
tags = []
|
|
97
|
+
if prune:
|
|
98
|
+
tags.append("PRUNED: +39% out-of-domain ppl measured - domain use only")
|
|
99
|
+
if kvq:
|
|
100
|
+
tags.append("KV q8 [est - needs FA; measured trap on Pascal-class]")
|
|
101
|
+
if hw_name != "as-is":
|
|
102
|
+
desc += f" + {hw_name}"
|
|
103
|
+
rows.append(dict(tps=tps, q=q, euro=euro, bits=bits, desc=desc,
|
|
104
|
+
tags=tags, flags=flags, warn=warn))
|
|
105
|
+
# Pareto: drop rows beaten on every axis
|
|
106
|
+
keep = []
|
|
107
|
+
for r in sorted(rows, key=lambda x: (-x["tps"], x["q"], x["euro"])):
|
|
108
|
+
if not any(k["tps"] >= r["tps"] and k["q"] <= r["q"] and k["euro"] <= r["euro"]
|
|
109
|
+
and (k["tps"], k["q"], k["euro"]) != (r["tps"], r["q"], r["euro"]) for k in keep):
|
|
110
|
+
keep.append(r)
|
|
111
|
+
if tgt:
|
|
112
|
+
meeting = [r for r in keep if r["tps"] >= tgt]
|
|
113
|
+
ranked = (sorted(meeting, key=lambda x: (x["q"], x["euro"], -x["tps"])) or
|
|
114
|
+
sorted(keep, key=lambda x: -x["tps"])[:1])
|
|
115
|
+
headline = "cheapest configuration meeting the target" if meeting else \
|
|
116
|
+
"TARGET NOT REACHABLE on this hardware - fastest available:"
|
|
117
|
+
else:
|
|
118
|
+
ranked = sorted(keep, key=lambda x: (-x["tps"], x["q"], x["euro"]))
|
|
119
|
+
headline = "speed frontier (quality ceiling x%.2f)" % maxq
|
|
120
|
+
print(f"\nquantprobe optimize - {m.get('hint', 'custom model')} on "
|
|
121
|
+
f"{'this machine' if not getattr(a, 'machine', None) else a.machine}"
|
|
122
|
+
+ (f" | target {tgt:g} tok/s" if tgt else "") + (f" | ctx {ctx}" if ctx else ""))
|
|
123
|
+
print(f" {headline}\n")
|
|
124
|
+
for i, r in enumerate(ranked[:6]):
|
|
125
|
+
star = "*" if i == 0 else " "
|
|
126
|
+
euro = "free" if r["euro"] == 0 else "hw upgrade"
|
|
127
|
+
print(f" {star} {r['tps']:6.1f} tok/s quality x{r['q']:.2f} {euro:>7s} {r['desc']}")
|
|
128
|
+
for tag in r["tags"]:
|
|
129
|
+
print(f" [{tag}]")
|
|
130
|
+
best = ranked[0]
|
|
131
|
+
# This ranking is at its most misleading exactly here. It orders by a bandwidth model, so when
|
|
132
|
+
# everything fits in VRAM it puts 2-bit above 4.5-bit (305 vs 197 tok/s on a 24 GB card).
|
|
133
|
+
# Measured, that gap does not exist: same 7B, all in VRAM, Q2_K vs Q4_K_M is 36% smaller and
|
|
134
|
+
# 4% SLOWER (pre-registration #16). `plan` already says so; `optimize` is the command that
|
|
135
|
+
# actually does the ranking, so it has to say so too - a warning only one of two commands
|
|
136
|
+
# gives is the inconsistency class that cost us the plan-vs-bench correction.
|
|
137
|
+
roomier = next((r for r in ranked if r["bits"] >= 4.5 and "all in VRAM" in r["desc"]), None)
|
|
138
|
+
if "all in VRAM" in best["desc"]:
|
|
139
|
+
print(f"\n note: all-in-VRAM is the placement our law knows least well, and the honest band")
|
|
140
|
+
print(f" here is NOT the +/-25% we quote elsewhere. Across 8 models, real speed landed between")
|
|
141
|
+
print(f" 0.91x and 1.84x the prediction - usually faster, so read the speeds above as a")
|
|
142
|
+
print(f" floor, not a ceiling. One model came in SLOWER (gemma4-12b, -9%), so it is a floor")
|
|
143
|
+
print(f" with one measured exception, not a guarantee.")
|
|
144
|
+
if roomier and best["bits"] < 4.5:
|
|
145
|
+
print(f" It also already fits, and a lower quant buys almost nothing once it does: the same")
|
|
146
|
+
print(f" 7B at Q2_K vs Q4_K_M is 36% smaller and 4% SLOWER. The honest pick here is")
|
|
147
|
+
print(f" {roomier['bits']:g}-bit (quality x{roomier['q']:.2f}) - same speed in practice, better answers.")
|
|
148
|
+
print(f" We only have one GPU, and one GPU cannot fix this. `quantprobe bench --contribute`")
|
|
149
|
+
print(f" turns your machine into the datapoint that would - you review it before sending, and")
|
|
150
|
+
print(f" results OUTSIDE our predicted band are the most valuable ones we can receive.")
|
|
151
|
+
print(f"\n realize the pick:")
|
|
152
|
+
print(f" quantprobe {REALIZE.get(best['bits'], 'quantize')}")
|
|
153
|
+
print(f" quantprobe run --gguf <the file> ... # launches with: {best['flags']}")
|
|
154
|
+
print("\n (search over the validated law only - no new physics; quality = depth-aware recipe,")
|
|
155
|
+
print(" uniform quantization costs ~1.3x more at <=2.5 bits. Estimates +/-25%.)")
|
|
156
|
+
return ranked
|
|
@@ -16,8 +16,8 @@ MODELS = {
|
|
|
16
16
|
"deepseek-16b": dict(t=15.7, a=2.4, ne=1.3, moe=True, kvp=31104, nl=27, hint="DeepSeek-V2-Lite"), # MLA: 27L x (512+64) latent (exact)
|
|
17
17
|
"gemma-12b": dict(t=11.9, a=11.9, ne=11.9, moe=False, kvp=65536, hint="Gemma 4 12B"), # [est] SWA: long-ctx slope from global layers only
|
|
18
18
|
"mistral-7b": dict(t=7.2, a=7.2, ne=7.2, moe=False, kvp=131072, nl=32, hint="Mistral 7B"), # 32L x 8KV x 128d (exact)
|
|
19
|
-
"glm-air": dict(t=110, a=12, ne=2.7, moe=True, kvp=
|
|
20
|
-
"glm-744b": dict(t=753.3, a=32, ne=8, moe=True, kvp=
|
|
19
|
+
"glm-air": dict(t=110, a=12, ne=2.7, moe=True, kvp=188416, nl=46, hint="GLM-4.5-Air 106B"), # 46L x 8KV x 128d GQA (exact, zai-org/GLM-4.5-Air config.json)
|
|
20
|
+
"glm-744b": dict(t=753.3, a=32, ne=8, moe=True, kvp=89856, nl=78, hint="GLM-5.2 (753B)"), # MLA: 78L x (512+64) latent (exact, zai-org/GLM-5.2 config.json); a/ne [est]
|
|
21
21
|
"qwen3-235b": dict(t=235.1, a=22, ne=7.5, moe=True, kvp=192512, hint="Qwen3-235B-A22B"), # total exact; kvp: 94L x 4KV x 128d [est]
|
|
22
22
|
"kimi-k2.6": dict(t=1058.6, a=32, ne=6, moe=True, kvp=70272, hint="Kimi K2.6 (1T MLA)"), # total exact; kvp: 61L x 576 MLA latent [est]
|
|
23
23
|
"gpt-oss-120b": dict(t=120.4, a=5.1, ne=1.8, moe=True, kvp=73728, hint="gpt-oss-120b"), # total+active official; kvp: 36L x 8KV x 64d [est]
|
|
@@ -131,7 +131,51 @@ def ubatch_flags(placement, vram_resident_gb, vc):
|
|
|
131
131
|
return None # nothing host-resident: no transfer to amortise
|
|
132
132
|
if vc * 0.90 - vram_resident_gb < UBATCH_HEADROOM_GB:
|
|
133
133
|
return None # no room for the bigger compute buffer; the -39% case
|
|
134
|
-
|
|
134
|
+
ub = safe_ubatch(vc * 0.90 - vram_resident_gb)
|
|
135
|
+
return "-b %d -ub %d" % (ub, ub) if ub else None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# llama.cpp's CUDA compute buffer is EXACTLY LINEAR in the ubatch. Measured (pre-registration #23,
|
|
139
|
+
# Qwen3-30B-A3B-Q2_K, llama-bench -v, the runtime's own report):
|
|
140
|
+
#
|
|
141
|
+
# -ub 1024 601.50 MiB -ub 1536 902.25 MiB -ub 2048 1203.00 MiB
|
|
142
|
+
#
|
|
143
|
+
# 0.5874 MiB per ubatch token at all three points - no curvature, no step. That linearity is what
|
|
144
|
+
# makes the cliff predictable rather than merely observable: the buffer grows smoothly, VRAM runs
|
|
145
|
+
# out abruptly, and the speed falls off where the two cross.
|
|
146
|
+
COMPUTE_BUFFER_MIB_PER_UB_TOKEN = 0.5874
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def safe_ubatch(headroom_gb, cap=2048):
|
|
150
|
+
"""Largest power-of-two ubatch whose compute buffer fits in `headroom_gb`, or 0.
|
|
151
|
+
|
|
152
|
+
This replaces a hard-coded `-ub 2048`, and the replacement is a bug fix, not a refinement.
|
|
153
|
+
Pre-registration #23 swept the ubatch on the split placement with KV evicted - the exact
|
|
154
|
+
configuration v1.14.x shipped as the prefill champion - and found a cliff, not a plateau:
|
|
155
|
+
|
|
156
|
+
-ub 512 303.32 -ub 1536 381.21 <- buffer 902 MiB, still fits
|
|
157
|
+
-ub 1024 387.37 -ub 2048 209.64 <- buffer 1203 MiB, does not -45% in one step
|
|
158
|
+
-ub 3072 209.46
|
|
159
|
+
-ub 4096 210.84
|
|
160
|
+
|
|
161
|
+
Past the edge the runtime does not fail; it silently spills and holds that degraded speed for
|
|
162
|
+
every larger ubatch. So the failure is invisible to anyone who does not sweep, which is why we
|
|
163
|
+
shipped it: v1.14.x quoted 391.72 tok/s for a command that delivers 209 on the same box the
|
|
164
|
+
391.72 was measured on. The difference was ~250 MiB of desktop VRAM - one browser window.
|
|
165
|
+
|
|
166
|
+
A HALF of the nominal headroom is required, not all of it: the buffer is not the only thing
|
|
167
|
+
that grows, and the measured margin between the last good point (902 MiB) and the first bad one
|
|
168
|
+
(1203 MiB) is under 300 MiB on a 6 GB card. Sizing to the last byte would re-create the cliff
|
|
169
|
+
one step further out.
|
|
170
|
+
"""
|
|
171
|
+
budget_mib = max(0.0, headroom_gb) * 1024 * 0.5
|
|
172
|
+
ub = 0
|
|
173
|
+
n = 256
|
|
174
|
+
while n <= cap:
|
|
175
|
+
if n * COMPUTE_BUFFER_MIB_PER_UB_TOKEN <= budget_mib:
|
|
176
|
+
ub = n
|
|
177
|
+
n *= 2
|
|
178
|
+
return ub
|
|
135
179
|
|
|
136
180
|
|
|
137
181
|
# The measured Pareto frontier for a MoE whose experts do not fit VRAM, on the reference box
|
|
@@ -141,27 +185,86 @@ def ubatch_flags(placement, vram_resident_gb, vc):
|
|
|
141
185
|
#
|
|
142
186
|
# (label, pp2048, tg128, extra flags beyond the placement's own)
|
|
143
187
|
MOE_FRONTIER = [
|
|
144
|
-
("
|
|
145
|
-
("evict KV to RAM (-nkvo 1)", 391.72, 16.54, "-nkvo 1"),
|
|
146
|
-
("all experts to CPU, KV in VRAM", 345.41, 18.68, ""),
|
|
188
|
+
("KV in VRAM, safe batch", 386.04, 21.58, "-b 1024 -ub 1024"),
|
|
147
189
|
]
|
|
148
|
-
#
|
|
149
|
-
#
|
|
190
|
+
# Re-measured 2026-07-27 (pre-registration #25), ALL FOUR CELLS IN ONE SESSION with matched flags,
|
|
191
|
+
# because pre-registration #24 established 10-13% of drift BETWEEN sessions against sub-1% error
|
|
192
|
+
# bars within one. The previous table compared numbers from different days.
|
|
193
|
+
#
|
|
194
|
+
# placement / batch pp2048 tg128
|
|
195
|
+
# split, ub 512 307.13 22.02 <- kept, but see the margin note
|
|
196
|
+
# split, ub 1024, KV in VRAM 386.04 21.58 <- NEW, and it dominates two shipped rows
|
|
197
|
+
# all experts to CPU, ub 2048 381.82 19.79 <- DROPPED: dominated on both axes
|
|
198
|
+
# split, ub 1024, KV evicted (-nkvo) 381.60 17.95 <- DROPPED: dominated on both axes
|
|
199
|
+
#
|
|
200
|
+
# Two of the three rows we shipped were dominated by a cell nobody had measured, and the reason is
|
|
201
|
+
# instructive. "split + KV in VRAM" was only ever benchmarked at ub 2048 (161.59 pp - past the
|
|
202
|
+
# compute-buffer cliff, see safe_ubatch) and at ub 512 (307.13 pp). At ub 1024 it wins outright.
|
|
203
|
+
# So the whole "evict KV to buy prompt speed" trade was an ARTEFACT of measuring one cell past a
|
|
204
|
+
# cliff: keeping KV in VRAM gives MORE prefill (386.04 vs 381.60) and 20% more decode. The frontier
|
|
205
|
+
# had three points because the search never tried the one that beats them.
|
|
206
|
+
#
|
|
207
|
+
# THE FRONTIER IS GONE, and dropping it is the honest reading of our own numbers. The ub-512 row
|
|
208
|
+
# (307.13 / 22.02) survives Pareto only on decode, by 22.02 vs 21.58 - a 0.44 tok/s gap against
|
|
209
|
+
# combined error bars of 0.456, i.e. 0.96 sigma. That is not a measurement, it is noise, and a row
|
|
210
|
+
# retained on it manufactures exactly the false frontier this table has already produced twice.
|
|
211
|
+
#
|
|
212
|
+
# So Law 7 - "there is no single best placement, there is a frontier selected by the prompt:
|
|
213
|
+
# generation ratio" - is REFUTED for this model on this box. There IS a single best configuration.
|
|
214
|
+
# The frontier existed because three of its four cells were measured in the wrong place: one past
|
|
215
|
+
# the compute-buffer cliff, one on a different day, and one under a flag (-nkvo) that was never
|
|
216
|
+
# needed. Re-measured together, one point wins everything.
|
|
217
|
+
#
|
|
218
|
+
# The claim shrank three times before it died: 2.25x spread, then 1.33x once a dominated point was
|
|
219
|
+
# corrected, then 1.23x once all cells shared a session - and at that width the surviving choice is
|
|
220
|
+
# inside its own error bars. Each shrink came from fixing one of our own measurement errors, which
|
|
221
|
+
# is the pattern worth remembering: a feature that only looks valuable through a flawed measurement
|
|
222
|
+
# stops looking valuable as the measurement improves.
|
|
223
|
+
#
|
|
224
|
+
# Flash attention was tested and does NOTHING here: 387.24/21.69 with -fa 1 against 386.04/21.58
|
|
225
|
+
# without, both inside their error bars. The entire win is the ubatch and KV residency.
|
|
226
|
+
# Row 3 shipped as `-ub 2048 / 391.72 / 16.54` in v1.14.0-v1.14.1 and that command was ON THE WRONG
|
|
227
|
+
# SIDE OF A CLIFF (pre-registration #23). Re-measured across the ubatch on the same box:
|
|
228
|
+
#
|
|
229
|
+
# -ub 1024 386.14 pp 18.06 tg <- shipped now
|
|
230
|
+
# -ub 1536 381.21 pp
|
|
231
|
+
# -ub 2048 209.64 pp <- shipped before: -45.7% prefill, and 16.54 tg
|
|
232
|
+
#
|
|
233
|
+
# The correction costs 1.4% of the quoted prefill number and BUYS 9.2% of decode, so the row is
|
|
234
|
+
# strictly better than the one it replaces on one axis and within noise on the other. The 391.72
|
|
235
|
+
# was not fabricated - it is reproducible on a card with nothing else on it. It is simply not
|
|
236
|
+
# reproducible on a card with a browser open, and advice that needs a clean desktop to hold is
|
|
237
|
+
# advice we should not have given.
|
|
238
|
+
# Two cells are deliberately EXCLUDED because they are dominated on both axes:
|
|
239
|
+
# all experts to CPU + KV evicted 336.31 / 15.82 - beaten by row 2
|
|
240
|
+
# split + KV in VRAM + ub 2048 163.39 / 20.13 - beaten by row 1
|
|
241
|
+
#
|
|
242
|
+
# That second one shipped ON this frontier in v1.14.0, as the "decode champion", because the
|
|
243
|
+
# frontier was built with -ub pinned at 2048 while only placement and KV were varied. Measured
|
|
244
|
+
# afterwards: the same configuration at ub 512 gives 280.64 pp for the same 20.25 tg - 72% more
|
|
245
|
+
# prompt processing, free. Pinning one dimension while sweeping the others is precisely the error
|
|
246
|
+
# the Law 4 fungibility corollary warns about, made in the code that implements the corollary.
|
|
247
|
+
# A frontier is only Pareto-optimal with respect to the dimensions actually swept.
|
|
248
|
+
#
|
|
249
|
+
# EPILOGUE, 2026-07-27: that same excluded cell - "split + KV in VRAM" - is now the WINNER. It was
|
|
250
|
+
# excluded on a measurement at ub 2048, which is past the compute-buffer cliff; at ub 1024 it beats
|
|
251
|
+
# every row we shipped. The lesson repeated itself one level up. Excluding a configuration is also
|
|
252
|
+
# a claim, and it inherits the scope of the sweep that produced it: this one was really "dominated
|
|
253
|
+
# AT ub 2048", which is not the same statement and should never have been recorded as though it was.
|
|
150
254
|
|
|
151
255
|
|
|
152
256
|
def workload_frontier(prompt_to_gen):
|
|
153
|
-
"""Pick the
|
|
154
|
-
|
|
155
|
-
Total time for P prompt tokens and G generated is `P/pp + G/tg`, so the optimum moves as the
|
|
156
|
-
ratio does. Measured crossovers on the reference box:
|
|
257
|
+
"""Pick the configuration that minimises total time at a given prompt:generation ratio.
|
|
157
258
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
259
|
+
Kept as a function, and it now returns the SAME row at every ratio, because pre-registration
|
|
260
|
+
#25 collapsed the frontier to one point. Total time for P prompt tokens and G generated is
|
|
261
|
+
still `P/pp + G/tg`, so the machinery is correct and would select again the moment a second
|
|
262
|
+
configuration is measured that beats this one somewhere - which is why this is not deleted.
|
|
162
263
|
|
|
163
|
-
|
|
164
|
-
|
|
264
|
+
What it must NOT do is present a choice that does not exist. Every earlier version of this
|
|
265
|
+
docstring quoted a workload-dependent crossover (2.25x, then 1.33x, then 1.23x); all three were
|
|
266
|
+
artefacts of comparing cells measured past a cliff, on different days, or under a flag that was
|
|
267
|
+
never needed. See MOE_FRONTIER for the numbers that replaced them.
|
|
165
268
|
"""
|
|
166
269
|
G = 1.0
|
|
167
270
|
P = max(prompt_to_gen, 0.0) * G
|
|
@@ -268,9 +371,11 @@ def fits_in_vram_advice(placement, bits):
|
|
|
268
371
|
"""
|
|
269
372
|
if placement != "all in VRAM":
|
|
270
373
|
return None
|
|
271
|
-
note = ("this is the placement our law knows least well
|
|
272
|
-
"
|
|
273
|
-
"
|
|
374
|
+
note = ("this is the placement our law knows least well, and the honest band here is NOT the "
|
|
375
|
+
"+/-25% we quote elsewhere. Across 8 models measured all-in-VRAM, real speed landed "
|
|
376
|
+
"between 0.91x and 1.84x the prediction - usually faster, so treat the number above as "
|
|
377
|
+
"a floor, not a ceiling. One model came in SLOWER (gemma4-12b, -9%), so it is a floor "
|
|
378
|
+
"with one measured exception, not a guarantee.")
|
|
274
379
|
if bits < 4.5:
|
|
275
380
|
note += (" It also already fits, and going lower-bit buys almost nothing: the same 7B at "
|
|
276
381
|
"Q2_K vs Q4_K_M is 36% smaller and 4% SLOWER (19.17 vs 20.03 tok/s). Quantize "
|
|
@@ -533,11 +638,18 @@ def run(args):
|
|
|
533
638
|
if ph:
|
|
534
639
|
print(f"\n phase: {ph}")
|
|
535
640
|
chat, rag = workload_frontier(0.5), workload_frontier(200)
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
641
|
+
if chat["label"] != rag["label"]:
|
|
642
|
+
print("\n workload: the best setup depends on how much prompt you read per token you write:")
|
|
643
|
+
print(f" chat, short prompts -> {chat['label']:<26} {chat['pp']:>6.0f} pp / {chat['tg']:>5.1f} tg")
|
|
644
|
+
print(f" long prompts, RAG, docs -> {rag['label']:<26} {rag['pp']:>6.0f} pp / {rag['tg']:>5.1f} tg")
|
|
645
|
+
print(f" Choosing wrong costs up to {rag['speedup_vs_worst']:.2f}x on a long-prompt workload.")
|
|
646
|
+
else:
|
|
647
|
+
print(f"\n workload: one setup wins at every prompt:generation ratio - {rag['label']}")
|
|
648
|
+
print(f" ({rag['pp']:.0f} pp / {rag['tg']:.1f} tg). Earlier versions offered a choice here; "
|
|
649
|
+
"re-measuring")
|
|
650
|
+
print(" every cell in ONE session (pre-registration #25) showed the alternatives were "
|
|
651
|
+
"dominated,")
|
|
652
|
+
print(" so there is nothing to choose. One fewer knob, and the honest number.")
|
|
541
653
|
if ub:
|
|
542
654
|
print(f"\n prompt speed: `{ub}` is worth **+73% prefill** on this placement (measured "
|
|
543
655
|
f"199.9 -> 345.9 tok/s, pre-registration #19). It costs nothing on generation "
|
|
@@ -588,5 +700,9 @@ def run(args):
|
|
|
588
700
|
if moe and vc > 0 and not nlay:
|
|
589
701
|
print("\n note: MoE partial expert offload (measured +12.4% decode, ~2-3x prefill) needs this\n"
|
|
590
702
|
" model's layer count to emit exact -ot flags - re-run with --gguf <file> to unlock it.")
|
|
703
|
+
print("\n concurrency: every number above is SINGLE-STREAM. Measured with 8 parallel slots, "
|
|
704
|
+
"aggregate\n throughput is ~2x higher and saturates by about 4 slots "
|
|
705
|
+
"(pre-registration #26). The same\n ratio appeared on every placement AND on a dense "
|
|
706
|
+
"control, so it is a ceiling we do not model -\n read our figures as one user's speed, not a server's capacity.")
|
|
591
707
|
print("\n (eta bands fitted from published measurements; estimates +/-25%. "
|
|
592
708
|
"Hybrid needs --no-mmap.)")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.15.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
|
|
@@ -118,7 +118,7 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
118
118
|
## When quantprobe won't help you
|
|
119
119
|
|
|
120
120
|
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
121
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well
|
|
121
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. Across 8 models and 13 benchmarks, real speed landed between **0.91× and 1.84× the prediction** — usually faster, so read that row as a floor. One model came in *slower* (gemma4-12b, −9%), so it is a floor with one measured exception rather than a guarantee. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
122
122
|
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
123
123
|
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
124
124
|
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|