File size: 2,126 Bytes
2af40f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | """verdict_quant.py - the PLAN.md step-5 quantisation gate. RECONSTRUCTED 2026-11-21.
PLAN.md step 5: before any download link appears, compare the merged fp16 against the Q4_K_M
quantisation on the same benchmark, because quantisation is where small-model tool-calling breaks
quietly. `bench_gguf.py` produces both arms on the frozen 60 questions through the same engine, so the
difference between them is the quantisation damage and nothing else.
"""
import json, pathlib, time
Q = pathlib.Path("/home/marimo/dragon_fsds/quant")
ARMS = {"merged_fp16": Q/"agent_benchmark_v4_merged_fp16_results.json",
"q4km": Q/"agent_benchmark_v4_q4km_results.json"}
def load(p):
if not p.exists(): return None
j = json.loads(p.read_text())
for k, v in j.items():
if isinstance(v, dict) and "answer_ok" in v: return {"arm": k, **v}
return None
t0 = time.time(); out = {}
for name, p in ARMS.items(): out[name] = load(p)
verdict = {"at": time.strftime("%Y-%m-%d %H:%M:%S"), "questions": "frozen 60 (questions_families_seed11.json)",
"arm": out}
fp, q4 = out.get("merged_fp16"), out.get("q4km")
if fp and q4:
d = {k: round(q4[k] - fp[k], 3) for k in ("resolve_first","reaches_candidate_tags","args_ok","answer_ok")}
verdict["delta_q4_minus_fp16"] = d
verdict["gate"] = ("pass - quantisation preserves tool use" if q4["resolve_candidate"] if False else
("pass - tool use preserved" if min(d["resolve_first"], d["args_ok"], d["reaches_candidate_tags"]) >= -0.05
else "FAIL - quantisation degrades tool use"))
verdict["publish_rule"] = ("PLAN.md step 5: publish only if the artefact is verified at Q4_K_M, "
"which is what the 8 GB target runs")
else:
verdict["gate"] = "incomplete - one or both arms have not been measured"
verdict["seconds"] = round(time.time()-t0, 1)
verdict["note"] = "RECONSTRUCTED verdict_quant.py; the original was never published."
(Q/"VERDICT_QUANT.json").write_text(json.dumps(verdict, indent=2, default=str))
print(json.dumps(verdict, indent=2, default=str)[:1500])
|