#!/bin/bash # Train ORPO for the 3-stage collaborative-vs-independent ablation. # # Configurations to produce: # (b) planner-INDEP ORPO + V/F SFT only ← uses planner_INDEP only # (e) planner-COLLAB + validator-COLLAB + fixer ← all three aligned # (d) planner-COLLAB + fixer (validator stays SFT) ← same checkpoints; just swap at eval # Total ORPO runs: 4 (planner_INDEP, planner_COLLAB, validator_COLLAB, fixer). set -e cd /home/datht/mats-sql-tist/alignment-handbook # Free GPU memory by killing any vLLM endpoints first for pidf in /tmp/collab_planner_vllm.pid /tmp/collab_validator_vllm.pid /tmp/collab_fixer_vllm.pid; do [ -f "$pidf" ] && kill "$(cat $pidf)" 2>/dev/null || true done sleep 5 LOG=/tmp/collab_orpo_train.log LOG_GPU1=/tmp/collab_orpo_gpu1.log # Validator stays SFT-only this experiment — its outputs are too templated # (only 4 informative pairs from 1431 questions, vs 1628 for planner). Skip its ORPO run. # Methodology argument is preserved structurally; validator-collab is documented as future work. # GPU 1 in background: fixer ORPO (shared between INDEP and COLLAB methods, since terminal) ( set -e echo "[GPU1] ORPO fixer (shared)..." | tee $LOG_GPU1 CUDA_VISIBLE_DEVICES=1 PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info \ /home/datht/anaconda3/envs/mats/bin/accelerate launch \ --main_process_port 29563 \ --config_file recipes/accelerate_configs/single_gpu1_local.yaml \ scripts/run_orpo.py recipes/qwen-coder-0.5b-bird/orpo-fixer.yaml 2>&1 | tee -a $LOG_GPU1 echo "DONE_GPU1_ORPO" >> $LOG_GPU1 ) & GPU1_PID=$! # GPU 0: planner-INDEP, then planner-COLLAB echo "[GPU0 1/2] ORPO planner INDEPENDENT..." | tee $LOG CUDA_VISIBLE_DEVICES=0 PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info \ /home/datht/anaconda3/envs/mats/bin/accelerate launch \ --main_process_port 29560 \ --config_file recipes/accelerate_configs/single_gpu0_local.yaml \ scripts/run_orpo.py recipes/qwen-coder-0.5b-bird/orpo-planner-independent.yaml 2>&1 | tee -a $LOG echo "[GPU0 2/2] ORPO planner COLLABORATIVE..." | tee -a $LOG CUDA_VISIBLE_DEVICES=0 PYTHONPATH=src/ ACCELERATE_LOG_LEVEL=info \ /home/datht/anaconda3/envs/mats/bin/accelerate launch \ --main_process_port 29561 \ --config_file recipes/accelerate_configs/single_gpu0_local.yaml \ scripts/run_orpo.py recipes/qwen-coder-0.5b-bird/orpo-planner-collaborative.yaml 2>&1 | tee -a $LOG wait $GPU1_PID || true echo "DONE_COLLAB_ORPO" | tee -a $LOG