Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/train/omega-llm/tools/combined/regression.py # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / train / omega-llm / tools / combined / regression.py` 89 lines ยท 3971 bytes Raw Blame History 1 """Replay both historical conditions. The input kit supplies fixed private checkpoints.""" 2 import argparse 3 from concurrent.futures import ThreadPoolExecutor 4 import json 5 from pathlib import Path 6 import subprocess 7 import time 8 9 10 def command(args, **kwargs): 11 return subprocess.run(args, check=True, **kwargs) 12 13 14 def fixed_examples(bench, tasks, kit, out, prompts): 15 values = { 16 "in1": [(x,) for x in (23, 18, 22, 27, 35, 54, 81, 210)], 17 "in2": [(2,11),(13,3),(11,11),(21,0),(1,19),(32,7),(13,26),(20,4)], 18 "in3": [(2,11,5),(13,3,13),(11,11,11),(21,0,0),(1,19,26),(32,7,14),(13,26,4),(20,4,1)], 19 "arr": [(7,0,3,11,3,2,9,13),(9,2,3,2,1,12,0,9)], 20 "cnt": [(0,), (2,), (5,), (8,)], 21 } 22 lines = tasks.read_text().splitlines() 23 headers = [f"note {k} " + " ".join(map(str, x)) for k, xs in values.items() for x in xs] 24 public = out / "public.om" 25 public.write_text("\n".join(headers + [line for line in lines if not line.startswith( 26 tuple(f"note {k} " for k in values))]) + "\n") 27 rows = command([bench, "table", public, kit/"omc", out], capture_output=True, text=True) 28 for line in rows.stdout.splitlines(): 29 task, *ys = line.split() 30 sig = (prompts / f"prompt-{task}").read_text().splitlines()[-1] 31 if " view " in sig or " edit " in sig: 32 xs = [n + a for a in values["arr"] for n in values["cnt"]] 33 else: 34 xs = values["in" + str(sig.count(" ulong") - 1)] 35 stride = 8 if " edit " in sig else 1 36 assert len(ys) == len(xs) * stride 37 (out / f"cases-{task}").write_text("".join(" ".join(map(str, (*x, *ys[i*stride:(i+1)*stride])))+"\n" 38 for i, x in enumerate(xs))) 39 40 41 def main(): 42 parser = argparse.ArgumentParser(description=__doc__) 43 parser.add_argument("kit", type=Path) 44 parser.add_argument("out", type=Path) 45 parser.add_argument("--jobs", type=int, default=1) 46 args = parser.parse_args() 47 kit, out = args.kit.resolve(), args.out.resolve() 48 out.mkdir() 49 src = Path(__file__).resolve().parents[1] / "bench" 50 bench = out / "bench" 51 with (src/"bench.om").open("rb") as inp, bench.open("wb") as exe: 52 command([kit/"omc"], stdin=inp, stdout=exe) 53 bench.chmod(0o700) 54 prompts = out / "prompts" 55 prompts.mkdir() 56 tasks = src / "tasks.om" 57 command([bench, "prompts", tasks, prompts]) 58 fixed_examples(bench, tasks, kit, out, prompts) 59 60 def replay(prompt): 61 task = prompt.name.removeprefix("prompt-") 62 argv = [kit/"solve", prompt] 63 if mode == "checked": 64 argv.append(out / f"cases-{task}") 65 start = time.monotonic() 66 result = subprocess.run(argv, capture_output=True, timeout=240) 67 if result.returncode == 0: 68 (answers / f"answer-{task}").write_bytes(result.stdout) 69 elif mode != "checked" or result.returncode != 1 or result.stdout: 70 raise RuntimeError((task, result.returncode, result.stderr)) 71 return {"id": task, "route": result.stderr.decode().strip(), "seconds": time.monotonic()-start} 72 73 for mode in ("checked", "plain"): 74 answers = out / mode 75 answers.mkdir() 76 with ThreadPoolExecutor(max_workers=args.jobs) as pool: 77 rows = list(pool.map(replay, sorted(prompts.glob("prompt-*")))) 78 score = command([bench, "score", tasks, src/"expect.txt", kit/"omc", answers], capture_output=True, text=True) 79 (answers/"score-all").write_text(score.stdout) 80 verdicts = {r[1]:r[3] for line in score.stdout.splitlines() if (r:=line.split()) and r[0]=="R"} 81 assert len(rows) == len(verdicts) == 165 82 for row in rows: 83 row["verdict"] = verdicts[row["id"]] 84 (answers/"results.json").write_text(json.dumps(rows, indent=2)+"\n") 85 print(mode, next(line for line in score.stdout.splitlines() if line.startswith("SCORE ")), flush=True) 86 87 88 if __name__ == "__main__": 89 main()