quantprobe 1.20.1__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.
Files changed (34) hide show
  1. {quantprobe-1.20.1/quantprobe.egg-info → quantprobe-1.20.2}/PKG-INFO +1 -1
  2. {quantprobe-1.20.1 → quantprobe-1.20.2}/pyproject.toml +1 -1
  3. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/__init__.py +1 -1
  4. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/optimize.py +9 -0
  5. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/plan.py +47 -14
  6. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/runtime.py +8 -1
  7. {quantprobe-1.20.1 → quantprobe-1.20.2/quantprobe.egg-info}/PKG-INFO +1 -1
  8. {quantprobe-1.20.1 → quantprobe-1.20.2}/LICENSE +0 -0
  9. {quantprobe-1.20.1 → quantprobe-1.20.2}/README.md +0 -0
  10. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/__main__.py +0 -0
  11. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/auto.py +0 -0
  12. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/calibrate.py +0 -0
  13. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/cli.py +0 -0
  14. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/dashboard.py +0 -0
  15. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/detect.py +0 -0
  16. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/fetch.py +0 -0
  17. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/probe.py +0 -0
  18. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/recipes/mistral-7b.json +0 -0
  19. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/recipes/qwen2.5-7b.json +0 -0
  20. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/recipes/qwen3-30b.json +0 -0
  21. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/recipes/qwen3.5-35b.json +0 -0
  22. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/recipes.py +0 -0
  23. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/spec.py +0 -0
  24. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe/target.py +0 -0
  25. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe.egg-info/SOURCES.txt +0 -0
  26. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe.egg-info/dependency_links.txt +0 -0
  27. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe.egg-info/entry_points.txt +0 -0
  28. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe.egg-info/requires.txt +0 -0
  29. {quantprobe-1.20.1 → quantprobe-1.20.2}/quantprobe.egg-info/top_level.txt +0 -0
  30. {quantprobe-1.20.1 → quantprobe-1.20.2}/setup.cfg +0 -0
  31. {quantprobe-1.20.1 → quantprobe-1.20.2}/tests/test_engine.py +0 -0
  32. {quantprobe-1.20.1 → quantprobe-1.20.2}/tests/test_evaluator.py +0 -0
  33. {quantprobe-1.20.1 → quantprobe-1.20.2}/tests/test_pipeline.py +0 -0
  34. {quantprobe-1.20.1 → 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.1
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.1"
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.1"
11
+ __version__ = "1.20.2"
@@ -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
@@ -725,8 +725,10 @@ def apply_calibration_overrides(hw, args):
725
725
  if "pure CPU" in an.get("placement", ""):
726
726
  pred = 0.62 * hw["rb"] / act_a # dense CPU eta, same as evaluate()
727
727
  ratios["cpu"] = max(0.70, min(1.40, ts / pred))
728
+ hw["_anchor_cpu_act"] = act_a
728
729
  elif "all-in-VRAM" in an.get("placement", "") and hw.get("vb"):
729
- pred = hw.get("geta", 0.45) * hw["vb"] / act_a
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
730
732
  ratios["gpu"] = max(0.70, min(1.40, ts / pred))
731
733
  hw["_anchor_gpu_act"] = act_a # for the size-class dispatcher below
732
734
  # FORMAT RESCALING (L-16): the anchor measured ONE format's eta; the target
@@ -743,7 +745,10 @@ def apply_calibration_overrides(hw, args):
743
745
  continue
744
746
  if ratios:
745
747
  if "cpu" in ratios:
746
- hw["rb"] = hw["rb"] * ratios["cpu"]
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"]
747
752
  if "gpu" in ratios:
748
753
  # NOT applied to vb here: whether the GPU ratio is valid depends on the TARGET's
749
754
  # size class (resolve_gpu_eta below), which is not known yet. Stored instead.
@@ -777,12 +782,17 @@ def resolve_gpu_eta(hw, args, active_b, bits, vb, geta):
777
782
  fmt_bw = getattr(args, "fmt_bw", None) if hw.get("_cal_active") else None
778
783
  act_est = (active_b or 0) * (bits or 4.5) / 8 * 1.08
779
784
  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)
785
+ same_class = bool(anchor_act and act_est and act_est / 2 <= anchor_act <= act_est * 2)
781
786
  big = act_est >= 1.5
782
787
  # The size-class guard holds with OR without format knowledge: an out-of-class anchor ratio
783
788
  # never touches a big target (that misapplication is what the ratchet test caught).
784
789
  use_ratio = bool(ratio) and (same_class or not big)
785
- if fmt_bw and 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.
786
796
  eta_fmt = fmt_bw / 192.2
787
797
  if not use_ratio and ratio:
