quantprobe 1.20.0__tar.gz → 1.20.2__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.20.0/quantprobe.egg-info → quantprobe-1.20.2}/PKG-INFO +1 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2}/pyproject.toml +1 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/__init__.py +1 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/calibrate.py +16 -5
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/optimize.py +9 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/plan.py +109 -18
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/runtime.py +10 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/spec.py +23 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2/quantprobe.egg-info}/PKG-INFO +1 -1
- {quantprobe-1.20.0 → quantprobe-1.20.2}/LICENSE +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/README.md +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/__main__.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/auto.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/cli.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/detect.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/fetch.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/probe.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/recipes/mistral-7b.json +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/recipes/qwen2.5-7b.json +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/recipes/qwen3-30b.json +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/recipes/qwen3.5-35b.json +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/recipes.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe/target.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe.egg-info/SOURCES.txt +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/setup.cfg +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/tests/test_engine.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/tests/test_evaluator.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/tests/test_pipeline.py +0 -0
- {quantprobe-1.20.0 → quantprobe-1.20.2}/tests/test_transforms.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.20.
|
|
3
|
+
Version: 1.20.2
|
|
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.20.
|
|
7
|
+
version = "1.20.2"
|
|
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.20.
|
|
11
|
+
__version__ = "1.20.2"
|
|
@@ -146,11 +146,22 @@ def _bench_anchor(model_path, ngl, metric_tokens, llama_dir=None):
|
|
|
146
146
|
if tag in line and "|" in line:
|
|
147
147
|
try:
|
|
148
148
|
toks = float(line.split("|")[-2].strip().split()[0])
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
anchor = dict(placement=("pure CPU (-ngl 0)" if ngl == 0 else "all-in-VRAM (-ngl 99)"),
|
|
150
|
+
metric=tag, tok_s=toks,
|
|
151
|
+
model=os.path.basename(model_path),
|
|
152
|
+
model_gb=round(os.path.getsize(model_path) / 1e9, 3),
|
|
153
|
+
sustained_sm=clk.sustained())
|
|
154
|
+
# the anchor's own spec, so plan can price this arm with the SAME formula it uses
|
|
155
|
+
# for every row (active bytes with the 1.08 overhead), and rescale the ratio by
|
|
156
|
+
# format (L-16) when the target's format mix differs from the anchor's
|
|
157
|
+
try:
|
|
158
|
+
from . import spec as specmod
|
|
159
|
+
s = specmod.from_gguf(model_path)
|
|
160
|
+
anchor["act_gb"] = round(s["a"] * s["bits"] / 8 * 1.08, 4)
|
|
161
|
+
anchor["fmt_bw"] = s.get("fmt_bw")
|
|
162
|
+
except Exception:
|
|
163
|
+
pass
|
|
164
|
+
return anchor, None
|
|
154
165
|
except (ValueError, IndexError):
|
|
155
166
|
break
|
|
156
167
|
return None, "could not parse llama-bench output - anchor skipped"
|
|
@@ -55,12 +55,21 @@ def resolve(a):
|
|
|
55
55
|
db=auto["disk_bw"], geta=auto.get("geta", 0.45), gl=auto.get("gl"),
|
|
56
56
|
hint="THIS machine [auto-detected]")
|
|
57
57
|
print("[quantprobe] hardware auto-detected (pass --machine/flags to optimize another box)")
|
|
58
|
+
# the SAME calibration path plan/bench use - without it optimize searched over
|
|
59
|
+
# uncalibrated constants and disagreed with plan about the same machine (the v1.10.5
|
|
60
|
+
# cross-command bug class; found by audit before any user hit it)
|
|
61
|
+
planmod.apply_calibration_overrides(hw, a)
|
|
58
62
|
vc = planmod.agg_cap(a.vram) if a.vram is not None else hw.get("vc", 0)
|
|
59
63
|
vb = planmod.agg_bw(a.vram_bw, 0.85) if a.vram_bw is not None else hw.get("vb", 0)
|
|
60
64
|
rc = a.ram if a.ram is not None else hw.get("rc", 16)
|
|
61
65
|
rb = a.ram_bw if a.ram_bw is not None else hw.get("rb", 40)
|
|
62
66
|
db = planmod.agg_bw(a.disk_bw, 0.75) if a.disk_bw is not None else hw.get("db", 0.5)
|
|
63
67
|
geta = hw.get("geta", 0.45); gl = hw.get("gl")
|
|
68
|
+
# size-classed anchor dispatch, same function as plan/bench. Bits are being SEARCHED here,
|
|
69
|
+
# so the size class is evaluated at a representative 4.5 bits - the class boundary is a 4x
|
|
70
|
+
# band, which no bits choice inside the search range crosses for a given model.
|
|
71
|
+
vb, geta = planmod.resolve_gpu_eta(hw, a, ac, getattr(a, "bits", None) or 4.5, vb or 0, geta)
|
|
72
|
+
rb = planmod.resolve_cpu_bw(hw, a, ac, getattr(a, "bits", None) or 4.5, rb or 40)
|
|
64
73
|
ctx = getattr(a, "ctx", 0) or 0
|
|
65
74
|
kvp = (a.kv_per_pos * 1024 if getattr(a, "kv_per_pos", None) else m.get("kvp", planmod.DEFAULT_KVP))
|
|
66
75
|
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
|
|
@@ -698,6 +698,7 @@ def apply_calibration_overrides(hw, args):
|
|
|
698
698
|
cal, age = calmod.load()
|
|
699
699
|
if not cal:
|
|
700
700
|
return hw
|
|
701
|
+
hw["_cal_active"] = True
|
|
701
702
|
applied = []
|
|
702
703
|
if cal.get("ram_bw_measured"):
|
|
703
704
|
hw["rb"] = round(cal["ram_bw_measured"] / 0.544)
|
|
@@ -711,32 +712,128 @@ def apply_calibration_overrides(hw, args):
|
|
|
711
712
|
if cal.get("boost_verdict") and "healthy" not in cal["boost_verdict"]:
|
|
712
713
|
print(f"[quantprobe] GPU health at last calibration: {cal['boost_verdict']}")
|
|
713
714
|
if not getattr(args, "no_anchors", False):
|
|
714
|
-
ratios = {}
|
|
715
|
+
ratios, notes = {}, []
|
|
715
716
|
for an in (cal.get("anchors") or []):
|
|
716
717
|
try:
|
|
717
|
-
|
|
718
|
-
|
|
718
|
+
ts = float(an["tok_s"])
|
|
719
|
+
# act_gb prices the anchor with the SAME active-byte convention every row uses
|
|
720
|
+
# (params x bits/8 x 1.08). Old calibrations without it fall back to file size -
|
|
721
|
+
# a known ~8% low bias, which the clamp bounds and a re-calibrate removes.
|
|
722
|
+
act_a = float(an.get("act_gb") or an["model_gb"])
|
|
723
|
+
if act_a <= 0 or ts <= 0:
|
|
719
724
|
continue
|
|
720
725
|
if "pure CPU" in an.get("placement", ""):
|
|
721
|
-
pred = 0.62 * hw["rb"] /
|
|
726
|
+
pred = 0.62 * hw["rb"] / act_a # dense CPU eta, same as evaluate()
|
|
722
727
|
ratios["cpu"] = max(0.70, min(1.40, ts / pred))
|
|
728
|
+
hw["_anchor_cpu_act"] = act_a
|
|
723
729
|
elif "all-in-VRAM" in an.get("placement", "") and hw.get("vb"):
|
|
724
|
-
|
|
730
|
+
eta_a = (an["fmt_bw"] / 192.2) if an.get("fmt_bw") else hw.get("geta", 0.45)
|
|
731
|
+
pred = eta_a * hw["vb"] / act_a
|
|
725
732
|
ratios["gpu"] = max(0.70, min(1.40, ts / pred))
|
|
733
|
+
hw["_anchor_gpu_act"] = act_a # for the size-class dispatcher below
|
|
734
|
+
# FORMAT RESCALING (L-16): the anchor measured ONE format's eta; the target
|
|
735
|
+
# may decode another. Both sides priced from the measured per-format ladder
|
|
736
|
+
# (spec.FORMAT_EBW); missing data -> no rescale.
|
|
737
|
+
tgt_bw = getattr(args, "fmt_bw", None)
|
|
738
|
+
anc_bw = an.get("fmt_bw")
|
|
739
|
+
if tgt_bw and anc_bw:
|
|
740
|
+
f = tgt_bw / anc_bw
|
|
741
|
+
ratios["gpu"] = max(0.60, min(1.50, ratios["gpu"] * f))
|
|
742
|
+
if abs(f - 1.0) > 0.03:
|
|
743
|
+
notes.append(f"format x{f:.2f}")
|
|
726
744
|
except (KeyError, TypeError, ValueError, ZeroDivisionError):
|
|
727
745
|
continue
|
|
728
746
|
if ratios:
|
|
729
747
|
if "cpu" in ratios:
|
|
730
|
-
|
|
748
|
+
# stored, not applied: validity depends on the TARGET's size class, resolved in
|
|
749
|
+
# resolve_gpu_eta (a 0.5B CPU anchor measures 16% hotter per byte than the
|
|
750
|
+
# flagship's CPU path - the small-model bias exists on BOTH tiers)
|
|
751
|
+
hw["_cpu_ratio"] = ratios["cpu"]
|
|
731
752
|
if "gpu" in ratios:
|
|
732
|
-
|
|
753
|
+
# NOT applied to vb here: whether the GPU ratio is valid depends on the TARGET's
|
|
754
|
+
# size class (resolve_gpu_eta below), which is not known yet. Stored instead.
|
|
755
|
+
hw["_gpu_ratio"] = ratios["gpu"]
|
|
756
|
+
extra = ("; " + ", ".join(notes)) if notes else ""
|
|
733
757
|
print("[quantprobe] anchored: "
|
|
734
758
|
+ ", ".join(f"{k.upper()} x{v:.2f}" for k, v in sorted(ratios.items()))
|
|
735
|
-
+ " from your calibrate anchor runs [tier ratios
|
|
736
|
-
" --no-anchors disables]")
|
|
759
|
+
+ f" from your calibrate anchor runs [tier ratios{extra}; --no-anchors disables]")
|
|
737
760
|
return hw
|
|
738
761
|
|
|
739
762
|
|
|
763
|
+
def resolve_gpu_eta(hw, args, active_b, bits, vb, geta):
|
|
764
|
+
"""The size-classed GPU dispatcher - ONE function, used by plan AND runtime.best_flags.
|
|
765
|
+
|
|
766
|
+
The #65 ladder measured the failure this prevents the same day anchors shipped: a 0.5B
|
|
767
|
+
anchor priced a 7B GPU arm 34% low, because small models pay a size floor (#59) that big
|
|
768
|
+
models do not - the anchor conflates format eta with that floor. Rules, each measured:
|
|
769
|
+
- target active >= 1.5 GB and format known: eta comes from the per-format ladder
|
|
770
|
+
(spec.FORMAT_EBW / 192.2 ref) - the reference box's own big-model GPU calibration,
|
|
771
|
+
format-resolved (L-16). The anchor's machine ratio applies ONLY if the anchor sits
|
|
772
|
+
within 4x of the target's active bytes (same size class).
|
|
773
|
+
- smaller targets, or unknown format: the anchor ratio applies as before (a same-class
|
|
774
|
+
small anchor measured -8%/+10%).
|
|
775
|
+
Returns (vb, geta) with the choice printed.
|
|
776
|
+
"""
|
|
777
|
+
ratio = hw.get("_gpu_ratio")
|
|
778
|
+
# the format-ladder eta is a CALIBRATION-class refinement: it applies only on the
|
|
779
|
+
# calibrated auto-detect path. Preset machines keep their fitted geta and the one-sided
|
|
780
|
+
# floor semantics - the ratchet test caught exactly this scope creep (+47% on gemma's
|
|
781
|
+
# custom mixed-quant file when the ladder eta overrode a preset).
|
|
782
|
+
fmt_bw = getattr(args, "fmt_bw", None) if hw.get("_cal_active") else None
|
|
783
|
+
act_est = (active_b or 0) * (bits or 4.5) / 8 * 1.08
|
|
784
|
+
anchor_act = hw.get("_anchor_gpu_act")
|
|
785
|
+
same_class = bool(anchor_act and act_est and act_est / 2 <= anchor_act <= act_est * 2)
|
|
786
|
+
big = act_est >= 1.5
|
|
787
|
+
# The size-class guard holds with OR without format knowledge: an out-of-class anchor ratio
|
|
788
|
+
# never touches a big target (that misapplication is what the ratchet test caught).
|
|
789
|
+
use_ratio = bool(ratio) and (same_class or not big)
|
|
790
|
+
if fmt_bw:
|
|
791
|
+
# format-eta on BOTH sides: the anchor ratio is priced against the anchor's format eta,
|
|
792
|
+
# so targets must use format eta too or the two references diverge (measured: pricing
|
|
793
|
+
# the ratio on fmt-eta while the row used table-eta halved the small-model predictions).
|
|
794
|
+
# Within the anchor's class the ratio then encodes the measured size floor and the
|
|
795
|
+
# anchored prediction of the anchor's own arm is exact by construction.
|
|
796
|
+
eta_fmt = fmt_bw / 192.2
|
|
797
|
+
if not use_ratio and ratio:
|
|
798
|
+
print(f"[quantprobe] GPU eta from the measured format ladder: {eta_fmt:.2f} "
|
|
799
|
+
f"(fmt {fmt_bw:.0f} GB/s ref; anchor outside this size class, machine ratio not applied)")
|
|
800
|
+
return (vb * ratio, eta_fmt) if use_ratio else (vb, eta_fmt)
|
|
801
|
+
if ratio and not use_ratio:
|
|
802
|
+
print("[quantprobe] GPU anchor is outside this model's size class - machine ratio not "
|
|
803
|
+
"applied (small anchors mis-price big models; #65).")
|
|
804
|
+
return (vb * ratio, geta) if use_ratio else (vb, geta)
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
def resolve_cpu_bw(hw, args, active_b, bits, rb):
|
|
808
|
+
"""CPU-tier twin of resolve_gpu_eta: the anchor's machine ratio applies only within the
|
|
809
|
+
anchor's size class. Same measured basis: the 0.5B CPU anchor runs 32.6 GB/s effective where
|
|
810
|
+
the flagship's CPU expert path measured 28.0 (E3) - a +16% small-model bias that, applied to
|
|
811
|
+
a 30B, over-promised the split row by 25% (caught by the post-ship consistency check)."""
|
|
812
|
+
ratio = hw.get("_cpu_ratio")
|
|
813
|
+
if not ratio:
|
|
814
|
+
return rb
|
|
815
|
+
act_est = (active_b or 0) * (bits or 4.5) / 8 * 1.08
|
|
816
|
+
anchor_act = hw.get("_anchor_cpu_act")
|
|
817
|
+
same_class = bool(anchor_act and act_est and act_est / 2 <= anchor_act <= act_est * 2)
|
|
818
|
+
if same_class or act_est < 1.5:
|
|
819
|
+
return rb * ratio
|
|
820
|
+
print("[quantprobe] CPU anchor is outside this model's size class - machine ratio not "
|
|
821
|
+
"applied (small anchors mis-price big models; #65).")
|
|
822
|
+
return rb
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
def append_threads_flag(flags, placement):
|
|
826
|
+
"""--threads for CPU-resident placements - ONE helper for plan's printout AND runtime's
|
|
827
|
+
launched command, so the command a user sees is the command run/bench executes (E-06's
|
|
828
|
+
fork auto-detected 6 of 12 threads; C-07 measured the 40% class of swing)."""
|
|
829
|
+
import os as _os
|
|
830
|
+
n = _os.cpu_count() or 0
|
|
831
|
+
if n and any(k in placement for k in ("->RAM", "CPU", "disk", "split experts")) \
|
|
832
|
+
and "--threads" not in flags:
|
|
833
|
+
return f"{flags} --threads {n}", n
|
|
834
|
+
return flags, None
|
|
835
|
+
|
|
836
|
+
|
|
740
837
|
def run(args):
|
|
741
838
|
from . import spec as specmod
|
|
742
839
|
specmod.apply(args)
|
|
@@ -778,6 +875,8 @@ def run(args):
|
|
|
778
875
|
import os as _os
|
|
779
876
|
_g = getattr(args, 'gguf', None)
|
|
780
877
|
true_size = _os.path.getsize(_g) / 1e9 if _g and _os.path.isfile(_g) else None
|
|
878
|
+
vb, geta = resolve_gpu_eta(hw, args, a, args.bits, vb, geta)
|
|
879
|
+
rb = resolve_cpu_bw(hw, args, a, args.bits, rb)
|
|
781
880
|
size, act, cfgs = evaluate(t, a, ne, moe, args.bits, vc, vb, rc, rb, db, geta, gl=gl, ctx=ctx,
|
|
782
881
|
kvp=kvp, n_layer=nlay, true_size_gb=true_size)
|
|
783
882
|
q = qual_of(moe, args.bits)
|
|
@@ -802,15 +901,7 @@ def run(args):
|
|
|
802
901
|
# VRAM headroom). Not part of the law: `evaluate` is untouched and no anchor can move.
|
|
803
902
|
ub = ubatch_flags(best[0], ne * max(args.bits, 4.5) / 8 * 1.08 if moe else 0.0, vc)
|
|
804
903
|
run_flags = f"{best[3]} {ub}" if ub else best[3]
|
|
805
|
-
|
|
806
|
-
# replication got 6 of 12 on a Ryzen 8600G and reported "decode struggled at 2 t/s ... this
|
|
807
|
-
# flag alone helped it jump past 9"; our own C-07 measured a 40% swing from the CPU-thread
|
|
808
|
-
# runtime alone). Emit the logical count explicitly whenever the placement has CPU-resident
|
|
809
|
-
# work; harmless when it does not.
|
|
810
|
-
import os as _os2
|
|
811
|
-
nthreads = _os2.cpu_count() or 0
|
|
812
|
-
if nthreads and any(k in best[0] for k in ("->RAM", "CPU", "disk", "split experts")):
|
|
813
|
-
run_flags = f"{run_flags} --threads {nthreads}"
|
|
904
|
+
run_flags, nthreads = append_threads_flag(run_flags, best[0])
|
|
814
905
|
print(f"\n run it: llama-server -m model.gguf {run_flags}")
|
|
815
906
|
if "--threads" in run_flags:
|
|
816
907
|
print(f" (--threads {nthreads} = this machine's LOGICAL cores; llama.cpp's own"
|
|
@@ -74,6 +74,9 @@ def best_flags(a):
|
|
|
74
74
|
kvp = (a.kv_per_pos * 1024 if getattr(a, "kv_per_pos", None)
|
|
75
75
|
else m.get("kvp", planmod.DEFAULT_KVP))
|
|
76
76
|
_true = os.path.getsize(gguf) / 1e9 if gguf and os.path.isfile(gguf) else None
|
|
77
|
+
# same size-classed GPU-eta dispatch as plan (ONE shared function; layer 3 enforces parity)
|
|
78
|
+
vb, geta = planmod.resolve_gpu_eta(hw, a, ac, a.bits, vb, geta)
|
|
79
|
+
rb = planmod.resolve_cpu_bw(hw, a, ac, a.bits, rb)
|
|
77
80
|
_, _, cfgs = planmod.evaluate(t, ac, ne, moe, a.bits, vc, vb, rc, rb, db, geta, act_scale, gl,
|
|
78
81
|
ctx=ctx, kvp=kvp, true_size_gb=_true,
|
|
79
82
|
n_layer=planmod.effective_n_layer(a, m))
|
|
@@ -91,7 +94,10 @@ def best_flags(a):
|
|
|
91
94
|
print(f"[quantprobe] note: the fastest placement ({cfgs[0][0]}, {cfgs[0][1]:.1f} tok/s) needs an "
|
|
92
95
|
f"expert-caching runtime; launching the fastest STOCK-llama.cpp placement instead.")
|
|
93
96
|
best = runnable[0]
|
|
94
|
-
|
|
97
|
+
# same --threads logic as plan's printout - the command a user SEES must be the command
|
|
98
|
+
# run/bench EXECUTE (found by the end-to-end audit: plan printed --threads, run dropped it)
|
|
99
|
+
fl_str, _ = planmod.append_threads_flag(best[3].replace('"', ""), best[0])
|
|
100
|
+
return best, fl_str.split()
|
|
95
101
|
|
|
96
102
|
|
|
97
103
|
def run(a):
|
|
@@ -130,11 +136,14 @@ def bench(a):
|
|
|
130
136
|
# defect in this project's history, so unknown flags now RAISE.
|
|
131
137
|
BENCH_VALUED = {"-ngl", "-ot", "-ub", "-b", "-c", "-t"} # take a value, same spelling in bench
|
|
132
138
|
BENCH_TRANSLATE = {"--no-mmap": ["--mmap", "0"]} # spelled differently in llama-bench
|
|
139
|
+
BENCH_VALUED_RENAME = {"--threads": "-t"} # take a value, renamed in bench
|
|
133
140
|
bflags, i = [], 0
|
|
134
141
|
while i < len(flags):
|
|
135
142
|
f = flags[i]
|
|
136
143
|
if f in BENCH_TRANSLATE:
|
|
137
144
|
bflags += BENCH_TRANSLATE[f]; i += 1
|
|
145
|
+
elif f in BENCH_VALUED_RENAME:
|
|
146
|
+
bflags += [BENCH_VALUED_RENAME[f], flags[i + 1]]; i += 2
|
|
138
147
|
elif f in BENCH_VALUED:
|
|
139
148
|
bflags += [f, flags[i + 1]]; i += 2
|
|
140
149
|
else:
|
|
@@ -22,6 +22,20 @@ def _field(r, *names):
|
|
|
22
22
|
return None
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
# Effective decode bandwidth BY FORMAT on the reference box, e2e (GB/s). This is L-16 made
|
|
26
|
+
# actionable: eta is a property of the format, so an anchor measured on one format must be
|
|
27
|
+
# rescaled before it prices another (prereg #65 measured the cost of NOT doing this: -34% on
|
|
28
|
+
# Q4_K_M from a Q8_0 anchor). 'measured' = e2e on a real 7B (#52/#53) or in-situ per-op (#58);
|
|
29
|
+
# 'derived' = scaled from the kernelprobe ladder. Formats not listed (IQ*, exotic) are excluded
|
|
30
|
+
# from the weighting; if coverage falls below 60% of bytes the factor is withheld entirely -
|
|
31
|
+
# no number beats a wrong number.
|
|
32
|
+
FORMAT_EBW = {
|
|
33
|
+
"Q4_0": 119.1, "Q4_K": 106.4, "Q2_K": 65.4, "Q3_K": 57.3, "Q6_K": 100.0, # measured
|
|
34
|
+
"Q8_0": 115.0, "Q5_K": 103.0, "Q5_0": 117.0, "Q5_1": 115.0, # derived
|
|
35
|
+
"F16": 150.0, "F32": 150.0, "BF16": 150.0, # derived
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
25
39
|
def from_gguf(path):
|
|
26
40
|
from gguf import GGUFReader
|
|
27
41
|
r = GGUFReader(path)
|
|
@@ -29,6 +43,7 @@ def from_gguf(path):
|
|
|
29
43
|
total = 0
|
|
30
44
|
routed = 0
|
|
31
45
|
iq_bytes = all_bytes = 0
|
|
46
|
+
fmt_wsum = fmt_bytes = 0.0
|
|
32
47
|
for t in r.tensors:
|
|
33
48
|
n = 1
|
|
34
49
|
for d in t.shape:
|
|
@@ -45,6 +60,10 @@ def from_gguf(path):
|
|
|
45
60
|
all_bytes += nb
|
|
46
61
|
if t.tensor_type.name.startswith("IQ"):
|
|
47
62
|
iq_bytes += nb
|
|
63
|
+
tn = t.tensor_type.name
|
|
64
|
+
if tn in FORMAT_EBW:
|
|
65
|
+
fmt_wsum += nb * FORMAT_EBW[tn]
|
|
66
|
+
fmt_bytes += nb
|
|
48
67
|
ne_params = total - routed
|
|
49
68
|
|
|
50
69
|
n_exp = _field(r, ".expert_count")
|
|
@@ -79,9 +98,11 @@ def from_gguf(path):
|
|
|
79
98
|
except Exception:
|
|
80
99
|
arch = None
|
|
81
100
|
break
|
|
101
|
+
fmt_bw = (fmt_wsum / fmt_bytes) if (all_bytes and fmt_bytes / all_bytes >= 0.6) else None
|
|
82
102
|
return dict(t=total / 1e9, a=active / 1e9, ne=ne_params / 1e9, moe=moe,
|
|
83
103
|
bits=round(bits, 2), kvp=int(kvp), n_layer=n_layer, arch=arch,
|
|
84
|
-
iq_share=(iq_bytes / all_bytes) if all_bytes else 0.0
|
|
104
|
+
iq_share=(iq_bytes / all_bytes) if all_bytes else 0.0,
|
|
105
|
+
fmt_bw=round(fmt_bw, 1) if fmt_bw else None)
|
|
85
106
|
|
|
86
107
|
|
|
87
108
|
def apply(a, quiet=False):
|
|
@@ -106,6 +127,7 @@ def apply(a, quiet=False):
|
|
|
106
127
|
if getattr(a, "n_layer", None) is None:
|
|
107
128
|
a.n_layer = s["n_layer"] # enables the MoE partial-offload -ot regex (needs real layer indices)
|
|
108
129
|
a.iq_share = s.get("iq_share", 0.0) # read-only: lets plan warn when IQ weights land on a CPU tier
|
|
130
|
+
a.fmt_bw = s.get("fmt_bw") # read-only: lets anchored predictions rescale by format (L-16)
|
|
109
131
|
if used and not quiet:
|
|
110
132
|
print(f"[quantprobe] read from GGUF: " + ", ".join(used))
|
|
111
133
|
return True
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.20.
|
|
3
|
+
Version: 1.20.2
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|