File size: 2,303 Bytes
bc7101b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# MATH dataset experiment. Resumes from GRPO ckpt, fine-tunes on MATH, runs
# capacity_diagnostic + TF + AR ablations on the final ckpt, pushes to HF.
set -uo pipefail

REPO="LauraGG/blt-reasoner-pilot1"
OUT="/home/ubuntu/work/blt_math"
CFG="/home/ubuntu/experiments/blt_reasoner/configs/exp7b_math.json"
RESUME_FROM="/home/ubuntu/work/blt_grpo_opt13/final"
LOG="/home/ubuntu/work/queue_math.log"

log() { echo "[$(date +%T)] $*" | tee -a "$LOG"; }

mkdir -p "$OUT"
cd /home/ubuntu
export TOKENIZERS_PARALLELISM=false TRANSFORMERS_NO_ADVISORY_WARNINGS=1 HF_HUB_DISABLE_PROGRESS_BARS=1
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

log "==========================================="
log "MATH fine-tune from $RESUME_FROM (GSM8K-trained baseline)"
log "==========================================="
python3 -u -m experiments.blt_reasoner.train --config "$CFG" \
    --resume_from "$RESUME_FROM" \
    > "$OUT/train.log" 2>&1
log "train exit=$?"

log "Capacity diagnostic on math final"
python3 -u -m experiments.blt_reasoner.scripts.capacity_diagnostic \
    --ckpt "$OUT/final" --config "$CFG" --n 100 --K 16 --max_new_tokens 192 \
    --out "$OUT/final/capacity_diagnostic.json" \
    > "$OUT/capacity.log" 2>&1
log "capacity diag exit=$?"

log "TF ablation (MATH-aware)"
python3 -u -m experiments.blt_reasoner.scripts.ablate_teacher_forced \
    --ckpt "$OUT/final" --config "$CFG" --n 200 --K 16 \
    --out "$OUT/final/ablation_teacher_forced.json" \
    > "$OUT/tf_eval.log" 2>&1
log "TF ablate exit=$?"

log "AR ablation (MATH boxed-answer parsing)"
python3 -u -m experiments.blt_reasoner.eval \
    --ckpt "$OUT/final" --config "$CFG" --n 200 --K 16 \
    --max_new_tokens 256 --temperature 0.0 \
    --out "$OUT/final/ablation_n200_K16.json" \
    > "$OUT/ar_eval.log" 2>&1
log "AR ablate exit=$?"

log "pushing math_exp/ to HF"
python3 - <<PYEND
import os
from huggingface_hub import HfApi
token = os.environ.get("BLT_HF_TOKEN", "").strip()
assert token.startswith("hf_"), "BLT_HF_TOKEN missing"
api = HfApi(token=token)
api.upload_folder(folder_path="$OUT", path_in_repo="math_exp",
                   repo_id="$REPO", repo_type="model",
                   commit_message="MATH dataset fine-tune from GRPO ckpt")
print("[push] done")
PYEND
log "queue_math.sh DONE"