quantprobe 1.12.1__tar.gz → 1.13.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.12.1/quantprobe.egg-info → quantprobe-1.13.0}/PKG-INFO +1 -1
  2. {quantprobe-1.12.1 → quantprobe-1.13.0}/pyproject.toml +1 -1
  3. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/__init__.py +1 -1
  4. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/plan.py +42 -1
  5. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/runtime.py +25 -7
  6. {quantprobe-1.12.1 → quantprobe-1.13.0/quantprobe.egg-info}/PKG-INFO +1 -1
  7. {quantprobe-1.12.1 → quantprobe-1.13.0}/LICENSE +0 -0
  8. {quantprobe-1.12.1 → quantprobe-1.13.0}/README.md +0 -0
  9. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/__main__.py +0 -0
  10. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/auto.py +0 -0
  11. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/cli.py +0 -0
  12. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/dashboard.py +0 -0
  13. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/detect.py +0 -0
  14. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/fetch.py +0 -0
  15. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/optimize.py +0 -0
  16. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/probe.py +0 -0
  17. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/recipes/mistral-7b.json +0 -0
  18. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/recipes/qwen2.5-7b.json +0 -0
  19. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/recipes/qwen3-30b.json +0 -0
  20. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/recipes/qwen3.5-35b.json +0 -0
  21. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/recipes.py +0 -0
  22. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/spec.py +0 -0
  23. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe/target.py +0 -0
  24. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe.egg-info/SOURCES.txt +0 -0
  25. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe.egg-info/dependency_links.txt +0 -0
  26. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe.egg-info/entry_points.txt +0 -0
  27. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe.egg-info/requires.txt +0 -0
  28. {quantprobe-1.12.1 → quantprobe-1.13.0}/quantprobe.egg-info/top_level.txt +0 -0
  29. {quantprobe-1.12.1 → quantprobe-1.13.0}/setup.cfg +0 -0
  30. {quantprobe-1.12.1 → quantprobe-1.13.0}/tests/test_engine.py +0 -0
  31. {quantprobe-1.12.1 → quantprobe-1.13.0}/tests/test_evaluator.py +0 -0
  32. {quantprobe-1.12.1 → quantprobe-1.13.0}/tests/test_pipeline.py +0 -0
  33. {quantprobe-1.12.1 → quantprobe-1.13.0}/tests/test_transforms.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.12.1
