File size: 1,879 Bytes
6d5c79f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# Download Zenex checkpoint from Hugging Face Model Hub
#
# Usage:
#   scripts/hf_pull.sh                   # pull latest.pt to checkpoints/train-zenex-moe/artifacts/
#   scripts/hf_pull.sh v3                # pull from HF repo but save as train-zenex-moe-v3

set -euo pipefail

HF_USERNAME="${HF_USERNAME:-shashankmacherla09}"
HF_REPO_NAME="${HF_REPO_NAME:-zenex-moe}"
HF_REPO="$HF_USERNAME/$HF_REPO_NAME"
VARIANT="${1:-}"

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CHECKPOINT_DIR="$ROOT/checkpoints/train-zenex-moe"

if [[ -n "$VARIANT" && "$VARIANT" != --* ]]; then
    CHECKPOINT_DIR="$ROOT/checkpoints/train-zenex-moe-$VARIANT"
fi

ARTIFACTS_DIR="$CHECKPOINT_DIR/artifacts"
mkdir -p "$ARTIFACTS_DIR"

echo "==> Hugging Face Pull Configuration"
echo "    Repo: $HF_REPO"
echo "    Target: $ARTIFACTS_DIR"
echo ""

export PATH="$HOME/Library/Python/3.9/bin:$HOME/.local/bin:$PATH"

echo "==> Downloading from $HF_REPO..."
python3 - "$HF_REPO" "$ARTIFACTS_DIR" "$TOKENIZER_DIR" <<'PYTHON'
import sys, os
from pathlib import Path
from huggingface_hub import hf_hub_download

repo_id, artifacts_dir, tokenizer_dir = sys.argv[1:4]

# Download checkpoint
try:
    Path(artifacts_dir).mkdir(parents=True, exist_ok=True)
    ckpt = hf_hub_download(repo_id, "latest.pt", repo_type="model", local_dir=artifacts_dir)
    print(f"✓ Checkpoint: {ckpt}")
except Exception as e:
    print(f"⚠ Checkpoint error: {e}")

# Download tokenizer
Path(tokenizer_dir).mkdir(parents=True, exist_ok=True)
for fname in ["tokenizer.model", "tokenizer.vocab"]:
    try:
        path = hf_hub_download(repo_id, fname, repo_type="model", local_dir=tokenizer_dir)
        print(f"✓ {fname}")
    except Exception as e:
        print(f"⚠ {fname}: {e}")

print(f"\n==> Ready at:")
print(f"    Checkpoint: {artifacts_dir}/latest.pt")
print(f"    Tokenizer: {tokenizer_dir}/")
PYTHON