quantprobe 1.19.0__tar.gz → 1.20.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {quantprobe-1.19.0/quantprobe.egg-info → quantprobe-1.20.1}/PKG-INFO +1 -1
  2. {quantprobe-1.19.0 → quantprobe-1.20.1}/pyproject.toml +1 -1
  3. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/__init__.py +1 -1
  4. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/calibrate.py +69 -19
  5. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/cli.py +4 -0
  6. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/plan.py +120 -24
  7. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/runtime.py +8 -0
  8. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/spec.py +23 -1
  9. {quantprobe-1.19.0 → quantprobe-1.20.1/quantprobe.egg-info}/PKG-INFO +1 -1
  10. {quantprobe-1.19.0 → quantprobe-1.20.1}/LICENSE +0 -0
  11. {quantprobe-1.19.0 → quantprobe-1.20.1}/README.md +0 -0
  12. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/__main__.py +0 -0
  13. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/auto.py +0 -0
  14. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/dashboard.py +0 -0
  15. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/detect.py +0 -0
  16. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/fetch.py +0 -0
  17. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/optimize.py +0 -0
  18. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/probe.py +0 -0
  19. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/recipes/mistral-7b.json +0 -0
  20. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/recipes/qwen2.5-7b.json +0 -0
  21. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/recipes/qwen3-30b.json +0 -0
  22. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/recipes/qwen3.5-35b.json +0 -0
  23. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/recipes.py +0 -0
  24. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe/target.py +0 -0
  25. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe.egg-info/SOURCES.txt +0 -0
  26. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe.egg-info/dependency_links.txt +0 -0
  27. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe.egg-info/entry_points.txt +0 -0
  28. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe.egg-info/requires.txt +0 -0
  29. {quantprobe-1.19.0 → quantprobe-1.20.1}/quantprobe.egg-info/top_level.txt +0 -0
  30. {quantprobe-1.19.0 → quantprobe-1.20.1}/setup.cfg +0 -0
  31. {quantprobe-1.19.0 → quantprobe-1.20.1}/tests/test_engine.py +0 -0
  32. {quantprobe-1.19.0 → quantprobe-1.20.1}/tests/test_evaluator.py +0 -0
  33. {quantprobe-1.19.0 → quantprobe-1.20.1}/tests/test_pipeline.py +0 -0
  34. {quantprobe-1.19.0 → quantprobe-1.20.1}/tests/test_transforms.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.19.0
3
+ Version: 1.20.1
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.19.0"
7
+ version = "1.20.1"
8
8
  description = "Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -8,4 +8,4 @@ Three commands, all grounded in measured laws (see LAWS.md in the repo):
8
8
  Every constant in `plan` is fitted from measurements published in the repo, including two
9
9
  pre-registered hardware predictions confirmed within 8%.
10
10
  """
11
- __version__ = "1.19.0"
11
+ __version__ = "1.20.1"
@@ -84,7 +84,7 @@ def gpu_state():
84
84
  class ClockSampler:
85
85
  """Samples clocks.sm in a thread while a benchmark runs - the boost-state instrument."""
86
86
 
87
- def __init__(self, every=3.0):
87
+ def __init__(self, every=1.0):
88
88
  self.every, self.samples, self._stop = every, [], threading.Event()
89
89
  self._t = threading.Thread(target=self._loop, daemon=True)
90
90
 
@@ -104,9 +104,15 @@ class ClockSampler:
104
104
  self._t.join(timeout=5)
105
105
 
106
106
  def sustained(self):
107
- """Median SM MHz over loaded samples (>1000 MHz), or None."""
107
+ """Median SM MHz over loaded samples (>1000 MHz); None below 3 samples.
108
+
109
+ The minimum matters: a short benchmark gives the sampler only the model-LOAD phase,
110
+ where clocks sit mid-ramp - measured on the reference box as a false STUCK-BOOST verdict
111
+ (1506 read during load; the very next real benchmarks sustained 1873-1898). One or two
112
+ samples are a coin flip, not a diagnosis.
113
+ """
108
114
  loaded = sorted(s for s, _ in self.samples if s > 1000)
109
- return loaded[len(loaded) // 2] if loaded else None
115
+ return loaded[len(loaded) // 2] if len(loaded) >= 3 else None
110
116
 
111
117
 
112
118
  def boost_verdict(sustained, sm_max, temp):
@@ -125,33 +131,62 @@ def boost_verdict(sustained, sm_max, temp):
125
131
  "cards cannot reset it live: REBOOT, then re-run calibrate")
126
132
 
127
133
 
128
- def cpu_anchor(model_path, llama_dir=None):
129
- """Pure-CPU tg32 on the user's own file: a real measured reference point.
130
-
131
- Placement chosen because it needs no VRAM-fit logic and no MoE byte accounting - it is the
132
- one arm that runs identically on every machine that can load the file at all.
133
- """
134
+ def _bench_anchor(model_path, ngl, metric_tokens, llama_dir=None):
135
+ """One llama-bench arm on the user's own file, clocks sampled. Returns (dict, err)."""
134
136
  from .runtime import find_llama
