File size: 2,555 Bytes
ecbe19a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #!/usr/bin/env bash
# The quantisation toolchain, pinned. Written 2026-11-21 so the NEXT session does not have to search
# for it again. Every URL below was resolved and every step below was run on 2026-11-21.
#
# WHY THIS IS A SCRIPT AND NOT A PARAGRAPH: the agent that needed this spent a search session finding
# it, and a search session is a session that did not build anything. Run this instead.
set -euo pipefail
TAG="b12602" # llama.cpp release tag, pinned
DEST="${1:-/home/marimo/tools}"
mkdir -p "$DEST" && cd "$DEST"
REL="https://github.com/ggml-org/llama.cpp/releases/download/${TAG}"
echo "== 1. prebuilt binaries (llama-quantize, llama-cli, llama-server) =="
for asset in "llama-${TAG}-bin-ubuntu-x64.tar.gz" "llama-${TAG}-bin-ubuntu-cuda-13.5-x64.tar.gz" "cudart-llama-${TAG}-bin-ubuntu-cuda-13.5-x64.tar.gz" ; do
[ -s "$asset" ] || curl -sSL -o "$asset" "${REL}/${asset}"
echo " $asset $(stat -c%s "$asset") bytes"
done
echo "== 2. the same tag's SOURCE (the converter needs conversion/ and gguf-py/, not one file) =="
[ -s "${TAG}.tar.gz" ] || curl -sSL -o "${TAG}.tar.gz" \
"https://github.com/ggml-org/llama.cpp/archive/refs/tags/${TAG}.tar.gz"
tar xzf "${TAG}.tar.gz"
echo " converter: $(ls llama.cpp-${TAG}/convert_hf_to_gguf.py)"
echo "== 3. unpack the binaries =="
for f in *.tar.gz; do d="${f%.tar.gz}"; [ -d "$d" ] || { mkdir -p "$d"; tar xzf "$f" -C "$d"; }; done
find . -name 'llama-quantize' -o -name 'llama-server' | sed 's/^/ /'
echo "== 4. python deps =="
pip install -q gguf sentencepiece
python -c "import gguf, sentencepiece; print(' gguf', gguf.__version__, '| sentencepiece', sentencepiece.__version__)"
cat <<EOF
Done. Use them like this (see merge_v7.py / quant_gguf.py / bench_gguf.py in this directory):
# HF fp16 -> GGUF f16 -> Q4_K_M
PYTHONPATH=${DEST}/llama.cpp-${TAG}:${DEST}/llama.cpp-${TAG}/gguf-py \
python ${DEST}/llama.cpp-${TAG}/convert_hf_to_gguf.py <merged-dir> \
--outfile model-f16.gguf --outtype f16
${DEST}/llama-cpu/llama-${TAG}/llama-quantize model-f16.gguf model-Q4_K_M.gguf Q4_K_M
# benchmark a GGUF with tool calling (this is what bench_gguf.py drives)
${DEST}/llama-cuda/llama-${TAG}/llama-server -m model-Q4_K_M.gguf \
--jinja -c 32768 -ngl 999 -fa on -ctk q8_0 -ctv q8_0 --host 127.0.0.1 --port 8099
NOTE: -fa takes a VALUE ("on"/"off"/"auto") in this build; bare "-fa" is an argparse error and the
server exits with only a usage dump in its log. That cost one debugging cycle on 2026-11-21.
EOF
|