Avra98 commited on
Commit
a7ae163
·
verified ·
1 Parent(s): a91401d

S2 backtracking sweep launcher

Browse files
latent_multi_output_cell_policy/backtracking/launch_s2_sweep.sh ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Stage-2 latent backtracking sweep: 8 combinations, one per GPU, from the
3
+ # Stage-1 GRPO checkpoint. Compares no-backtrack controls vs backtracking
4
+ # (rehearsal of stage-1 consistency with k=1) and warm-up on/off.
5
+ set -uo pipefail
6
+
7
+ PY=/opt/pytorch/bin/python
8
+ REPO=/home/ubuntu/curriculum-cot-code
9
+ SCRIPT="${REPO}/latent_multi_output_cell_policy/sft_latent_multi_output_train.py"
10
+ S1_GRPO=/home/ubuntu/hf_checkpoints/latent_stages/stage01_latent_grpo_i1_20empty_latent_recurrent_hidden
11
+ TRAIN="${REPO}/data/sudoku_t3_20empty_value_qwen_text_stage1_train.jsonl"
12
+ EVAL="${REPO}/data/sudoku_t3_20empty_value_qwen_text_stage1_eval.jsonl"
13
+ ROOT=/home/ubuntu/bt_runs/s2_sweep_$(date +%Y%m%d_%H%M%S)
14
+ mkdir -p "${ROOT}/logs"
15
+ echo "Sweep root: ${ROOT}"
16
+
17
+ # Common knobs (kept small enough for an 8-way single-GPU sweep).
18
+ COMMON=(
19
+ --model_name Qwen/Qwen2.5-1.5B-Instruct
20
+ --train_jsonl "${TRAIN}" --eval_jsonl "${EVAL}"
21
+ --cache_dir /home/ubuntu/.hf_cache
22
+ --init_adapter_dir "${S1_GRPO}"
23
+ --seed 0 --gpu_id 0
24
+ --stage_i 2 --num_cot_tokens 2 --latent_mode recurrent_hidden
25
+ --total_empties_hint 20
26
+ --per_device_train_batch_size 8 --gradient_accumulation_steps 2
27
+ --num_epochs 8 --learning_rate 5e-5 --enable_gradient_checkpointing
28
+ --logging_steps 20 --eval_steps 400 --save_steps 400
29
+ --eval_rows 20 --max_completion_length 24 --limit_train_rows 4000
30
+ --max_steps 1200
31
+ --eval_value_precision_stop 0 --eval_value_recall_stop 0 --eval_solve_rate_stop 0
32
+ --lora_r 32 --lora_alpha 64 --lora_dropout 0.05
33
+ )
34
+
35
+ # name|extra flags
36
+ declare -a COMBOS=(
37
+ "ctrl_nobt|--latent_warmup_steps 0"
38
+ "ctrl_warm|--latent_warmup_steps 150"
39
+ "bt_rr03_warm|--backtrack_enable --remember_rate 0.3 --backtrack_detect_threshold 0 --latent_warmup_steps 150"
40
+ "bt_rr05_warm|--backtrack_enable --remember_rate 0.5 --backtrack_detect_threshold 0 --latent_warmup_steps 150"
41
+ "bt_rr03_adapt|--backtrack_enable --remember_rate 0.3 --backtrack_detect_threshold 0.95 --latent_warmup_steps 150"
42
+ "bt_rr05_adapt|--backtrack_enable --remember_rate 0.5 --backtrack_detect_threshold 0.97 --latent_warmup_steps 150"
43
+ "bt_rr03_nowarm|--backtrack_enable --remember_rate 0.3 --backtrack_detect_threshold 0.95 --latent_warmup_steps 0"
44
+ "bt_rr02_adapt|--backtrack_enable --remember_rate 0.2 --backtrack_detect_threshold 0.97 --latent_warmup_steps 150"
45
+ )
46
+
47
+ launch() {
48
+ local gpu="$1" name="$2" extra="$3"
49
+ local out="${ROOT}/${name}"
50
+ local log="${ROOT}/logs/${name}.log"
51
+ mkdir -p "${out}"
52
+ echo "[gpu ${gpu}] ${name} :: ${extra}"
53
+ CUDA_VISIBLE_DEVICES="${gpu}" nohup "${PY}" "${SCRIPT}" "${COMMON[@]}" \
54
+ --output_dir "${out}" --wandb_mode disabled ${extra} > "${log}" 2>&1 &
55
+ echo "$!" > "${ROOT}/logs/${name}.pid"
56
+ }
57
+
58
+ # Launch combo 0 first and wait for the shared stage-2 data cache + pools to be
59
+ # built, so the other 7 jobs hit a warm cache (no concurrent .tmp write race).
60
+ IFS='|' read -r name0 extra0 <<< "${COMBOS[0]}"
61
+ launch 0 "${name0}" "${extra0}"
62
+ echo "Waiting for stage-2 data cache to build (combo 0)..."
63
+ for _ in $(seq 1 120); do
64
+ if grep -q "latent sft train step 00001" "${ROOT}/logs/${name0}.log" 2>/dev/null; then
65
+ echo "Cache warm; launching remaining combos."
66
+ break
67
+ fi
68
+ sleep 5
69
+ done
70
+
71
+ for i in $(seq 1 7); do
72
+ IFS='|' read -r name extra <<< "${COMBOS[$i]}"
73
+ launch "${i}" "${name}" "${extra}"
74
+ sleep 1
75
+ done
76
+
77
+ echo "All combos launched under ${ROOT}"
78
+ echo "${ROOT}" > /home/ubuntu/bt_runs/LATEST_S2_SWEEP