unparallelled commited on
Commit
b3b21cc
·
verified ·
1 Parent(s): d067a93

Upload scripts/finish2_mix64k.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/finish2_mix64k.sh +138 -0
scripts/finish2_mix64k.sh ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # Corrected finisher. The driver (mix64k_h200.sh) cannot run the evals:
4
+ # run_seg 695 waits for a checkpoint at step 695, but CP_CKPT_FREQ=100 means
5
+ # none can exist (695 % 100 = 95). So its watcher never fired, training ran
6
+ # straight to CP_MAX_STEPS=1300, and the driver will die at
7
+ # "step 695 checkpoint missing". The training itself is CORRECT and complete --
8
+ # only the eval orchestration is lost.
9
+ #
10
+ # This runs the evals itself off the janitor-preserved keep_step_*.ckpt, which
11
+ # exist at every multiple of 100 precisely because the janitor copies rank_0
12
+ # before CP_CKPT_KEEP can prune it. Eval loads rank_0 only (NP=1), so that is
13
+ # all it needs.
14
+ #
15
+ # 1. wait for the trainer to exit (eval needs the GPUs)
16
+ # 2. eval step 1200 at 4 lengths, one GPU each
17
+ # 3. plot+upload as 32,744 lands, again when 65,512 lands
18
+ # 4. cliff verdict; if CLIFF, also eval the last pre-cliff checkpoint
19
+ # 5. upload everything byte-verified, print a teardown verdict
20
+ # =============================================================================
21
+ set -uo pipefail
22
+ cd "$(dirname "$0")"
23
+ source /root/Adhi/BluTrain/envv/bin/activate
24
+ export LD_LIBRARY_PATH="/root/Adhi/BluTrain/Tensor-Implementations/lib:/root/Adhi/BluTrain/Profiler/lib:${LD_LIBRARY_PATH:-}"
25
+ PY=python; HF=hf
26
+ REPO=unparallelled/BluScriptCP
27
+ LOG=mix64k_logs; CK=checkpoints_bluscriptcp/rank_0
28
+ T=65536; ORIG=32768; SCALE=2
29
+ DATA=Data_Loader/Data/mix50
30
+ HAY="$PWD/Data_Loader/Data/b2_8192_16384/val_shard_00000.bin"
31
+ F="$LOG/finish.log"; : > "$F"
32
+ say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$F" >&2; }
33
+
34
+ up(){ local src=$1 dst=$2
35
+ [ -e "$src" ] || { say " MISSING (not uploaded): $src"; return 1; }
36
+ $HF upload "$REPO" "$src" "$dst" >>"$LOG/upload.log" 2>&1 || { say " UPLOAD FAILED $dst"; return 1; }
37
+ if [ -f "$src" ]; then
38
+ $PY - "$REPO" "$src" "$dst" <<'PYEOF' | tee -a "$F"
39
+ import sys, os
40
+ from huggingface_hub import HfApi
41
+ repo, loc, rem = sys.argv[1], sys.argv[2], sys.argv[3]
42
+ want=os.path.getsize(loc)
43
+ got={f.rfilename:(f.size or 0) for f in HfApi().repo_info(repo,files_metadata=True).siblings}.get(rem)
44
+ print((" VERIFIED " if got==want else " *** MISMATCH/ABSENT ")+f"{rem} local={want:,} remote={got}")
45
+ sys.exit(0 if got==want else 1)
46
+ PYEOF
47
+ else say " sent (dir) $dst"; fi
48
+ }
49
+
50
+ plot(){ $PY mk_mix64k_plots.py --tag "$1" --out mix64k_results >>"$F" 2>&1 \
51
+ && say " plotted mix64k_results_$1.{png,html}" || say " PLOT FAILED ($1)"; }
52
+
53
+ run_eval(){ # $1 = tag $2 = ckpt basename in rank_0
54
+ local TAG=$1 CKF=$2
55
+ [ -f "$CK/$CKF" ] || { say "eval $TAG: $CKF absent, SKIP"; return 1; }
56
+ say "EVAL $TAG from $CKF -- 4 lengths, one GPU each"
57
+ for LEN in 8192 16360 32744 65512; do
58
+ ( GEN_DATA_ROOT=$DATA HAY="$HAY" PY=$PY OUT=mix64k_${TAG}_len_$LEN TASKS="niah_single" \
59
+ CKPTS="m$TAG" N=100 PROMPT_LEN=$LEN MAX_NEW=24 T=$T \
60
+ DEPTHS="0.0,0.25,0.5,0.75,1.0" YARN_ORIG=$ORIG YARN=$SCALE \
61
+ GPUS=$(( (LEN==8192)?0:(LEN==16360)?1:(LEN==32744)?2:3 )) JOBS_PER_GPU=1 \
62
+ BF16=1 GREEDY=1 CKPT_EXTRA="m$TAG=$CKF" ./run_longeval.sh \
63
+ >> "$LOG/eval_${TAG}_$LEN.log" 2>&1 ) &
64
+ done
65
+ # plot as soon as 32,744 scores, without waiting for the slow 65,512 job
66
+ ( for i in $(seq 1 400); do
67
+ [ -s "mix64k_${TAG}_len_32744/summary.csv" ] && break; sleep 20; done
68
+ for L in 8192 16360 32744; do
69
+ v=$(sed -n 2p "mix64k_${TAG}_len_$L/summary.csv" 2>/dev/null); say " $TAG len $L -> ${v:-pending}"; done
70
+ plot "$TAG"
71
+ up "mix64k_results_${TAG}.png" "plots/mix64k_results_${TAG}.png"
72
+ up "mix64k_results_${TAG}.html" "plots/mix64k_results_${TAG}.html"
73
+ say " EARLY PLOT for $TAG is on HF (8k/16k/32k)" ) &
74
+ wait
75
+ for LEN in 8192 16360 32744 65512; do
76
+ v=$(sed -n 2p "mix64k_${TAG}_len_$LEN/summary.csv" 2>/dev/null)
77
+ say " FINAL $TAG len $LEN -> ${v:-NO RESULT}"
78
+ done
79
+ plot "$TAG"
80
+ up "mix64k_results_${TAG}.png" "plots/mix64k_results_${TAG}.png"
81
+ up "mix64k_results_${TAG}.html" "plots/mix64k_results_${TAG}.html"
82
+ }
83
+
84
+ say "=== corrected finisher armed ==="
85
+ say "waiting for the trainer to exit (it runs to step 1300, then frees the GPUs)"
86
+ for i in $(seq 1 900); do
87
+ pgrep -f 'build/bluscriptCP_exe[c]' >/dev/null || break
88
+ sleep 20
89
+ done
90
+ sleep 20
91
+ say "trainer exited; last step: $(grep -aE '^step +[0-9]+' "$LOG/train.log" | tail -1 | grep -oE '^step +[0-9]+')"
92
+ say "preserved checkpoints: $(ls $CK/keep_step_*.ckpt 2>/dev/null | wc -l)"
93
+
94
+ # ---- FINAL checkpoint first. Eval 1200 only if the final looks BAD. --------
95
+ FIN=$(ls $CK/keep_step_*.ckpt 2>/dev/null | sed -E 's/.*keep_step_([0-9]+)\.ckpt/\1/' | sort -n | tail -1)
96
+ [ -n "$FIN" ] || { say "no preserved checkpoint to evaluate"; FIN=""; }
97
+ if [ -n "$FIN" ]; then
98
+ say "=== evaluating the FINAL checkpoint, step $FIN ==="
99
+ run_eval "$FIN" "keep_step_${FIN}.ckpt"
100
+ say "--- verdict for step $FIN against the parent (67/65/52/29) ---"
101
+ $PY /root/verdict.py "$FIN" 2>&1 | tee -a "$F"
102
+ VER=$($PY /root/verdict.py "$FIN" 2>/dev/null | grep -oE '^VERDICT [A-Z]+' | awk '{print $2}')
103
+ say "verdict: ${VER:-UNKNOWN}"
104
+ if [ "$VER" = "BAD" ] || [ "$VER" = "UNKNOWN" ]; then
105
+ say "=== final is ${VER} -- evaluating step 1200 to bracket where it turned ==="
106
+ [ -f "$CK/keep_step_1200.ckpt" ] && run_eval 1200 keep_step_1200.ckpt \
107
+ || say " keep_step_1200.ckpt absent"
108
+ else
109
+ say "=== final is GOOD -- skipping the 1200 eval (saves ~38 min of GPU) ==="
110
+ fi
111
+ fi
112
+
113
+ read -r V O B C <<<"$($PY /root/cliff.py "$LOG/train.log")"
114
+ say "cliff detector on the MIX run: $V (onset=$O baseline=$B current=$C)"
115
+ say " for contrast, 100% b5 from the SAME parent: CLIFF at step 1199, ended 45/17/2/1"
116
+ if [ "$V" = "CLIFF" ]; then
117
+ PRE=$(( ((O - 49) / 100) * 100 ))
118
+ say "cliff at $O -- also evaluating the pre-cliff checkpoint at $PRE"
119
+ [ -f "$CK/keep_step_${PRE}.ckpt" ] && run_eval "pre${PRE}" "keep_step_${PRE}.ckpt"
120
+ fi
121
+
122
+ say "=== uploading everything ==="
123
+ for d in mix64k_*_len_*; do [ -d "$d" ] && up "$d" "logs/$d/"; done
124
+ up "$LOG/master.log" "logs/mix64k/master.log"
125
+ up "$LOG/train.log" "logs/mix64k/train.log"
126
+ up "$LOG/probe.log" "logs/mix64k/probe.log"
127
+ up "$F" "logs/mix64k/finish.log"
128
+ for f in mix64k_h200.sh finish2_mix64k.sh mk_mix64k_plots.py mix_buckets.py; do up "$f" "scripts/$f"; done
129
+ up "$DATA/MANIFEST.txt" "docs/mix50_MANIFEST.txt"
130
+ say "=== uploading model checkpoints (rank_0; eval and CP_INIT_FROM need only this) ==="
131
+ for k in $CK/keep_step_*.ckpt; do
132
+ [ -e "$k" ] || continue
133
+ s=$(basename "$k" | grep -oE '[0-9]+')
134
+ up "$k" "checkpoints/mix64k_step_${s}.ckpt"
135
+ done
136
+ BAD=$(grep -c 'MISMATCH/ABSENT\|UPLOAD FAILED\|MISSING (not uploaded)' "$F" 2>/dev/null || echo 0)
137
+ [ "$BAD" -eq 0 ] && say "=== ALL UPLOADS VERIFIED -- safe to tear down ===" \
138
+ || say "=== $BAD UPLOAD PROBLEM(S) -- DO NOT TEAR DOWN ==="