Download push_ckpts.sh from Kavin60606/fdstudio-scripts: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/datasets/Kavin60606/fdstudio-scripts/resolve/main/push_ckpts.sh
- Command line
-
hf download hf://datasets/Kavin60606/fdstudio-scripts/push_ckpts.sh
-
curl -L -o push_ckpts.sh https://huggingface.co/datasets/Kavin60606/fdstudio-scripts/resolve/main/push_ckpts.sh
1.94 kB
| # Incrementally push each COMPLETED checkpoint to HF as it saves — so we don't gamble on one giant | |
| # 117GB upload at completion. Self-extracts HF_TOKEN from the box's onstart. Runs until training done. | |
| 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)" | |
| export HF_HUB_DISABLE_XET=1 | |
| CK=/workspace/openpi/checkpoints/pi05_yam7h_ea/run_ax91 | |
| REPO=Kavin60606/fdstudio-run_ax91 | |
| PUSHED=/root/pushed_ckpts.txt; touch "$PUSHED" | |
| echo "checkpoint pusher up @ $(date -u +%T) -> $REPO/checkpoints/" | |
| while true; do | |
| for d in "$CK"/*/; do | |
| step=$(basename "$d") | |
| [[ "$step" =~ ^[0-9]+$ ]] || continue | |
| grep -qx "$step" "$PUSHED" && continue | |
| # skip a dir still being written (modified in the last 120s) — push only settled checkpoints | |
| [ -n "$(find "$d" -newermt '-120 seconds' 2>/dev/null | head -1)" ] && continue | |
| echo ">>> pushing step $step ($(du -sh "$d"|cut -f1)) @ $(date -u +%T)" | |
| 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 | |
| echo "$step" >> "$PUSHED"; echo ">>> DONE step $step" | |
| else | |
| echo ">>> FAILED step $step (will retry next loop)" | |
| fi | |
| done | |
| if [ -f /workspace/.tdone ]; then echo "training finished — one final sweep then exit"; sleep 10 | |
| for d in "$CK"/*/; do step=$(basename "$d"); [[ "$step" =~ ^[0-9]+$ ]] || continue; grep -qx "$step" "$PUSHED" && continue | |
| /.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 | |
| echo "ALL PUSHED: $(sort -n $PUSHED | tr '\n' ' ')"; break | |
| fi | |
| sleep 90 | |
| done | |