Upload scripts/p1_finish.sh with huggingface_hub
Browse files- scripts/p1_finish.sh +140 -0
scripts/p1_finish.sh
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# =============================================================================
|
| 3 |
+
# End-of-session: wait for phase 1 -> NIAH eval -> upload everything -> verdict.
|
| 4 |
+
# Leaves the box ready for teardown. Does NOT start phase 2.
|
| 5 |
+
#
|
| 6 |
+
# EVAL DESIGN
|
| 7 |
+
# task/N/haystack are IDENTICAL to the prior 1.06B evals (niah_single, N=100,
|
| 8 |
+
# b2 val_shard_00000) so the numbers sit on the same axis as 83/70/50/31.
|
| 9 |
+
# Two prompt lengths only -- 8192 and 16360. The phase-1 model has a 16k
|
| 10 |
+
# window, so 32744/65512 would measure a window it was never trained for.
|
| 11 |
+
# base680 (varybatch, un-extended) runs the same eval as the "before": it
|
| 12 |
+
# shows what the extension bought vs zero-shot YaRN.
|
| 13 |
+
# =============================================================================
|
| 14 |
+
set -uo pipefail
|
| 15 |
+
cd "$(dirname "$0")"
|
| 16 |
+
export PATH=/root/Adhi/BluTrain/envv/bin:$PATH
|
| 17 |
+
source /root/Adhi/BluTrain/envv/bin/activate 2>/dev/null
|
| 18 |
+
REPO=unparallelled/BluScriptCP
|
| 19 |
+
L=p1_logs; M="$L/finish.log"
|
| 20 |
+
say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M" >&2; }
|
| 21 |
+
|
| 22 |
+
# ---- 1. wait for training ---------------------------------------------------
|
| 23 |
+
say "waiting for phase 1 to finish..."
|
| 24 |
+
while ! grep -qa 'PHASE 1 TRAINING COMPLETE\|FATAL' "$L/master.log" 2>/dev/null; do
|
| 25 |
+
pgrep -f bluscriptCP_exec >/dev/null 2>&1 || { sleep 20
|
| 26 |
+
grep -qa 'PHASE 1 TRAINING COMPLETE\|FATAL' "$L/master.log" 2>/dev/null || {
|
| 27 |
+
say "trainer gone without COMPLETE -- aborting eval"; exit 1; }; }
|
| 28 |
+
sleep 30
|
| 29 |
+
done
|
| 30 |
+
grep -qa FATAL "$L/master.log" && { say "phase 1 FAILED -- no eval"; exit 1; }
|
| 31 |
+
say "phase 1 complete: $(grep -a 'training done' "$L/master.log" | tail -1)"
|
| 32 |
+
|
| 33 |
+
RN=$(cat "$L/runnum")
|
| 34 |
+
FINAL=$(ls -t checkpoints_bluscriptcp/rank_0/blumodelcp_run${RN}_step_*.ckpt | head -1)
|
| 35 |
+
FSTEP=$(basename "$FINAL" | grep -oE 'step_[0-9]+' | cut -d_ -f2)
|
| 36 |
+
say "final checkpoint: $(basename "$FINAL") ($(stat -c%s "$FINAL") bytes)"
|
| 37 |
+
|
| 38 |
+
# ---- 2. eval ----------------------------------------------------------------
|
| 39 |
+
A1B_680="CP_N_EMBD=1536 CP_N_LAYER=24 CP_N_HEAD=12 CP_N_KVHEAD=4 CP_FFN=4096 CP_WEIGHT_TYING=1"
|
| 40 |
+
HAYSTACK="Data_Loader/Data/b2_8192_16384/val_shard_00000.bin"
|
| 41 |
+
[ -f "$HAYSTACK" ] || { say "FATAL: haystack missing"; exit 1; }
|
| 42 |
+
for PL in 8192 16360; do
|
| 43 |
+
O="p1_eval_len${PL}"
|
| 44 |
+
[ -f "$O/state/DONE" ] && { say "len $PL already done"; continue; }
|
| 45 |
+
say "eval prompt_len=$PL (p1final @step $FSTEP + base680 baseline), 2 GPUs"
|
| 46 |
+
A1B="$A1B_680" HAY="$HAYSTACK" \
|
| 47 |
+
CKPT_EXTRA="p1final=$(basename "$FINAL") base680=varybatch.ckpt" \
|
| 48 |
+
CKPTS="p1final base680" TASKS=niah_single N=100 \
|
| 49 |
+
T=16384 YARN=4 YARN_ORIG=4096 PROMPT_LEN=$PL \
|
| 50 |
+
GPUS=0,1 NP=1 OUT="$O" \
|
| 51 |
+
./run_longeval.sh >> "$L/eval_${PL}.log" 2>&1
|
| 52 |
+
if [ -s "$O/summary.csv" ]; then mkdir -p "$O/state"; touch "$O/state/DONE"
|
| 53 |
+
say " len $PL OK"; else say " len $PL PRODUCED NO SUMMARY -- see $L/eval_${PL}.log"; fi
|
| 54 |
+
done
|
| 55 |
+
|
| 56 |
+
# ---- 3. results -------------------------------------------------------------
|
| 57 |
+
say "=== PHASE 1 RESULTS (niah_single, N=100, same haystack as the 1.06B runs) ==="
|
| 58 |
+
python - <<'PY' 2>&1 | tee -a "$M"
|
| 59 |
+
import csv,os
|
| 60 |
+
for pl in (8192,16360):
|
| 61 |
+
f=f"p1_eval_len{pl}/summary.csv"
|
| 62 |
+
if not os.path.exists(f): print(f" len {pl}: NO RESULT"); continue
|
| 63 |
+
for r in csv.DictReader(open(f)):
|
| 64 |
+
k={x.lower():y for x,y in r.items()}
|
| 65 |
+
print(f" len {pl:5d} {r}")
|
| 66 |
+
PY
|
| 67 |
+
grep -ahA7 '=== niah_single' "$L"/eval_*.log 2>/dev/null | grep -aE 'accuracy|===' | tail -8 | tee -a "$M"
|
| 68 |
+
|
| 69 |
+
# ---- 4. upload everything, VERIFY every byte --------------------------------
|
| 70 |
+
up(){ [ -f "$1" ] || { say " MISSING $1"; return 1; }
|
| 71 |
+
hf upload "$REPO" "$1" "$2" >>"$L/upload.log" 2>&1
|
| 72 |
+
python - "$REPO" "$1" "$2" <<'PY'
|
| 73 |
+
import sys,os
|
| 74 |
+
from huggingface_hub import HfApi
|
| 75 |
+
w=os.path.getsize(sys.argv[2])
|
| 76 |
+
g={f.rfilename:(f.size or 0) for f in HfApi().repo_info(sys.argv[1],files_metadata=True).siblings}.get(sys.argv[3])
|
| 77 |
+
ok=(g==w); print((" VERIFIED " if ok else " *** FAILED ")+f"{sys.argv[3]} local={w:,} remote={g}")
|
| 78 |
+
sys.exit(0 if ok else 1)
|
| 79 |
+
PY
|
| 80 |
+
}
|
| 81 |
+
verify_remote(){ # local remote -- confirm HF reports the same byte size
|
| 82 |
+
python - "$REPO" "$1" "$2" <<'VEOF'
|
| 83 |
+
import sys,os
|
| 84 |
+
from huggingface_hub import HfApi
|
| 85 |
+
w=os.path.getsize(sys.argv[2])
|
| 86 |
+
g={f.rfilename:(f.size or 0) for f in HfApi().repo_info(sys.argv[1],files_metadata=True).siblings}.get(sys.argv[3])
|
| 87 |
+
ok=(g==w); print((" VERIFIED " if ok else " *** FAILED ")+f"{sys.argv[3]} local={w:,} remote={g}")
|
| 88 |
+
sys.exit(0 if ok else 1)
|
| 89 |
+
VEOF
|
| 90 |
+
}
|
| 91 |
+
say "=== uploading ==="
|
| 92 |
+
BAD=0
|
| 93 |
+
for f in p1_680m.sh p2_680m.sh p1_shipper.sh p1_finish.sh dl_p23.sh run_longeval.sh \
|
| 94 |
+
mix_buckets.py HANDOFF_H200_32K.md; do up "$f" "scripts/$f" || BAD=$((BAD+1)); done
|
| 95 |
+
up Scripts/Blutrain/bluscriptCP.cpp src/bluscriptCP.cpp || BAD=$((BAD+1))
|
| 96 |
+
for m in p1mix p2mix p3mix; do up "Data_Loader/Data/$m/MANIFEST.txt" "data/${m}_MANIFEST.txt" || BAD=$((BAD+1)); done
|
| 97 |
+
for g in "$L"/*.log "$L"/master.log; do [ -f "$g" ] && { up "$g" "logs/p1_$(basename "$g")" || BAD=$((BAD+1)); }; done
|
| 98 |
+
for pl in 8192 16360; do
|
| 99 |
+
for f in p1_eval_len${pl}/summary.csv p1_eval_len${pl}/depth_summary.csv; do
|
| 100 |
+
[ -f "$f" ] && { up "$f" "evals/p1_len${pl}_$(basename "$f")" || BAD=$((BAD+1)); }; done
|
| 101 |
+
for f in p1_eval_len${pl}/scores/*.csv; do
|
| 102 |
+
[ -f "$f" ] && { up "$f" "evals/p1_len${pl}_$(basename "$f")" || BAD=$((BAD+1)); }; done
|
| 103 |
+
done
|
| 104 |
+
up "vault_out/ClaudeReport_session_2026-09-15_680m_tied_head_fix_and_phase1_extension.md" \
|
| 105 |
+
"docs/ClaudeReport_session_2026-09-15_680m_tied_head_fix_and_phase1_extension.md" || BAD=$((BAD+1))
|
| 106 |
+
|
| 107 |
+
# ---- 5. final checkpoint: FULL resumable, both ranks -------------------------
|
| 108 |
+
# The shipper already uploads the final step as a full resumable save (it is in
|
| 109 |
+
# EVAL_STEPS). Re-uploading under a second name would push ~11 GB twice, so wait
|
| 110 |
+
# for it, then only fill in what it did not get.
|
| 111 |
+
say "=== final checkpoint (full resumable, both ranks) ==="
|
| 112 |
+
for i in $(seq 1 60); do [ -f "$L/shipped_${FSTEP}.ok" ] && break; sleep 30; done
|
| 113 |
+
if [ -f "$L/shipped_${FSTEP}.ok" ] && [ "$(cat "$L/shipped_${FSTEP}.kind" 2>/dev/null)" = full ]; then
|
| 114 |
+
say " shipper shipped step $FSTEP as FULL resumable -- verifying, not re-uploading"
|
| 115 |
+
for r in 0 1; do for ext in ckpt zero_g1; do
|
| 116 |
+
f="checkpoints_bluscriptcp/rank_$r/blumodelcp_run${RN}_step_${FSTEP}.$ext"
|
| 117 |
+
[ -f "$f" ] || continue
|
| 118 |
+
verify_remote "$f" "checkpoints/p1_680m_step${FSTEP}_rank${r}.$ext" || BAD=$((BAD+1))
|
| 119 |
+
done; done
|
| 120 |
+
else
|
| 121 |
+
say " shipper did NOT complete step $FSTEP -- uploading it here"
|
| 122 |
+
for r in 0 1; do for ext in ckpt zero_g1; do
|
| 123 |
+
f="checkpoints_bluscriptcp/rank_$r/blumodelcp_run${RN}_step_${FSTEP}.$ext"
|
| 124 |
+
[ -f "$f" ] || continue
|
| 125 |
+
up "$f" "checkpoints/p1_680m_final_step${FSTEP}_rank${r}.$ext" || BAD=$((BAD+1))
|
| 126 |
+
done; done
|
| 127 |
+
fi
|
| 128 |
+
|
| 129 |
+
# stop the shipper so nothing is mid-flight at teardown
|
| 130 |
+
SP=$(cat "$L/shipper.pid" 2>/dev/null)
|
| 131 |
+
[ -n "$SP" ] && kill "$SP" 2>/dev/null && say "shipper stopped (pid $SP)"
|
| 132 |
+
|
| 133 |
+
# ---- 6. verdict -------------------------------------------------------------
|
| 134 |
+
say "=== TEARDOWN VERDICT ==="
|
| 135 |
+
if [ "$BAD" -eq 0 ]; then
|
| 136 |
+
say "ALL UPLOADS VERIFIED ($REPO) -- SAFE TO TEAR DOWN"
|
| 137 |
+
else
|
| 138 |
+
say "*** $BAD UPLOAD(S) FAILED -- DO NOT TEAR DOWN ***"
|
| 139 |
+
fi
|
| 140 |
+
say "done"
|