135
137
  try:
136
138
  binp = find_llama(llama_dir, "llama-bench")
137
139
  except SystemExit:
138
140
  return None, "llama-bench not found - anchor skipped (pass --llama-dir)"
141
+ tag = f"tg{metric_tokens}"
139
142
  with ClockSampler() as clk:
140
- out = _run([binp, "-m", model_path, "-ngl", "0", "-n", "32", "-p", "0", "-r", "1"],
141
- timeout=1800)
143
+ out = _run([binp, "-m", model_path, "-ngl", str(ngl), "-n", str(metric_tokens),
144
+ "-p", "0", "-r", "1"], timeout=1800)
142
145
  for line in out.splitlines():
143
- if "tg32" in line and "|" in line:
146
+ if tag in line and "|" in line:
144
147
  try:
145
148
  toks = float(line.split("|")[-2].strip().split()[0])
146
- return dict(placement="pure CPU (-ngl 0)", metric="tg32", tok_s=toks,
147
- model=os.path.basename(model_path),
148
- model_gb=round(os.path.getsize(model_path) / 1e9, 3),
149
- sustained_sm=clk.sustained()), None
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
150
165
  except (ValueError, IndexError):
151
166
  break
152
167
  return None, "could not parse llama-bench output - anchor skipped"
153
168
 
154
169
 
170
+ def cpu_anchor(model_path, llama_dir=None):
171
+ """Pure-CPU tg32 on the user's own file: a real measured reference point.
172
+
173
+ Placement chosen because it needs no VRAM-fit logic and no MoE byte accounting - it is the
174
+ one arm that runs identically on every machine that can load the file at all.
175
+ """
176
+ return _bench_anchor(model_path, 0, 32, llama_dir)
177
+
178
+
179
+ def gpu_anchor(model_path, vram_gb, llama_dir=None):
180
+ """All-in-VRAM tg128 on the user's own file - the GPU-tier anchor. Only offered when the file
181
+ clearly fits (80% of detected VRAM), because an OOM teaches nothing and wastes minutes.
182
+ tg128 rather than tg64: the run must outlast the model-load phase by enough for the clock
183
+ sampler to collect real loaded samples (see ClockSampler.sustained)."""
184
+ gb = os.path.getsize(model_path) / 1e9
185
+ if not vram_gb or gb > 0.8 * vram_gb:
186
+ return None, f"model {gb:.1f} GB does not clearly fit {vram_gb or 0:.0f} GB VRAM - GPU anchor skipped"
187
+ return _bench_anchor(model_path, 99, 128, llama_dir)
188
+
189
+
155
190
  def load():
156
191
  """Return (calibration dict, age_days) or (None, None). Used by plan."""
157
192
  try:
@@ -189,19 +224,34 @@ def run(a):
189
224
  cal["disk_bw_measured"] = round(measure_disk(model), 2)
190
225
  print(f" disk: {cal['disk_bw_measured']:.2f} GB/s sequential on your file [measured]")
191
226
  if not getattr(a, "skip_bench", False):
227
+ cal["anchors"] = []
192
228
  print(" anchor: running llama-bench -ngl 0 tg32 on your file (1-10 min on big models)...")
193
229
  anchor, why = cpu_anchor(model, getattr(a, "llama_dir", None))
194
230
  if anchor:
