evaluation_all / code /gpair_dispatcher.sh
yqi19's picture
Upload folder using huggingface_hub
8aa2acf verified
Raw
History Blame Contribute Delete
3.37 kB
#!/usr/bin/env bash
# gpair_dispatcher.sh — long-running tmux-resident dispatcher for GR00T pair eval.
# Polls every 30s: for each free GPU (no gpair_g<g> tmux session), pop the next
# job from a priority list of queue files and launch it. Independent of Claude
# wakeups — runs until all queue files are empty (and then continues idle, in
# case new queues get added).
#
# Queue file priority order (first non-empty wins):
# 1) cs_queue.txt — HARD color_size残余 (highest)
# 2) vs_queue.txt — verb_spatial
# 3) ecs_queue.txt — EASY color_size
# 4) any *_queue.txt below LOG_DIR (lex-sorted)
#
# Each line: "<ckpt>:<seed>". After successful dispatch, line is removed.
# Logs each dispatch to dispatcher.log.
set -u
ROOT=/workspace/groot_eval
H="$ROOT/harness"
LD="$ROOT/logs/gr00t_pair"
DLOG="$LD/dispatcher.log"
PRIORITY=(cs_queue.txt vs_queue.txt ecs_queue.txt af_queue.txt)
INTERVAL=30
PORT_BASE=5700
mkdir -p "$LD"
echo "[$(date +%F\ %H:%M:%S)] dispatcher start (pid $$, interval ${INTERVAL}s)" >> "$DLOG"
# log-rotation: cap at 5000 lines
trim_log() { [[ -f "$DLOG" ]] && [[ "$(wc -l < "$DLOG")" -gt 5000 ]] && tail -3000 "$DLOG" > "$DLOG.tmp" && mv "$DLOG.tmp" "$DLOG"; }
pop_one() {
# echo "<ckpt>:<seed> <queue_file>" or nothing
local f
for f in "${PRIORITY[@]}"; do
local qf="$LD/$f"
[[ -s "$qf" ]] || continue
local line; line=$(head -1 "$qf")
[[ -n "$line" ]] && { echo "$line $qf"; return 0; }
done
# any other *_queue.txt
for qf in "$LD"/*_queue.txt; do
[[ -s "$qf" ]] || continue
case "$(basename "$qf")" in cs_queue.txt|vs_queue.txt|ecs_queue.txt) continue;; esac
local line; line=$(head -1 "$qf")
[[ -n "$line" ]] && { echo "$line $qf"; return 0; }
done
return 1
}
while true; do
for g in 0 1 2 3 4 5 6 7; do
if tmux has-session -t "gpair_g$g" 2>/dev/null; then continue; fi
# GPU free — try to grab next job
pair=$(pop_one) || continue
job=${pair%% *}; qf=${pair##* }
port=$((PORT_BASE + g))
# all-factor job: "af:<ckpt>" → runs run_af_one_ckpt_fast.sh (3 seeds in one launch)
if [[ "$job" == af:* ]]; then
ck=${job#af:}
if [[ ! -d "/workspace/groot_eval/gr00t_af_ckpts/$ck" ]]; then
echo "[$(date +%H:%M:%S)] WAIT af $ck not present in gr00t_af_ckpts/" >> "$DLOG"
continue
fi
tmux new-session -d -s "gpair_g$g" \
"bash $H/run_af_one_ckpt_fast.sh $ck $g $port > $LD/r_af_${ck}.log 2>&1"
sed -i '1d' "$qf"
echo "[$(date +%H:%M:%S)] DISPATCH AF $ck → g$g (port $port) from $(basename $qf)" >> "$DLOG"
continue
fi
# pair-grid job: "ckpt:seed" or "ckpt:seed:mode"
IFS=':' read -r ck sd mode <<<"$job"
mode=${mode:-hard}
if [[ ! -d "/workspace/gr00t_pair_ckpt/$ck" ]]; then
echo "[$(date +%H:%M:%S)] WAIT $ck:$sd not yet downloaded (skip this round)" >> "$DLOG"
continue
fi
if [[ "$mode" == "easy" ]]; then
tag="${ck}_EASY_seed${sd}"
else
tag="${ck}_seed${sd}"
fi
tmux new-session -d -s "gpair_g$g" \
"COLOR_SIZE_MODE=$mode SEEDS_OVERRIDE=$sd bash $H/run_groot_one_ckpt.sh $ck $g $port > $LD/r_${tag}.log 2>&1"
sed -i '1d' "$qf"
echo "[$(date +%H:%M:%S)] DISPATCH $ck:$sd:$mode → g$g (port $port) from $(basename $qf)" >> "$DLOG"
done
trim_log
sleep "$INTERVAL"
done