RSIChallenge / auto-impl /scripts /ptb_download_missing.sh
Jerry999's picture
Add files using upload-large-folder tool
158258b verified
Raw History Blame Contribute Delete
3.83 kB
#!/bin/bash
# Fetch what the sweep is still missing: the three base models whose weights never landed, and
# the test data of the six benchmarks that have none. Run this anywhere that can reach
# huggingface.co -- a compute node can, the login pod cannot (curl returns 000 there).
#
# bash scripts/ptb_download_missing.sh # download
# bash scripts/ptb_download_missing.sh --check # report what is present, download nothing
#
# Safe to re-run: `hf download` verifies each file and fetches only what is absent.
set -uo pipefail
REPO=/home/jiaruiliu/local/git-repos/auto-impl
export HF_HOME=/home/jiaruiliu/ptb-data/hf_cache
# Qwen3-1.7B-Base already has its weights, so it is not listed here.
MODELS=(
google/gemma-3-4b-pt # gated
Qwen/Qwen3-4B-Base
HuggingFaceTB/SmolLM3-3B-Base
)
# gsm8k already has test_data.json.
TASKS=(aime2025 arenahardwriting bfcl gpqamain healthbench humaneval) # gpqamain is gated
UPSTREAM="$REPO/third_party/PostTrainBench"
has_weights() { # $1 = HF model id
local d="$HF_HOME/hub/models--${1//\//--}"
# The parentheses matter: without them -print -quit binds only to the last -name.
[ -d "$d" ] && [ -n "$(find "$d" \( -name '*.safetensors' -o -name '*.bin' \) -print -quit 2>/dev/null)" ]
}
report() {
echo "── base model 权重 ($HF_HOME) ──"
for m in "${MODELS[@]}" Qwen/Qwen3-1.7B-Base; do
has_weights "$m" && echo " 就绪 $m" || echo " 缺失 $m"
done
echo "── benchmark test_data ──"
for t in "${TASKS[@]}" gsm8k; do
f="$UPSTREAM/src/eval/tasks/$t/test_data.json"
[ -s "$f" ] && echo " 就绪 $t ($(du -h "$f" | cut -f1))" || echo " 缺失 $t"
done
}
if [ "${1:-}" = "--check" ]; then report; exit 0; fi
# The compute nodes reach the internet directly; an inherited proxy breaks them.
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY no_proxy NO_PROXY X2P_PROXY_URL
if [ -z "${HF_TOKEN:-}" ]; then
HF_TOKEN=$(grep -m1 '^HF_TOKEN=' "$REPO/.env" 2>/dev/null | cut -d= -f2-)
fi
export HF_TOKEN
[ -n "$HF_TOKEN" ] || echo "!! HF_TOKEN 为空 -- gemma-3-4b-pt 和 gpqamain 是 gated,会失败"
if ! command -v hf >/dev/null 2>&1; then
echo "!! 找不到 hf 命令。装一个: pip install -U 'huggingface_hub[cli]'"
echo " 或者改用容器路径: cd $REPO && FULL_CACHE=0 TASKS='${TASKS[*]} gsm8k' \\"
echo " MODELS='${MODELS[*]}' sbatch scripts/ptb_setup.sbatch"
exit 1
fi
echo "════ 下载前 ════"; report; echo
# A download that died part-way leaves the repo directory behind with no snapshot in it, and
# upstream's download_resources.py then reports "already cached" forever. Clear those husks.
for m in "${MODELS[@]}"; do
d="$HF_HOME/hub/models--${m//\//--}"
if [ -d "$d" ] && ! has_weights "$m"; then
echo "清理无权重的残留目录: $d"
rm -rf "$d"
fi
done
failed=()
for m in "${MODELS[@]}"; do
if has_weights "$m"; then echo "── 跳过 $m (已就绪)"; continue; fi
echo "── 下载 $m"
hf download "$m" || failed+=("model:$m")
done
missing_tasks=()
for t in "${TASKS[@]}"; do
[ -s "$UPSTREAM/src/eval/tasks/$t/test_data.json" ] || missing_tasks+=("$t")
done
if [ ${#missing_tasks[@]} -gt 0 ]; then
echo "── 下载 test_data: ${missing_tasks[*]}"
# The script reads MY_HF_TOKEN, not HF_TOKEN.
( cd "$UPSTREAM" && MY_HF_TOKEN="$HF_TOKEN" \
python3 src/judges/test_data_download/download_test_data.py --tasks "${missing_tasks[@]}" ) \
|| failed+=("test_data:${missing_tasks[*]}")
fi
echo; echo "════ 下载后 ════"; report
if [ ${#failed[@]} -gt 0 ]; then
echo; echo "!! 失败: ${failed[*]}"
exit 1
fi
echo; echo "全部就绪。回到会话里说一声,我提交 sweep。"