195
- cal["anchors"] = [anchor]
231
+ cal["anchors"].append(anchor)
196
232
  print(f" anchor: {anchor['tok_s']:.2f} tok/s pure-CPU on "
197
233
  f"{anchor['model']} ({anchor['model_gb']:g} GB) [measured]")
198
- v = boost_verdict(anchor.get("sustained_sm"), st and st.get("sm_max"),
234
+ else:
235
+ print(f" anchor: {why}")
236
+ vram_gb = None
237
+ if st:
238
+ out = _run(["nvidia-smi", "--query-gpu=memory.total", "--format=csv,noheader,nounits"])
239
+ try:
240
+ vram_gb = float(out.strip().splitlines()[0]) / 1024
241
+ except (ValueError, IndexError):
242
+ pass
243
+ ganchor, gwhy = gpu_anchor(model, vram_gb, getattr(a, "llama_dir", None))
244
+ if ganchor:
245
+ cal["anchors"].append(ganchor)
246
+ print(f" anchor: {ganchor['tok_s']:.2f} tok/s all-in-VRAM on "
247
+ f"{ganchor['model']} [measured]")
248
+ v = boost_verdict(ganchor.get("sustained_sm"), st and st.get("sm_max"),
199
249
  st and st.get("temp"))
200
250
  if v:
201
251
  cal["boost_verdict"] = v
202
252
  print(f" GPU under load: {v}")
203
253
  else:
204
- print(f" anchor: {why}")
254
+ print(f" anchor: {gwhy}")
205
255
  elif model:
206
256
  print(f" --model: file not found: {model}")
207
257
  else:
@@ -45,6 +45,8 @@ def main():
45
45
  q.add_argument("--gguf", default=None, help="optional: read total/active/bits/KV exactly from this GGUF")
46
46
  q.add_argument("--ctx", type=int, default=0, help="context depth: adds KV reads/token + KV memory to the prediction (Law 4 v2)")
47
47
  q.add_argument("--kv-per-pos", type=float, default=None, help="KV bytes per position in KB (default: model preset, or 96)")
48
+ q.add_argument("--no-anchors", action="store_true",
49
+ help="ignore calibrate's anchor runs; use the plain law constants")
48
50
 
49
51
  def hwargs(sp):
50
52
  sp.add_argument("--model", default=None); sp.add_argument("--machine", default=None)
@@ -57,6 +59,8 @@ def main():
57
59
  sp.add_argument("--ctx", type=int, default=0, help="context depth for the prediction (Law 4 v2)")
58
60
  sp.add_argument("--kv-per-pos", type=float, default=None, help="KV bytes per position in KB")
59
61
  sp.add_argument("--llama-dir", default=None); sp.add_argument("--dry", action="store_true")
62
+ sp.add_argument("--no-anchors", action="store_true",
63
+ help="ignore calibrate's anchor runs; use the plain law constants")
60
64
 
61
65
  r = sub.add_parser("run", help="plan the best placement, then launch llama.cpp chat with those flags")
62
66
  r.add_argument("--gguf", required=True); hwargs(r)
@@ -676,6 +676,124 @@ def check_presets(args):
676
676
  " or pass flags: --vram/--vram-bw/--ram/--ram-bw/--disk-bw (no flags = auto-detect this box)" % (mac, ", ".join(sorted(MACHINES))))
677
677
 
678
678
 
