quantprobe 1.9.2__tar.gz → 1.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {quantprobe-1.9.2/quantprobe.egg-info → quantprobe-1.10.0}/PKG-INFO +1 -1
  2. {quantprobe-1.9.2 → quantprobe-1.10.0}/pyproject.toml +4 -1
  3. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/__init__.py +1 -1
  4. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/cli.py +6 -0
  5. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/probe.py +30 -0
  6. quantprobe-1.10.0/quantprobe/recipes/mistral-7b.json +50 -0
  7. quantprobe-1.10.0/quantprobe/recipes/qwen2.5-7b.json +50 -0
  8. quantprobe-1.10.0/quantprobe/recipes/qwen3-30b.json +50 -0
  9. quantprobe-1.10.0/quantprobe/recipes/qwen3.5-35b.json +50 -0
  10. quantprobe-1.10.0/quantprobe/recipes.py +75 -0
  11. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/spec.py +9 -1
  12. {quantprobe-1.9.2 → quantprobe-1.10.0/quantprobe.egg-info}/PKG-INFO +1 -1
  13. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe.egg-info/SOURCES.txt +5 -0
  14. {quantprobe-1.9.2 → quantprobe-1.10.0}/LICENSE +0 -0
  15. {quantprobe-1.9.2 → quantprobe-1.10.0}/README.md +0 -0
  16. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/__main__.py +0 -0
  17. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/auto.py +0 -0
  18. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/dashboard.py +0 -0
  19. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/detect.py +0 -0
  20. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/fetch.py +0 -0
  21. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/optimize.py +0 -0
  22. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/plan.py +0 -0
  23. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/runtime.py +0 -0
  24. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe/target.py +0 -0
  25. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe.egg-info/dependency_links.txt +0 -0
  26. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe.egg-info/entry_points.txt +0 -0
  27. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe.egg-info/requires.txt +0 -0
  28. {quantprobe-1.9.2 → quantprobe-1.10.0}/quantprobe.egg-info/top_level.txt +0 -0
  29. {quantprobe-1.9.2 → quantprobe-1.10.0}/setup.cfg +0 -0
  30. {quantprobe-1.9.2 → quantprobe-1.10.0}/tests/test_engine.py +0 -0
  31. {quantprobe-1.9.2 → quantprobe-1.10.0}/tests/test_evaluator.py +0 -0
  32. {quantprobe-1.9.2 → quantprobe-1.10.0}/tests/test_pipeline.py +0 -0
  33. {quantprobe-1.9.2 → quantprobe-1.10.0}/tests/test_transforms.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.9.2
3
+ Version: 1.10.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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quantprobe"
7
- version = "1.9.2"
7
+ version = "1.10.0"
8
8
  description = "Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -26,3 +26,6 @@ quantprobe = "quantprobe.cli:main"
26
26
 
27
27
  [tool.setuptools]
28
28
  packages = ["quantprobe"]
29
+
30
+ [tool.setuptools.package-data]
31
+ quantprobe = ["recipes/*.json"]
@@ -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.9.2"
11
+ __version__ = "1.10.0"
@@ -85,9 +85,12 @@ def main():
85
85
  z.add_argument("--protect-late", type=int, default=12, help="protect the last N layers at 4-bit (default 12)")
86
86
  z.add_argument("--protect", default=None, help="protect an explicit band LO-HI (e.g. 36-47) instead of --protect-late")
87
87
  z.add_argument("--imatrix", default=None, help="importance-matrix file (build one with `probe --imatrix auto`); improves quality at zero size cost")
88
+ z.add_argument("--recipe", default=None, help="use a MEASURED fragile band from the community atlas instead of the default guess (see: quantprobe recipes)")
88
89
  z.add_argument("--llama-dir", default=None)
89
90
  z.add_argument("--dry", action="store_true")
90
91
 
