mats-sql-bundle / code /slurm_logs /gen_v5_data_qwen72b.sbatch
thanhdath's picture
Push code: scripts, slurm sbatch, recipes, utils (v3 + selector series)
778d47d verified
Raw
History Blame Contribute Delete
3.39 kB
#!/bin/bash
#SBATCH --job-name=vl
#SBATCH --partition=gpu
#SBATCH --qos=batch-long
#SBATCH --gres=gpu:a100:4
#SBATCH --cpus-per-task=16
#SBATCH --mem=300G
#SBATCH --time=14:00:00
#SBATCH --output=/weka/s225250685/mats-tist/slurm_logs/gen_v5_data_qwen72b_%j.out
# Phase 1 — Generate selector v5 SFT training data via Qwen-2.5-72B teacher.
# Steps (all in this one job):
# (a) Serve Qwen-72B with vLLM TP=4 on port 8200
# (b) Generate K=8 SQL candidates per BIRD-train question
# (c) Build pairwise pair records with hard-neg ranking + (NO, NO) class -1
# (d) Distill teacher reasoning for each pair
# (e) Save HF DatasetDict at data/sft_selector_v5_pairwise_rich
# (f) Tear down vLLM server
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 PYTHONNOUSERSITE=1 NO_PROXY=localhost,127.0.0.1 no_proxy=localhost,127.0.0.1
export PYTHONPATH=/weka/s225250685/mats-tist TOKENIZERS_PARALLELISM=false
export DB_EXEC_API_DISABLE=1
PY=/weka/s225250685/conda-envs/handbook/bin/python
VLLM=/weka/s225250685/conda-envs/handbook/bin/vllm
LOG=/weka/s225250685/mats-tist/slurm_logs/gen_v5_data_qwen72b_${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..720}; do
curl --noproxy '*' -fs "$1" >/dev/null 2>&1 && return 0
sleep 5
done
return 1
}
echo "[$(date)] === Phase 1a-1c: serve Qwen-72B teacher ===" | tee -a "$LOG"
$VLLM serve "Qwen/Qwen2.5-72B-Instruct" \
--served-model-name teacher --port 8200 \
--dtype bfloat16 \
--tensor-parallel-size 4 \
--gpu-memory-utilization 0.95 \
--max-model-len 4096 \
--max-num-seqs 32 \
--enforce-eager \
--disable-log-requests \
> "$LOG.serve" 2>&1 &
if ! wait_url http://localhost:8200/v1/models; then
echo "[$(date)] vLLM teacher failed to come up; see $LOG.serve" | tee -a "$LOG"
tail -100 "$LOG.serve" | tee -a "$LOG"
exit 1
fi
echo "[$(date)] Teacher ready" | tee -a "$LOG"
# ---------- Phase 1a — generate K=8 candidates ----------
echo "[$(date)] === Phase 1a: generating BIRD-train candidates ===" | tee -a "$LOG"
$PY scripts/gen_qwen72b_candidates_bird_train.py \
--input data/sft_bird_with_evidence_train_text2sql.json \
--out data/qwen72b_candidates_bird_train.jsonl \
--teacher_host http://localhost:8200 \
--model_name teacher \
--K 8 --threads 24 \
--resume \
2>&1 | tee -a "$LOG.cands"
# ---------- Phase 1b — pair construction ----------
echo "[$(date)] === Phase 1b: pair construction ===" | tee -a "$LOG"
$PY scripts/build_selector_v5_pairs.py \
--input data/qwen72b_candidates_bird_train.jsonl \
--out data/selector_v5_pairs_raw.jsonl \
--max_yn 4 --max_nn 1 \
2>&1 | tee -a "$LOG.pairs"
# ---------- Phase 1c — reasoning distillation + save DatasetDict ----------
echo "[$(date)] === Phase 1c: reasoning distillation ===" | tee -a "$LOG"
$PY scripts/gen_qwen72b_reasoning.py \
--input data/selector_v5_pairs_raw.jsonl \
--out_dir data/sft_selector_v5_pairwise_rich \
--teacher_host http://localhost:8200 \
--model_name teacher \
--threads 48 \
2>&1 | tee -a "$LOG.reason"
echo "[$(date)] === Phase 1 DONE ===" | tee -a "$LOG"
kill_vllm