"""Full reproduction driver: Table 1 Cello row, arXiv 2611.04574. Runs 8 configurations x 5 runs each (300 epochs, full batch, best-epoch eval), then summarizes and uploads everything to the Hub dataset repo. Deviations from the paper protocol are limited to: * patched main.py/model.py/train.py (shot estimator + baseline dispatch), * unseeded runs exactly as the authors' code does (no manual_seed anywhere). """ import json import os import subprocess import sys import time from concurrent.futures import ThreadPoolExecutor ROOT = os.environ.get("SQMM_ROOT", os.getcwd()) OUT = os.path.join(ROOT, "out") THREADS = 2 # repo default / paper runs used 2 torch threads # (name, extra args) CONFIGS = [ ("sqmm_exact", []), ("sqmm_shots2048", ["--shots", "2048"]), ("qiren", ["--model", "qiren"]), ("finer", ["--model", "finer"]), ("siren", ["--model", "siren"]), ("iga", ["--model", "iga"]), ("msa_inr", ["--model", "msa_inr"]), ("cafe_enc", ["--model", "cafe_enc"]), ] def run_config(name, extra): outdir = os.path.join(OUT, name) os.makedirs(outdir, exist_ok=True) cmd = [ sys.executable, "main.py", "--dataset", "cello", "--epochs", "300", "--runs", "5", "--threads", str(THREADS), "--output-dir", outdir, ] + extra t0 = time.time() with open(os.path.join(outdir, "stdout.log"), "w") as logf: proc = subprocess.run(cmd, cwd=ROOT, stdout=logf, stderr=subprocess.STDOUT) status = "ok" if proc.returncode == 0 else f"FAIL({proc.returncode})" print(f"[driver] {name}: {status} in {time.time()-t0:.0f}s", flush=True) return name, status def summarize(): summary = {} for name, _ in CONFIGS: path = os.path.join(OUT, name, "results.json") if not os.path.exists(path): summary[name] = {"error": "missing results.json"} continue with open(path) as f: r = json.load(f) runs = r.get("runs") or r.get("cello", {}).get("runs_detail") or [] summary[name] = r with open(os.path.join(OUT, "summary.json"), "w") as f: json.dump(summary, f, indent=2) # human-readable table print("\n===== SUMMARY (MSE x10^-3, mean +/- sd over 5 runs, best-epoch) =====") for name, _ in CONFIGS: r = summary[name] if "error" in r: print(f"{name:>16}: ERROR {r['error']}") continue cell = (r.get("summary") or {}).get("cello", {}) mean = cell.get("mean_mse_best") std = cell.get("std_mse_best") if mean is None: print(f"{name:>16}: unexpected structure, keys={list(r.keys())}") continue print(f"{name:>16}: {mean*1000:.2f} +/- {std*1000:.2f} (psnr {cell.get('mean_psnr_best', float('nan')):.2f})") if __name__ == "__main__": os.makedirs(OUT, exist_ok=True) t0 = time.time() with ThreadPoolExecutor(max_workers=4) as ex: for name, status in ex.map(lambda c: run_config(*c), CONFIGS): print(f"[driver] finished {name}: {status}", flush=True) print(f"[driver] all configs done in {time.time()-t0:.0f}s", flush=True) summarize()