#!/usr/bin/env bash # Pod setup for the hfdi-speed bench (one RTX PRO 6000, disposable rented pod, public weights + public code only). # Stack = reax14/Dockerfile's (torch 2.14.0+cu130, transformers 5.17.0, FLA 0.5.2, kit 25c6ec7b) in a venv, plus the # karpo-decision package (Apache-2.0) at a pinned commit for the packed kernels and the author-engine baseline. # bash pod_setup_hfdi.sh /workspace (idempotent; logs to /workspace/setup.log) set -euo pipefail W=${1:-/workspace} KARPO_REV=b8e6fd7463cea8662c556d6257955d7ef9c10d19 D3U_REV=3ac9ff15579ca9193a0d44f4fa9056f2ea62731d KIT_REV=25c6ec7b6b5f44a216c63c3a700de3a9c6d6699d cd "$W" exec > >(tee -a "$W/setup.log") 2>&1 echo "== setup $(date -u +%FT%TZ)" nvidia-smi --query-gpu=name,driver_version,memory.total --format=csv if [ ! -x "$W/venv/bin/python" ]; then # Python 3.12 (karpo-decision needs >= 3.12): uv-managed interpreter when the host has an older one command -v uv >/dev/null || { curl -LsSf https://astral.sh/uv/install.sh | sh; } export PATH="$HOME/.local/bin:$PATH" uv venv --python 3.12 --seed "$W/venv" fi P="$W/venv/bin/pip" "$P" install -q "pip==26.2.1" || true "$W/venv/bin/python" -c 'import torch,sys; sys.exit(0 if torch.__version__.startswith("2.14.0") else 1)' 2>/dev/null || \ PIP_CONFIG_FILE=/dev/null "$P" install -q torch==2.14.0 torchvision==0.29.0 --index-url https://download.pytorch.org/whl/cu130 "$P" install -q "transformers==5.17.0" "accelerate==1.15.0" "safetensors==0.8.0" "flash-linear-attention==0.5.2" "kernels==0.16.1" \ "huggingface-hub==1.31.0" "einops==0.8.2" pillow numpy "uvicorn==0.29.0" "pybase64>=1.4" "backports.zstd>=1.0" hf_transfer [ -d "$W/kit" ] || git clone -q https://github.com/apolinario/decision-index "$W/kit" git -C "$W/kit" checkout -q "$KIT_REV" "$P" install -q --no-deps -e "$W/kit" [ -d "$W/karpo-decision" ] || git clone -q https://github.com/machinepulse-ai/karpo-decision "$W/karpo-decision" git -C "$W/karpo-decision" checkout -q c52d350 echo "karpo-decision $(git -C "$W/karpo-decision" rev-parse HEAD)" "$P" install -q --no-deps -e "$W/karpo-decision" "$W/venv/bin/pip" freeze > "$W/pip-freeze.txt" # weights (public, pinned revisions) export HF_HUB_ENABLE_HF_TRANSFER=1 HF_HUB_DISABLE_IMPLICIT_TOKEN=1 mkdir -p "$W/model" [ -f "$W/model/part-karpo/.done" ] || { "$W/venv/bin/hf" download MachinePulseAI/karpo-decision-31B --revision "$KARPO_REV" \ --local-dir "$W/model/part-karpo" --exclude 'assets/*' && touch "$W/model/part-karpo/.done"; } if [ "${WITH_D3U:-1}" = 1 ]; then # python snapshot_download: the hf CLI (huggingface-hub 1.31) took the exclude patterns as file names (21 MB of assets only) [ -f "$W/model/part-d3u/.done" ] || { "$W/venv/bin/python" -c "from huggingface_hub import snapshot_download as s; s('vllm-sr/d3-ultra', revision='$D3U_REV', local_dir='$W/model/part-d3u', ignore_patterns=['*.png', '*.jpg', '*.mp4', 'evaluation/*', '.eval_results/*', 'assets/*'], max_workers=16)" && touch "$W/model/part-d3u/.done"; } fi if [ "${WITH_NV4:-0}" = 1 ]; then # public compressed-tensors NVFP4 quantization of karpo-decision-31B (third party, llm-compressor NVFP4 W4A4), pinned [ -f "$W/model/part-karpo-nv4/.done" ] || { "$W/venv/bin/python" -c "from huggingface_hub import snapshot_download as s; s('machinez/karpo-decision-31B-NVFP4', revision='2ab6b034047b35834d8e8b586479062a72b5e9a1', local_dir='$W/model/part-karpo-nv4', ignore_patterns=['assets/*'], max_workers=16)" && touch "$W/model/part-karpo-nv4/.done"; } fi [ -e "$W/model/part-karpo2" ] || ln -s part-karpo "$W/model/part-karpo2" # 2x31B duo stand-in (same shape as karpo + a karpo fine-tune) du -sh "$W/model"/* || true echo "== setup done $(date -u +%FT%TZ)"