- ml_porosity/benchmark/ runner, scripts 32-35, scripts/run_bench.sh;
misspec= option in synth_d2 (default path reproduces P2r bit for bit).
- configs/protocol_bench.{yaml,sha256,lock.json} locked 29/10 14:39 UTC
(sha256 aa763f0a...), configs/d2_synth_bench.yaml.
- T2 mechanism declaration and results; operations/p6_supervisor.py.
- Docs, report and paper edits of 29/10.
outputs/ stays out of git; the repository folder is synced as a whole to
the new server. Main S1 runs are still training at this commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
5.0 KiB
Python
87 lines
5.0 KiB
Python
"""protocol_bench runner (configs/protocol_bench.yaml): status | lock | posterior | train | summarize | repro | dev-budgets.
|
||
|
||
python scripts/34_run_bench.py lock # first lock (refuses if results exist)
|
||
python scripts/34_run_bench.py posterior --studies S1 S2 --device cuda:0 --workers 4 --gpu-mem-gb 6
|
||
python scripts/34_run_bench.py train --studies S1 S2 S3 S4 S8 --device cuda:1 --workers 4
|
||
python scripts/34_run_bench.py summarize # outputs/bench/summary/
|
||
python scripts/34_run_bench.py repro --device cuda:0 # P2r reproduction cell → outputs/bench/repro/
|
||
python scripts/34_run_bench.py posterior train --dev --rids 902 903 --studies S2 --presets rp_L1 ... # dev only
|
||
python scripts/34_run_bench.py dev-budgets --device cuda:0 # TCN budgets on dev 902–905 (R10, c = 1)
|
||
|
||
Main realizations 8–15 run only after the lock; --dev restricts to realizations 900–905 and writes under
|
||
outputs/bench/dev; repro writes under outputs/bench/repro. --regimes / --presets / --rids filter the planned cells
|
||
(a partial run is resumed, never a different design). Threads default to 2 per worker (OMP/MKL/OPENBLAS).
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import os
|
||
import traceback
|
||
from pathlib import Path
|
||
|
||
for _k, _v in {"OMP_NUM_THREADS": "2", "MKL_NUM_THREADS": "2", "OPENBLAS_NUM_THREADS": "2", "NUMEXPR_NUM_THREADS": "2",
|
||
"NUMBA_NUM_THREADS": "2", "PYTHONHASHSEED": "0", "PYTHONUTF8": "1", "CUBLAS_WORKSPACE_CONFIG": ":4096:8"}.items():
|
||
os.environ.setdefault(_k, _v)
|
||
|
||
STAGES = ["status", "lock", "posterior", "train", "summarize", "repro", "dev-budgets", "all"]
|
||
|
||
|
||
def main() -> None:
|
||
from ml_porosity.benchmark.cells import bench_root
|
||
from ml_porosity.benchmark.protocol import freeze, load_protocol
|
||
from ml_porosity.benchmark.runner import run, status
|
||
|
||
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||
ap.add_argument("stages", nargs="+", choices=STAGES)
|
||
ap.add_argument("--studies", nargs="+", default=["S1", "S2", "S3", "S4", "S8"], choices=["S1", "S2", "S3", "S4", "S8"])
|
||
ap.add_argument("--device", default="cuda:0")
|
||
ap.add_argument("--workers", type=int, default=4)
|
||
ap.add_argument("--threads", type=int, default=int(os.environ.get("THREADS", "2")))
|
||
ap.add_argument("--gpu-mem-gb", type=float, default=6.0, help="per-worker CUDA allocation cap for the SMC (GiB)")
|
||
ap.add_argument("--dev", action="store_true", help="dev realizations only → outputs/bench/dev")
|
||
ap.add_argument("--rids", type=int, nargs="+", default=None)
|
||
ap.add_argument("--regimes", nargs="+", default=None)
|
||
ap.add_argument("--presets", nargs="+", default=None, help="S2 presets to run (default: all main presets)")
|
||
ap.add_argument("--controls", action="store_true", help="S2: also the control presets rp_C, wv_C")
|
||
ap.add_argument("--seeds", type=int, nargs="+", default=None, help="dev only: network seeds (default: protocol)")
|
||
ap.add_argument("--drift", type=float, nargs="+", default=None, help="dev only: drift factors c (overrides the study grid)")
|
||
ap.add_argument("--n-train", type=int, nargs="+", default=None, help="dev only: N (overrides the study grid)")
|
||
ap.add_argument("--n-boot", type=int, default=2000)
|
||
args = ap.parse_args()
|
||
if args.workers < 1:
|
||
ap.error("--workers must be positive")
|
||
if (args.seeds or args.drift or args.n_train) and not args.dev:
|
||
ap.error("--seeds, --drift and --n-train are dev options")
|
||
grid = {"drift_factors": args.drift, "n_train": args.n_train} if (args.drift or args.n_train) else None
|
||
p = load_protocol()
|
||
mode = "dev" if args.dev else "main"
|
||
stages = ["posterior", "train", "summarize"] if args.stages == ["all"] else args.stages
|
||
try:
|
||
for stage in stages:
|
||
if stage == "status":
|
||
print(status(bench_root(dev=args.dev)))
|
||
elif stage == "lock":
|
||
print(freeze())
|
||
elif stage in ("posterior", "train"):
|
||
run(stage, p, args.studies, args.device, args.workers, args.gpu_mem_gb, args.threads, mode, rids=args.rids,
|
||
regimes=args.regimes, presets=args.presets, controls=args.controls, seeds=args.seeds, grid=grid)
|
||
elif stage == "repro":
|
||
from ml_porosity.benchmark.repro import compare
|
||
for st in ("posterior", "train"):
|
||
run(st, p, [], args.device, 1, args.gpu_mem_gb, args.threads, "repro")
|
||
print(compare(p))
|
||
elif stage == "summarize":
|
||
from ml_porosity.benchmark.summary import summarize
|
||
summarize(p, bench_root(dev=args.dev), args.n_boot, dev=args.dev)
|
||
elif stage == "dev-budgets":
|
||
from ml_porosity.benchmark.devbudgets import dev_budgets
|
||
print(dev_budgets(p, args.device, args.workers, args.gpu_mem_gb, args.threads, rids=args.rids))
|
||
except Exception:
|
||
traceback.print_exc()
|
||
raise SystemExit(1)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|