#!/usr/bin/env bash # Queue a formal 100-seed All-5 evaluation without racing the corresponding # training process. Each watcher is pinned to the GPU vacated by its method. set -euo pipefail method="${1:?method: dino|stereo|moe|local_arca}" gpu="${2:?physical GPU index}" skip_tasks=",${3:-}," eval_workers="${EVAL_WORKERS:-1}" root=/workspace/RoboFactory/runs/strict640x480_v2 py=/workspace/venvs/robofactory-act/bin/python3.10 case "$method" in dino) checkpoint="$root/results/frozen_dinov3_act_all5_80k/checkpoint_080000.pt" evaluator=/workspace/act_liftbarrier/evaluate_shared_act.py result_dir="$root/results/frozen_dinov3_act_all5_80k/formal_heldout_100" ;; stereo) checkpoint="$root/results/stereo_cross_relbias_all5_80k/checkpoint_080000.pt" evaluator=/workspace/act_liftbarrier/evaluate_stereo_act.py result_dir="$root/results/stereo_cross_relbias_all5_80k/formal_heldout_100" ;; moe) checkpoint="$root/results/stereo_ffn_moe_all5_80k/checkpoint_080000.pt" evaluator=/workspace/act_liftbarrier/evaluate_stereo_act.py result_dir="$root/results/stereo_ffn_moe_all5_80k/formal_heldout_100" ;; local_arca) checkpoint="$root/results/local_arca_all5_80k/checkpoint_080000.pt" evaluator=/workspace/act_liftbarrier/evaluate_stereo_act.py result_dir="$root/results/local_arca_all5_80k/formal_heldout_100" ;; *) echo "unknown method: $method" >&2; exit 2 ;; esac while [[ ! -s "$checkpoint" ]]; do sleep 60 done mkdir -p "$result_dir" for task in lift_barrier camera_alignment three_robots_stack_cube long_pipeline_delivery take_photo; do case "$skip_tasks" in *",$task,"*) echo "SKIP_ASSIGNED_TASK $method $task"; continue;; esac result="$result_dir/eval_${task}.json" # A parallel worker may have already completed this exact frozen protocol on # another freed GPU. Reuse only a complete 100-episode JSON; never treat a # partial file as valid. if [[ -s "$result" ]] && "$py" - "$result" <<'PY' import json, sys r = json.load(open(sys.argv[1], encoding="utf-8")) raise SystemExit(0 if r.get("episodes") == 100 and len(r.get("rows", [])) == 100 else 1) PY then echo "REUSE_FORMAL_EVAL $method $task" continue fi # A single worker owns the freed GPU, avoiding concurrent simulator processes # silently contending for one policy replica. The seed file is frozen and # verified by the evaluator before any rollout starts. CUDA_VISIBLE_DEVICES="$gpu" "$py" -u "$evaluator" \ --checkpoint "$checkpoint" --task "$task" \ --seed-file "$root/heldout_seeds/$task.json" --episodes 100 \ --workers "$eval_workers" --devices 0 --max-steps 1500 \ --output "$result" done printf 'FORMAL_ALL5_EVALUATION_COMPLETE %s\n' "$method"