92
+ sub.add_parser("recipes", help="the community fragility atlas: bands already measured, so you can skip the probe")
93
+
91
94
  o = sub.add_parser("optimize", help="cheapest path to a target speed: search bits x placement x KV x hardware over the law")
92
95
  o.add_argument("--tps", type=float, default=None, help="target tok/s (omit for the speed frontier)")
93
96
  o.add_argument("--max-quality", type=float, default=None, help="quality-cost ceiling (default 1.12)")
@@ -145,6 +148,9 @@ def main():
145
148
  elif a.cmd == "hw":
146
149
  from . import detect
147
150
  detect.run(a)
151
+ elif a.cmd == "recipes":
152
+ from . import recipes
153
+ recipes.run(a)
148
154
  elif a.cmd == "quantize":
149
155
  from . import probe
150
156
  probe.quantize(a)
@@ -273,10 +273,40 @@ def quantize(a):
273
273
  if not os.path.isfile(a.gguf):
274
274
  raise SystemExit(f"GGUF not found: {a.gguf} (point --gguf at a real high-precision GGUF: f16/bf16/Q8)")
275
275
  n_lay = n_layers(a.gguf)
276
+ rec_key = getattr(a, "recipe", None)
276
277
  if a.protect:
277
278
  lo, hi = (int(x) for x in a.protect.split("-"))
279
+ elif rec_key:
280
+ from . import recipes as recmod
281
+ r = recmod.find(key=rec_key)
282
+ if not r:
283
+ raise SystemExit(f"no recipe '{rec_key}'. See what has been measured: quantprobe recipes")
284
+ if r["model"]["n_layer"] != n_lay:
285
+ raise SystemExit(
286
+ f"recipe '{rec_key}' is for a {r['model']['n_layer']}-layer model; this file has "
287
+ f"{n_lay}.\n A fragile band is only meaningful for the model it was measured on.")
288
+ lo, hi = r["probe"]["fragile_band"]
289
+ print(f"[quantprobe] using measured recipe '{rec_key}': protect layers {lo}-{hi} "
290
+ f"({r['probe']['shape']}-fragile, {r['probe']['fragility_ratio']}x median)")
291
+ print(f" measured {r['provenance']['measured']} on {r['provenance']['hardware']}; "
292
+ f"evidence: {r['provenance']['raw_log']}")
278
293
  else:
279
294
  lo, hi = n_lay - a.protect_late, n_lay - 1
295
+ # If someone has already measured THIS model, say so - the default is a guess, and a
296
+ # measured band is strictly better information (Law 3: fragility is not predictable).
297
+ try:
298
+ from . import recipes as recmod
299
+ from .spec import from_gguf
300
+ arch = from_gguf(a.gguf).get("arch")
301
+ r = recmod.find(arch=arch, n_layer=n_lay)
302
+ if r:
303
+ rlo, rhi = r["probe"]["fragile_band"]
304
+ if (rlo, rhi) != (lo, hi):
305
+ print(f"[quantprobe] a MEASURED recipe exists for this model class "
306
+ f"({r['model']['name']}): fragile band {rlo}-{rhi}, not the default "
307
+ f"{lo}-{hi}.\n Use it: --recipe {r['model']['key']}")
308
+ except Exception:
309
+ pass
280
310
  out = a.out or os.path.splitext(a.gguf)[0] + "-depthaware.gguf"
281
311
  imat = getattr(a, "imatrix", None)
282
312
  if imat and not os.path.isfile(imat) and not getattr(a, "dry", False):
