Download worker/prep-kernel.sh from apetersson/v41-quant-worker: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/datasets/apetersson/v41-quant-worker/resolve/main/worker/prep-kernel.sh
- Command line
-
hf download hf://datasets/apetersson/v41-quant-worker/worker/prep-kernel.sh
-
curl -L -o prep-kernel.sh https://huggingface.co/datasets/apetersson/v41-quant-worker/resolve/main/worker/prep-kernel.sh
2.82 kB
| # CPU worker: minimal staging for the kernel phase in a fresh datacenter — worker bundle plus a | |
| # single GGUF shard, so the GPU pod that follows does zero network work. | |
| set -uo pipefail | |
| trap 'echo "prep aborted rc=$? at line $LINENO"' ERR | |
| STAMP=$(date -u +%Y%m%dT%H%M%SZ); WORK=${WORK:-/workspace/v41-quant} | |
| mkdir -p "$WORK/logs"; exec > >(tee -a "$WORK/logs/prep-kernel-$STAMP.log") 2>&1 | |
| BUNDLE_URL=${BUNDLE_URL:-https://huggingface.co/datasets/apetersson/v41-quant-worker/resolve/main/v41-runtimes-20260910T1240.tgz} | |
| MODEL_REPO=${MODEL_REPO:-apetersson/DeepSeek-V4.1-Flash-MixedQ2-GGUF} | |
| echo "=== prep-kernel $STAMP" | |
| export DEBIAN_FRONTEND=noninteractive | |
| apt-get update -qq && apt-get install -y -qq --no-install-recommends ca-certificates curl python3-pip >/tmp/apt.log 2>&1 | |
| python3 -m pip install --quiet --no-cache-dir --break-system-packages huggingface_hub 2>/dev/null \ | |
| || python3 -m pip install --quiet --no-cache-dir huggingface_hub | |
| echo "--- worker bundle" | |
| curl -fsSL --retry 10 --retry-delay 20 --retry-all-errors -H "Authorization: Bearer ${HF_TOKEN:-}" \ | |
| -o /tmp/runtimes.tgz "$BUNDLE_URL" | |
| tar xzf /tmp/runtimes.tgz -C "$WORK" --warning=no-unknown-keyword | |
| echo "--- first GGUF shard" | |
| python3 - "$MODEL_REPO" "$WORK/gguf-published" <<'PYEOF' | |
| import json, os, sys, time | |
| from huggingface_hub import HfApi, hf_hub_download | |
| repo, dest = sys.argv[1:3] | |
| token = os.environ.get("HF_TOKEN") | |
| api = HfApi(token=token) | |
| files = sorted(f for f in api.list_repo_files(repo) if f.endswith(".gguf"))[:1] | |
| os.makedirs(dest, exist_ok=True) | |
| for name in files: | |
| t0 = time.time() | |
| path = hf_hub_download(repo, name, local_dir=dest, token=token) | |
| print(f" {name}: {os.path.getsize(path)/1e9:.2f} GB in {time.time()-t0:.0f}s", flush=True) | |
| # the kernel harness also needs the config-free path but SGLang later wants these | |
| for name in ("config.json", "tokenizer.json", "tokenizer_config.json"): | |
| try: | |
| hf_hub_download(repo, name, local_dir=dest, token=token) | |
| except Exception: | |
| pass | |
| PYEOF | |
| python3 - "$WORK" <<'PYEOF' | |
| import json, os, sys | |
| work = sys.argv[1] | |
| required = ["scripts/v41_quant_experts.py", "scripts/v41_quant_kernel_smoke.py", | |
| "runtimes/v41-quant/ggml-cuda-smoke/kernel_smoke.c", | |
| "runtimes/v41-quant/worker/gpu-kernel.sh"] | |
| record = {"missing": [p for p in required if not os.path.exists(os.path.join(work, p))]} | |
| shards = [f for f in os.listdir(os.path.join(work, "gguf-published")) if f.endswith(".gguf")] if os.path.isdir(os.path.join(work, "gguf-published")) else [] | |
| record["shards"] = shards | |
| record["ok"] = not record["missing"] and bool(shards) | |
| json.dump(record, open(os.path.join(work, "prep-kernel.json"), "w"), indent=1) | |
| print(json.dumps(record, indent=1)) | |
| sys.exit(0 if record["ok"] else 1) | |
| PYEOF | |
| echo "=== prep-kernel finished" | |