TRACE-VLA code snapshot 2026-11-22 11:47 +07: 456 canonical files + SHA256 manifest + sync report (part 2)
ae1ed83 verified Download code/trace_validation/scripts/aggregate_gate_c.py from phammminhhieu/trace-vla-code: direct link, hf CLI and curl.
- Browser
- Download file 3.54 kB
-
https://huggingface.co/phammminhhieu/trace-vla-code/resolve/main/code/trace_validation/scripts/aggregate_gate_c.py
- Command line
-
hf download hf://phammminhhieu/trace-vla-code/code/trace_validation/scripts/aggregate_gate_c.py
-
curl -L -o aggregate_gate_c.py https://huggingface.co/phammminhhieu/trace-vla-code/resolve/main/code/trace_validation/scripts/aggregate_gate_c.py
3.54 kB
| #!/usr/bin/env python3 | |
| """Aggregate Phase C closed-loop eval results for the Gate C verdict. | |
| Reads results/eval_<arm>_<step>_<cond>.json (TRACE arms, written by | |
| eval_trace.py), results/eval_rawmem_05000_long_hybrid.json and the | |
| fs1 sweep RESULT lines in results/eval_c00_<step>_b.log / | |
| results/eval_c00_long4_b.log. Prints the full success-rate table and | |
| writes results/gate_c_summary.json. No numbers are invented: missing | |
| files are reported as missing. | |
| """ | |
| import json | |
| import re | |
| from pathlib import Path | |
| TV = Path.home() / "sera_v4_experiments" / "trace_validation" | |
| RES = TV / "results" | |
| STEPS = ["00500", "01000", "02000", "05000"] | |
| TRACE_EVALS = [("base", "textonly"), ("rawmem", "hybrid"), | |
| ("rawmem", "correct"), ("rawmem", "nodemo"), | |
| ("rawmem", "swapped"), ("rawmem", "shuffled")] | |
| def trace_sr(path): | |
| if not path.exists(): | |
| return None | |
| d = json.loads(path.read_text()) | |
| per_task = {} | |
| tot_s, tot_n = 0, 0 | |
| for spec, t in d["tasks"].items(): | |
| n = len(t["episodes"]) | |
| per_task[spec] = {"successes": t["successes"], "n": n, | |
| "shadow_successes": t.get("shadow_successes", 0)} | |
| tot_s += t["successes"] | |
| tot_n += n | |
| return {"successes": tot_s, "n": tot_n, | |
| "sr": round(100.0 * tot_s / tot_n, 1) if tot_n else None, | |
| "per_task": per_task} | |
| def fs1_sr(path): | |
| if not path.exists(): | |
| return None | |
| tot_s, tot_n = 0, 0 | |
| per = {} | |
| for line in path.read_text().splitlines(): | |
| if not line.startswith("RESULT "): | |
| continue | |
| r = json.loads(line[len("RESULT "):]) | |
| key = f"{r['suite']}#{r['task_id']}" | |
| per.setdefault(key, [0, 0]) | |
| per[key][1] += 1 | |
| tot_n += 1 | |
| if r["success"]: | |
| per[key][0] += 1 | |
| tot_s += 1 | |
| if tot_n == 0: | |
| return None | |
| return {"successes": tot_s, "n": tot_n, | |
| "sr": round(100.0 * tot_s / tot_n, 1), | |
| "per_task": {k: {"successes": v[0], "n": v[1]} | |
| for k, v in sorted(per.items())}} | |
| def main(): | |
| out = {"trace": {}, "c00": {}, "long": {}} | |
| for arm, cond in TRACE_EVALS: | |
| for step in STEPS: | |
| r = trace_sr(RES / f"eval_{arm}_{step}_{cond}.json") | |
| if r is not None: | |
| out["trace"][f"{arm}_{cond}_{step}"] = r | |
| for step in STEPS: | |
| # chain3 logs use the 6-digit checkpoint dir names (000500...). | |
| r = fs1_sr(RES / f"eval_c00_{step.zfill(6)}_b.log") | |
| if r is not None: | |
| out["c00"][f"c00_b_{step}"] = r | |
| r = trace_sr(RES / "eval_rawmem_05000_long_hybrid.json") | |
| if r is not None: | |
| out["long"]["rawmem_hybrid_05000"] = r | |
| r = fs1_sr(RES / "eval_c00_long4_b.log") | |
| if r is not None: | |
| out["long"]["c00_b_long4"] = r | |
| def sr_of(d, key): | |
| v = d.get(key) | |
| return v["sr"] if v else None | |
| gains = {} | |
| for step in STEPS: | |
| c = sr_of(out["trace"], f"rawmem_correct_{step}") | |
| n = sr_of(out["trace"], f"rawmem_nodemo_{step}") | |
| if c is not None and n is not None: | |
| gains[step] = round(c - n, 1) | |
| out["demo_gain_rawmem_correct_minus_nodemo"] = gains | |
| out["h1_c01_textonly_05000_sr"] = sr_of(out["trace"], | |
| "base_textonly_05000") | |
| out["h1_c00_b_05000_sr"] = sr_of(out["c00"], "c00_b_05000") | |
| (RES / "gate_c_summary.json").write_text(json.dumps(out, indent=1)) | |
| print(json.dumps(out, indent=1)) | |
| if __name__ == "__main__": | |
| main() | |