| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| set -u |
| cd /weka/s225250685/mats-tist |
|
|
| export HF_HOME=/weka/s225250685/Huggingface |
| export HF_HUB_CACHE=/weka/s225250685/Huggingface/hub |
| export DB_EXEC_API_DISABLE=1 |
| export PYTHONNOUSERSITE=1 |
| export NO_PROXY=localhost,127.0.0.1 |
| export PYTHONPATH=/weka/s225250685/mats-tist |
| export TOKENIZERS_PARALLELISM=false |
|
|
| PY=/weka/s225250685/conda-envs/handbook/bin/python |
| VLLM=/weka/s225250685/conda-envs/handbook/bin/vllm |
| ACCEL=/weka/s225250685/conda-envs/handbook/bin/accelerate |
| AH=/weka/s225250685/mats-tist/alignment-handbook |
|
|
| PLANNER=$AH/output/planner-iter2-collab-3B |
| SEL_V2=$AH/output/selector-3B-v2-rows |
| FIXER_V2=$AH/output/fixer-v2-1.5B-execerr-orpo-expanded |
| VALIDATOR=$AH/output/validator-v4-0.5B-orpo |
| SEM_FIXER=$AH/output/semantic-fixer-v3-1.5B-orpo-nogate |
|
|
| LOG=/weka/s225250685/mats-tist/slurm_logs/orpo_v2_${SLURM_JOB_ID}.log |
| : > "$LOG" |
|
|
| nvidia-smi --query-gpu=name,memory.total --format=csv,noheader | tee -a "$LOG" |
|
|
| kill_vllm() { |
| pkill -9 -f "vllm serve" 2>/dev/null || true |
| pkill -9 -f "VLLM::EngineCore" 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 "==== [A] building ORPO training data ====" | tee -a "$LOG" |
|
|
| |
| |
| echo " [A1] exec-error fixer data (expanded with gold SQL)..." | tee -a "$LOG" |
| $PY scripts/build_fixer_v2_execerr.py 2>&1 | tee -a "$LOG" |
| |
| [ -L data/hf_fixer_v2_execerr_expanded ] || ln -sf hf_fixer_v2_execerr data/hf_fixer_v2_execerr_expanded |
|
|
| echo " [A2] validator v4 ORPO data..." | tee -a "$LOG" |
| $PY scripts/build_validator_v4_orpo.py 2>&1 | tee -a "$LOG" |
|
|
| echo " [A3] semantic fixer v3 data (wrong→gold + preserve)..." | tee -a "$LOG" |
| $PY scripts/build_semantic_fixer_v3.py 2>&1 | tee -a "$LOG" |
|
|
| echo "==== [A] data build done ====" | tee -a "$LOG" |
| $PY - << 'PYEOF' |
| from datasets import load_from_disk |
| for name, path in [("fixer_v2_expanded", "data/hf_fixer_v2_execerr_expanded"), |
| ("validator_v4_orpo", "data/hf_validator_v4_orpo"), |
| ("semantic_fixer_v3", "data/hf_semantic_fixer_v3")]: |
| try: |
| d = load_from_disk(path) |
| split = "train_dpo" if "train_dpo" in d else "train" |
| print(f" {name}: {len(d[split])} train pairs") |
| except Exception as e: |
| print(f" {name}: MISSING — {e}") |
| PYEOF |
|
|
| |
| |
| |
| |
| echo "==== [B] ORPO fixer v2 exec-error (1.5B, expanded data) ====" | tee -a "$LOG" |
| cd $AH |
| PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info $ACCEL launch \ |
| --main_process_port 29611 \ |
| --config_file recipes/accelerate_configs/single_gpu0_local.yaml \ |
| scripts/run_orpo.py \ |
| recipes/scaleup-3stage/orpo-fixer-v2-execerr.yaml 2>&1 | tee -a "$LOG" |
| cd /weka/s225250685/mats-tist |
|
|
| if [ ! -f "$FIXER_V2/config.json" ]; then |
| echo "FIXER V2 ORPO FAILED" | tee -a "$LOG"; exit 1 |
| fi |
| echo "==== [B] fixer v2 saved: $FIXER_V2 ====" | tee -a "$LOG" |
|
|
| |
| |
| |
| |
| echo "==== [C] ORPO validator v4 (0.5B) ====" | tee -a "$LOG" |
| cd $AH |
| PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info $ACCEL launch \ |
| --main_process_port 29612 \ |
| --config_file recipes/accelerate_configs/single_gpu0_local.yaml \ |
| scripts/run_orpo.py \ |
| recipes/scaleup-3stage/orpo-validator-v4.yaml 2>&1 | tee -a "$LOG" |
| cd /weka/s225250685/mats-tist |
|
|
| if [ ! -f "$VALIDATOR/config.json" ]; then |
| echo "VALIDATOR ORPO FAILED" | tee -a "$LOG"; exit 1 |
| fi |
| echo "==== [C] validator v4 saved: $VALIDATOR ====" | tee -a "$LOG" |
|
|
| |
| |
| |
| |
| echo "==== [D] ORPO semantic fixer v3 (1.5B, no-gate) ====" | tee -a "$LOG" |
| cd $AH |
| PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info $ACCEL launch \ |
| --main_process_port 29613 \ |
| --config_file recipes/accelerate_configs/single_gpu0_local.yaml \ |
| scripts/run_orpo.py \ |
| recipes/scaleup-3stage/orpo-semantic-fixer-v3.yaml 2>&1 | tee -a "$LOG" |
| cd /weka/s225250685/mats-tist |
|
|
| if [ ! -f "$SEM_FIXER/config.json" ]; then |
| echo "SEMANTIC FIXER ORPO FAILED" | tee -a "$LOG"; exit 1 |
| fi |
| echo "==== [D] semantic fixer v3 saved: $SEM_FIXER ====" | tee -a "$LOG" |
|
|
| |
| |
| |
| |
| |
| |
| kill_vllm |
| echo "==== [E] launching 5 endpoints ====" | tee -a "$LOG" |
|
|
| $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 " planner READY" | tee -a "$LOG" |
|
|
| |
| $VLLM serve "$VALIDATOR" --served-model-name validator_sel --port 8101 --dtype bfloat16 \ |
| --gpu-memory-utilization 0.08 --enforce-eager --max-model-len 6144 > "${LOG}.vs" 2>&1 & |
| wait_url http://localhost:8101/v1/models && echo " validator_v4 sel READY" | tee -a "$LOG" |
|
|
| $VLLM serve "$VALIDATOR" --served-model-name validator_cond --port 8104 --dtype bfloat16 \ |
| --gpu-memory-utilization 0.08 --enforce-eager --max-model-len 6144 > "${LOG}.vc" 2>&1 & |
| wait_url http://localhost:8104/v1/models && echo " validator_v4 cond READY" | tee -a "$LOG" |
|
|
| $VLLM serve "$FIXER_V2" --served-model-name fixer --port 8102 --dtype bfloat16 \ |
| --gpu-memory-utilization 0.15 --enforce-eager --max-model-len 4096 > "${LOG}.f" 2>&1 & |
| wait_url http://localhost:8102/v1/models && echo " fixer_v2 READY" | tee -a "$LOG" |
|
|
| $VLLM serve "$SEM_FIXER" --served-model-name fixer_v3 --port 8105 --dtype bfloat16 \ |
| --gpu-memory-utilization 0.15 --enforce-eager --max-model-len 4096 > "${LOG}.fs" 2>&1 & |
| wait_url http://localhost:8105/v1/models && echo " sem_fixer_v3 READY" | tee -a "$LOG" |
|
|
| OUT=eval_results/scaleup_BoN8_d_K8_3stage_orpov2_nogate_bird_dev.jsonl |
| rm -f "$OUT" |
|
|
| echo "==== [E] K=8 rollout: fixer_v2 exec-err gate + sem_fixer NO GATE ====" | tee -a "$LOG" |
| $PY scripts/run_pipeline_rollouts.py \ |
| --input_file data/sft_bird_with_evidence_dev_text2sql.json \ |
| --output_file "$OUT" \ |
| --planner_host http://localhost:8100 \ |
| --validator_host none \ |
| --validator_sel_host http://localhost:8101 \ |
| --validator_cond_host http://localhost:8104 \ |
| --fixer_host http://localhost:8102 \ |
| --fixer_gate_exec_ok \ |
| --fixer_v3_host http://localhost:8105 \ |
| --sem_fixer_no_gate \ |
| --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" |
|
|
| echo "==== [E] oracle/greedy metrics ====" | tee -a "$LOG" |
| $PY scripts/compute_bestofn_metrics.py "$OUT" orpov2_nogate 2>&1 | tee -a "$LOG" |
|
|
| |
| |
| |
| kill_vllm |
| echo "==== [F] selector v2 apply ====" | tee -a "$LOG" |
| $VLLM serve "$SEL_V2" --served-model-name selector --port 8103 --dtype bfloat16 \ |
| --gpu-memory-utilization 0.85 --enforce-eager --max-model-len 8192 > "${LOG}.sel" 2>&1 & |
| wait_url http://localhost:8103/v1/models && echo " selector READY" | tee -a "$LOG" |
|
|
| label="$(basename $OUT .jsonl)_selectorV2rows" |
| $PY scripts/compute_bestofn_with_selector.py \ |
| "$OUT" "$label" --selector_host http://localhost:8103 --row_preview 2>&1 | tee -a "$LOG" |
|
|
| echo "==== ALL_DONE ====" | tee -a "$LOG" |
|
|