interplane.Get Omega
Read in your language

omega-principia

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-principia / scripts / replay_adaptive_samples.py

32 lines · 1376 bytes Raw Blame History
1"""Reproduce raw specialist outputs and measure sampler RSS, CPU and wall time."""
2import argparse
3import json
4import resource
5import sys
6import time
7from pathlib import Path
8sys.path.insert(0,str(Path(__file__).resolve().parent/"adaptive_collider"))
9from council import sample
10
11def main():
12 parser=argparse.ArgumentParser()
13 parser.add_argument("archive",type=Path)
14 args=parser.parse_args()
15 rows=[]
16 for frozen in sorted(args.archive.glob("live-*/frozen.json")):
17 pair=json.loads(frozen.read_text())
18 for i,record in enumerate(pair["trace"]):
19 start=time.monotonic()
20 observed=[]
21 sample(record["role"],bytes.fromhex(record["prompt_hex"]),observed)
22 check=observed[0]
23 for key in ("sampler","base","strand","tokens","top_k","temperature_milli","output_hex"):
24 if check.get(key)!=record.get(key) or key not in check:
25 raise ValueError(f"{frozen.parent.name} {record['role']} differs at {key}")
26 rows.append({"pair":frozen.parent.name,"sample":i,"role":record["role"],
27 "cpu_s":check["cpu_s"],"wall_s":time.monotonic()-start})
28 print(json.dumps({"replayed":len(rows),"rows":rows,
29 "max_sampler_rss_kib":resource.getrusage(resource.RUSAGE_CHILDREN).ru_maxrss}))
30
31if __name__=="__main__":
32 main()