mats-sql-bundle / code /slurm_logs /eval_after_orpo_iter1.sbatch
thanhdath's picture
Push code: scripts, slurm sbatch, recipes, utils (v3 + selector series)
778d47d verified
Raw
History Blame Contribute Delete
4.99 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=100G
#SBATCH --time=08:00:00
#SBATCH --output=/weka/s225250685/mats-tist/slurm_logs/eval_after_orpo_iter1_%j.out
# After ORPO iter1, eval 3 pipeline configs to compare collab vs independent:
# COLLAB: planner-orpo + val-sel-collab + val-cond-collab + fixer-orpo + selector(SFT)
# INDEPENDENT: planner-orpo + val-sel-indep + val-cond-indep + fixer-orpo + selector(SFT)
# pass@1 greedy on planner only (sanity)
# Show: oracle pass@8, selector EX for COLLAB and INDEPENDENT side-by-side
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/orpo-planner-iter1
VAL_SEL_C=$AH/output/orpo-val-sel-collab-iter1
VAL_SEL_I=$AH/output/orpo-val-sel-indep-iter1
VAL_COND_C=$AH/output/orpo-val-cond-collab-iter1
VAL_COND_I=$AH/output/orpo-val-cond-indep-iter1
FIXER=$AH/output/orpo-fixer-iter1
SELECTOR=$AH/output/sft-selector-3B-griffith-v5
LOG=/weka/s225250685/mats-tist/slurm_logs/eval_after_orpo_iter1_${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; }
# Wait for all 6 ORPO models
for i in $(seq 1 96); do
ok=0
for p in "$PLANNER" "$VAL_SEL_C" "$VAL_SEL_I" "$VAL_COND_C" "$VAL_COND_I" "$FIXER"; do
[ -f "$p/config.json" ] && ok=$((ok+1))
done
echo " [$i*5min] ORPO models ready: $ok/6" | tee -a "$LOG"
[ "$ok" -eq 6 ] && break
sleep 300
done
run_pipeline() {
local LABEL=$1; local VSEL=$2; local VCOND=$3
kill_vllm
$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
$VLLM serve "$VSEL" --served-model-name validator_sel --port 8101 \
--dtype bfloat16 --gpu-memory-utilization 0.10 \
--enforce-eager --max-model-len 6144 > "${LOG}.vs" 2>&1 &
wait_url http://localhost:8101/v1/models
$VLLM serve "$VCOND" --served-model-name validator_cond --port 8104 \
--dtype bfloat16 --gpu-memory-utilization 0.10 \
--enforce-eager --max-model-len 6144 > "${LOG}.vc" 2>&1 &
wait_url http://localhost:8104/v1/models
$VLLM serve "$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
OUT=eval_results/orpo1_${LABEL}_passAt8_bird_dev.jsonl
rm -f "$OUT"
$PY scripts/run_pipeline_rollouts.py \
--input_file data/sft_bird_with_evidence_dev_text2sql.json \
--output_file "$OUT" \
--planner_host http://localhost:8100 --planner_format qwen \
--validator_host none \
--validator_sel_host http://localhost:8101 \
--validator_cond_host http://localhost:8104 \
--fixer_host http://localhost:8102 \
--fixer_gate_exec_ok \
--griffith_prompts \
--K 8 --K_val 1 --K_fix 1 \
--temperature 1.0 --top_p 0.9 \
--max_planner_tokens 1024 --max_validator_tokens 384 --max_fixer_tokens 512 \
--max_questions -1 --n_threads 4 2>&1 | tee -a "$LOG"
$PY scripts/compute_bestofn_metrics.py "$OUT" orpo1_${LABEL}_passAt8 2>&1 | tee -a "$LOG"
}
# COLLAB pipeline
echo "==== [COLLAB] planner-orpo + val-sel-collab + val-cond-collab + fixer-orpo ====" | tee -a "$LOG"
run_pipeline COLLAB "$VAL_SEL_C" "$VAL_COND_C"
# INDEPENDENT pipeline
echo "==== [INDEP] planner-orpo + val-sel-indep + val-cond-indep + fixer-orpo ====" | tee -a "$LOG"
run_pipeline INDEP "$VAL_SEL_I" "$VAL_COND_I"
# Selector EX on both
kill_vllm
$VLLM serve "$SELECTOR" --served-model-name selector --port 8103 \
--dtype bfloat16 --gpu-memory-utilization 0.85 \
--enforce-eager --max-model-len 4096 > "${LOG}.sel" 2>&1 &
wait_url http://localhost:8103/v1/models
for L in COLLAB INDEP; do
$PY scripts/compute_bestofn_with_selector.py \
eval_results/orpo1_${L}_passAt8_bird_dev.jsonl orpo1_${L}_selectorEX \
--selector_host http://localhost:8103 --row_preview 2>&1 | tee -a "$LOG"
done
echo "==== ALL_DONE ====" | tee -a "$LOG"
echo "" | tee -a "$LOG"
echo "=== FINAL COMPARISON (ORPO iter1) ===" | tee -a "$LOG"
grep -E "orpo1_COLLAB_|orpo1_INDEP_|oracle|selector" "$LOG" | tail -20 | tee -a "$LOG"