unparallelled commited on
Commit
feb336c
·
verified ·
1 Parent(s): 24756f0

Upload scripts/eval_at_2000.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/eval_at_2000.sh +95 -0
scripts/eval_at_2000.sh ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # eval_at_1000.sh -- capture the long b3 arm at step 1000 and score it.
4
+ #
5
+ # WHY A WATCHER AND NOT A TIMER: CP_CKPT_KEEP=2 with CP_CKPT_FREQ=25 means a
6
+ # checkpoint is pruned ~50 steps (~10 min) after it is written. The step-1000
7
+ # files must be secured the instant they appear on BOTH ranks, or they are gone.
8
+ #
9
+ # ORDER MATTERS: kill the trainer FIRST (stopping further saves, hence further
10
+ # pruning), then copy aside. Copying while the trainer runs risks reading a file
11
+ # that the pruner deletes mid-copy.
12
+ #
13
+ # EVAL REUSES decide_len_* ON PURPOSE. run_longeval.sh's prompt signature covers
14
+ # N/length/depths/seed/haystack but NOT the model set, so armA_c/l1/l2/l3 are
15
+ # already .done there and get skipped -- only l3long's 3 cells actually run.
16
+ # 15 min instead of 40. Directly comparable to the decision table.
17
+ #
18
+ # CAVEAT ON THE NUMBER THIS PRODUCES: step 1000 sits in the FLAT LR region
19
+ # (constant 3.0e-4 until step 3899). WSD's decay is where much of the loss drop
20
+ # lands, so this checkpoint UNDERSTATES what the same data/steps would give after
21
+ # a decay. It is a valid step-1000-vs-step-400 comparison (both undecayed at
22
+ # eval? no -- l3@400 WAS decayed, its 400-step cosine ran to completion). So
23
+ # l3long@1000 is undecayed and l3@400 is decayed: this comparison is BIASED
24
+ # AGAINST l3long. If it wins anyway, that is robust. If it loses, run the short
25
+ # decay before believing it: STEPS=1100 STABLE=900 ./b3_long_run.sh resume 17
26
+ # =============================================================================
27
+ set -uo pipefail
28
+ cd "$(dirname "$0")"
29
+ ROOT="$(cd ../.. && pwd)"
30
+ export LD_LIBRARY_PATH="$ROOT/Tensor-Implementations/lib:$ROOT/Profiler/lib:${LD_LIBRARY_PATH:-}"
31
+ export OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
32
+ PY=/root/Adhi/BluTrain/envv/bin/python
33
+ CK=checkpoints_bluscriptcp/rank_0
34
+ LOG=eval2000_logs; mkdir -p "$LOG"
35
+ M="$LOG/master.log"
36
+ say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M" >&2; }
37
+
38
+ RN=$(cat b3long_logs/runnum)
39
+ TARGET=${TARGET:-2000}
40
+ NAME="blumodelcp_run${RN}_step_${TARGET}.ckpt"
41
+ say "watching for $NAME on both ranks (run $RN, target step $TARGET)"
42
+
43
+ for i in $(seq 1 2400); do # up to 20 h, 30 s poll
44
+ n=$(ls checkpoints_bluscriptcp/rank_*/"$NAME" 2>/dev/null | wc -l)
45
+ [ "$n" -ge 2 ] && break
46
+ sleep 30
47
+ done
48
+ n=$(ls checkpoints_bluscriptcp/rank_*/"$NAME" 2>/dev/null | wc -l)
49
+ [ "$n" -ge 2 ] || { say "FATAL: $NAME never appeared on 2 ranks"; exit 1; }
50
+ say "step $TARGET present on $n ranks -- stopping trainer NOW to halt pruning"
51
+
52
+ for p in $(pgrep -f 'b3_long_run\.sh'); do kill "$p" 2>/dev/null; done
53
+ sleep 2
54
+ for p in $(pgrep -f 'mpirun.*bluscriptCP_exec') $(pgrep -f 'build/bluscriptCP_exec'); do kill "$p" 2>/dev/null; done
55
+ sleep 10
56
+ say "trainer stopped at step $(grep -acE '^step +[0-9]+ \|' b3long_logs/l3long.log)"
57
+
58
+ # preserve under a name the pruner will never touch (different run prefix)
59
+ SAFE="l3long2000_${NAME}"
60
+ for r in 0 1; do
61
+ [ -f "checkpoints_bluscriptcp/rank_$r/$SAFE" ] && continue
62
+ cp "checkpoints_bluscriptcp/rank_$r/$NAME" "checkpoints_bluscriptcp/rank_$r/$SAFE"
63
+ done
64
+ say "preserved as $SAFE ($(ls checkpoints_bluscriptcp/rank_*/$SAFE | wc -l) ranks, $(du -ch checkpoints_bluscriptcp/rank_*/$SAFE | tail -1 | cut -f1))"
65
+
66
+ EXTRA="armA_c=blumodelcp_run28_step_400.ckpt \
67
+ l1=lenbucket_l1_blumodelcp_run1_step_400.ckpt \
68
+ l2=lenbucket_l2_blumodelcp_run2_step_400.ckpt \
69
+ l3=blumodelcp_run1_step_400.ckpt \
70
+ l3long=l3long1000_blumodelcp_run17_step_1000.ckpt \
71
+ l3long2k=$SAFE"
72
+ MODELS="armA_c l1 l2 l3 l3long l3long2k"
73
+ say "eval models: $MODELS (only l3long's cells are new)"
74
+
75
+ for LEN in 4096 8192 16360; do
76
+ say "PROMPT_LEN=$LEN"
77
+ GEN_DATA_ROOT=lendata/b3_16384_32768 \
78
+ HAY="$PWD/lendata/haystack/b2val_haystack.bin" \
79
+ PY=$PY OUT=decide_len_$LEN TASKS="niah_single" CKPTS="$MODELS" N=100 \
80
+ PROMPT_LEN=$LEN MAX_NEW=24 T=16384 DEPTHS="0.0,0.25,0.5,0.75,1.0" \
81
+ YARN_ORIG=4096 GPUS=0,1 JOBS_PER_GPU=2 BF16=1 GREEDY=1 \
82
+ CKPT_EXTRA="$EXTRA" ./run_longeval.sh >> "$LOG/eval_$LEN.log" 2>&1 \
83
+ || say " WARN nonzero at $LEN"
84
+ say " -> $(sed -n 1p decide_len_$LEN/summary.csv) / $(sed -n 2p decide_len_$LEN/summary.csv)"
85
+ done
86
+ say "=== EVAL@1000 DONE ==="
87
+
88
+ # ---- CONTINUE the run from where it stopped -------------------------------
89
+ # resume mode pins CP_REWARMUP_ANCHOR=0, so the flat 3.0e-4 continues instead of
90
+ # a fresh 100-step warmup ramp re-anchoring at step 1000 (bluscriptCP.cpp:2105).
91
+ say "resuming run $RN to step 4000"
92
+ setsid nohup ./b3_long_run.sh resume "$RN" >> b3long_boot.out 2>&1 < /dev/null &
93
+ sleep 90
94
+ say "resumed: step $(grep -acE '^step +[0-9]+ \|' b3long_logs/l3long.log) logged, $(pgrep -c -f 'build/bluscriptCP_exec') trainer proc(s)"
95
+ say "LR after resume: $(grep -aE '^step ' b3long_logs/l3long.log | tail -1 | grep -oE 'lr [0-9.e-]+') (expect flat 1.8000e-04 = CP_REWARMUP_PEAK 0.3 x max_lr 6e-4; NOT ramping)"