"""Hand check of 3+3 cells: count episode successes straight from named JSON files (no loader), compare to cmp_data.json.""" import json, glob R = "/proj/dmfexp/zwhong/rsm_rise" def count(files): k = n = 0 for f in files: j = json.load(open(f)) eps = j["episodes"] k += sum(bool(e["success"]) for e in eps); n += len(eps) return k, n, len(files) checks = { "PUB square_sub_20100|rsm (M@best b0.98 CH11 N128 P16 logit, 3 train x 3 eval seeds)": [f"{R}/runs/square_sub_20100/eval_onactor/E1-Mb-R0.98-11-ch-N128-argmax-ONACTORP16lo-es{e}-sS0As{s}.json" for e in range(3) for s in range(3)], "PUB threading_expert_play|bc (S3H1plain greedy: eval_onactor/BC-ONS3H1plain + eval_plain/BC-PLAINBC, duplicate seeds pooled)": sorted(glob.glob(f"{R}/runs/threading_expert_play/eval_onactor/BC-ONS3H1plain-es?-sS3H1plains?.json")) + sorted(glob.glob(f"{R}/runs/threading_expert_play/eval_plain/BC-PLAINBC-es?-sS3H1plains?.json")), "PUB two_piece_expert_play|df (pin H50 mpcd N128 M8 W3*; files from the loader provenance)": None, "REPRO threading_expert_play|rsm": [f"{R}/runs_repro/threading_expert_play/eval/rsm_es{e}.json" for e in range(3)], "REPRO threading_expert_play|bc": [f"{R}/runs_repro/threading_expert_play/eval/bc_es{e}.json" for e in range(3)], "REPRO threading_expert_play|idql": [f"{R}/runs_repro/threading_expert_play/eval/idql_es{e}.json" for e in range(3)], } d = json.load(open(f"{R}/scratch/cmp_table/cmp_data.json")) out = [] for name, files in checks.items(): if not files: continue side, cell = name.split(" ", 1); t, key = cell.split(" ")[0].split("|") k, n, nf = count(files) ref = d["published_legacy" if side == "PUB" else "repro"][t][key] line = f"{name}: hand {k}/{n} ({nf} files) table {ref['k']}/{ref['n']} ({ref['n_cells']} cells) -> {'MATCH' if (k,n)==(ref['k'],ref['n']) else 'DIFF'}" print(line); out.append(line) open(f"{R}/scratch/cmp_table/handcheck.txt","w").write("\n".join(out)+"\n")