#!/usr/bin/env bash # R6 (declared in docs/research/r6-replication.md, hashed before the first run; outside every lock). # scripts/run_r6.sh fingerprints # B1: fingerprints of realizations 16-23 (before any training) # scripts/run_r6.sh b3 # B3: sigma_a = 3.5 ms with fixed drift hyperparameters (scripts/47) # scripts/run_r6.sh c1 R10 R0 Rm5 # B1: c = 1 posteriors + the seven registered methods, realizations 16-23 # scripts/run_r6.sh c0 R10 R0 Rm5 # B1: c = 0 (zero-drift guard of H2a) # scripts/run_r6.sh sa # B2: Rm5, sigma_a,reg 3.5 and 14 ms, realizations 8-15 # scripts/run_r6.sh arms # B1: SMC-MAP, Anchor-LS, Ctl-GP (scripts/46) # scripts/run_r6.sh summary # scripts/46 summary -> outputs/replication/summary/ # Posteriors and training use the locked scripts 14 and 15 with the arguments of scripts/run_p2r_main.sh (no # --save-preds); both skip jobs that already have a CSV, so any stage can be restarted with the same command. set -euo pipefail cd "$(dirname "$0")/.." PY="${PY:-.venv/bin/python}" DEVICE="${DEVICE:-cuda:0}" WORKERS="${WORKERS:-2}" THREADS="${THREADS:-2}" export OMP_NUM_THREADS=$THREADS MKL_NUM_THREADS=$THREADS OPENBLAS_NUM_THREADS=$THREADS NUMEXPR_NUM_THREADS=$THREADS \ NUMBA_NUM_THREADS=$THREADS VECLIB_MAXIMUM_THREADS=$THREADS OUT=outputs/replication BUDGETS=outputs/p2/diag/train/budgets.json post() { # rids snr dens c-list out [extra] local rids="$1" snr="$2" dens="$3" cs="$4" out="$5"; shift 5 "$PY" scripts/14_diag_posterior.py --rids $rids --n 4 16 --seeds 0 --particles 1024 --wavelets estR \ --device "$DEVICE" --workers "$WORKERS" --gpu-mem-gb 1.5 --c $cs --snr "$snr" --anchor-density "$dens" \ --out-dir "$OUT/posterior/$out" "$@" } train() { local rids="$1" snr="$2" dens="$3" cs="$4" out="$5"; shift 5 "$PY" 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" \ --c $cs --snr "$snr" --anchor-density "$dens" --post-dir "$OUT/posterior/$out" --out-dir "$OUT/train/$out" "$@" } regime() { "$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" } NEW="16 17 18 19 20 21 22 23" OLD="8 9 10 11 12 13 14 15" stage="$1"; shift echo "== r6 $stage $* ($(date -u +%FT%TZ))" case "$stage" in fingerprints) CUDA_VISIBLE_DEVICES= "$PY" scripts/46_r6_replication.py --stage fingerprints ;; b3) CUDA_VISIBLE_DEVICES= "$PY" scripts/47_r6_fixed_hyper.py --stage hyper "$PY" scripts/47_r6_fixed_hyper.py --stage post --device "$DEVICE" --gpu-mem-gb 1.5 CUDA_VISIBLE_DEVICES= "$PY" scripts/47_r6_fixed_hyper.py --stage summary ;; c1|c0) [[ -f "$OUT/fingerprints.json" ]] || { echo "run the fingerprints stage first" >&2; exit 1; } c=${stage#c} for r in "$@"; do read -r snr dens <<< "$(regime "$r")" post "$NEW" "$snr" "$dens" "$c" "$r" train "$NEW" "$snr" "$dens" "$c" "$r" done ;; sa) read -r snr dens <<< "$(regime Rm5)" for sa in 3.5 14; do post "$OLD" "$snr" "$dens" 1 "Rm5_sa$sa" --sigma-a-reg "$sa" train "$OLD" "$snr" "$dens" 1 "Rm5_sa$sa" --sigma-a-reg "$sa" done ;; arms) "$PY" scripts/46_r6_replication.py --stage arms --device "$DEVICE" --workers "$WORKERS" ;; summary) CUDA_VISIBLE_DEVICES= "$PY" scripts/46_r6_replication.py --stage summary ;; *) echo "unknown stage: $stage" >&2; exit 2 ;; esac echo "== r6 $stage $* done ($(date -u +%FT%TZ))"