mats-sql-bundle / code /slurm_logs /build_orpo_iter2_data.sbatch
thanhdath's picture
Push code: scripts, slurm sbatch, recipes, utils (v3 + selector series)
778d47d verified
Raw
History Blame Contribute Delete
3.82 kB
#!/bin/bash
#SBATCH --job-name=vl
#SBATCH --partition=gpu-large
#SBATCH --qos=batch-long
#SBATCH --gres=gpu:1
#SBATCH --cpus-per-task=4
#SBATCH --mem=120G
#SBATCH --time=04:00:00
#SBATCH --output=/weka/s225250685/mats-tist/slurm_logs/build_orpo_iter2_data_%j.out
# Block 3: Build iter2 validator ORPO data for ONE (agent, mode) combo.
# Vars (set via --export when submitting):
# AGENT ∈ {validator_sel, validator_cond}
# MODE ∈ {collab_v2, independent}
# LABEL = short tag for output naming, e.g. "sel_collab", "sel_indep", "cond_collab", "cond_indep"
set -u; cd /weka/s225250685/mats-tist
set -a; source .env; set +a
export HF_HOME=/weka/s225250685/Huggingface HF_HUB_CACHE=/weka/s225250685/Huggingface/hub
export DB_EXEC_API_DISABLE=1 PYTHONNOUSERSITE=1 NO_PROXY=localhost,127.0.0.1
export PYTHONPATH=/weka/s225250685/mats-tist TOKENIZERS_PARALLELISM=false
PY=/weka/s225250685/conda-envs/handbook/bin/python
VLLM=/weka/s225250685/conda-envs/handbook/bin/vllm
AH=/weka/s225250685/mats-tist/alignment-handbook
PLANNER=$AH/output/sft-planner-3B-griffith-v4
NEW_FIXER=$AH/output/sft-fixer-critique-aware-v6
# Pick validator host based on AGENT
if [ "$AGENT" = "validator_sel" ]; then
VAL_MODEL=$AH/output/sft-validator-sel-llama1b-paper-v1
OUT_TAG=sel
else
VAL_MODEL=$AH/output/sft-validator-cond-llama1b-paper-v1
OUT_TAG=cond
fi
# Pick output suffix based on MODE
if [ "$MODE" = "collab_v2" ]; then
OUT_MODE_TAG=collab
else
OUT_MODE_TAG=indep
fi
OUT_DIR=data/hf_orpo_val_${OUT_TAG}_paper_iter2_${OUT_MODE_TAG}
LOG=/weka/s225250685/mats-tist/slurm_logs/build_orpo_iter2_${LABEL}_${SLURM_JOB_ID}.log
: > "$LOG"
kill_vllm() { pkill -9 -f "vllm serve" 2>/dev/null || true; sleep 5; }
trap kill_vllm EXIT
wait_url() { for i in {1..240}; do curl --noproxy '*' -fs "$1" >/dev/null 2>&1 && return 0; sleep 5; done; return 1; }
echo "[$(date)] === Booting vLLM ensemble for ${LABEL} ===" | tee -a "$LOG"
echo " AGENT=$AGENT MODE=$MODE OUT=$OUT_DIR" | tee -a "$LOG"
echo " PLANNER=$PLANNER" | tee -a "$LOG"
echo " VAL=$VAL_MODEL" | tee -a "$LOG"
echo " FIXER=$NEW_FIXER" | tee -a "$LOG"
# planner (largest) — 0.30 GPU mem
$VLLM serve "$PLANNER" --served-model-name planner --port 8100 \
--dtype bfloat16 --gpu-memory-utilization 0.30 \
--enforce-eager --max-model-len 8192 > "${LOG}.p" 2>&1 &
wait_url http://localhost:8100/v1/models && echo "[$(date)] planner ready" | tee -a "$LOG"
# validator (Llama-1B) — 0.10 GPU mem
$VLLM serve "$VAL_MODEL" --served-model-name validator --port 8101 \
--dtype bfloat16 --gpu-memory-utilization 0.10 \
--enforce-eager --max-model-len 6144 > "${LOG}.v" 2>&1 &
wait_url http://localhost:8101/v1/models && echo "[$(date)] validator ready" | tee -a "$LOG"
# new critique-aware fixer — 0.12 GPU mem (only used for collab_v2 mode)
if [ "$MODE" = "collab_v2" ]; then
if [ ! -d "$NEW_FIXER" ]; then
echo "FATAL: new fixer $NEW_FIXER not found. Block 2 must finish first." | tee -a "$LOG"
exit 1
fi
$VLLM serve "$NEW_FIXER" --served-model-name fixer --port 8102 \
--dtype bfloat16 --gpu-memory-utilization 0.12 \
--enforce-eager --max-model-len 6144 > "${LOG}.f" 2>&1 &
wait_url http://localhost:8102/v1/models && echo "[$(date)] fixer ready" | tee -a "$LOG"
fi
echo "[$(date)] === Building iter2 ORPO data: AGENT=$AGENT MODE=$MODE ===" | tee -a "$LOG"
$PY scripts/build_orpo_data.py \
--agent "$AGENT" --mode "$MODE" \
--planner_host http://localhost:8100 \
--validator_host http://localhost:8101 \
--fixer_host http://localhost:8102 \
--K 8 --temperature 1.0 --max_questions -1 --seed 42 \
--out "$OUT_DIR" 2>&1 | tee -a "$LOG.build"
echo "[$(date)] === DONE: $OUT_DIR ===" | tee -a "$LOG"
ls -la "$OUT_DIR" 2>&1 | tee -a "$LOG"
kill_vllm