#!/bin/bash #SBATCH --job-name=vl #SBATCH --partition=gpu-large,gpu #SBATCH --qos=batch-long #SBATCH --gres=gpu:1 #SBATCH --cpus-per-task=8 #SBATCH --mem=60G #SBATCH --time=01:30:00 #SBATCH --output=/weka/s225250685/mats-tist/slurm_logs/build_fixer_data_v7_%j.out # v7: Critique-conditional fixer SFT data builder. # Output completion = planner_sql if validator-OK, else gold_sql. set -u; cd /weka/s225250685/mats-tist set -a; source /weka/s225250685/mats-tist/.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 VAL_SEL=$AH/output/sft-validator-sel-llama1b-paper-v1 VAL_COND=$AH/output/sft-validator-cond-llama1b-paper-v1 LOG=/weka/s225250685/mats-tist/slurm_logs/build_fixer_data_v7_${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..180}; do curl --noproxy '*' -fs "$1" >/dev/null 2>&1 && return 0; sleep 5; done; return 1; } echo "[$(date)] Booting planner + val-sel + val-cond..." | tee -a "$LOG" $VLLM serve "$PLANNER" --served-model-name planner --port 8200 \ --dtype bfloat16 --gpu-memory-utilization 0.40 \ --enforce-eager --max-model-len 8192 > "${LOG}.p" 2>&1 & wait_url http://localhost:8200/v1/models && echo "[$(date)] planner ready" | tee -a "$LOG" $VLLM serve "$VAL_SEL" --served-model-name validator --port 8201 \ --dtype bfloat16 --gpu-memory-utilization 0.15 \ --enforce-eager --max-model-len 6144 > "${LOG}.vs" 2>&1 & wait_url http://localhost:8201/v1/models && echo "[$(date)] val-sel ready" | tee -a "$LOG" $VLLM serve "$VAL_COND" --served-model-name validator --port 8204 \ --dtype bfloat16 --gpu-memory-utilization 0.15 \ --enforce-eager --max-model-len 6144 > "${LOG}.vc" 2>&1 & wait_url http://localhost:8204/v1/models && echo "[$(date)] val-cond ready" | tee -a "$LOG" echo "[$(date)] === Building critique-conditional fixer SFT data (v7) ===" | tee -a "$LOG" $PY scripts/build_fixer_critique_conditional_v7.py \ --planner_host http://localhost:8200 \ --val_sel_host http://localhost:8201 \ --val_cond_host http://localhost:8204 \ --K 8 --temperature 1.0 --max_questions -1 --threads 12 --seed 42 \ --out data/hf_fixer_critique_conditional_v7 \ 2>&1 | tee -a "$LOG.build" echo "[$(date)] === DONE ===" | tee -a "$LOG" ls -la data/hf_fixer_critique_conditional_v7/ 2>&1 | tee -a "$LOG" kill_vllm