| |
| """Compare a pi0.5 Task-E eval directory against the current ACT/XSA evidence.""" |
|
|
| from __future__ import annotations |
|
|
| import argparse |
| from pathlib import Path |
| import re |
| import statistics |
|
|
|
|
| RESULT_RE = re.compile(r"\[RESULT\].*?score=([0-9.]+).*?steps=([0-9]+).*?done=(True|False)") |
| BASKET_RE = re.compile(r"\[BASKET\].*?(object_[123]): .*?inside=(True|False)") |
|
|
| DEFAULT_BASELINE_LOGS = [ |
| Path("logs/eval_task_e_xsa_final_seed11_recheck.log"), |
| Path("logs/eval_task_e_xsa_final_seed12_recheck.log"), |
| Path("logs/eval_task_e_xsa_final_seed13_recheck.log"), |
| Path("logs/eval_task_e_deployed_xsa_final_seed11_verify.log"), |
| ] |
| CURRENT_POLICY_SHA = "c3eacae3f1b0ec8ccde9fdc05d680fff119cc2ca70e1f79e4ddd5610c4bbfa93" |
|
|
|
|
| def parse_log(path: Path) -> tuple[float | None, dict[str, bool]]: |
| if not path.exists(): |
| return None, {} |
| text = path.read_text(errors="replace") |
| result = RESULT_RE.search(text) |
| baskets = {obj: inside == "True" for obj, inside in BASKET_RE.findall(text)} |
| return (float(result.group(1)) if result else None), baskets |
|
|
|
|
| def collect_pi05(eval_dir: Path) -> list[tuple[Path, float, dict[str, bool]]]: |
| rows = [] |
| for log in sorted(eval_dir.glob("seed*.log")): |
| score, baskets = parse_log(log) |
| if score is not None: |
| rows.append((log, score, baskets)) |
| return rows |
|
|
|
|
| def print_rows(title: str, rows: list[tuple[Path, float, dict[str, bool]]]) -> None: |
| print(f"[{title}]") |
| if not rows: |
| print(" no complete result logs") |
| return |
| for path, score, baskets in rows: |
| basket_text = ", ".join(f"{obj}={inside}" for obj, inside in sorted(baskets.items())) |
| print(f" {path}: score={score:.2f}; {basket_text or 'basket=unknown'}") |
| scores = [score for _, score, _ in rows] |
| print( |
| f" summary: n={len(scores)} mean={statistics.fmean(scores):.2f} " |
| f"min={min(scores):.2f} max={max(scores):.2f}" |
| ) |
|
|
|
|
| def main() -> int: |
| parser = argparse.ArgumentParser() |
| parser.add_argument("eval_dir", type=Path) |
| parser.add_argument("--repo", type=Path, default=Path.cwd()) |
| args = parser.parse_args() |
|
|
| repo = args.repo.resolve() |
| eval_dir = args.eval_dir if args.eval_dir.is_absolute() else repo / args.eval_dir |
| baseline_rows = [] |
| for log in DEFAULT_BASELINE_LOGS: |
| path = log if log.is_absolute() else repo / log |
| score, baskets = parse_log(path) |
| if score is not None: |
| baseline_rows.append((path, score, baskets)) |
|
|
| pi05_rows = collect_pi05(eval_dir) |
| print(f"[CURRENT_DEPLOYED_POLICY_SHA] {CURRENT_POLICY_SHA}") |
| print_rows("ACT_XSA_BASELINE_EVIDENCE", baseline_rows) |
| print_rows("PI05_CANDIDATE_EVIDENCE", pi05_rows) |
|
|
| if len(pi05_rows) < 3: |
| print("[DECISION] HOLD: pi0.5 does not yet have all seed11/12/13 results.") |
| return 0 |
|
|
| pi05_scores = [score for _, score, _ in pi05_rows] |
| baseline_independent = [score for path, score, _ in baseline_rows if "xsa_final_seed" in path.name] |
| baseline_mean = statistics.fmean(baseline_independent) if baseline_independent else 0.0 |
| pi05_mean = statistics.fmean(pi05_scores) |
|
|
| if min(pi05_scores) >= baseline_mean and pi05_mean > baseline_mean: |
| print("[DECISION] REVIEW_FOR_DEPLOY: pi0.5 is clearly better on this evidence set.") |
| else: |
| print("[DECISION] HOLD_ACT_XSA: pi0.5 is not clearly better than the current ACT/XSA baseline.") |
| return 0 |
|
|
|
|
| if __name__ == "__main__": |
| raise SystemExit(main()) |
|
|