File size: 1,861 Bytes
592942b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Robustly pre-download all HF models a run needs, with resume + retries, via the
configured HF_ENDPOINT mirror. Run this before extraction so the pipeline never hangs
on a flaky mid-run download.

    HF_ENDPOINT=https://hf-mirror.com HF_HOME=/root/rivermind-data/hf_cache \
        python3 predownload.py smoke      # just the smoke-test models
        python3 predownload.py all        # full size ladder + aux models
"""
import sys
import time

from huggingface_hub import snapshot_download

AUX = [
    "Helsinki-NLP/opus-mt-en-de",
    "Helsinki-NLP/opus-mt-de-en",
    "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli",
]
SMOKE = ["EleutherAI/pythia-410m"] + AUX
ALL = [
    "EleutherAI/pythia-70m", "EleutherAI/pythia-160m", "EleutherAI/pythia-410m",
    "EleutherAI/pythia-1.4b", "EleutherAI/pythia-2.8b",
    "gpt2", "gpt2-medium", "Qwen/Qwen2.5-0.5B",
] + AUX


def fetch(repo, retries=6):
    for a in range(retries):
        try:
            print(f"DL {repo} (attempt {a})", flush=True)
            # prefer safetensors; skip duplicate .bin weights where present
            snapshot_download(repo, ignore_patterns=["*.bin", "*.h5", "*.msgpack", "*.ot"])
            print(f"OK {repo}", flush=True)
            return True
        except Exception as e:
            print(f"ERR {repo}: {str(e)[:120]}", flush=True)
            time.sleep(4)
    # last resort: allow .bin too (some repos have no safetensors)
    try:
        snapshot_download(repo)
        print(f"OK(bin) {repo}", flush=True)
        return True
    except Exception as e:
        print(f"GIVEUP {repo}: {str(e)[:120]}", flush=True)
        return False


if __name__ == "__main__":
    mode = sys.argv[1] if len(sys.argv) > 1 else "smoke"
    repos = {"smoke": SMOKE, "all": ALL}[mode]
    ok = sum(fetch(r) for r in repos)
    print(f"ALL_DONE {ok}/{len(repos)} ok", flush=True)