Upload scripts/t128c_ship.sh with huggingface_hub
Browse files- scripts/t128c_ship.sh +52 -0
scripts/t128c_ship.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Ship every t128c checkpoint to HF BEFORE the trainer's KEEP=4 rotation can
|
| 3 |
+
# delete it. Rotation drops a save 200 steps (~53 min) behind the newest, so
|
| 4 |
+
# there is ample slack -- but nothing was shipping until this ran.
|
| 5 |
+
#
|
| 6 |
+
# rank_0 .ckpt for EVERY save (2.1 GB, enough to EVALUATE)
|
| 7 |
+
# full 16-file at MILESTONES (17.6 GB, enough to RESUME)
|
| 8 |
+
set -uo pipefail
|
| 9 |
+
cd "$(dirname "$0")"
|
| 10 |
+
PY=/root/Adhi/BluTrain/envv/bin/python
|
| 11 |
+
REPO=unparallelled/BluScriptCP
|
| 12 |
+
RUN=4; PREFIX=blumodelcp; CKD=checkpoints_bluscriptcp
|
| 13 |
+
L=t128c_logs; mkdir -p "$L"; S="$L/shipped.txt"; touch "$S"
|
| 14 |
+
MILESTONES=" 300 600 "
|
| 15 |
+
say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$L/ship.log" >&2; }
|
| 16 |
+
|
| 17 |
+
up(){ # local_path remote_name
|
| 18 |
+
grep -qxF "$2" "$S" && return 0
|
| 19 |
+
[ -s "$1" ] || return 1
|
| 20 |
+
$PY - "$1" "$2" "$REPO" <<'PY' || return 1
|
| 21 |
+
import sys
|
| 22 |
+
from huggingface_hub import HfApi
|
| 23 |
+
HfApi().upload_file(path_or_fileobj=sys.argv[1],
|
| 24 |
+
path_in_repo="checkpoints/"+sys.argv[2],
|
| 25 |
+
repo_id=sys.argv[3])
|
| 26 |
+
PY
|
| 27 |
+
echo "$2" >> "$S"; say " shipped $2 ($(du -h "$1"|cut -f1))"
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
say "=== t128c shipper: rank_0 every save, full set at${MILESTONES}==="
|
| 31 |
+
while :; do
|
| 32 |
+
# newest step present anywhere
|
| 33 |
+
STEPS=$(ls $CKD/rank_0/${PREFIX}_run${RUN}_step_*.ckpt 2>/dev/null \
|
| 34 |
+
| sed -E 's/.*_step_([0-9]+)\.ckpt/\1/' | sort -n)
|
| 35 |
+
for s in $STEPS; do
|
| 36 |
+
up "$CKD/rank_0/${PREFIX}_run${RUN}_step_${s}.ckpt" "t128c_step${s}_rank0.ckpt"
|
| 37 |
+
case "$MILESTONES" in *" $s "*)
|
| 38 |
+
for r in 0 1 2 3 4 5 6 7; do
|
| 39 |
+
up "$CKD/rank_${r}/${PREFIX}_run${RUN}_step_${s}.ckpt" "t128c_step${s}_rank${r}.ckpt"
|
| 40 |
+
up "$CKD/rank_${r}/${PREFIX}_run${RUN}_step_${s}.zero_g1" "t128c_step${s}_rank${r}.zero_g1"
|
| 41 |
+
done
|
| 42 |
+
say " MILESTONE $s: full resumable set up";;
|
| 43 |
+
esac
|
| 44 |
+
done
|
| 45 |
+
# stop once the trainer is gone AND step 600 is shipped
|
| 46 |
+
if ! ps -eo args | grep -qE '^[^ ]*build/bluscriptCP_exec'; then
|
| 47 |
+
grep -qxF "t128c_step600_rank0.ckpt" "$S" && { say "=== SHIPPER DONE ($(wc -l < "$S") files) ==="; exit 0; }
|
| 48 |
+
sleep 60
|
| 49 |
+
ps -eo args | grep -qE '^[^ ]*build/bluscriptCP_exec' || { say "=== trainer gone; shipped $(wc -l < "$S") files ==="; exit 0; }
|
| 50 |
+
fi
|
| 51 |
+
sleep 45
|
| 52 |
+
done
|