#!/usr/bin/env bash # E3 restart after the DDP OOM at mb 6144 without activation checkpointing: same data (data/s3) and schedule; # mb 4096 x accum 9 (same tokens per optimizer step) without checkpointing, fallback to checkpointing at mb 8192 x accum 4. # Then: E3 agent evals, E3 CodeSOTA (log-likelihood tasks) on 4 GPUs + GSM chat + probes, then base / E2 CodeSOTA and E1 / E2 GSM. set -uo pipefail cd /workspace/slayer1b source /venv/main/bin/activate export SLAYER_TRAINER=/workspace/ckpt/train_gpt_ref_r24_2.py SLAYER_TOKENIZER=/workspace/ckpt/tokenizer.json PYTORCH_ALLOC_CONF=expandable_segments:True export GSM_MAX=200 log() { echo "$(date -u +%FT%TZ) $*" | tee -a logs/e3_pipeline.log; } ALL=$(/workspace/benchrepo/research/.venv-eval/bin/python -c " import sys; sys.path.insert(0,'/workspace/benchrepo/research/common'); import zadania as Z ids=set() for v in vars(Z).values(): if isinstance(v, dict): ids |= {k for k, t in v.items() if isinstance(t, dict) and t.get('repo') and k[:1]=='T' and k[1:].isdigit()} print(' '.join(sorted(ids, key=lambda k:int(k[1:]))))") bench_spread() { # $1 ckpt, $2 label, $3.. gpus (bench_suite.sh drops the generative tasks) local ck=$1 lab=$2; shift 2 local gpus=("$@") n=$# i for i in $(seq 0 $((n-1))); do z=$(python3 -c "import sys; ids=sys.argv[3:]; print(','.join(ids[int(sys.argv[1])::int(sys.argv[2])]))" $i $n $ALL) ZAD="$z" timeout 2400 bash bench_suite.sh "$ck" "${lab}_p$i" "${gpus[$i]}" > "logs/benchfull_${lab}_p$i.log" 2>&1 & done wait } gsm() { # $1 ckpt, $2 label, $3 first gpu, $4 n gpus for r in $(seq 0 $(($4-1))); do CUDA_VISIBLE_DEVICES=$(($3+r)) python gsm_chat_eval.py run "$1" --rank $r --world $4 --out results/gsm/$2 > logs/gsm_$2_r$r.log 2>&1 & done; wait } train() { # $1 mb, $2 accum, $3 ckpt flag torchrun --nproc_per_node 8 train.py --ckpt /workspace/ckpt/wagi_95000.pt --ckpt-sha256 ad675d0cd61b2291b4cfbfd93c8a5d28217a12498fef7c7f997728911ddb952b \ --data data/s3 --out runs/e3 --lr 5e-5 --epochs 1 --mb-tokens "$1" --accum "$2" $3 --schedule wsd --decay-frac 0.25 \ --min-lr-ratio 0.0 --warmup 0.02 --eval-every 300 --save-every 0 --save-before-decay > logs/e3_train.log 2>&1 } log "E3 train: mb 4096 x 9, no activation checkpointing" if ! train 4096 9 --no-act-ckpt; then grep -q OutOfMemoryError logs/e3_train.log || { log "train failed (not OOM)"; exit 1; } mv logs/e3_train.log logs/e3_train_oom4096.log log "OOM again -> fallback: activation checkpointing, mb 8192 x 4" train 8192 4 --act-ckpt || { log "train failed"; exit 1; } fi E3=$(ls -t runs/e3/sft_step*.pt | head -1) log "trained $E3" DATA=data/s2_toolcall bash vast_run.sh eval "$E3" > logs/e3_eval.log 2>&1 log "E3 agent evals done" bench_spread "$E3" full_e3 0 1 2 3 & gsm "$E3" e3 4 2 & ( CUDA_VISIBLE_DEVICES=6 python probe_suite.py "$E3" r3_t0 --temp 0 > logs/probe_r3_t0.log 2>&1 ) & ( CUDA_VISIBLE_DEVICES=7 python probe_suite.py "$E3" r3_t0.7 --temp 0.7 > logs/probe_r3_t0.7.log 2>&1 ) & wait log "E3 bench/gsm/probes done" bench_spread /workspace/ckpt/wagi_95000.pt full_base 0 1 2 & bench_spread runs/e2/sft_step601.pt full_e2 3 4 5 & gsm runs/e1/sft_step592.pt e1 6 1 & gsm runs/e2/sft_step601.pt e2 7 1 & wait log "E3_PIPELINE_DONE (stop the instance to stop billing)"