a8nova's picture
nnopt port: Bonsai-27B-llama.cpp
9d62c0e verified
Raw History Blame Contribute Delete
1.91 kB
#!/usr/bin/env bash
# Run once after downloading this folder: bash fetch.sh
# Downloads the original GGUF and the PrismML llama.cpp fork; build.sh applies src/patches/.
set -euo pipefail
cd "$(dirname "$0")"
REPO=nnopt-dev/Bonsai-27B-llama.cpp
# The repository's manifest first (Hugging Face counts a download when config.json is requested).
curl -fsSL "https://huggingface.co/$REPO/resolve/main/config.json" -o ../config.json
sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d" " -f1; else shasum -a 256 "$1" | cut -d" " -f1; fi; }
get() { # get URL FILE SHA256: download once, check the sha256
if [ -f "$2" ] && [ "$(sha256_of "$2")" = "$3" ]; then return 0; fi
mkdir -p "$(dirname "$2")"
curl -fL --retry 3 -o "$2.part" "$1"
[ "$(sha256_of "$2.part")" = "$3" ] || { echo "fetch.sh: sha256 mismatch for $1" >&2; rm -f "$2.part"; exit 1; }
mv "$2.part" "$2"
}
git_at() { # git_at URL COMMIT DIR: the exact commit, shallow
if [ "$(git -C "$3" rev-parse HEAD 2>/dev/null || true)" = "$2" ]; then return 0; fi
rm -rf "$3"; mkdir -p "$3"
git -C "$3" init -q && git -C "$3" remote add origin "$1"
git -C "$3" fetch -q --depth 1 origin "$2" && git -C "$3" -c advice.detachedHead=false checkout -q FETCH_HEAD
}
# The fork, unchanged, at 5ae2e169 (build.sh finds it in inputs/reference_code and copies it before patching).
git_at https://github.com/PrismML-Eng/llama.cpp 5ae2e169eac202d2f065606539c3ad6ab8b51333 inputs/reference_code
# The original weights, unchanged.
get "https://huggingface.co/prism-ml/Bonsai-27B-gguf/resolve/f10afb355f104535e3e3e98cf7ab7795c72bd292/Bonsai-27B-Q1_0.gguf" \
"inputs/weights/Bonsai-27B-Q1_0.gguf" 17ef842e47450caeb8eaa3ebfbbab5d2f2278b62b79be107985fb69a2f819aa0
mkdir -p bin
echo "$PWD/inputs/weights/Bonsai-27B-Q1_0.gguf" > bin/model_path.txt
echo "fetch.sh: done. Next: bash build.sh, then bash deploy.sh ~/bonsai27b"