P2r main grid: runner, summary, results; close the P2r decision
- scripts/11: check_rids guard; scripts 14/15 accept the protocol_p2r main grid (realizations 8-15) only when protocol_p2r and its inputs match the locked SHA-256 - scripts/run_p2r_main.sh: per-regime pipelines (posterior then training) on cuda:0/cuda:1 - scripts/18_summarize_p2r.py: H2a / H2b / H3 / sigma_a verdicts per the locked rules - docs/plan.md, report.html: H2a and H2b pass, sigma_a arm fails, no Pivot 1 - logs/index.csv: run records of the P2r grid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
71
scripts/run_p2r_main.sh
Executable file
71
scripts/run_p2r_main.sh
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
# Main grid of protocol_p2r (configs/protocol_p2r.yaml, locked): realizations 8–15, regimes R10 R0 Rm5 R0h R10tb.
|
||||
# scripts/run_p2r_main.sh # all stages in order
|
||||
# scripts/run_p2r_main.sh R10 summary # only the named stages
|
||||
# WORKERS=3 scripts/run_p2r_main.sh check parallel # all regimes and the σ_a arm at once, then the summary
|
||||
# check pytest tests/test_protocol.py (locked SHA-256 of protocol_p2 / protocol_p2r and their inputs)
|
||||
# <regime> SMC posterior (scripts/14: P = 1024, K = 1, estR wavelet, c 0 1 2, N 4 16, registration seed 0), then
|
||||
# training (scripts/15: Oracle B3b B3c B3c-R B3d B3d-Sa M2-Sa, 5 seeds, budgets of the protocol, saved
|
||||
# predictions for H3 and the blur bound) → outputs/p2r/{posterior,train}/<regime>/
|
||||
# sigma_a grid.sigma_a_arm: R10, c 1, N 4 16, every method registered with σ_a = 3.5 / 14 ms
|
||||
# → outputs/p2r/{posterior,train}/R10_sa<σ_a>/
|
||||
# summary scripts/18_summarize_p2r.py: H2a, H2b, H3 (descriptive), σ_a arm, blur bound → outputs/p2r/summary/
|
||||
# GPU jobs run on cuda:1 (override with DEVICE=...). Scripts 14 and 15 refuse realizations 8–15 unless protocol_p2r and
|
||||
# its inputs match the locked hashes, and skip jobs that already have a CSV, so the runner can be restarted.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
PY="${PY:-.venv/bin/python}"
|
||||
[[ -n "${RUNLOG_DIR:-}" ]] || exec "$PY" -m ml_porosity.runlog -n p2r_main -- bash "scripts/$(basename "$0")" "$@"
|
||||
step() { "$PY" -m ml_porosity.runlog "$@"; }
|
||||
DEVICE="${DEVICE:-cuda:1}"
|
||||
WORKERS="${WORKERS:-4}"
|
||||
THREADS="${THREADS:-2}"
|
||||
export OMP_NUM_THREADS=$THREADS MKL_NUM_THREADS=$THREADS OPENBLAS_NUM_THREADS=$THREADS NUMEXPR_NUM_THREADS=$THREADS \
|
||||
NUMBA_NUM_THREADS=$THREADS
|
||||
OUT=outputs/p2r
|
||||
RIDS=(8 9 10 11 12 13 14 15)
|
||||
BUDGETS=outputs/p2/diag/train/budgets.json # protocol_p2r inputs.budgets (hash checked by scripts 14/15)
|
||||
POST=(scripts/14_diag_posterior.py --rids "${RIDS[@]}" --n 4 16 --seeds 0 --particles 1024 --wavelets estR
|
||||
--device "$DEVICE" --workers "$WORKERS" --gpu-mem-gb 6)
|
||||
TRAIN=(scripts/15_diag_train.py --rids "${RIDS[@]}" --n 4 16 --seeds 0 1 2 3 4 --reg-seed 0 --device "$DEVICE"
|
||||
--workers "$WORKERS" --variants a --methods Oracle B3b B3c B3c-R B3d B3d-Sa M2-Sa --budgets-from "$BUDGETS"
|
||||
--save-preds)
|
||||
regime() { # prints "snr_db anchor_density" of a regime from configs/d2_synth_p2r.yaml
|
||||
"$PY" -c "import sys, yaml; r = yaml.safe_load(open('configs/d2_synth_p2r.yaml'))['regimes'][sys.argv[1]]; \
|
||||
print(r['snr_db'], r['anchor_density'])" "$1"
|
||||
}
|
||||
|
||||
for stage in ${@:-check R10 R0 Rm5 R0h R10tb sigma_a summary}; do
|
||||
case "$stage" in
|
||||
check)
|
||||
CUDA_VISIBLE_DEVICES= "$PY" -m pytest -q -p no:cacheprovider tests/test_protocol.py ;;
|
||||
R10|R0|Rm5|R0h|R10tb)
|
||||
read -r snr dens <<< "$(regime "$stage")"
|
||||
step -n "p2r_post_$stage" -- "$PY" "${POST[@]}" --c 0 1 2 --snr "$snr" --anchor-density "$dens" \
|
||||
--out-dir "$OUT/posterior/$stage"
|
||||
step -n "p2r_train_$stage" -- "$PY" "${TRAIN[@]}" --c 0 1 2 --snr "$snr" --anchor-density "$dens" \
|
||||
--post-dir "$OUT/posterior/$stage" --out-dir "$OUT/train/$stage" ;;
|
||||
sigma_a)
|
||||
read -r snr dens <<< "$(regime R10)"
|
||||
for sa in 3.5 14; do
|
||||
step -n "p2r_post_R10_sa$sa" -- "$PY" "${POST[@]}" --c 1 --snr "$snr" --anchor-density "$dens" \
|
||||
--sigma-a-reg "$sa" --out-dir "$OUT/posterior/R10_sa$sa"
|
||||
step -n "p2r_train_R10_sa$sa" -- "$PY" "${TRAIN[@]}" --c 1 --snr "$snr" --anchor-density "$dens" \
|
||||
--sigma-a-reg "$sa" --post-dir "$OUT/posterior/R10_sa$sa" --out-dir "$OUT/train/R10_sa$sa"
|
||||
done ;;
|
||||
parallel)
|
||||
# Each regime and the σ_a arm run as independent pipelines at the same time (WORKERS each), then the summary.
|
||||
# Results do not depend on scheduling: every job seeds its random streams from (rid, c, N, seed, well).
|
||||
pids=()
|
||||
for s in R10 R0 Rm5 R0h R10tb sigma_a; do
|
||||
bash "scripts/$(basename "$0")" "$s" > "${RUNLOG_DIR}/pipeline_$s.out" 2>&1 & pids+=($!)
|
||||
done
|
||||
fail=0
|
||||
for p in "${pids[@]}"; do wait "$p" || fail=1; done
|
||||
[[ $fail == 0 ]] || { echo "a pipeline failed (see ${RUNLOG_DIR}/pipeline_*.out)" >&2; exit 1; }
|
||||
bash "scripts/$(basename "$0")" summary ;;
|
||||
summary)
|
||||
CUDA_VISIBLE_DEVICES= step -n p2r_summary -- "$PY" scripts/18_summarize_p2r.py ;;
|
||||
*) echo "unknown stage: $stage" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user