#!/bin/bash # Round-2 self-driving chain (coordinator 5): G -> H -> I with routing # measurements + pair-splits interleaved. Assumes arm G is ALREADY # training when this starts. Each arm launches the moment the previous # one finishes; the previous arm's measurements run in parallel with # the next arm's training at batch 8 (proven safe in Stage 1). set -u EXP="$HOME/sera_v4_experiments" LOG="$EXP/round2_probe/chain_ghi.log" TOOLS="$EXP/tools" cd "$HOME/lerobot" || exit 1 log() { echo "[$(date -Is)] $*" >> "$LOG"; } wait_train_done() { sleep 30 while pgrep -f "tools/train_v4.py" > /dev/null; do sleep 60; done } measure() { # run-name label BATCH=8 bash "$TOOLS/measure_steps.sh" "$1" "$2" 2000 5000 10000 >> "$LOG" 2>&1 .venv/bin/python "$TOOLS/measure_pair_split.py" \ --ckpt "$EXP/$1/checkpoints/010000/pretrained_model" \ --out "$EXP/round2_probe/results/pairsplit-$2-10000.json" \ --batch 8 >> "$LOG" 2>&1 } log "CHAIN_GHI START" # Reference pair-split for D@10k while G trains. .venv/bin/python "$TOOLS/measure_pair_split.py" \ --ckpt "$EXP/sera-v4-d-skillroute/checkpoints/010000/pretrained_model" \ --out "$EXP/round2_probe/results/pairsplit-d-skillroute-10000.json" \ --batch 8 >> "$LOG" 2>&1 log "PAIRSPLIT_D DONE" wait_train_done log "G TRAIN DONE -> launch H" bash "$TOOLS/run_arm_h.sh" >> "$LOG" 2>&1 measure sera-v4-g-mi g-mi log "G MEASURED" wait_train_done log "H TRAIN DONE -> launch I" bash "$TOOLS/run_arm_i.sh" >> "$LOG" 2>&1 measure sera-v4-h-ortho h-ortho log "H MEASURED" wait_train_done log "I TRAIN DONE" measure sera-v4-i-intracl i-intracl log "I MEASURED" .venv/bin/python "$TOOLS/gate_eval.py" "$EXP/measurement/results" g-mi,h-ortho,i-intracl >> "$LOG" 2>&1 log "CHAIN_GHI_DONE"