679
+ def apply_calibration_overrides(hw, args):
680
+ """MEASURED beats spec-sheet, on this machine only - the ONE place calibration and anchors
681
+ touch the constants, shared by plan AND runtime.best_flags so the two commands can never
682
+ disagree about the same input again (the v1.10.5 bug class; layer 3 enforces it, and caught
683
+ this function's absence the same day the anchors shipped).
684
+
685
+ Calibration (rb/db): calibrate measures the DELIVERED stream; the law's constants were fitted
686
+ against theoretical-peak inputs on the reference box, whose measured stream was 26.1 of a
687
+ 48 GB/s peak (0.544). Expressing the user's measurement in the same peak-units keeps every
688
+ fitted eta valid. Assumption stated: stream-realism fraction is machine-similar.
689
+
690
+ Anchors (prereg #64, gate: LOO median error 19.0% -> 5.8%): each anchor becomes a TIER-LOCAL
691
+ ratio between what the anchor arm measured and what the law predicts for that same arm - the
692
+ ratio then scales that tier's bandwidth for every OTHER prediction. The target's own
693
+ measurement is never consulted (that would be a lookup, the #59 failure class). Ratios are
694
+ clamped 0.70-1.40; anchor models are dense, so dense etas price their arms; the clamp absorbs
695
+ anchor-format bias (L-16). `--no-anchors` disables.
696
+ """
697
+ from . import calibrate as calmod
698
+ cal, age = calmod.load()
699
+ if not cal:
700
+ return hw
701
+ hw["_cal_active"] = True
702
+ applied = []
703
+ if cal.get("ram_bw_measured"):
704
+ hw["rb"] = round(cal["ram_bw_measured"] / 0.544)
705
+ applied.append(f"ram {cal['ram_bw_measured']:g} GB/s measured")
706
+ if cal.get("disk_bw_measured"):
707
+ hw["db"] = cal["disk_bw_measured"]
708
+ applied.append(f"disk {cal['disk_bw_measured']:g} GB/s measured")
709
+ if applied:
710
+ stale = f"; {age:.0f} days old - re-run `quantprobe calibrate`" if age and age > calmod.STALE_DAYS else ""
711
+ print(f"[quantprobe] calibration applied [{'; '.join(applied)}] ({cal.get('date','?')}{stale})")
712
+ if cal.get("boost_verdict") and "healthy" not in cal["boost_verdict"]:
713
+ print(f"[quantprobe] GPU health at last calibration: {cal['boost_verdict']}")
714
+ if not getattr(args, "no_anchors", False):
715
+ ratios, notes = {}, []
716
+ for an in (cal.get("anchors") or []):
717
+ try:
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:
724
+ continue
725
+ if "pure CPU" in an.get("placement", ""):
726
+ pred = 0.62 * hw["rb"] / act_a # dense CPU eta, same as evaluate()
727
+ ratios["cpu"] = max(0.70, min(1.40, ts / pred))
728
+ elif "all-in-VRAM" in an.get("placement", "") and hw.get("vb"):
729
+ pred = hw.get("geta", 0.45) * hw["vb"] / act_a
730
+ ratios["gpu"] = max(0.70, min(1.40, ts / pred))
731
+ hw["_anchor_gpu_act"] = act_a # for the size-class dispatcher below
732
+ # FORMAT RESCALING (L-16): the anchor measured ONE format's eta; the target
733
+ # may decode another. Both sides priced from the measured per-format ladder
734
+ # (spec.FORMAT_EBW); missing data -> no rescale.
735
+ tgt_bw = getattr(args, "fmt_bw", None)
736
+ anc_bw = an.get("fmt_bw")
737
+ if tgt_bw and anc_bw:
738
+ f = tgt_bw / anc_bw
739
+ ratios["gpu"] = max(0.60, min(1.50, ratios["gpu"] * f))
740
+ if abs(f - 1.0) > 0.03:
741
+ notes.append(f"format x{f:.2f}")
742
+ except (KeyError, TypeError, ValueError, ZeroDivisionError):
743
+ continue
744
+ if ratios:
745
+ if "cpu" in ratios:
746
+ hw["rb"] = hw["rb"] * ratios["cpu"]
747
+ if "gpu" in ratios:
748
+ # NOT applied to vb here: whether the GPU ratio is valid depends on the TARGET's
749
+ # size class (resolve_gpu_eta below), which is not known yet. Stored instead.
750
+ hw["_gpu_ratio"] = ratios["gpu"]
751
+ extra = ("; " + ", ".join(notes)) if notes else ""
752
+ print("[quantprobe] anchored: "
753
+ + ", ".join(f"{k.upper()} x{v:.2f}" for k, v in sorted(ratios.items()))
754
+ + f" from your calibrate anchor runs [tier ratios{extra}; --no-anchors disables]")
755
+ return hw
756
+
757
+
758
+ def resolve_gpu_eta(hw, args, active_b, bits, vb, geta):
759
+ """The size-classed GPU dispatcher - ONE function, used by plan AND runtime.best_flags.
760
+
761
+ The #65 ladder measured the failure this prevents the same day anchors shipped: a 0.5B
762
+ anchor priced a 7B GPU arm 34% low, because small models pay a size floor (#59) that big
763
+ models do not - the anchor conflates format eta with that floor. Rules, each measured:
764
+ - target active >= 1.5 GB and format known: eta comes from the per-format ladder
765
+ (spec.FORMAT_EBW / 192.2 ref) - the reference box's own big-model GPU calibration,
766
+ format-resolved (L-16). The anchor's machine ratio applies ONLY if the anchor sits
767
+ within 4x of the target's active bytes (same size class).
768
+ - smaller targets, or unknown format: the anchor ratio applies as before (a same-class
769
+ small anchor measured -8%/+10%).
770
+ Returns (vb, geta) with the choice printed.
771
+ """
772
+ ratio = hw.get("_gpu_ratio")
773
+ # the format-ladder eta is a CALIBRATION-class refinement: it applies only on the
774
+ # calibrated auto-detect path. Preset machines keep their fitted geta and the one-sided
775
+ # floor semantics - the ratchet test caught exactly this scope creep (+47% on gemma's
776
+ # custom mixed-quant file when the ladder eta overrode a preset).
777
+ fmt_bw = getattr(args, "fmt_bw", None) if hw.get("_cal_active") else None
778
+ act_est = (active_b or 0) * (bits or 4.5) / 8 * 1.08
779
+ anchor_act = hw.get("_anchor_gpu_act")
780
+ same_class = bool(anchor_act and act_est and act_est / 4 <= anchor_act <= act_est * 4)
781
+ big = act_est >= 1.5
782
+ # The size-class guard holds with OR without format knowledge: an out-of-class anchor ratio
783
+ # never touches a big target (that misapplication is what the ratchet test caught).
784
+ use_ratio = bool(ratio) and (same_class or not big)
785
+ if fmt_bw and big:
786
+ eta_fmt = fmt_bw / 192.2
787
+ if not use_ratio and ratio:
788
+ print(f"[quantprobe] GPU eta from the measured format ladder: {eta_fmt:.2f} "
789
+ f"(fmt {fmt_bw:.0f} GB/s ref; anchor outside this size class, machine ratio not applied)")
790
+ return (vb * ratio, eta_fmt) if use_ratio else (vb, eta_fmt)
791
+ if ratio and not use_ratio:
792
+ print("[quantprobe] GPU anchor is outside this model's size class - machine ratio not "
793
+ "applied (small anchors under-price big models; #65). CPU anchor still applies.")
794
+ return (vb * ratio, geta) if use_ratio else (vb, geta)
795
+
796
+
679
797
  def run(args):
