ConsDrive / scripts /chain_tracker_finetune.sh
ZenoNing's picture
Upload ConsDrive v2 source (part 2)
314ecfb verified
Raw History Blame Contribute Delete
3.14 kB
#!/bin/bash
# Cross-fitted tracker banks -> stage-3 fine-tune on them -> closed-loop evals with the 4 Hz det_v1 tracker.
# 1. wait for outputs/detector/det_fold{0,1}of2 (each trained without its fold's routes)
# 2. tracker banks: fold-k routes through the fold-k detector (8 shards per fold, 2 per GPU); the
# per-frame detections are cached in simlingo_data/tracker_dets so other tracker settings can be
# re-run on CPU (scripts/chain_coast_ablation.sh)
# 3. fine-tune config/fastvlm_stage3_tracker.yaml (from the speed-dropout stage-3 checkpoint)
# 4. three 220-route evals: fine-tuned x2 and the speed-dropout checkpoint zero-shot, all with
# OBJECT_SOURCE=detector (det_v1) DETECTOR_UPDATE_EVERY=5 SPEED_MASK_STALL_S=15
set -u
cd /workspace/code/ConsDrive_v2_eval
PY=/venv/fastvlm/bin/python
log() { echo "[$(date '+%F %T')] $*"; }
for k in 0 1; do
until grep -q "TRAIN_EXIT=" outputs/detector/det_fold${k}of2/train.log 2>/dev/null; do sleep 60; done
grep -q "TRAIN_EXIT=0" outputs/detector/det_fold${k}of2/train.log || { log "fold $k detector failed"; exit 1; }
done
log "fold detectors done"
OUT=eval_results/tracker_offline
for k in 0 1; do
for s in 0 1 2 3 4 5 6 7; do
gpu=$((4 * k + s / 2))
CUDA_VISIBLE_DEVICES=$gpu OMP_NUM_THREADS=4 $PY scripts/eval_tracker_offline.py \
--detector outputs/detector/det_fold${k}of2/last.pt --out $OUT/banks_fold$k --split all --fold $k/2 \
--shard $s/8 --write-banks --bank-folder tracker_bank --skip-existing --decode-threads 6 \
--save-detections --detections-folder tracker_dets \
> $OUT/banks_fold${k}_shard$s.log 2>&1 &
done
done
wait
n_bank=$(find simlingo_data/tracker_bank -name objects.npz | wc -l)
n_oracle=$(find simlingo_data/object_bank -name objects.npz | wc -l)
log "tracker banks: $n_bank / $n_oracle"
[ "$n_bank" -eq "$n_oracle" ] || { log "bank coverage incomplete"; exit 1; }
FT=outputs/fastvlm_stage3_tracker/$(date +%Y-%m-%d_%H-%M-%S)
echo "$FT" > /tmp/stage3_tracker_outdir
log "fine-tune -> $FT"
CONFIG_NAME=fastvlm_stage3_tracker OUTPUT_DIR=$FT bash scripts/run_train_fastvlm_stage3.sh > /dev/null 2>&1
rc=$?
echo "TRAIN_EXIT=$rc" >> $FT/train.log
[ $rc -eq 0 ] || { log "fine-tune failed ($rc)"; exit 1; }
log "fine-tune done: $(ls $FT/checkpoints)"
SD=outputs/fastvlm_stage3_speeddrop/2026-11-02_06-08-03
DET=/workspace/code/ConsDrive_v2_eval/outputs/detector/det_v1/last.pt
ENV="OBJECT_SOURCE=detector DETECTOR_CKPT=$DET DETECTOR_UPDATE_EVERY=5 SPEED_MASK_STALL_S=15"
B=eval_results/Bench2Drive
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 tracker_ft_det4hz_mask15 8 "$ENV"
launch 1 $FT tracker_ft_det4hz_mask15_repeat 8 "$ENV"
launch 2 $SD speeddrop_det4hz_mask15_zeroshot 8 "$ENV"
log "evals launched"