interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / evidence / OLLM-AB4-ROUNDS-4-11-20261122 / harness / make_receipt.py

225 lines · 13252 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Evidence generator (measuring harness): reads the raw campaign logs on the Spark and writes
3receipt.json and RESULTS.md so that no figure in the evidence bundle is typed by hand.
4usage: make_receipt.py OUT_DIR
5Derived figures are labelled derived and carry their inputs.
6"""
7import glob, hashlib, json, os, re, sys
8
9CAMP = "/home/drakestapleton/work/ollm-helix-rlvr-20261121"
10VLOOP = "/home/drakestapleton/work/ollm-loop-20261121"
11R = f"{CAMP}/rounds"
12YR = "/home/drakestapleton/yardsticks/receipts"
13out = sys.argv[1]
14os.makedirs(out, exist_ok=True)
15STEPS, BATCH, WINDOW = 1400, 64, 256 # steps: gpu_round_r*.out; B and T: train/omega-llm/docs/LOOP.md "Arms" (tune keeps shapes)
16TOKENS_TRAINED = STEPS * BATCH * WINDOW
17
18
19def sha(p):
20 h = hashlib.sha256()
21 with open(p, "rb") as f:
22 for b in iter(lambda: f.read(1 << 20), b""):
23 h.update(b)
24 return h.hexdigest()
25
26
27def e_line(p):
28 for l in open(p):
29 if l.startswith("E "):
30 a = l.split()
31 return {"step": int(a[1]), "windows": int(a[2]), "loss_micro_nats": int(a[3]), "raw": l.strip(), "log": p}
32
33
34def score(p):
35 s = {"passes": [], "families": {}, "file": p, "file_sha256": sha(p)}
36 for l in open(p):
37 a = l.split()
38 if l.startswith("SCORE "):
39 s.update(tasks=int(a[2]), passed=int(a[4]), passcut=int(a[6]), seen=int(a[8]), raw=l.strip())
40 elif l.startswith("R ") and a[-1] == "pass":
41 s["passes"].append(a[1])
42 elif l.startswith("F "):
43 s["families"][a[1]] = dict(zip(["tasks", "pass", "passcut", "wrong", "nocompile", "noend", "refused", "missing", "timeout", "seen"], map(int, a[2:])))
44 return s
45
46
47def receipt(name):
48 p = f"{YR}/2026-11-22-{name}.json"
49 d = json.load(open(p))
50 return {k: d.get(k) for k in ["name", "exit", "start", "seconds", "gpu_W_mean", "gpu_util_mean", "nvrm_errors_delta", "window_id"]} | {"path": p, "sha256": sha(p)}
51
52
53ck_names = {sha(p): os.path.basename(p) for p in glob.glob(f"{CAMP}/ckpt/loop_r*.ck")}
54tok47 = {}
55for l in open(f"{R}/supplement/mix_tokens_r4_r7.txt"):
56 a = l.split()
57 if a and a[0].startswith("r"):
58 tok47[a[0]] = {"tokens": int(a[3]), "tok_sha256": a[4], "tok_file": a[1]}
59
60
61def manifest(n):
62 p = f"{R}/r{n}/r{n}_manifest.txt"
63 d = {"file": p, "file_sha256": sha(p), "sources": [], "teacher_plan_text_in_mix": False}
64 for l in open(p):
65 a = l.split()
66 if l.startswith("source "):
67 g = dict(zip(a[0::2], a[1::2]))
68 d["sources"].append({"name": a[1], "kept": int(g["kept"]), "weight": int(g["weight"]), "sha256": g["sha256"]})
69 if a[1] == "c2align":
70 d["teacher_plan_text_in_mix"] = True
71 elif l.startswith("audit_records "):
72 d["distinct_records"] = int(a[1])
73 elif l.startswith("repo source "):
74 g = dict(zip(a[3::2], a[4::2]))
75 d["repo_docs"] = int(g["docs"])
76 d["repo_distinct_docs"] = int(g.get("distinct_docs", g["docs"]))
77 d["repo_bytes"] = int(g["bytes"])
78 elif l.startswith("repo slice replayed "):
79 m = re.search(r"distinct_docs (\d+) distinct_bytes (\d+)", l)
80 d["replayed_slice"] = {"distinct_docs": int(m.group(1)), "distinct_bytes": int(m.group(2))}
81 elif l.startswith("mix "):
82 m = re.search(r"bytes (\d+) .*repo_share_pct ([\d.]+) sha256 (\w+)", l)
83 d["mix_bytes"], d["repo_share_pct"], d["mix_sha256"] = int(m.group(1)), float(m.group(2)), m.group(3)
84 elif l.startswith("tok "):
85 m = re.search(r"tokens (\d+) sha256 (\w+)", l)
86 d["tokens"], d["tok_sha256"] = int(m.group(1)), m.group(2)
87 elif l.startswith("round "):
88 d["note"] = l.strip()
89 if "tokens" not in d and f"r{n}" in tok47:
90 d["tokens"], d["tok_sha256"] = tok47[f"r{n}"]["tokens"], tok47[f"r{n}"]["tok_sha256"]
91 if "tokens" in d:
92 d["derived_passes_over_mix"] = round(TOKENS_TRAINED / d["tokens"], 2)
93 return d
94
95
96WHAT = {
97 3: "state at takeover (earlier agent's round 3)",
98 4: "round 4 task mix (adds breadth and cycle-2 traces), narrow rehearsal slice",
99 5: "continuation: round 3's own mix and settings applied again",
100 6: "round 6 task mix (adds generator variants 6 to 9), wide rehearsal at 50%",
101 7: "round 6 task mix, wide rehearsal at 30%",
102 8: "ablation: round 4 task mix, wide rehearsal at 50%",
103 9: "ablation: round 4 task mix, round 4's small slice replayed to 50%",
104 10: "round 6 configuration again, new shuffle seed",
105 11: "round 6 configuration again, new shuffle seed",
106}
107rounds = []
108r0 = {"round": "r0", "what": "pre-campaign looped checkpoint (LOOP.md step 6000), measured today", "checkpoint": f"{VLOOP}/run/loop/ck6000.bin",
109 "checkpoint_sha256": sha(f"{VLOOP}/run/loop/ck6000.bin"), "held": e_line(f"{R}/geval_loop_r0_ck6000.log"), "spark_receipt": receipt("ollm-r0-baseline-geval")}
110rounds.append(r0)
111r3 = {"round": "r3", "what": WHAT[3], "checkpoint": f"{CAMP}/ckpt/loop_r3.ck", "checkpoint_sha256": sha(f"{CAMP}/ckpt/loop_r3.ck"),
112 "held": e_line(f"{CAMP}/logs/geval_loop_r3.log"), "bench": score(f"{R}/score_r3ctl.txt")}
113rounds.append(r3)
114for n in range(4, 12):
115 ck = f"{CAMP}/ckpt/loop_r{n}.ck"
116 if not os.path.exists(f"{R}/r{n}/DONE_GPU") or not os.path.exists(ck):
117 continue
118 sc = f"{R}/score_r5ctl.txt" if n == 5 else f"{R}/score_r{n}.txt"
119 go = open(f"{R}/r{n}/gpu_round.out").read()
120 prev = re.search(r"prev_sha256=(\w+)", go).group(1)
121 xb, xa = re.search(r"XID_BEFORE=(\d+) XID_AFTER=(\d+)", go).groups()
122 d = {"round": f"r{n}", "what": WHAT[n], "parent": ck_names.get(prev, prev), "parent_sha256": prev, "checkpoint": ck, "checkpoint_sha256": sha(ck),
123 "held": e_line(f"{R}/r{n}/geval_loop_r{n}.log"), "bench": score(sc), "spark_receipt": receipt(f"ollm-rlvr-r{n}-gb10"),
124 "xid_before": int(xb), "xid_after": int(xa), "mix": manifest(n),
125 "train_T_lines": [l.strip() for l in open(f"{R}/r{n}/train_loop_r{n}.log") if l.startswith("T ")]}
126 rounds.append(d)
127
128passk = {}
129for tag in ["r3", "r6"]:
130 d = f"{R}/passk_{tag}"
131 per = [open(f"{d}/score_s{s}.txt").read().split("SCORE ")[1].split("\n")[0] for s in range(1, 9)]
132 anyp = [l.split() for l in open(f"{d}/pass_any.txt")]
133 passk[tag] = {"K": 8, "temp_milli": 700, "per_seed_score": ["SCORE " + x for x in per], "tasks_passing_in_any_sample": len(anyp),
134 "tasks": {a[1]: {"family": a[2], "samples_passing": int(a[0])} for a in anyp}}
135union = set()
136for d in rounds:
137 union |= set(d.get("bench", {}).get("passes", []))
138greedy_union = set(union)
139for p in passk.values():
140 union |= set(p["tasks"])
141
142by = {d["round"]: d for d in rounds}
143h = lambda r: by[r]["held"]["loss_micro_nats"] if r in by else None
144plan_b = {"file": f"{R}/PLAN-B.md", "file_sha256": sha(f"{R}/PLAN-B.md"), "registered": open("/home/drakestapleton/handoffs/ab4-finish-20261122/PLAN-B.registered").read().strip()}
145if all(r in by for r in ["r8", "r9"]):
146 diff = h("r9") - h("r8")
147 plan_b["held_r9_minus_r8_micro_nats"] = diff
148 plan_b["rehearsal_reading"] = "breadth of the rehearsal draw is the cause (difference above 0.3)" if diff > 300000 else ("share, not breadth (difference at most 0.1)" if abs(diff) <= 100000 else "both contribute (difference between 0.1 and 0.3)")
149late = [r for r in ["r8", "r9", "r10", "r11"] if r in by]
150if late:
151 plan_b["best_pass_r8_to_r11"] = max(by[r]["bench"]["passed"] for r in late)
152 plan_b["benchmark_gain_reached_8"] = plan_b["best_pass_r8_to_r11"] >= 8
153if all(r in by for r in ["r10", "r11"]):
154 plan_b["held_r11_minus_r10_micro_nats"] = h("r11") - h("r10")
155 plan_b["held_r10_minus_r0_micro_nats"] = h("r10") - h("r0")
156 plan_b["held_r11_minus_r0_micro_nats"] = h("r11") - h("r0")
157 plan_b["held_plateau_criterion_met"] = abs(h("r11") - h("r10")) < 50000 and abs(h("r10") - h("r0")) <= 150000 and abs(h("r11") - h("r0")) <= 150000
158
159windows = []
160for p in sorted(glob.glob(f"{YR}/2026-11-22-ollm-rlvr-r*-gb10.json") + glob.glob(f"{YR}/2026-11-22-ollm-teacher-para-*.json") + glob.glob(f"{YR}/2026-11-22-ollm-r0-baseline-geval.json")):
161 d = json.load(open(p))
162 if d["name"] in ("ollm-rlvr-r1-gb10", "ollm-rlvr-r2-gb10", "ollm-rlvr-r3-gb10"):
163 continue
164 windows.append({"name": d["name"], "window_id": d["window_id"], "start": d["start"], "seconds": d["seconds"], "exit": d["exit"], "nvrm_errors_delta": d["nvrm_errors_delta"]})
165
166teacher_out = open(f"{R}/para/teacher_p1.out").read()
167m = re.search(r"PARAPHRASE_SUMMARY.*", teacher_out)
168rec = {
169 "schema": "ollm-ab4-rounds/2",
170 "date": "2026-11-22",
171 "host": os.uname().nodename,
172 "pins": {l.split()[1]: l.split()[0] for l in open(f"{R}/pins.sha256")},
173 "derived_inputs": {"steps": STEPS, "batch": BATCH, "window": WINDOW, "tokens_trained_per_round": TOKENS_TRAINED},
174 "rounds": rounds,
175 "plan_b": plan_b,
176 "pass_at_k_diagnostic": passk,
177 "tasks_passing_anywhere": {"greedy_scores_only": sorted(greedy_union), "greedy_or_pass_at_8": sorted(union)},
178 "gpu_windows_opened_by_this_work": windows,
179 "cycle2_sweep": {"task_281_summary_lines": [l.strip() for l in open(f"{R}/c2_task281_summary.txt")],
180 "files": {os.path.basename(p): sha(p) for p in sorted(glob.glob(f"{CAMP}/ab4_cycle2/stage3/*.tsv") + glob.glob(f"{CAMP}/ab4_cycle2/stage5/*_c2.om"))}},
181 "teacher_rewording": {"summary": m.group(0) if m else None, "usable_records": 0},
182}
183json.dump(rec, open(f"{out}/receipt.json", "w"), indent=1, sort_keys=True)
184
185f = lambda v: f"{v/1e6:.3f}"
186b3, b0 = h("r3"), h("r0")
187L = ["# Results (generated by harness/make_receipt.py from the raw logs; do not edit)", "",
188 f"Each trained round is {STEPS:,} `gtrainf` steps of {BATCH} windows of {WINDOW} tokens = {TOKENS_TRAINED:,} tokens (derived; B and T from `train/omega-llm/docs/LOOP.md`).",
189 "\"Passes over mix\" is that figure divided by the mix's token count (derived).", "",
190 "| Round | Parent | What | Distinct task records | Rehearsal share of mix | Distinct repo documents | Passes over mix | Frozen benchmark pass / tasks | `held.tok` loss | vs r3 | vs r0 |",
191 "|---|---|---|---:|---:|---:|---:|---:|---:|---:|---:|"]
192for d in rounds:
193 mx, hh = d.get("mix", {}), d["held"]["loss_micro_nats"]
194 b = d.get("bench")
195 L.append("| {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} |".format(
196 d["round"], d.get("parent", ""), d["what"], f"{mx['distinct_records']:,}" if "distinct_records" in mx else "",
197 f"{mx['repo_share_pct']}%" if "repo_share_pct" in mx else "", f"{mx['repo_distinct_docs']:,}" if "repo_distinct_docs" in mx else "",
198 mx.get("derived_passes_over_mix", ""), f"{b['passed']} / {b['tasks']}" if b else "(not scored here)", f(hh), f"{(hh-b3)/1e6:+.3f}", f"{(hh-b0)/1e6:+.3f}"))
199L += ["", "Round 5 reuses round 3's mix file byte for byte (`supplement/mix_tokens_r4_r7.txt`); that mix was built by the earlier agent and has no manifest here.",
200 "Round 9's 'distinct repo documents' is the size of the replayed slice.", "",
201 "## Passing task ids, windows and driver log counts", "",
202 "| Round | Passing task ids | Spark window | `nvrm_errors_delta` | Xid before / after | Teacher plan text in mix |", "|---|---|---|---:|---|---|"]
203for d in rounds:
204 sr = d.get("spark_receipt", {})
205 L.append("| {} | {} | {} | {} | {} | {} |".format(d["round"], " ".join(d.get("bench", {}).get("passes", [])), sr.get("window_id", "(earlier agent)"), sr.get("nvrm_errors_delta", ""),
206 f"{d['xid_before']} / {d['xid_after']}" if "xid_before" in d else "", ("yes (30 alignment records)" if d.get("mix", {}).get("teacher_plan_text_in_mix") else ("no" if "mix" in d and d["mix"]["sources"] else ""))))
207L += ["", "Every scored row: `seen 6`, `passcut 0`. Headline score is one greedy sample per task (seed 42, 128 tokens, temperature 0).", "",
208 "## Other GPU windows opened by this work", "", "| Name | Window | Seconds | Exit | `nvrm_errors_delta` |", "|---|---|---:|---:|---:|"]
209for w in windows:
210 if not w["name"].startswith("ollm-rlvr-r"):
211 L.append(f"| {w['name']} | {w['window_id']} | {w['seconds']} | {w['exit']} | {w['nvrm_errors_delta']} |")
212L += ["", "## Pass-at-8 diagnostic (never a training source, never the headline)", "",
213 "| Model | Tasks passing in at least one of 8 samples (temperature 0.7) | Per-sample pass counts |", "|---|---:|---|"]
214for tag in ["r3", "r6"]:
215 p = passk[tag]
216 L.append(f"| {tag} | {p['tasks_passing_in_any_sample']} / 159 | {' '.join(x.split()[4] for x in p['per_seed_score'])} |")
217L += ["", f"Tasks passing in any greedy score above: {len(greedy_union)} ({' '.join(sorted(greedy_union))}).",
218 f"Tasks passing in any greedy score or any pass-at-8 sample: {len(union)} of 159 ({' '.join(sorted(union))}).", "",
219 "## Criteria registered beforehand (`campaign-plan/PLAN-B.md`)", ""]
220for k, v in plan_b.items():
221 if k not in ("file",):
222 L.append(f"- `{k}`: {v}")
223L += ["", "## Checkpoints (sha256)", ""] + [f"- `{d['round']}` `{d['checkpoint_sha256']}`" for d in rounds]
224open(f"{out}/RESULTS.md", "w").write("\n".join(L) + "\n")
225print("\n".join(L))