680
798
  from . import spec as specmod
681
799
  specmod.apply(args)
@@ -697,30 +815,7 @@ def run(args):
697
815
  print("[quantprobe] no hardware flags: auto-detected this machine "
698
816
  f"(vram {hw['vc']:g}GB@{hw['vb']:g} | ram {hw['rc']:g}GB@{hw['rb']:g} | disk {hw['db']:g} GB/s). "
699
817
  "Pass --machine/flags to estimate a different box.")
700
- # calibration overrides detection: MEASURED beats spec-sheet, on this machine only.
701
- # Constants scoped deliberately (prereg #59: fitted constants do not transfer; measured
702
- # local ones are exactly what does). Delete ~/.quantprobe/calibration.json to disable.
703
- from . import calibrate as calmod
704
- cal, age = calmod.load()
705
- if cal:
706
- applied = []
707
- if cal.get("ram_bw_measured"):
708
- # calibrate measures the DELIVERED stream; the law's constants were fitted
709
- # against theoretical-peak inputs on the reference box, whose measured stream
710
- # was 26.1 of a 48 GB/s peak (0.544). Expressing the user's measurement in the
711
- # same peak-units keeps every fitted eta valid: peak_equiv = measured / 0.544.
712
- # Assumption stated: stream-realism fraction is machine-similar. Anchoring on a
713
- # measurement with one stated assumption beats assuming the peak outright.
714
- hw["rb"] = round(cal["ram_bw_measured"] / 0.544)
715
- applied.append(f"ram {cal['ram_bw_measured']:g} GB/s measured")
716
- if cal.get("disk_bw_measured"):
717
- hw["db"] = cal["disk_bw_measured"]
718
- applied.append(f"disk {cal['disk_bw_measured']:g} GB/s measured")
719
- if applied:
720
- stale = f"; {age:.0f} days old - re-run `quantprobe calibrate`" if age and age > calmod.STALE_DAYS else ""
721
- print(f"[quantprobe] calibration applied [{'; '.join(applied)}] ({cal.get('date','?')}{stale})")
722
- if cal.get("boost_verdict") and "healthy" not in cal["boost_verdict"]:
723
- print(f"[quantprobe] GPU health at last calibration: {cal['boost_verdict']}")
818
+ apply_calibration_overrides(hw, args)
724
819
  vc = hw.get("vc", args.vram); vb = hw.get("vb", args.vram_bw)
