code-HFD / scripts /infer /watch_swa_visual_qa.sh
Tinghong-Ye22's picture
Add files using upload-large-folder tool
06f9561 verified
Raw History Blame Contribute Delete
1.28 kB
#!/usr/bin/env bash
set -Eeuo pipefail
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
RUN_DIR=$1
PYTHON_BIN=${HFD_INFER_PYTHON:-$ROOT/.venv-psi/bin/python}
INTERVAL=${HFD_INFER_CHECK_INTERVAL:-30}
MIN_STEP=${HFD_INFER_MIN_CHECKPOINT_STEP:-0}
while true; do
newest=""
for path in "$RUN_DIR"/checkpoints/ckpt_*; do
[[ -f "$path/model.safetensors" && -f "$path/hfd_fused_delta_manifest.json" ]] || continue
step=${path##*_}
(( step >= MIN_STEP )) || continue
marker="$RUN_DIR/swa_visual_qa/ckpt_${step}/.complete"
[[ -f "$marker" ]] || newest=$step
done
if [[ -n "$newest" ]]; then
base="$RUN_DIR/swa_visual_qa/ckpt_${newest}"
mkdir -p "$base"
CUDA_VISIBLE_DEVICES=0 "$PYTHON_BIN" -u "$ROOT/scripts/infer/swa_visual_qa.py" "$RUN_DIR" \
--ckpt-step "$newest" --split train --index 0 --device cuda:0 --output "$base/train" &
p0=$!
CUDA_VISIBLE_DEVICES=1 "$PYTHON_BIN" -u "$ROOT/scripts/infer/swa_visual_qa.py" "$RUN_DIR" \
--ckpt-step "$newest" --split val --index 0 --device cuda:0 --output "$base/val" &
p1=$!
wait "$p0"; wait "$p1"
touch "$base/.complete"
else
echo "[$(date '+%F %T')] no pending SWA checkpoint"
fi
[[ "${HFD_INFER_ONCE:-0}" == "1" ]] && exit 0
sleep "$INTERVAL"
done