#!/bin/bash # Owner's order (2026-11-16): ShotStream eval runs on GPUs 2,3. If it finishes while LongLive is still generating, # stop the single-GPU run (GPU1) and put all 4 GPUs on LongLive (claim-based workers, ~/longlive_run/worker.sh). # Writes "[ALL] LongLive DONE" to ~/longlive_run/logs/run.log at the end, which is what pipeline.sh waits for. set -uo pipefail L=~/longlive_run/logs/run.log; W=~/longlive_run log() { echo "$(TZ=Asia/Dubai date '+%F %T') [LL_BOOST] $*"; } want() { case "$1" in *_n4_*) echo 333;; *_n6_*) echo 501;; *_n8_*) echo 669;; esac; } nvalid() { local c=0 f e; for f in $W/outputs/*.mp4; do [ -f "$f" ] || continue; e=$(basename $f .mp4) [ "$(ffprobe -v error -count_packets -select_streams v:0 -show_entries stream=nb_read_packets -of csv=p=0 $f 2>/dev/null)" = "$(want $e)" ] && c=$((c+1)); done; echo $c; } if [ ! -e ~/gen_common/stages/ll_boost_started ]; then log "watching: ShotStream eval vs LongLive" until grep -q EVAL_FINISHED ~/eval/logs/eval_shotstream.log 2>/dev/null; do grep -qE "\[ALL\] LongLive DONE|EXIT_CODE=[1-9]" $L && { log "LongLive finished first; nothing to do"; exit 0; } sleep 30 done grep -qE "\[ALL\] LongLive DONE|EXIT_CODE=[1-9]" $L && { log "LongLive already finished; nothing to do"; exit 0; } log "ShotStream eval finished before LongLive -> switching LongLive to GPUs 0-3" touch ~/gen_common/stages/ll_boost_started # kill run_all.sh first (so it cannot write an EXIT_CODE line), then its python child for p in $(pgrep -f "longlive_run/run_all.sh"); do kill -9 $p; done pkill -f "interactive_episode.py --config_path"; sleep 15 echo "$(date -u +%FT%T.%6NZ) [BOOST] single-GPU run stopped; continuing with multi-GPU workers (logs/run_gpu*.log)" >> $L fi for round in 1 2; do rm -rf $W/claims; mkdir -p $W/claims # all workers are stopped here, so every claim is stale log "round $round: workers on GPUs 0 1 2 3 ($(nvalid)/200 valid outputs)" for g in 0 1 2 3; do tmux new-window -d -t main -n llw$g "bash -c '~/longlive_run/worker.sh $g >> ~/longlive_run/logs/run_gpu$g.log 2>&1'"; done sleep 60 while tmux list-windows -t main -F '#W' | grep -qE '^llw[0-3]$'; do sleep 30; done n=$(nvalid); log "round $round finished: $n/200 valid outputs" [ "$n" -ge 200 ] && break done if [ "$n" -ge 200 ]; then echo "$(date -u +%FT%T.%6NZ) [ALL] LongLive DONE (multi-GPU)" >> $L else echo "$(date -u +%FT%T.%6NZ) [BOOST] EXIT_CODE=1 ($n/200 valid outputs)" >> $L; fi