725
820
  rc = hw.get("rc", args.ram); rb = hw.get("rb", args.ram_bw)
726
821
  db = hw.get("db", args.disk_bw); geta = hw.get("geta", 0.45); gl = hw.get("gl", None)
@@ -740,6 +835,7 @@ def run(args):
740
835
  import os as _os
741
836
  _g = getattr(args, 'gguf', None)
742
837
  true_size = _os.path.getsize(_g) / 1e9 if _g and _os.path.isfile(_g) else None
838
+ vb, geta = resolve_gpu_eta(hw, args, a, args.bits, vb, geta)
743
839
  size, act, cfgs = evaluate(t, a, ne, moe, args.bits, vc, vb, rc, rb, db, geta, gl=gl, ctx=ctx,
744
840
  kvp=kvp, n_layer=nlay, true_size_gb=true_size)
745
841
  q = qual_of(moe, args.bits)
@@ -45,6 +45,9 @@ def best_flags(a):
45
45
  db=auto["disk_bw"], geta=auto.get("geta", 0.45), gl=auto.get("gl"))
46
46
  print("[quantprobe] hardware auto-detected (run `quantprobe hw` for details; "
47
47
  "pass --machine/flags to estimate a different box)")
48
+ # the SAME calibration+anchor path plan uses - one function, so the commands can
49
+ # never disagree about the same input (v1.10.5 bug class; layer 3 enforces this)
50
+ planmod.apply_calibration_overrides(hw, a)
48
51
  vc = planmod.agg_cap(a.vram) if a.vram is not None else hw.get("vc", 0)
49
52
  vb = planmod.agg_bw(a.vram_bw, 0.85) if a.vram_bw is not None else hw.get("vb", 0)
50
53
  rc = a.ram if a.ram is not None else hw.get("rc", 16)
@@ -71,6 +74,8 @@ def best_flags(a):
71
74
  kvp = (a.kv_per_pos * 1024 if getattr(a, "kv_per_pos", None)
72
75
  else m.get("kvp", planmod.DEFAULT_KVP))
73
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)
74
79
  _, _, cfgs = planmod.evaluate(t, ac, ne, moe, a.bits, vc, vb, rc, rb, db, geta, act_scale, gl,
75
80
  ctx=ctx, kvp=kvp, true_size_gb=_true,
76
81
  n_layer=planmod.effective_n_layer(a, m))
@@ -188,6 +193,9 @@ def tier_view(a, best):
188
193
  db=auto["disk_bw"], geta=auto.get("geta", 0.45), gl=auto.get("gl"))
189
194
  print("[quantprobe] hardware auto-detected (run `quantprobe hw` for details; "
190
195
  "pass --machine/flags to estimate a different box)")
196
+ # the SAME calibration+anchor path plan uses - one function, so the commands can
197
+ # never disagree about the same input (v1.10.5 bug class; layer 3 enforces this)
198
+ planmod.apply_calibration_overrides(hw, a)
191
199
  vc = planmod.agg_cap(a.vram) if a.vram is not None else hw.get("vc", 0)
192
200
  rc = a.ram if a.ram is not None else hw.get("rc", 16)
193
201
  size = os.path.getsize(a.gguf) / 1e9 if a.gguf and os.path.isfile(a.gguf) else 0
@@ -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.19.0
3
+ Version: 1.20.1
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