@@ -0,0 +1,50 @@
1
+ {
2
+ "schema": 1,
3
+ "model": {
4
+ "key": "mistral-7b",
5
+ "name": "Mistral-7B-Instruct-v0.3",
6
+ "arch": "llama",
7
+ "n_layer": 32,
8
+ "moe": false
9
+ },
10
+ "probe": {
11
+ "reference_ppl": 5.2055,
12
+ "band_deltas": [
13
+ {
14
+ "lo": 0,
15
+ "hi": 7,
16
+ "delta_ppl": 6.525
17
+ },
18
+ {
19
+ "lo": 8,
20
+ "hi": 15,
21
+ "delta_ppl": 0.148
22
+ },
23
+ {
24
+ "lo": 16,
25
+ "hi": 23,
26
+ "delta_ppl": 0.2248
27
+ },
28
+ {
29
+ "lo": 24,
30
+ "hi": 31,
31
+ "delta_ppl": 0.2587
32
+ }
33
+ ],
34
+ "fragile_band": [
35
+ 0,
36
+ 7
37
+ ],
38
+ "fragility_ratio": 26.99,
39
+ "shape": "early"
40
+ },
41
+ "provenance": {
42
+ "measured": "2026-06",
43
+ "eval": "WikiText-2 test (held out)",
44
+ "hardware": "GTX 1060 6GB / 16GB DDR4-3000 / i5-7600K",
45
+ "base_quant": "Q6_K",
46
+ "raw_log": "weights/data/mistral_atlas.log",
47
+ "method": "band probe: one band's FFNs -> q2_k at a time, rest at base; delta vs reference",
48
+ "contributor": "FedericoTs"
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "schema": 1,
3
+ "model": {
4
+ "key": "qwen2.5-7b",
5
+ "name": "Qwen2.5-7B-Instruct",
6
+ "arch": "qwen2",
7
+ "n_layer": 28,
8
+ "moe": false
9
+ },
10
+ "probe": {
11
+ "reference_ppl": 6.1496,
12
+ "band_deltas": [
13
+ {
14
+ "lo": 0,
15
+ "hi": 6,
16
+ "delta_ppl": 0.8829
17
+ },
18
+ {
19
+ "lo": 7,
20
+ "hi": 13,
21
+ "delta_ppl": 0.5406
22
+ },
23
+ {
24
+ "lo": 14,
25
+ "hi": 20,
26
+ "delta_ppl": 0.5814
27
+ },
28
+ {
29
+ "lo": 21,
30
+ "hi": 27,
31
+ "delta_ppl": 1.8545
32
+ }
33
+ ],
34
+ "fragile_band": [
35
+ 21,
36
+ 27
37
+ ],
38
+ "fragility_ratio": 2.53,
39
+ "shape": "late"
40
+ },
41
+ "provenance": {
42
+ "measured": "2026-06",
43
+ "eval": "WikiText-2 test (held out)",
44
+ "hardware": "GTX 1060 6GB / 16GB DDR4-3000 / i5-7600K",
45
+ "base_quant": "Q6_K",
46
+ "raw_log": "weights/data/qwen_mech_probe.log",
47
+ "method": "band probe: one band's FFNs -> q2_k at a time, rest at base; delta vs reference",
48
+ "contributor": "FedericoTs"
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "schema": 1,
3
+ "model": {
4
+ "key": "qwen3-30b",
5
+ "name": "Qwen3-30B-A3B",
6
+ "arch": "qwen3moe",
7
+ "n_layer": 48,
8
+ "moe": true
9
+ },
10
+ "probe": {
11
+ "reference_ppl": 10.3912,
12
+ "band_deltas": [
13
+ {
14
+ "lo": 0,
15
+ "hi": 11,
16
+ "delta_ppl": 0.5907
17
+ },
18
+ {
19
+ "lo": 12,
20
+ "hi": 23,
21
+ "delta_ppl": 0.0165
22
+ },
23
+ {
24
+ "lo": 24,
25
+ "hi": 35,
26
+ "delta_ppl": 0.1352
27
+ },
28
+ {
29
+ "lo": 36,
30
+ "hi": 47,
31
+ "delta_ppl": 1.3374
32
+ }
33
+ ],
34
+ "fragile_band": [
35
+ 36,
36
+ 47
37
+ ],
38
+ "fragility_ratio": 3.68,
39
+ "shape": "late"
40
+ },
41
+ "provenance": {
42
+ "measured": "2026-06",
43
+ "eval": "WikiText-2 test (held out)",
44
+ "hardware": "GTX 1060 6GB / 16GB DDR4-3000 / i5-7600K",
45
+ "base_quant": "Q4_K_M",
46
+ "raw_log": "weights/data/q30_bands.log",
47
+ "method": "band probe: one band's FFNs -> q2_k at a time, rest at base; delta vs reference",
48
+ "contributor": "FedericoTs"
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "schema": 1,
3
+ "model": {
4
+ "key": "qwen3.5-35b",
5
+ "name": "Qwen3.5-35B-A3B",
6
+ "arch": "qwen35moe",
7
+ "n_layer": 40,
8
+ "moe": true
9
+ },
10
+ "probe": {
11
+ "reference_ppl": 5.4298,
12
+ "band_deltas": [
13
+ {
14
+ "lo": 0,
15
+ "hi": 9,
16
+ "delta_ppl": 0.0909
17
+ },
18
+ {
19
+ "lo": 10,
20
+ "hi": 19,
21
+ "delta_ppl": 0.1531
22
+ },
23
+ {
24
+ "lo": 20,
25
+ "hi": 29,
26
+ "delta_ppl": 0.1579
27
+ },
28
+ {
29
+ "lo": 30,
30
+ "hi": 39,
31
+ "delta_ppl": 0.4492
32
+ }
33
+ ],
34
+ "fragile_band": [
35
+ 30,
36
+ 39
37
+ ],
38
+ "fragility_ratio": 2.89,
39
+ "shape": "late"
40
+ },
41
+ "provenance": {
42
+ "measured": "2026-07-25",
43
+ "eval": "WikiText-2 test (held out)",
44
+ "hardware": "GTX 1060 6GB / 16GB DDR4-3000 / i5-7600K",
45
+ "base_quant": "Q6_K",
46
+ "raw_log": "weights/data/apex_ab_stageA2.log",
47
+ "method": "band probe: one band's FFNs -> q2_k at a time, rest at base; delta vs reference",
48
+ "contributor": "FedericoTs"
49
+ }
50
+ }
@@ -0,0 +1,75 @@
1
+ """quantprobe recipes — the community fragility atlas.
2
+
3
+ Law 3 says where a model breaks under low-bit quantization is model-specific and must be
4
+ MEASURED. Measuring it is the expensive part of the pipeline (hours on a large model).
5
+
6
+ But the result is a property of the MODEL, not of your machine: Qwen3-30B's fragile band is
7
+ layers 36-47 whether you measured it on a GTX 1060 or an H100. So it needs measuring once,
8
+ globally, ever — and everyone after that skips straight to the build.
9
+
10
+ A recipe is a few numbers plus its evidence. Every entry carries the raw log it came from, the
11
+ eval corpus, and the hardware, because a recipe you cannot check is a recipe you should not use.
12
+ """
13
+ from __future__ import annotations
14
+ import json, os, glob
15
+
16
+
17
+ def _dir():
18
+ """Recipes ship with the package; a repo checkout falls back to the source tree."""
19
+ here = os.path.join(os.path.dirname(os.path.abspath(__file__)), "recipes")
20
+ if os.path.isdir(here):
21
+ return here
22
+ up = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "recipes")
23
+ return up if os.path.isdir(up) else here
24
+
25
+
26
+ def load_all():
27
+ out = []
28
+ for f in sorted(glob.glob(os.path.join(_dir(), "*.json"))):
29
+ try:
30
+ out.append(json.load(open(f, encoding="utf-8")))
31
+ except Exception:
32
+ continue # a malformed contribution must not break the tool
33
+ return out
34
+
35
+
36
+ def find(key=None, arch=None, n_layer=None):
37
+ """Explicit key wins. Otherwise match on (arch, n_layer) — the two things that make a
38
+ recipe applicable. Layer count alone is not enough: different architectures share it."""
39
+ all_r = load_all()
40
+ if key:
41
+ for r in all_r:
42
+ if r["model"]["key"] == key:
43
+ return r
44
+ return None
45
+ if arch and n_layer:
46
+ for r in all_r:
47
+ if r["model"]["arch"] == arch and r["model"]["n_layer"] == n_layer:
48
+ return r
49
+ return None
50
+
51
+
52
+ def describe(r):
53
+ p, m, pr = r["probe"], r["model"], r["provenance"]
54
+ lo, hi = p["fragile_band"]
55
+ return (f"{m['name']} ({m['n_layer']} layers, {'MoE' if m['moe'] else 'dense'}) — "
56
+ f"fragile band layers {lo}-{hi} ({p['shape']}-fragile, {p['fragility_ratio']}x "
57
+ f"the median band)\n"
58
+ f" measured {pr['measured']} on {pr['hardware']}, eval {pr['eval']}\n"
59
+ f" evidence: {pr['raw_log']}")
60
+
61
+
62
+ def run(a):
63
+ """`quantprobe recipes` — what has already been measured, so you don't have to."""
64
+ all_r = load_all()
65
+ if not all_r:
66
+ print("no recipes found (expected in quantprobe/recipes/*.json)")
67
+ return
68
+ print(f"\nquantprobe recipes — {len(all_r)} measured fragility bands\n")
69
+ print(" A recipe is someone's probe result. The fragile band is a property of the MODEL,")
70
+ print(" not your hardware, so it transfers: skip the probe, build in minutes.\n")
71
+ for r in all_r:
72
+ print(" " + describe(r).replace("\n", "\n "))
73
+ print(f" use it: quantprobe quantize --gguf <your-file> --recipe {r['model']['key']}\n")
74
+ print(" Measured one yourself? Open a PR with the JSON and your raw probe log —")
75
+ print(" every entry here carries its evidence, and contributions are held to the same bar.")
@@ -61,8 +61,16 @@ def from_gguf(path):
61
61
  kvp = n_layer * kv_heads * ((k_dim or 128) + (v_dim or k_dim or 128)) * 2
62
62
 
63
63
  bits = os.path.getsize(path) * 8 / total
64
+ arch = None
65
+ for field in r.fields.values(): # recipe matching needs (arch, n_layer), not layers alone
66
+ if field.name == "general.architecture":
67
+ try:
68
+ arch = bytes(field.parts[field.data[0]]).decode("utf-8")
69
+ except Exception:
70
+ arch = None
71
+ break
64
72
  return dict(t=total / 1e9, a=active / 1e9, ne=ne_params / 1e9, moe=moe,
65
- bits=round(bits, 2), kvp=int(kvp), n_layer=n_layer)
73
+ bits=round(bits, 2), kvp=int(kvp), n_layer=n_layer, arch=arch)
66
74
 
67
75
 
68
76
  def apply(a, quiet=False):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.9.2
3
+ Version: 1.10.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
@@ -11,6 +11,7 @@ quantprobe/fetch.py
11
11
  quantprobe/optimize.py
12
12
  quantprobe/plan.py
13
13
  quantprobe/probe.py
14
+ quantprobe/recipes.py
14
15
  quantprobe/runtime.py
15
16
  quantprobe/spec.py
16
17
  quantprobe/target.py
@@ -20,6 +21,10 @@ quantprobe.egg-info/dependency_links.txt
20
21
  quantprobe.egg-info/entry_points.txt
21
22
  quantprobe.egg-info/requires.txt
22
23
  quantprobe.egg-info/top_level.txt
24
+ quantprobe/recipes/mistral-7b.json
25
+ quantprobe/recipes/qwen2.5-7b.json
26
+ quantprobe/recipes/qwen3-30b.json
27
+ quantprobe/recipes/qwen3.5-35b.json
23
28
  tests/test_engine.py
24
29
  tests/test_evaluator.py
25
30
  tests/test_pipeline.py
File without changes
File without changes
File without changes