3
+ Version: 1.13.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.12.1"
7
+ version = "1.13.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.12.1"
11
+ __version__ = "1.13.0"
@@ -87,6 +87,37 @@ QUAL = {True: {2.0: 1.10, 2.5: 1.07, 3.0: 1.05, 4.5: 1.02, 6.5: 1.01, 8.5: 1.00
87
87
  False: {2.0: 1.45, 2.5: 1.30, 3.0: 1.12, 4.5: 1.03, 6.5: 1.01, 8.5: 1.00}}
88
88
 
89
89
 
90
+ UBATCH_HEADROOM_GB = 1.5 # VRAM the compute buffer needs before -ub 2048 is safe. NOT yet
91
+ # characterised as a curve - measured only as a boundary: with experts
92
+ # on CPU (little in VRAM) -ub 2048 gave +73% prefill, while a 4.36 GiB
93
+ # model filling a 6 GB card LOST 39% at the same setting. The ceiling
94
+ # is real; its shape is an open measurement (pre-registration #19).
95
+
96
+
97
+ def ubatch_flags(placement, vram_resident_gb, vc):
98
+ """-b/-ub for placements that leave weights in HOST memory. Prefill-only lever.
99
+
100
+ With `-ot ...=CPU` the expert tensors live in a host buffer, so CUDA is offered the op and
101
+ accepts it once the ubatch clears 32 tokens (ggml-cuda.cu: MUL_MAT_ID -> op->ne[2]). Those
102
+ weights then cross PCIe ONCE PER UBATCH instead of once per token, so the per-token transfer
103
+ cost falls as 1/ub. Measured on the reference box (pre-registration #19, r=3):
104
+
105
+ Qwen3-30B-A3B, -ot exps=CPU pp2048 199.90 -> 345.89 +73% at ub 512 -> 2048
106
+ dense 7B fully in VRAM pp2048 329.80 -> 200.31 -39% same flag, opposite sign
107
+
108
+ The control is why this is gated rather than defaulted: with nothing host-resident there is no
109
+ transfer to amortise and a larger ubatch only inflates the compute buffer, which on a tight
110
+ card costs more than it saves. Decode is unaffected either way (18.46 -> 18.76), because a
111
+ ubatch cannot be filled one token at a time.
112
+ """
113
+ host_resident = any(k in placement for k in ("->RAM", "CPU", "disk"))
114
+ if not host_resident or vc <= 0:
115
+ return None
116
+ if vc * 0.90 - vram_resident_gb < UBATCH_HEADROOM_GB:
117
+ return None # no room for the bigger compute buffer; the -39% case
118
+ return "-b 2048 -ub 2048"
119
+
120
+
90
121
  def effective_n_layer(args=None, model=None):
91
122
  """THE resolver for "how many layers does this model have". Do not hand-write this again.
92
123
 
@@ -408,7 +439,17 @@ def run(args):
408
439
  w = f" [{warn}]" if warn else ""
409
440
  print(f" {star} {tps:6.1f} tok/s {name}{w}")
410
441
  best = cfgs[0]
411
- print(f"\n run it: llama-server -m model.gguf {best[3]}")
442
+ # Prefill lever, appended only where the measurement says it pays (host-resident weights with
443
+ # VRAM headroom). Not part of the law: `evaluate` is untouched and no anchor can move.
444
+ ub = ubatch_flags(best[0], ne * max(args.bits, 4.5) / 8 * 1.08 if moe else 0.0, vc)
445
+ run_flags = f"{best[3]} {ub}" if ub else best[3]
446
+ print(f"\n run it: llama-server -m model.gguf {run_flags}")
447
+ if ub:
448
+ print(f"\n prompt speed: `{ub}` is worth **+73% prefill** on this placement (measured "
449
+ f"199.9 -> 345.9 tok/s, pre-registration #19). It costs nothing on generation "
450
+ f"(18.5 -> 18.8) and applies because your experts sit in RAM: they then cross PCIe "
451
+ f"once per batch instead of once per token. Do NOT set it when a model is fully in "
452
+ f"VRAM - measured there, the same flag LOSES 39%.")
412
453
  fit_adv = fits_in_vram_advice(best[0], args.bits)
413
454
  if fit_adv:
414
455
  print(f"\n note: {fit_adv}")
@@ -116,13 +116,31 @@ def bench(a):
116
116
  a.ctx = a.depth # prediction at the benched depth
117
117
  best, flags = best_flags(a)
118
118
  binp = "llama-bench" if getattr(a, "dry", False) else find_llama(a.llama_dir, "llama-bench")
119
- # llama-bench uses --mmap 0 rather than --no-mmap
120
- bflags = ["--mmap", "0" if "--no-mmap" in flags else "1"]
121
- for i, f in enumerate(flags):
122
- if f == "-ngl":
123
- bflags += ["-ngl", flags[i + 1]]
124
- if f == "-ot":
125
- bflags += ["-ot", flags[i + 1]]
119
+ # Forward the planned flags into llama-bench, translating where the two CLIs differ.
120
+ #
121
+ # This used to hand-list -ngl and -ot and SILENTLY DROP everything else, which means any flag
122
+ # the planner learns to emit is missing from `bench` - and predicted-vs-measured then drifts
123
+ # by exactly the size of the new lever, while both commands still look right. Pre-registration
124
+ # #19 measured a 1.73x prefill effect from -ub; had it shipped through the old forwarder,
125
+ # `bench` would have quietly measured the un-flagged configuration and reported the law as
126
+ # wrong. An allow-list that drops the unknown is the same shape as every other silent-fallback
127
+ # defect in this project's history, so unknown flags now RAISE.
128
+ BENCH_VALUED = {"-ngl", "-ot", "-ub", "-b", "-c", "-t"} # take a value, same spelling in bench
129
+ BENCH_TRANSLATE = {"--no-mmap": ["--mmap", "0"]} # spelled differently in llama-bench
130
+ bflags, i = [], 0
131
+ while i < len(flags):
132
+ f = flags[i]
133
+ if f in BENCH_TRANSLATE:
134
+ bflags += BENCH_TRANSLATE[f]; i += 1
135
+ elif f in BENCH_VALUED:
136
+ bflags += [f, flags[i + 1]]; i += 2
137
+ else:
138
+ raise SystemExit(
139
+ f"[quantprobe] internal: the planner emitted '{f}', which bench does not know how "
140
+ f"to forward. Add it to BENCH_VALUED or BENCH_TRANSLATE in runtime.py - dropping "
141
+ f"it would make every predicted-vs-measured figure wrong by the size of that flag.")
142
+ if "--mmap" not in bflags:
143
+ bflags += ["--mmap", "1"]
126
144
  cmd = [binp, "-m", a.gguf, "-n", "32", "-p", "0", "-r", str(a.reps)] + bflags
127
145
  if getattr(a, "depth", None):
128
146
  cmd += ["-d", str(a.depth)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantprobe
3
- Version: 1.12.1
3
+ Version: 1.13.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