quantprobe 1.15.0__tar.gz → 1.18.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.15.0/quantprobe.egg-info → quantprobe-1.18.0}/PKG-INFO +2 -2
- {quantprobe-1.15.0 → quantprobe-1.18.0}/README.md +1 -1
- {quantprobe-1.15.0 → quantprobe-1.18.0}/pyproject.toml +1 -1
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/__init__.py +1 -1
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/optimize.py +5 -5
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/plan.py +109 -11
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/spec.py +153 -141
- {quantprobe-1.15.0 → quantprobe-1.18.0/quantprobe.egg-info}/PKG-INFO +2 -2
- {quantprobe-1.15.0 → quantprobe-1.18.0}/LICENSE +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/__main__.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/auto.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/cli.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/detect.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/fetch.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/probe.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/recipes/mistral-7b.json +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/recipes/qwen2.5-7b.json +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/recipes/qwen3-30b.json +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/recipes/qwen3.5-35b.json +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/recipes.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/runtime.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe/target.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe.egg-info/SOURCES.txt +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/setup.cfg +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/tests/test_engine.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/tests/test_evaluator.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.0}/tests/test_pipeline.py +0 -0
- {quantprobe-1.15.0 → quantprobe-1.18.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.18.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
|
|
@@ -118,7 +118,7 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
118
118
|
## When quantprobe won't help you
|
|
119
119
|
|
|
120
120
|
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
121
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it.
|
|
121
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. We do not have a point prediction for it, and we would rather say so than quote a number wearing a band too wide to mean anything. What we can state is **one-sided and exception-free**: across 8 models and 13 benchmarks, real speed was **≥ 0.90× the printed number every single time**, and in 12 of the 13 it was strictly higher — typically 1.1×–1.8×. That is a falsifiable claim with the same logical form as our ±25% band, just asymmetric: one measurement below 0.90× kills it. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
122
122
|
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
123
123
|
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
124
124
|
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
@@ -100,7 +100,7 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
100
100
|
## When quantprobe won't help you
|
|
101
101
|
|
|
102
102
|
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
103
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it.
|
|
103
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. We do not have a point prediction for it, and we would rather say so than quote a number wearing a band too wide to mean anything. What we can state is **one-sided and exception-free**: across 8 models and 13 benchmarks, real speed was **≥ 0.90× the printed number every single time**, and in 12 of the 13 it was strictly higher — typically 1.1×–1.8×. That is a falsifiable claim with the same logical form as our ±25% band, just asymmetric: one measurement below 0.90× kills it. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
104
104
|
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
105
105
|
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
106
106
|
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantprobe"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.18.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.18.0"
|
|
@@ -136,11 +136,11 @@ def run(a):
|
|
|
136
136
|
# gives is the inconsistency class that cost us the plan-vs-bench correction.
|
|
137
137
|
roomier = next((r for r in ranked if r["bits"] >= 4.5 and "all in VRAM" in r["desc"]), None)
|
|
138
138
|
if "all in VRAM" in best["desc"]:
|
|
139
|
-
print(f"\n note:
|
|
140
|
-
print(f"
|
|
141
|
-
print(f"
|
|
142
|
-
print(f"
|
|
143
|
-
print(f"
|
|
139
|
+
print(f"\n note: we do not have a point prediction for all-in-VRAM - measured efficiency")
|
|
140
|
+
print(f" varies too much across models for the number above to carry a band. What we can")
|
|
141
|
+
print(f" state is one-sided and exception-free: in 13 of 13 benchmarks real speed was")
|
|
142
|
+
print(f" >= 0.90x this number, and in 12 of 13 it was HIGHER, typically 1.1x-1.8x. Read it")
|
|
143
|
+
print(f" as a floor, not a ceiling.")
|
|
144
144
|
if roomier and best["bits"] < 4.5:
|
|
145
145
|
print(f" It also already fits, and a lower quant buys almost nothing once it does: the same")
|
|
146
146
|
print(f" 7B at Q2_K vs Q4_K_M is 36% smaller and 4% SLOWER. The honest pick here is")
|
|
@@ -351,10 +351,13 @@ def fits_in_vram_advice(placement, bits):
|
|
|
351
351
|
This is the most common configuration for anyone with adequate VRAM, and it is where the law
|
|
352
352
|
is least trustworthy. Two separate facts, both measured, both worth telling the user:
|
|
353
353
|
|
|
354
|
-
1.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
1. There is NO point prediction for this regime - and pretending otherwise is worse than
|
|
355
|
+
saying so. Measured efficiency varies 0.32-0.56 across 8 models (six candidate
|
|
356
|
+
explanations refuted, prereg #15/#24); a number quoted with a band that wide is not a
|
|
357
|
+
prediction. What survives is a ONE-SIDED BOUND with the same logical form as the law's
|
|
358
|
+
own +/-25% claim, just asymmetric: real speed >= 0.90x the printed number, 13 of 13
|
|
359
|
+
benchmarks, no exceptions, falsified by any single measurement below it. In 12 of the 13
|
|
360
|
+
it was strictly above, typically 1.1x-1.8x.
|
|
358
361
|
|
|
359
362
|
2. Below 4.5 bits, quantizing further buys almost nothing. Same 7B, same card, only the
|
|
360
363
|
quantization changed (pre-registration #16, r=3):
|
|
@@ -371,15 +374,19 @@ def fits_in_vram_advice(placement, bits):
|
|
|
371
374
|
"""
|
|
372
375
|
if placement != "all in VRAM":
|
|
373
376
|
return None
|
|
374
|
-
note = ("
|
|
375
|
-
"
|
|
376
|
-
"
|
|
377
|
-
"
|
|
378
|
-
"
|
|
377
|
+
note = ("we do not have a point prediction for this placement - measured efficiency varies "
|
|
378
|
+
"too much across models for the number above to carry a band (0.32-0.56, six candidate "
|
|
379
|
+
"explanations refuted). What we can state is one-sided and has no exceptions: in 13 of "
|
|
380
|
+
"13 benchmarks real speed was >= 0.90x this number, and in 12 of 13 it was HIGHER, "
|
|
381
|
+
"typically 1.1x-1.8x. Read it as a floor, not a ceiling - a single measurement below "
|
|
382
|
+
"0.90x would falsify this and we ask for exactly that measurement below.")
|
|
379
383
|
if bits < 4.5:
|
|
380
384
|
note += (" It also already fits, and going lower-bit buys almost nothing: the same 7B at "
|
|
381
385
|
"Q2_K vs Q4_K_M is 36% smaller and 4% SLOWER (19.17 vs 20.03 tok/s). Quantize "
|
|
382
386
|
"to make a model FIT - once it fits, take the highest bits that still fit.")
|
|
387
|
+
fmt = format_advice(placement, bits)
|
|
388
|
+
if fmt:
|
|
389
|
+
note += "\n " + fmt
|
|
383
390
|
note += ("\n We only have one GPU, and one GPU cannot fix this. If you run this model, "
|
|
384
391
|
"`quantprobe bench --contribute` turns your machine into the datapoint that does - "
|
|
385
392
|
"it prints exactly what would be shared and you submit it yourself. Results that "
|
|
@@ -387,6 +394,45 @@ def fits_in_vram_advice(placement, bits):
|
|
|
387
394
|
return note
|
|
388
395
|
|
|
389
396
|
|
|
397
|
+
def format_advice(placement, bits):
|
|
398
|
+
"""The format lever: on an ALU-weak GPU, the quantization FORMAT sets decode speed, not just
|
|
399
|
+
the byte count. Measured (preregs #52/#53/#54, kernelprobe controls, 2026-07-28):
|
|
400
|
+
|
|
401
|
+
Qwen2.5-7B, all-in-VRAM, same card, same session, interleaved:
|
|
402
|
+
Q4_K_M 4.36 GB 22.72 tok/s eta 0.553
|
|
403
|
+
Q4_0 4.12 GB 26.87 tok/s eta 0.619 <- +19% where bytes explain +5.7%
|
|
404
|
+
Q2_K 2.80 GB 21.67 tok/s eta 0.340 <- SLOWER than Q4_0 while 32% smaller
|
|
405
|
+
|
|
406
|
+
Mechanism, isolated at the metal (own CUDA, zero llama.cpp): a matvec with NO unpacking runs
|
|
407
|
+
at 95% of the streaming ceiling; the same bytes unpacked naively run at 42%. The cost is the
|
|
408
|
+
per-block metadata decode - K-quants unpack a 6-bit scale AND a 6-bit min before any dot
|
|
409
|
+
product, Q4_0 reads one fp16 scale. So eta is a property of (format x kernel), not the tier.
|
|
410
|
+
|
|
411
|
+
Scope, stated rather than implied: measured on ONE Pascal-class card (GTX 1060, cc 6.1),
|
|
412
|
+
where ALU is scarce relative to bandwidth. On Ampere+ the unpack has headroom to hide and
|
|
413
|
+
the ranking may invert - we say so and ask for the datapoint. SPEED-only claim: Q4_0 is
|
|
414
|
+
lower-quality per byte than Q4_K_M; at equal fit take K-quants on a modern card, Q4_0 on an
|
|
415
|
+
old one, and never Q2_K when a 4-bit file also fits (it is smaller, slower AND lower quality
|
|
416
|
+
there - strictly dominated).
|
|
417
|
+
"""
|
|
418
|
+
if placement != "all in VRAM":
|
|
419
|
+
return None
|
|
420
|
+
if bits <= 3.0:
|
|
421
|
+
return ("FORMAT LEVER (pre-Ampere cards): this bit-width is in the regime where unpack "
|
|
422
|
+
"cost has REVERSED the byte ordering - measured Q2_K decodes 19% slower than Q4_0 "
|
|
423
|
+
"on the same model while being 32% smaller. If a ~4.5-bit file fits in VRAM, use "
|
|
424
|
+
"it instead; prefer Q4_0 over Q4_K_M on pre-Ampere (+19% measured, bytes explain "
|
|
425
|
+
"only 5.7%). On Ampere+ this is unverified and may invert.")
|
|
426
|
+
if bits <= 5.0:
|
|
427
|
+
return ("FORMAT LEVER (pre-Ampere cards): at this bit-width the FORMAT is worth more than "
|
|
428
|
+
"the bytes - Q4_0 measured +19% over Q4_K_M on the same model (26.87 vs 22.72 "
|
|
429
|
+
"tok/s). Mechanism (measured, preregs #56/#57): metadata application DENSITY - "
|
|
430
|
+
"K-quants apply fine-grained scale+min chains far more often per byte, and that "
|
|
431
|
+
"cost is intrinsic to the format definition, not a kernel bug. Speed-only: "
|
|
432
|
+
"Q4_K_M is higher quality per byte. On Ampere+ this is unverified and may invert.")
|
|
433
|
+
return None
|
|
434
|
+
|
|
435
|
+
|
|
390
436
|
def speculation_advice(moe, placement):
|
|
391
437
|
"""What speculative decoding is worth for THIS model and placement.
|
|
392
438
|
|
|
@@ -401,9 +447,35 @@ def speculation_advice(moe, placement):
|
|
|
401
447
|
|
|
402
448
|
Returns None when we have no measurement for the case rather than guessing.
|
|
403
449
|
"""
|
|
404
|
-
# Only the fully-offloaded case is measured (exps=CPU). A partial split puts some experts
|
|
405
|
-
# on the fast tier, which we have NOT measured - so it gets no claim either way.
|
|
406
450
|
experts_offloaded = "exps=CPU" in (placement or "")
|
|
451
|
+
if moe and "split experts" in (placement or ""):
|
|
452
|
+
# Measured on the flagship ITSELF, on this exact placement (pre-registration #28). The
|
|
453
|
+
# axis that matters is COPY vs NOVEL, not code vs prose: the prize attaches to output
|
|
454
|
+
# that reproduces context spans (edits, refactors, quoting) - most of what coding agents
|
|
455
|
+
# emit, and none of what fresh generation emits.
|
|
456
|
+
return ("if your output REUSES its context - edits, refactors, RAG quoting - add "
|
|
457
|
+
"`--spec-type ngram-simple --spec-ngram-simple-size-m 384 "
|
|
458
|
+
"--spec-ngram-simple-size-n 4` to llama-server: measured **4.7x decode at ~3-bit** "
|
|
459
|
+
"(21.3 -> 98.8 tok/s), no download. REQUIRES A LONG PROMPT: with these values the drafter "
|
|
460
|
+
"cannot fire until the context exceeds size_m+size_n+1 = 389 tokens, so on short "
|
|
461
|
+
"prompts it does NOTHING and llama.cpp's default m=48 (61-token floor) is better. "
|
|
462
|
+
"Output was byte-identical in every copy-regime test we ran, but that is evidence, "
|
|
463
|
+
"not a guarantee - a verify pass batches several positions and batched reductions "
|
|
464
|
+
"are not bit-identical to single-token decode, which at temp 0 can flip an argmax "
|
|
465
|
+
"(measured: a rejected-draft case diverged reproducibly). The multiplier SHRINKS "
|
|
466
|
+
"with bit-width - the SAME model at Q3_K_M gives 3.4x (17.5 -> 59.2) - because a "
|
|
467
|
+
"verify round is compute-bound, so extra bits cost dequantisation on every drafted "
|
|
468
|
+
"token, not just extra bytes moved. Speculation and quantization are NOT "
|
|
469
|
+
"independent levers. "
|
|
470
|
+
"BOTH tunables matter and llama.cpp's defaults (m=48, n=12) capture only 2.3x of "
|
|
471
|
+
"it: the cost unit is the VERIFY ROUND (one full weight read), not the token, so "
|
|
472
|
+
"what pays is delivering the same accepted tokens in fewer, longer runs. 108 tok/s "
|
|
473
|
+
"is 2.6x this box's raw-decode wall, which no runtime, fork or rewrite can pass. "
|
|
474
|
+
"Two traps, both measured: do NOT tune on acceptance rate (it falls 89%->68% while "
|
|
475
|
+
"throughput doubles), and do NOT over-shorten n (n=2 drafts 36% MORE and runs 25% "
|
|
476
|
+
"SLOWER). Novel generation gains nothing (0% acceptance), a 0.6B DRAFT MODEL is net "
|
|
477
|
+
"negative here (0.72x), and stacking a second drafter costs 10%. Note llama-cli "
|
|
478
|
+
"ignores --spec-type silently; the flag only works on llama-server.")
|
|
407
479
|
if moe and experts_offloaded:
|
|
408
480
|
return ("speculation will NOT pay here: measured +3% (ngram) and -24% (MTP) with experts "
|
|
409
481
|
"offloaded - a verify batch unions experts, and every extra one is a slow read.")
|
|
@@ -634,6 +706,17 @@ def run(args):
|
|
|
634
706
|
ub = ubatch_flags(best[0], ne * max(args.bits, 4.5) / 8 * 1.08 if moe else 0.0, vc)
|
|
635
707
|
run_flags = f"{best[3]} {ub}" if ub else best[3]
|
|
636
708
|
print(f"\n run it: llama-server -m model.gguf {run_flags}")
|
|
709
|
+
# I-quant files on a host tier: measured 2.7x slower than K-quants at the same size
|
|
710
|
+
# (pre-registration #31: IQ3_XS 10.6 GB/s vs Q2_K 28.4 / Q4_K_M 29.7 on pure-CPU decode).
|
|
711
|
+
# The warning fires only when weights actually land on the CPU - in VRAM the IQ formats
|
|
712
|
+
# are fine, so warning there would be crying wolf.
|
|
713
|
+
if getattr(args, "iq_share", 0.0) > 0.3 and any(
|
|
714
|
+
k in best[0] for k in ("->RAM", "CPU", "disk", "split experts")):
|
|
715
|
+
print(f"\n WARNING: this file is {args.iq_share*100:.0f}% I-quant (IQ*) tensors and this"
|
|
716
|
+
f" placement puts weights\n on the CPU tier, where IQ formats decode ~2.7x slower"
|
|
717
|
+
f" than K-quants of the same size\n (measured: 10.6 vs ~29 GB/s effective)."
|
|
718
|
+
f" Re-download the model as Q_K (e.g. Q3_K_M\n instead of IQ3_XS) before"
|
|
719
|
+
f" trusting the speed above.")
|
|
637
720
|
ph = phase_advice(best[0], cfgs)
|
|
638
721
|
if ph:
|
|
639
722
|
print(f"\n phase: {ph}")
|
|
@@ -650,6 +733,21 @@ def run(args):
|
|
|
650
733
|
print(" every cell in ONE session (pre-registration #25) showed the alternatives were "
|
|
651
734
|
"dominated,")
|
|
652
735
|
print(" so there is nothing to choose. One fewer knob, and the honest number.")
|
|
736
|
+
print()
|
|
737
|
+
print(" honesty on GENERATION speed (preregs #43/#60/#61): a plain fixed -ngl split measures")
|
|
738
|
+
print(" EQUAL tg to this -ot placement - three times, at degraded AND full clocks. The -ot")
|
|
739
|
+
print(" advice earns its keep on PROMPT PROCESSING (2.2x measured), on keeping KV in VRAM,")
|
|
740
|
+
print(" and on enabling the speculation numbers below - not on raw generation.")
|
|
741
|
+
print(" IF YOUR NUMBERS SAG 25-30% after hours of GPU churn: the cause on our box was a")
|
|
742
|
+
print(" STUCK BOOST STATE (SM 1506 vs 1835+ MHz at cool temps - diagnosed and confirmed by")
|
|
743
|
+
print(" cold-boot A/B, preregs #60/#61). Check `nvidia-smi --query-gpu=clocks.sm` under")
|
|
744
|
+
print(" load; consumer cards cannot reset it - reboot restores full speed. Not thermal,")
|
|
745
|
+
print(" not your config.")
|
|
746
|
+
print()
|
|
747
|
+
print(" long prompts, same document: send cache_prompt=true to llama-server. Measured")
|
|
748
|
+
print(" here (pre-registration #29): the second question against a 2k-token document")
|
|
749
|
+
print(" pays 183 ms of prompt time instead of 5381 - 29x - because the document KV is")
|
|
750
|
+
print(" reused and only the new question is processed. Restarting the server is cold.")
|
|
653
751
|
if ub:
|
|
654
752
|
print(f"\n prompt speed: `{ub}` is worth **+73% prefill** on this placement (measured "
|
|
655
753
|
f"199.9 -> 345.9 tok/s, pre-registration #19). It costs nothing on generation "
|
|
@@ -1,141 +1,153 @@
|
|
|
1
|
-
"""quantprobe autospec - read the MODEL's law-parameters from the GGUF itself.
|
|
2
|
-
|
|
3
|
-
A GGUF already contains everything the decode law needs:
|
|
4
|
-
total params = sum of tensor element counts
|
|
5
|
-
routed/active = expert tensor split + expert_used/expert_count from metadata
|
|
6
|
-
effective bits = file bytes x 8 / total params (the real number, not the type name)
|
|
7
|
-
kv bytes/pos = exact, from layer count x KV heads x head dims (MLA-aware)
|
|
8
|
-
So `--gguf model.gguf` alone fully specifies the model; flags remain as overrides.
|
|
9
|
-
"""
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
import os
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _field(r, *names):
|
|
15
|
-
for f in r.fields.values():
|
|
16
|
-
for n in names:
|
|
17
|
-
if f.name.endswith(n):
|
|
18
|
-
try:
|
|
19
|
-
return int(f.parts[f.data[0]][0])
|
|
20
|
-
except Exception:
|
|
21
|
-
pass
|
|
22
|
-
return None
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def from_gguf(path):
|
|
26
|
-
from gguf import GGUFReader
|
|
27
|
-
r = GGUFReader(path)
|
|
28
|
-
n_layer = _field(r, ".block_count") or 32
|
|
29
|
-
total = 0
|
|
30
|
-
routed = 0
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"""
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
r
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
"""quantprobe autospec - read the MODEL's law-parameters from the GGUF itself.
|
|
2
|
+
|
|
3
|
+
A GGUF already contains everything the decode law needs:
|
|
4
|
+
total params = sum of tensor element counts
|
|
5
|
+
routed/active = expert tensor split + expert_used/expert_count from metadata
|
|
6
|
+
effective bits = file bytes x 8 / total params (the real number, not the type name)
|
|
7
|
+
kv bytes/pos = exact, from layer count x KV heads x head dims (MLA-aware)
|
|
8
|
+
So `--gguf model.gguf` alone fully specifies the model; flags remain as overrides.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _field(r, *names):
|
|
15
|
+
for f in r.fields.values():
|
|
16
|
+
for n in names:
|
|
17
|
+
if f.name.endswith(n):
|
|
18
|
+
try:
|
|
19
|
+
return int(f.parts[f.data[0]][0])
|
|
20
|
+
except Exception:
|
|
21
|
+
pass
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def from_gguf(path):
|
|
26
|
+
from gguf import GGUFReader
|
|
27
|
+
r = GGUFReader(path)
|
|
28
|
+
n_layer = _field(r, ".block_count") or 32
|
|
29
|
+
total = 0
|
|
30
|
+
routed = 0
|
|
31
|
+
iq_bytes = all_bytes = 0
|
|
32
|
+
for t in r.tensors:
|
|
33
|
+
n = 1
|
|
34
|
+
for d in t.shape:
|
|
35
|
+
n *= int(d)
|
|
36
|
+
total += n
|
|
37
|
+
if "exps" in t.name or "_expert" in t.name:
|
|
38
|
+
routed += n
|
|
39
|
+
# bytes-weighted I-quant share. Measured (pre-registration #31): on the CPU tier the
|
|
40
|
+
# IQ formats deliver 10.6 GB/s against ~29 for K-quants at the same size - a 2.7x
|
|
41
|
+
# decode penalty for any host-resident placement. The K-format dequant is
|
|
42
|
+
# bandwidth-shaped on AVX2; the IQ codebook lookup is compute-shaped, and 4 cores
|
|
43
|
+
# cannot hide it.
|
|
44
|
+
nb = int(getattr(t, "n_bytes", 0) or 0)
|
|
45
|
+
all_bytes += nb
|
|
46
|
+
if t.tensor_type.name.startswith("IQ"):
|
|
47
|
+
iq_bytes += nb
|
|
48
|
+
ne_params = total - routed
|
|
49
|
+
|
|
50
|
+
n_exp = _field(r, ".expert_count")
|
|
51
|
+
n_used = _field(r, ".expert_used_count")
|
|
52
|
+
if routed and n_exp and n_used:
|
|
53
|
+
active = ne_params + routed * n_used / n_exp
|
|
54
|
+
moe = True
|
|
55
|
+
else:
|
|
56
|
+
active, moe = total, False
|
|
57
|
+
|
|
58
|
+
# exact KV bytes/pos (f16): MLA caches the latent; GQA caches heads x dims, K+V
|
|
59
|
+
kv_lora = _field(r, ".attention.kv_lora_rank")
|
|
60
|
+
if kv_lora:
|
|
61
|
+
rope = _field(r, ".rope.dimension_count") or 64
|
|
62
|
+
kvp = n_layer * (kv_lora + rope) * 2
|
|
63
|
+
else:
|
|
64
|
+
kv_heads = _field(r, ".attention.head_count_kv") or 8
|
|
65
|
+
k_dim = _field(r, ".attention.key_length")
|
|
66
|
+
v_dim = _field(r, ".attention.value_length")
|
|
67
|
+
if not k_dim:
|
|
68
|
+
emb = _field(r, ".embedding_length") or 4096
|
|
69
|
+
heads = _field(r, ".attention.head_count") or 32
|
|
70
|
+
k_dim = v_dim = emb // heads
|
|
71
|
+
kvp = n_layer * kv_heads * ((k_dim or 128) + (v_dim or k_dim or 128)) * 2
|
|
72
|
+
|
|
73
|
+
bits = os.path.getsize(path) * 8 / total
|
|
74
|
+
arch = None
|
|
75
|
+
for field in r.fields.values(): # recipe matching needs (arch, n_layer), not layers alone
|
|
76
|
+
if field.name == "general.architecture":
|
|
77
|
+
try:
|
|
78
|
+
arch = bytes(field.parts[field.data[0]]).decode("utf-8")
|
|
79
|
+
except Exception:
|
|
80
|
+
arch = None
|
|
81
|
+
break
|
|
82
|
+
return dict(t=total / 1e9, a=active / 1e9, ne=ne_params / 1e9, moe=moe,
|
|
83
|
+
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)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def apply(a, quiet=False):
|
|
88
|
+
"""Fill law-parameters from a.gguf for anything the user didn't set. Explicit flags win."""
|
|
89
|
+
g = getattr(a, "gguf", None)
|
|
90
|
+
if not g or not os.path.isfile(g):
|
|
91
|
+
return False
|
|
92
|
+
try:
|
|
93
|
+
s = from_gguf(g)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
if not quiet:
|
|
96
|
+
print(f"[quantprobe] autospec skipped ({e}); using flags/presets")
|
|
97
|
+
return False
|
|
98
|
+
used = []
|
|
99
|
+
if getattr(a, "total", None) is None and getattr(a, "model", None) is None:
|
|
100
|
+
a.total = s["t"]; a.active = a.active or s["a"]; a.always_active = a.always_active or s["ne"]
|
|
101
|
+
used.append(f"{s['t']:.1f}B total, {s['a']:.1f}B active")
|
|
102
|
+
if getattr(a, "bits", None) is None:
|
|
103
|
+
a.bits = s["bits"]; used.append(f"{s['bits']:g} effective bits")
|
|
104
|
+
if getattr(a, "kv_per_pos", None) is None:
|
|
105
|
+
a.kv_per_pos = s["kvp"] / 1024; used.append(f"KV {s['kvp']/1024:.0f} KB/pos")
|
|
106
|
+
if getattr(a, "n_layer", None) is None:
|
|
107
|
+
a.n_layer = s["n_layer"] # enables the MoE partial-offload -ot regex (needs real layer indices)
|
|
108
|
+
a.iq_share = s.get("iq_share", 0.0) # read-only: lets plan warn when IQ weights land on a CPU tier
|
|
109
|
+
if used and not quiet:
|
|
110
|
+
print(f"[quantprobe] read from GGUF: " + ", ".join(used))
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# --- tensor-role registry -----------------------------------------------------------------
|
|
115
|
+
# WHAT TRANSFERS between models is structure, not fragility. Which tensor classes exist and
|
|
116
|
+
# which are always-active is a property of the ARCHITECTURE, so it is knowable for a model
|
|
117
|
+
# nobody has ever probed. Which LAYERS are fragile is not (Law 3; Mistral is early-fragile
|
|
118
|
+
# where its near-twin Qwen is late, a 25x error if you guess).
|
|
119
|
+
#
|
|
120
|
+
# This registry exists because we shipped that bug: hybrid SSM architectures name their
|
|
121
|
+
# recurrent-state tensors ssm_*, our protection pattern only matched attn_*, and every SSM
|
|
122
|
+
# tensor silently landed at the aggressive base level (fixed in v1.6.4, cost -24% ppl).
|
|
123
|
+
# Anything unrecognised is now REPORTED rather than silently compressed.
|
|
124
|
+
TENSOR_ROLES = [
|
|
125
|
+
("routed-expert", r"ffn_(gate|up|down)_exps", "compressible: ~8 of N experts fire per token"),
|
|
126
|
+
("shared-expert", r"ffn_.*_shexp", "ALWAYS ACTIVE on every token - protect"),
|
|
127
|
+
("attention", r"attn_", "ALWAYS ACTIVE - protect"),
|
|
128
|
+
("recurrent/SSM", r"ssm_", "ALWAYS ACTIVE - protect"),
|
|
129
|
+
("embedding", r"(token_embd|output\.)", "ALWAYS ACTIVE - protect"),
|
|
130
|
+
("mtp-head", r"nextn", "ALWAYS ACTIVE when MTP is on - protect"),
|
|
131
|
+
("router", r"ffn_gate_inp", "tiny, kept at full precision"),
|
|
132
|
+
("norm", r"(_norm|norm\.)", "tiny, kept at full precision"),
|
|
133
|
+
("dense-ffn", r"ffn_(gate|up|down)\.", "dense FFN - the depth-aware band applies here"),
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def tensor_roles(path):
|
|
138
|
+
"""Classify a GGUF's tensors by role. Returns (roles, unknown) with byte totals, so the
|
|
139
|
+
builder can warn about weight classes it has no protection rule for."""
|
|
140
|
+
import re
|
|
141
|
+
from gguf import GGUFReader
|
|
142
|
+
r = GGUFReader(path)
|
|
143
|
+
roles, unknown = {}, {}
|
|
144
|
+
for t in r.tensors:
|
|
145
|
+
nbytes = int(t.n_bytes) if hasattr(t, "n_bytes") else 0
|
|
146
|
+
for name, pat, _ in TENSOR_ROLES:
|
|
147
|
+
if re.search(pat, t.name):
|
|
148
|
+
roles[name] = roles.get(name, 0) + nbytes
|
|
149
|
+
break
|
|
150
|
+
else:
|
|
151
|
+
key = re.sub(r"blk\.\d+\.", "", t.name)
|
|
152
|
+
unknown[key] = unknown.get(key, 0) + nbytes
|
|
153
|
+
return roles, unknown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.18.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
|
|
@@ -118,7 +118,7 @@ Copyability is the whole mechanism: code answers repeat their input, prose inven
|
|
|
118
118
|
## When quantprobe won't help you
|
|
119
119
|
|
|
120
120
|
- **Your model already fits comfortably in VRAM at 4 bits or more.** Community quants are near-lossless there, and — measured — quantizing further buys almost no speed once a model is resident: the same 7B at Q2_K vs Q4_K_M is 36% smaller and **4% slower**. Quantize to make a model *fit*; once it fits, stop.
|
|
121
|
-
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it.
|
|
121
|
+
- **You want a tight number for a model that fits entirely in VRAM.** This is the placement the law knows least well, and the ±25% band above does **not** apply to it. We do not have a point prediction for it, and we would rather say so than quote a number wearing a band too wide to mean anything. What we can state is **one-sided and exception-free**: across 8 models and 13 benchmarks, real speed was **≥ 0.90× the printed number every single time**, and in 12 of the 13 it was strictly higher — typically 1.1×–1.8×. That is a falsifiable claim with the same logical form as our ±25% band, just asymmetric: one measurement below 0.90× kills it. We have refuted six candidate explanations for the gap, including our own favourites: it is not fixed overhead, not GPU clock state, not bytes-per-token, not monotone in bit-width, not a per-format constant, and not a bytes-weighted mixture of the actual tensor types. Within a single architecture it moves cleanly with the dominant tensor type; across architectures it does not transfer. We would rather publish that than move a constant on thin evidence. **This is the single most useful thing you can send us:** `quantprobe bench --contribute` on a GPU-resident model turns your machine into the datapoint that fixes it.
|
|
122
122
|
- **You need task-level eval scores** (MMLU, HellaSwag). quantprobe measures perplexity and KL divergence only.
|
|
123
123
|
- **Your architecture isn't in the fragility atlas** (four families so far). The probe still works on your model; the published priors just won't apply. *Open an issue with your result — those are the most valuable datapoints.*
|
|
124
124
|
- **You want multi-token prediction modeled in the planner.** It isn't. Measured, the effect runs from **+17% (dense, GPU-resident) to −24% (MoE, experts in RAM)** — there's no single multiplier to apply. [Full 2×2 →](preregistrations/2026-07-24-law6-speculation-economics.md)
|
|
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
|