788
798
  print(f"[quantprobe] GPU eta from the measured format ladder: {eta_fmt:.2f} "
@@ -790,10 +800,40 @@ def resolve_gpu_eta(hw, args, active_b, bits, vb, geta):
790
800
  return (vb * ratio, eta_fmt) if use_ratio else (vb, eta_fmt)
791
801
  if ratio and not use_ratio:
792
802
  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.")
803
+ "applied (small anchors mis-price big models; #65).")
794
804
  return (vb * ratio, geta) if use_ratio else (vb, geta)
795
805
 
796
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
+
797
837
  def run(args):
798
838
  from . import spec as specmod
799
839
  specmod.apply(args)
@@ -836,6 +876,7 @@ def run(args):
836
876
  _g = getattr(args, 'gguf', None)
837
877
  true_size = _os.path.getsize(_g) / 1e9 if _g and _os.path.isfile(_g) else None
838
878
  vb, geta = resolve_gpu_eta(hw, args, a, args.bits, vb, geta)
879
+ rb = resolve_cpu_bw(hw, args, a, args.bits, rb)
839
880
  size, act, cfgs = evaluate(t, a, ne, moe, args.bits, vc, vb, rc, rb, db, geta, gl=gl, ctx=ctx,
840
881
  kvp=kvp, n_layer=nlay, true_size_gb=true_size)
841
882
  q = qual_of(moe, args.bits)
@@ -860,15 +901,7 @@ def run(args):
860
901
  # VRAM headroom). Not part of the law: `evaluate` is untouched and no anchor can move.
861
902
  ub = ubatch_flags(best[0], ne * max(args.bits, 4.5) / 8 * 1.08 if moe else 0.0, vc)
862
903
  run_flags = f"{best[3]} {ub}" if ub else best[3]
863
- # --threads: llama.cpp's auto-detection can pick PHYSICAL cores only (the first external
864
- # replication got 6 of 12 on a Ryzen 8600G and reported "decode struggled at 2 t/s ... this
865
- # flag alone helped it jump past 9"; our own C-07 measured a 40% swing from the CPU-thread
866
- # runtime alone). Emit the logical count explicitly whenever the placement has CPU-resident
867
- # work; harmless when it does not.
868
- import os as _os2
869
- nthreads = _os2.cpu_count() or 0
870
- if nthreads and any(k in best[0] for k in ("->RAM", "CPU", "disk", "split experts")):
871
- run_flags = f"{run_flags} --threads {nthreads}"
904
+ run_flags, nthreads = append_threads_flag(run_flags, best[0])
872
905
  print(f"\n run it: llama-server -m model.gguf {run_flags}")
873
906
  if "--threads" in run_flags:
874
907
  print(f" (--threads {nthreads} = this machine's LOGICAL cores; llama.cpp's own"
@@ -76,6 +76,7 @@ def best_flags(a):
76
76
  _true = os.path.getsize(gguf) / 1e9 if gguf and os.path.isfile(gguf) else None
77
77
  # same size-classed GPU-eta dispatch as plan (ONE shared function; layer 3 enforces parity)
78
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)
79
80
  _, _, cfgs = planmod.evaluate(t, ac, ne, moe, a.bits, vc, vb, rc, rb, db, geta, act_scale, gl,
80
81
  ctx=ctx, kvp=kvp, true_size_gb=_true,
81
82
  n_layer=planmod.effective_n_layer(a, m))
@@ -93,7 +94,10 @@ def best_flags(a):
93
94
  print(f"[quantprobe] note: the fastest placement ({cfgs[0][0]}, {cfgs[0][1]:.1f} tok/s) needs an "
94
95
  f"expert-caching runtime; launching the fastest STOCK-llama.cpp placement instead.")
95
96
  best = runnable[0]
96
- return best, best[3].replace('"', "").split()
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()
97
101
 
98
102
 
99
103
  def run(a):
@@ -132,11 +136,14 @@ def bench(a):
132
136
  # defect in this project's history, so unknown flags now RAISE.
133
137
  BENCH_VALUED = {"-ngl", "-ot", "-ub", "-b", "-c", "-t"} # take a value, same spelling in bench
134
138
  BENCH_TRANSLATE = {"--no-mmap": ["--mmap", "0"]} # spelled differently in llama-bench
139
+ BENCH_VALUED_RENAME = {"--threads": "-t"} # take a value, renamed in bench
135
140
  bflags, i = [], 0
136
141
  while i < len(flags):
137
142
  f = flags[i]
138
143
  if f in BENCH_TRANSLATE:
139
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
140
147
  elif f in BENCH_VALUED:
141
148
  bflags += [f, flags[i + 1]]; i += 2
142
149
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.20.1
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