File size: 3,520 Bytes
6071ec5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# E4 = light continuation of E3 on data/e4 (31% new in-domain/targeted data, 69% replay of s3), lr 1e-5 linear decay to 0.
# Starts when the central-protocol run of base/E3 has finished; then the same evals as E3, plus the central protocol for E4.
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 GSM_MAX=200
log() { echo "$(date -u +%FT%TZ) $*" | tee -a logs/e4_pipeline.log; }
until grep -q CENTRAL_DONE logs/e3_pipeline.log; do sleep 20; done
log "E4 train from E3"
torchrun --nproc_per_node 8 train.py --ckpt runs/e3/sft_step1605.pt --data data/e4 --out runs/e4 --lr 1e-5 --epochs 1 --mb-tokens 8192 --accum 4 \
  --act-ckpt --schedule wsd --decay-frac 0.95 --min-lr-ratio 0.0 --warmup 0.05 --eval-every 100 --save-every 0 > logs/e4_train.log 2>&1 || { log "train failed"; exit 1; }
E4=$(ls -t runs/e4/sft_step*.pt | head -1)
log "trained $E4"
mkdir -p /workspace/pkg/e4_release
python - "$E4" /workspace/pkg/e4_release <<'PY'
import json, shutil, sys, torch
from safetensors.torch import save_file
st = torch.load(sys.argv[1], map_location="cpu", weights_only=True)
save_file({k: v.float().contiguous() for k, v in st["model"].items() if k != "head.weight"}, f"{sys.argv[2]}/model.safetensors")
json.dump(st["config"], open(f"{sys.argv[2]}/config.json", "w"))
shutil.copy("/workspace/ckpt/tokenizer.json", f"{sys.argv[2]}/tokenizer.json")
PY
crun() { # gpu tasks
  ( cd /workspace/benchrepo/research && CUDA_VISIBLE_DEVICES=$1 .venv-eval/bin/python common/ewaluuj.py --model slayer --repo local/e4 --revision none \
    --model_path /workspace/pkg/e4_release --device cuda --batch 1 --dtype float32 --probka pelna --zadania $2 \
    --wyjscie /workspace/slayer1b/results/central/e4_g$1 --etykieta e4 > /workspace/slayer1b/logs/central_e4_g$1.log 2>&1 )
}
# phase A: agent 0/1 evals on GPUs 0-3, central protocol (without BLiMP) on 4-7
( for r in 0 1 2 3; do CUDA_VISIBLE_DEVICES=$r python evals.py --ckpt "$E4" --data data/s2_toolcall --tokenizer "$SLAYER_TOKENIZER" --rank $r --world 4 \
    --out results/e4_agent.r$r.json & done; wait ) &
crun 4 T05,T44 &
crun 5 T45,T51,T19,T46,T14 &
crun 6 T02,T06,T17 &
crun 7 T04,T07,T03 &
wait
log "phase A done"
# phase B: CodeSOTA panel200 log-likelihood on 0-3, GSM chat on 4-5, probes + settings on 6-7
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:]))))")
for i in 0 1 2 3; do
  z=$(python3 -c "import sys; ids=sys.argv[2:]; print(','.join(ids[int(sys.argv[1])::4]))" $i $ALL)
  ZAD="$z" timeout 2400 bash bench_suite.sh "$E4" "full_e4_p$i" $i > logs/benchfull_full_e4_p$i.log 2>&1 &
done
for r in 0 1; do CUDA_VISIBLE_DEVICES=$((4+r)) python gsm_chat_eval.py run "$E4" --rank $r --world 2 --out results/gsm/e4 > logs/gsm_e4_r$r.log 2>&1 & done
CUDA_VISIBLE_DEVICES=6 python probe_suite.py "$E4" r4_t0 --temp 0 > logs/probe_r4_t0.log 2>&1 &
CUDA_VISIBLE_DEVICES=7 python gen_settings.py "$E4" e4 --settings B_greedy_rep1.1,C_t0.3_p0.9_rep1.1 > logs/settings_e4.log 2>&1 &
wait
log "E4_PIPELINE_DONE (stop the instance to stop billing)"