Beicicc's picture
ProbeShift reproducibility bundle: code + results + paper + figures
592942b verified
Raw
History Blame Contribute Delete
1.86 kB
"""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)