#!/usr/bin/env bash
# setup.sh
set -euo pipefail
export HF_HOME=/workspace/hf UV_CACHE_DIR=/workspace/.uv-cache UV_LINK_MODE=copy
command -v uv >/dev/null || pip install -q --break-system-packages uv
if [ ! -x /workspace/venv/bin/python ]; then
  uv venv /workspace/venv --python 3.12
  PY=/workspace/venv/bin/python
  uv pip install --python $PY torch==2.9.1 \
    --index-url https://download.pytorch.org/whl/cu128
  uv pip install --python $PY numpy transformers==5.21.0 peft==0.21.2 \
    accelerate==1.15.0 flash-linear-attention==0.6.0 tilelang==0.1.15
fi
/workspace/venv/bin/python - <<'PY'
import inspect
import transformers.models.qwen3_5.modeling_qwen3_5 as qwen
kernel = inspect.getclosurevars(qwen.torch_chunk_gated_delta_rule)
assert kernel.nonlocals.get("is_new_implementation"), "fast kernels missing"
from huggingface_hub import snapshot_download
snapshot_download("Qwen/Qwen3.5-9B", revision="c202236235762e1c871ad0ccb60c8ee5ba337b9a")
PY
