quantprobe 1.6.4__tar.gz → 1.7.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.6.4/quantprobe.egg-info → quantprobe-1.7.0}/PKG-INFO +1 -1
- {quantprobe-1.6.4 → quantprobe-1.7.0}/pyproject.toml +1 -1
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/__init__.py +1 -1
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/auto.py +6 -3
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/cli.py +4 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/probe.py +47 -4
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/runtime.py +14 -1
- {quantprobe-1.6.4 → quantprobe-1.7.0/quantprobe.egg-info}/PKG-INFO +1 -1
- {quantprobe-1.6.4 → quantprobe-1.7.0}/LICENSE +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/README.md +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/__main__.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/detect.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/fetch.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/optimize.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/plan.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/spec.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe/target.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe.egg-info/SOURCES.txt +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/setup.cfg +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/tests/test_engine.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/tests/test_evaluator.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.0}/tests/test_pipeline.py +0 -0
- {quantprobe-1.6.4 → quantprobe-1.7.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.7.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.
|
|
7
|
+
version = "1.7.0"
|
|
8
8
|
description = "Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -8,4 +8,4 @@ Three commands, all grounded in measured laws (see LAWS.md in the repo):
|
|
|
8
8
|
Every constant in `plan` is fitted from measurements published in the repo, including two
|
|
9
9
|
pre-registered hardware predictions confirmed within 8%.
|
|
10
10
|
"""
|
|
11
|
-
__version__ = "1.
|
|
11
|
+
__version__ = "1.7.0"
|
|
@@ -199,8 +199,9 @@ def run(a):
|
|
|
199
199
|
dest = getattr(a, "dir", None) or "./models"
|
|
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
|
-
|
|
203
|
-
print("
|
|
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.")
|
|
204
205
|
if getattr(a, "dry", False):
|
|
205
206
|
print(" (--dry: nothing downloaded)")
|
|
206
207
|
return spath
|
|
@@ -214,7 +215,9 @@ def run(a):
|
|
|
214
215
|
out = os.path.join(dest, os.path.basename(spath).rsplit(".gguf", 1)[0] + "-depthaware.gguf")
|
|
215
216
|
pa = argparse.Namespace(gguf=srcfull, bands=4, chunks=32, eval=evalf, ngl=99,
|
|
216
217
|
workdir=dest, llama_dir=getattr(a, "llama_dir", None),
|
|
217
|
-
apply=True, out=out, dry_run=False
|
|
218
|
+
apply=True, out=out, dry_run=False,
|
|
219
|
+
imatrix=None if getattr(a, "no_imatrix", False) else "auto",
|
|
220
|
+
imatrix_chunks=100)
|
|
218
221
|
probemod.run(pa)
|
|
219
222
|
print("\n[quantprobe auto --custom] your personalized model:")
|
|
220
223
|
print(" quantprobe run --gguf " + out)
|
|
@@ -27,6 +27,8 @@ def main():
|
|
|
27
27
|
p.add_argument("--llama-dir", default=None, help="dir containing llama-quantize/llama-perplexity")
|
|
28
28
|
p.add_argument("--apply", action="store_true", help="after probing, BUILD the recommended depth-aware GGUF")
|
|
29
29
|
p.add_argument("--out", default=None, help="output path for --apply (default: <model>-depthaware.gguf)")
|
|
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
|
+
p.add_argument("--imatrix-chunks", type=int, default=100, help="calibration chunks when --imatrix auto (default 100)")
|
|
30
32
|
p.add_argument("--dry-run", action="store_true")
|
|
31
33
|
|
|
32
34
|
q = sub.add_parser("plan", help="evaluate every bit/tier placement, predict tok/s (Law 4)")
|
|
@@ -81,6 +83,7 @@ def main():
|
|
|
81
83
|
z.add_argument("--out", default=None, help="output path (default: <model>-depthaware.gguf)")
|
|
82
84
|
z.add_argument("--protect-late", type=int, default=12, help="protect the last N layers at 4-bit (default 12)")
|
|
83
85
|
z.add_argument("--protect", default=None, help="protect an explicit band LO-HI (e.g. 36-47) instead of --protect-late")
|
|
86
|
+
z.add_argument("--imatrix", default=None, help="importance-matrix file (build one with `probe --imatrix auto`); improves quality at zero size cost")
|
|
84
87
|
z.add_argument("--llama-dir", default=None)
|
|
85
88
|
z.add_argument("--dry", action="store_true")
|
|
86
89
|
|
|
@@ -101,6 +104,7 @@ def main():
|
|
|
101
104
|
au.add_argument("--max-quality", type=float, default=None)
|
|
102
105
|
au.add_argument("--allow-prune", action="store_true"); au.add_argument("--any-runtime", action="store_true")
|
|
103
106
|
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)")
|
|
107
|
+
au.add_argument("--no-imatrix", action="store_true", help="skip importance-matrix calibration in --custom (faster build, measurably worse quality)")
|
|
104
108
|
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")
|
|
105
109
|
au.add_argument("--serve", action="store_true", help="with --run: llama-server instead of chat")
|
|
106
110
|
au.add_argument("--extra", default=None)
|
|
@@ -114,8 +114,12 @@ def run(a):
|
|
|
114
114
|
f' {os.path.basename(a.gguf)} out-depthaware.gguf Q2_K 8', flush=True)
|
|
115
115
|
if getattr(a, "apply", False):
|
|
116
116
|
out = a.out or os.path.splitext(a.gguf)[0] + "-depthaware.gguf"
|
|
117
|
+
imat = getattr(a, "imatrix", None)
|
|
118
|
+
if imat == "auto":
|
|
119
|
+
imat = make_imatrix(a.llama_dir, a.gguf, a.eval, chunks=getattr(a, "imatrix_chunks", 100),
|
|
120
|
+
ngl=a.ngl, dry=a.dry_run)
|
|
117
121
|
print("\n[quantprobe] --apply: building the recommended GGUF now...", flush=True)
|
|
118
|
-
build_depthaware(a.llama_dir, a.gguf, out, lo, hi, bands[-1][1] + 1, dry=a.dry_run)
|
|
122
|
+
build_depthaware(a.llama_dir, a.gguf, out, lo, hi, bands[-1][1] + 1, dry=a.dry_run, imatrix=imat)
|
|
119
123
|
else:
|
|
120
124
|
print("\n (re-run with --apply --out model-2bit.gguf to BUILD this GGUF automatically)", flush=True)
|
|
121
125
|
|
|
@@ -125,11 +129,19 @@ def _band_re(lo, hi):
|
|
|
125
129
|
|
|
126
130
|
|
|
127
131
|
def build_depthaware(llama_dir, src, out, protect_lo, protect_hi, n_lay,
|
|
128
|
-
base="Q2_K", protect="q4_k", dry=False):
|
|
129
|
-
"""Actually PRODUCE the compressed GGUF: base bits everywhere, fragile band + attention +
|
|
132
|
+
base="Q2_K", protect="q4_k", dry=False, imatrix=None):
|
|
133
|
+
"""Actually PRODUCE the compressed GGUF: base bits everywhere, fragile band + attention +
|
|
134
|
+
embed + always-active tensors protected; optional importance-matrix calibration."""
|
|
130
135
|
# --dry previews the exact command WITHOUT requiring llama.cpp installed
|
|
131
136
|
q = exe("llama-quantize") if dry else os.path.join(find_llama(llama_dir), exe("llama-quantize"))
|
|
132
137
|
cmd = [q, "--allow-requantize"]
|
|
138
|
+
if imatrix:
|
|
139
|
+
cmd += ["--imatrix", imatrix]
|
|
140
|
+
# ALWAYS-ACTIVE tensors first: llama.cpp resolves --tensor-type first-match-wins (verified
|
|
141
|
+
# 2026-07-25), so this must precede the band rules or it silently does nothing. The shared
|
|
142
|
+
# expert fires on EVERY token (routed experts fire ~8/256) and is heavy-tailed: measured
|
|
143
|
+
# -3.2% ppl when protected at q8_0, for ~0.65% more bytes (pre-registration #12).
|
|
144
|
+
cmd += ["--tensor-type", "ffn_.*_shexp.*=q8_0"]
|
|
133
145
|
if protect_lo > 0:
|
|
134
146
|
cmd += ["--tensor-type", f"{_band_re(0, protect_lo - 1)}=q2_k"]
|
|
135
147
|
if protect_hi < n_lay - 1:
|
|
@@ -150,6 +162,32 @@ def build_depthaware(llama_dir, src, out, protect_lo, protect_hi, n_lay,
|
|
|
150
162
|
return out
|
|
151
163
|
|
|
152
164
|
|
|
165
|
+
def make_imatrix(llama_dir, src, eval_file, out=None, chunks=100, ngl=99, dry=False):
|
|
166
|
+
"""Generate an importance matrix: measured -8.5% ppl at ~3 bits, at zero size and speed
|
|
167
|
+
cost (pre-registration #12). The single largest quality lever in the recipe.
|
|
168
|
+
|
|
169
|
+
The calibration corpus should NOT be your evaluation text - calibrating on the same data
|
|
170
|
+
you score against inflates the result. Wikitext TRAIN is used against a wikitext TEST eval.
|
|
171
|
+
"""
|
|
172
|
+
out = out or os.path.splitext(src)[0] + ".imatrix.gguf"
|
|
173
|
+
if os.path.isfile(out):
|
|
174
|
+
print(f"[quantprobe] reusing existing imatrix: {out}")
|
|
175
|
+
return out
|
|
176
|
+
im = exe("llama-imatrix") if dry else os.path.join(find_llama(llama_dir), exe("llama-imatrix"))
|
|
177
|
+
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)")
|
|
180
|
+
print(" $ " + " ".join(cmd))
|
|
181
|
+
if dry:
|
|
182
|
+
return out
|
|
183
|
+
rc = subprocess.call(cmd)
|
|
184
|
+
if rc != 0 or not os.path.isfile(out):
|
|
185
|
+
print(f"[quantprobe] imatrix generation failed (exit {rc}); continuing WITHOUT calibration.")
|
|
186
|
+
return None
|
|
187
|
+
print(f"[quantprobe] imatrix ready -> {out} ({os.path.getsize(out)/1e6:.0f} MB)")
|
|
188
|
+
return out
|
|
189
|
+
|
|
190
|
+
|
|
153
191
|
def quantize(a):
|
|
154
192
|
"""Standalone compress: build a depth-aware GGUF from an explicit band (no probing)."""
|
|
155
193
|
if not os.path.isfile(a.gguf):
|
|
@@ -160,4 +198,9 @@ def quantize(a):
|
|
|
160
198
|
else:
|
|
161
199
|
lo, hi = n_lay - a.protect_late, n_lay - 1
|
|
162
200
|
out = a.out or os.path.splitext(a.gguf)[0] + "-depthaware.gguf"
|
|
163
|
-
|
|
201
|
+
imat = getattr(a, "imatrix", None)
|
|
202
|
+
if imat and not os.path.isfile(imat) and not getattr(a, "dry", False):
|
|
203
|
+
raise SystemExit(f"--imatrix file not found: {imat}\n"
|
|
204
|
+
" generate one first, or drop the flag to build without calibration.")
|
|
205
|
+
build_depthaware(a.llama_dir, a.gguf, out, lo, hi, n_lay,
|
|
206
|
+
dry=getattr(a, "dry", False), imatrix=imat)
|
|
@@ -66,7 +66,20 @@ def best_flags(a):
|
|
|
66
66
|
else m.get("kvp", planmod.DEFAULT_KVP))
|
|
67
67
|
_, _, cfgs = planmod.evaluate(t, ac, ne, moe, a.bits, vc, vb, rc, rb, db, geta, act_scale, gl,
|
|
68
68
|
ctx=ctx, kvp=kvp)
|
|
69
|
-
|
|
69
|
+
# run/bench/dashboard LAUNCH stock llama.cpp, so they may only pick placements stock
|
|
70
|
+
# llama.cpp can actually execute. The three-tier expert-cache row's "flags" field is a
|
|
71
|
+
# PROSE description ("+ runtime-managed expert cache"), not argv - exec'ing it hands
|
|
72
|
+
# llama-cli a bare "+" and it dies. optimize/auto already filter this; run/bench must too.
|
|
73
|
+
runnable = [c for c in cfgs if "expert cache" not in c[0]]
|
|
74
|
+
if not runnable:
|
|
75
|
+
raise SystemExit(
|
|
76
|
+
"no placement on this machine is runnable by stock llama.cpp for this file.\n"
|
|
77
|
+
" The planner's best row needs an expert-caching runtime (ktransformers/colibri-class).\n"
|
|
78
|
+
" See the full picture, including that row: quantprobe plan --gguf <file>")
|
|
79
|
+
if runnable[0] is not cfgs[0]:
|
|
80
|
+
print(f"[quantprobe] note: the fastest placement ({cfgs[0][0]}, {cfgs[0][1]:.1f} tok/s) needs an "
|
|
81
|
+
f"expert-caching runtime; launching the fastest STOCK-llama.cpp placement instead.")
|
|
82
|
+
best = runnable[0]
|
|
70
83
|
return best, best[3].replace('"', "").split()
|
|
71
84
|
|
|
72
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.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
|
|
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
|