Kavin60606 commited on
Commit
30e6274
·
verified ·
1 Parent(s): 804a195

Upload push_ckpts.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. push_ckpts.sh +30 -0
push_ckpts.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Incrementally push each COMPLETED checkpoint to HF as it saves — so we don't gamble on one giant
3
+ # 117GB upload at completion. Self-extracts HF_TOKEN from the box's onstart. Runs until training done.
4
+ eval "$(grep -oE 'export HF_HUB_ENABLE_HF_TRANSFER=1 HF_TOKEN=[^ ]+ WANDB_API_KEY=[^ ]+ WANDB_ENTITY=[^ ]+ XLA_PYTHON_CLIENT_MEM_FRACTION=[0-9.]+' /root/onstart.sh | head -1)"
5
+ export HF_HUB_DISABLE_XET=1
6
+ CK=/workspace/openpi/checkpoints/pi05_yam7h_ea/run_ax91
7
+ REPO=Kavin60606/fdstudio-run_ax91
8
+ PUSHED=/root/pushed_ckpts.txt; touch "$PUSHED"
9
+ echo "checkpoint pusher up @ $(date -u +%T) -> $REPO/checkpoints/"
10
+ while true; do
11
+ for d in "$CK"/*/; do
12
+ step=$(basename "$d")
13
+ [[ "$step" =~ ^[0-9]+$ ]] || continue
14
+ grep -qx "$step" "$PUSHED" && continue
15
+ # skip a dir still being written (modified in the last 120s) — push only settled checkpoints
16
+ [ -n "$(find "$d" -newermt '-120 seconds' 2>/dev/null | head -1)" ] && continue
17
+ echo ">>> pushing step $step ($(du -sh "$d"|cut -f1)) @ $(date -u +%T)"
18
+ if /.venv/bin/python -c "from huggingface_hub import HfApi; HfApi(token='$HF_TOKEN').upload_folder(folder_path='$d', repo_id='$REPO', repo_type='dataset', path_in_repo='checkpoints/$step')"; then
19
+ echo "$step" >> "$PUSHED"; echo ">>> DONE step $step"
20
+ else
21
+ echo ">>> FAILED step $step (will retry next loop)"
22
+ fi
23
+ done
24
+ if [ -f /workspace/.tdone ]; then echo "training finished — one final sweep then exit"; sleep 10
25
+ for d in "$CK"/*/; do step=$(basename "$d"); [[ "$step" =~ ^[0-9]+$ ]] || continue; grep -qx "$step" "$PUSHED" && continue
26
+ /.venv/bin/python -c "from huggingface_hub import HfApi; HfApi(token='$HF_TOKEN').upload_folder(folder_path='$d', repo_id='$REPO', repo_type='dataset', path_in_repo='checkpoints/$step')" && echo "$step" >> "$PUSHED" && echo "final-swept $step"; done
27
+ echo "ALL PUSHED: $(sort -n $PUSHED | tr '\n' ' ')"; break
28
+ fi
29
+ sleep 90
30
+ done