File size: 3,627 Bytes
314ecfb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #!/bin/bash
# Speed-dropout ablation on StreamPETR perception, appended to chain_stream_petr.sh:
# 1. wait for the main chain's three evals to finish (kills a CARLA whose worker log is idle > 30 min so
# the evaluator's watchdog retries the route)
# 2. fine-tune the *no-dropout* oracle stage-3 checkpoint on tracker_bank_sp for 1 epoch
# (speed_dropout_p = 0, otherwise the recipe of config/fastvlm_stage3_tracker.yaml)
# 3. two 220-route evals, 8 slots each, StreamPETR detector at 4 Hz, no speed mask:
# nodrop_sp_ft_det4hz_nomask - the fine-tune of step 2
# sp_ft_det4hz_nomask - the main chain's speed-dropout fine-tune with SPEED_MASK_STALL_S unset
set -u
cd /workspace/code/ConsDrive_v2_eval
PY=/venv/fastvlm/bin/python
B=eval_results/Bench2Drive
MAIN_LOG=/tmp/chain_sp.log
log() { echo "[$(date '+%F %T')] $*"; }
# ---------------------------------------------------------------- 1. wait for the main chain's evals
until grep -q "evals launched" $MAIN_LOG 2>/dev/null; do
grep -qE "failed|incomplete" $MAIN_LOG 2>/dev/null && { log "main chain failed"; exit 1; }
sleep 120
done
FT_SP=$(cat /tmp/stage3_tracker_sp_outdir)
log "main chain evals launched; speed-dropout fine-tune: $FT_SP"
MAIN_EVALS="sp_ft_det4hz_mask15 sp_ft_det4hz_mask15_repeat tracker_ft_spdet4hz_mask15_zeroshot"
all_done() {
for r in $MAIN_EVALS; do
[ "$(grep -l WORKER_EXIT $B/$r/logs/w*.log 2>/dev/null | wc -l)" -ge 16 ] || return 1
done
}
until all_done; do
now=$(date +%s)
for r in $MAIN_EVALS; do
for f in $B/$r/logs/w*.log; do
[ -f "$f" ] || continue
grep -q WORKER_EXIT "$f" && continue
if [ $((now - $(stat -c %Y "$f"))) -gt 1800 ]; then
w=$(basename "$f" .log)
port=$(grep -oE -- "--port [0-9]+" $B/$r/scripts/run_$w.sh | awk '{print $2}')
log "worker $r/$w idle > 30 min, killing CARLA on port $port"
pkill -9 -f "carla-rpc-port=$port( |$)"
touch "$f"
fi
done
done
sleep 300
done
log "main chain evals finished"
# ---------------------------------------------------------------- 2. no-dropout fine-tune on tracker_bank_sp
ORACLE=outputs/fastvlm_stage3_oracle/2026-11-01_07-40-56/checkpoints/epoch=002.ckpt
FT_ND=outputs/fastvlm_stage3_tracker_sp_nodrop/$(date +%Y-%m-%d_%H-%M-%S)
echo "$FT_ND" > /tmp/stage3_tracker_sp_nodrop_outdir
log "no-dropout fine-tune -> $FT_ND"
STAGE3_CHECKPOINT=$ORACLE TRACKER_BANK_FOLDER=tracker_bank_sp CONFIG_NAME=fastvlm_stage3_tracker OUTPUT_DIR=$FT_ND \
bash scripts/run_train_fastvlm_stage3.sh model.speed_dropout_p=0 > /dev/null 2>&1
rc=$?
ls $FT_ND/checkpoints/epoch=*.ckpt > /dev/null 2>&1 || rc=1
echo "TRAIN_EXIT=$rc" >> $FT_ND/train.log
[ $rc -eq 0 ] || { log "no-dropout fine-tune failed ($rc)"; exit 1; }
log "no-dropout fine-tune done: $(ls $FT_ND/checkpoints)"
# ---------------------------------------------------------------- 3. evals (no speed mask)
DET=/workspace/code/ConsDrive_v2_eval/outputs/stream_petr/sp_v1/last.pt
ENV="OBJECT_SOURCE=detector DETECTOR_CKPT=$DET DETECTOR_UPDATE_EVERY=5"
slots() { # eval index k, slot count n (two workers per slot)
local k=$1 n=$2 s="" j
for ((j = 0; j < n; j++)); do s+="$(( (j + 2 * k) % 8 )):$(( (j + k) % 7 )) "; done
echo "${s% }"
}
launch() { # k run_dir name n_slots extra_env
RUN_DIR=$2 RESULT_ROOT=$B/$3 SLOTS="$(slots $1 $4)" TAG=$3 \
PORT_BASE=$((20000 + 2000 * $1)) TM_PORT_BASE=$((30000 + 2000 * $1)) EXTRA_ENV="$5" \
bash scripts/run_full220_fastvlm.sh
}
launch 0 $FT_ND nodrop_sp_ft_det4hz_nomask 8 "$ENV"
launch 1 $FT_SP sp_ft_det4hz_nomask 8 "$ENV"
log "ablation evals launched"
|