Everything here is in the fork's repo at
docs/torad/bonsai-27b, including the
benchmark scripts, a serve command and the
chat template.
You need an NVIDIA GPU with at least 12 GB of memory for the serve command below, which holds one
conversation of up to 139,264 tokens.
The fork runs on any NVIDIA GPU from Ampere on, but I tuned it and measured every speed in this article on
sm_120 (GeForce and RTX PRO Blackwell), and some of its changes only run on newer chips. The tensor-core
kernel that multiplies the PQ2_0 weights during decode, with its TMA ring, its evict_first hint and its L2
prefetch, runs only on sm_120, so every other NVIDIA card, including B200 (sm_100) and GB10 (sm_121), uses
the slower CUDA-core PQ2_0 kernel. The paced L2 issuer and PDL run on sm_90 and newer, which covers Hopper,
B200, the RTX 50-series and GB10, while older cards run their kernels in program order and each kernel
fetches its own weights. The 4-bit attention kernel and the chunked Gated DeltaNet prefill run on sm_80 and
newer, which covers Ampere, Ada, Hopper, B200, the RTX 50-series and DGX Spark GB10, and the remaining
changes, such as the draft head's token lookup and the narrower recurrent state, run on every card. That's
why the model works on all of those cards but writes slower than the numbers here outside sm_120. The
numbers in this article come from main at bdb47f8, and the later commits on main change only comments and
docs. The
hardware support table
in the fork's README lists each change, where it runs, and what runs in its place elsewhere.
Every change in the fork has an environment switch that turns it off, so you can measure each one on your
own card.
To have a coding agent do the setup, paste this prompt into
Claude Code, Cursor or any agent that can run shell
commands on the machine with the card:
Set up and benchmark Ternary Bonsai 2 27B on this machine with the
torad-labs llama.cpp fork. Use only the commands and flags below. Do not add
or change flags. Stop and tell me if a check fails.
1. Check the hardware and tools.
- Run: nvidia-smi --query-gpu=name,memory.total,compute_cap --format=csv
Tell me the GPU name, its memory and its compute capability. I need an
NVIDIA GPU with 12 GB of memory or more for step 5. The fork runs on
any NVIDIA GPU from Ampere on (compute capability 8.0 or newer), but
the PQ2_0 tensor-core decode path, and the published numbers, are
RTX 50-series and RTX PRO Blackwell only (sm_120, compute capability
12.0). On any other card from Ampere on, expect it to work but run
slower than those numbers, and keep going. If the compute capability
is below 8.0, stop and tell me.
- Run: nvcc --version. I need CUDA 12.8 or newer.
- Make sure git, cmake, ninja, sha256sum and the Hugging Face CLI (hf)
are installed. If hf is missing: pip install -U huggingface_hub
- The model file is about 7.7 GB. Make sure there is room on disk.
2. Clone main at the measured commit and build it. The build targets the GPU in this machine, so run
it here, with CMake 3.24 or newer.
git clone https://github.com/torad-labs/llama.cpp && cd llama.cpp && git checkout bdb47f8
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DGGML_CUDA=ON -DGGML_NATIVE=ON -DCMAKE_CUDA_ARCHITECTURES=120a \
-DGGML_CUDA_FA=ON -DGGML_CUDA_FA_ALL_QUANTS=OFF -DGGML_CUDA_GRAPHS=ON \
-DLLAMA_BUILD_SERVER=ON -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF
cmake --build build --target llama-server llama-bench llama-perplexity -j
If the compute capability is 12.0, add -DCMAKE_CUDA_ARCHITECTURES=120a
to the first cmake line, as the measured build did.
3. Download the model with its MTP draft head (one file: PrismML's weights
plus the 8-bit draft head, Apache-2.0) and verify the checksum.
hf download ProCreations/Ternary-Bonsai-2-27B-MTP \
Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf \
--revision efffdea64c1f9e93cc7fa6bb24f72ae9d66ecf51 --local-dir .
echo "3cb3f0056d2e34ee44245a64396004a21f8492573d6ce1266ec4b7222c131dd4 ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf" | sha256sum -c
4. Quick speed check before starting the server (no draft head, empty
context). Report pp512 and tg128 in tok/s. On an RTX 5080 at its stock
power limit, main's published numbers are about 2,720 and 110.9.
build/bin/llama-bench -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf \
-ngl 99 -fa 1 -ctk q4_0 -ctv q4_0 -p 512 -n 128 -r 5
5. Start the server (one conversation, draft head on) and leave it running.
This is the configuration behind the published numbers, and it peaked
at 10,496 MiB on the RTX 5080, so it fits a 12 GB card.
build/bin/llama-server -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf \
--alias bonsai-2-27b -ngl 99 -fa on -c 139264 -np 1 --jinja \
--cache-type-k q4_0 --cache-type-v q4_0 -cts q8_0 --attn-mask-bits \
--chat-template-file docs/torad/bonsai-27b/chat-template.jinja \
--reasoning-format deepseek --temp 1.0 --top-p 0.95 --top-k 20 \
--spec-type draft-mtp --spec-draft-n-max 2 -ctkd q4_0 -ctvd q4_0 \
--host 127.0.0.1 --port 8080
When it is up, curl http://127.0.0.1:8080/health, then send one short
chat request to http://127.0.0.1:8080/v1/chat/completions with model
"bonsai-2-27b" and show me the reply. With the draft head on, an RTX
5080 writes about 200 tok/s on a short request.
6. Optional: the full depth table. It takes a while. Stop the server first
to free the card.
build/bin/llama-bench -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf \
-ngl 99 -fa 1 -ctk q4_0 -ctv q4_0 -p 512 -n 128 -d 0,32768,131072 -r 5
Published main numbers on an RTX 5080: tg128 110.9, 103.2 and 83.8.
Finish with a short summary: GPU, CUDA version, build result, checksum
result, the tok/s numbers, and whether the server answered.
To do it by hand, follow three steps. First, build the fork from source (CUDA 12.8 or newer) on the machine with the card, because the build targets the GPU it finds there:
git clone https://github.com/torad-labs/llama.cpp && cd llama.cpp && git checkout bdb47f8
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DGGML_CUDA=ON -DGGML_NATIVE=ON -DCMAKE_CUDA_ARCHITECTURES=120a \
-DGGML_CUDA_FA=ON -DGGML_CUDA_FA_ALL_QUANTS=OFF -DGGML_CUDA_GRAPHS=ON \
-DLLAMA_BUILD_SERVER=ON -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF
cmake --build build --target llama-server llama-bench llama-perplexity -j
These are the flags of the build I measured, at bdb47f8 with CUDA 13.3.
-DCMAKE_CUDA_ARCHITECTURES=120a
is there because the PQ2_0 tensor-core kernel only launches when the binary includes an sm_120 image. On any
other card, drop it, and with CMake 3.24 or newer
-DGGML_NATIVE=ON
builds for the GPUs in the machine you build on, or set
CMAKE_CUDA_ARCHITECTURES
to your card's architecture. The README
lists the value for each card.
Next, fetch the model file from Hugging Face (Apache-2.0) with the [hf
command][hf-cli] and check it against its checksum. The file holds
PrismML's weights byte for byte plus the 8-bit draft head, and it's the file I measured every
number in this article with.
hf download ProCreations/Ternary-Bonsai-2-27B-MTP Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf \
--revision efffdea64c1f9e93cc7fa6bb24f72ae9d66ecf51 --local-dir .
echo "3cb3f0056d2e34ee44245a64396004a21f8492573d6ce1266ec4b7222c131dd4 ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf" | sha256sum -c
Then serve it. This is the configuration every served number in this article ran with, one conversation in
a 139,264-token window, and it peaked at 10,496 MiB on the RTX 5080, so it fits a 12 GB card:
build/bin/llama-server -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf --alias bonsai-2-27b \
-ngl 99 -fa on -c 139264 -np 1 --jinja \
--cache-type-k q4_0 --cache-type-v q4_0 -cts q8_0 --attn-mask-bits \
--chat-template-file docs/torad/bonsai-27b/chat-template.jinja --reasoning-format deepseek \
--temp 1.0 --top-p 0.95 --top-k 20 \
--spec-type draft-mtp --spec-draft-n-max 2 -ctkd q4_0 -ctvd q4_0 \
--host 127.0.0.1 --port 8080
For lower drift in very long conversations, swap -cts q8_0 for -cts f16 (chapter
7). It costs 34 MiB more per state copy, and I haven't benchmarked it on the RTX 5080, so the speed and
memory numbers here are for q8_0. The fork's
Bonsai page
also has a four-conversation command with --kv-unified, --checkpoint-every and
--cache-ram, which I didn't measure for this article.
Reproduce the numbers
To check my numbers against yours, use the same commands I ran. The runs pinned the card with
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=0. The llama-bench table in chapter 2 is
three legs (c008fe8, main, c008fe8) of this command:
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=0 \
build/bin/llama-bench -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf -ngl 99 -fa 1 -ctk q4_0 -ctv q4_0 \
-p 512 -n 128 -d 0,32768,131072 -r 5 -o csv
The served tables used the serve command above, with -c 65536 in place of
-c 139264
for the short conversation, and with
--spec-type draft-mtp --spec-draft-n-max 2 -ctkd q4_0 -ctvd q4_0
left out for the runs without the draft head, or --spec-draft-n-max 3 for three drafted tokens.
Each request to
/v1/chat/completions
asked for max_tokens 512 with temperature 0,
top_k
1 and seed 1, which overrides the server's sampling flags so every run writes the same greedy
tokens. Speeds are the server's own predicted_per_second timing.
docs/torad/bonsai-27b/bench-server.sh
reads the same timings from a running server.
The KL numbers in chapter 6 came from llama-perplexity, built with
--target llama-perplexity, over 8 chunks of 1,024 tokens:
build/bin/llama-perplexity -m ./Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0.gguf -c 1024 -b 1024 --chunks 8 \
-fa on -ctk q4_0 -ctv q4_0 -cts q8_0 --attn-mask-bits -ngl 99 -ub 1 -f text.txt \
--kl-divergence-base base.kld
Run it once to write the base file (-ngl 0 --threads 4
for the CPU reference), then again with --kl-divergence and the -ub batch size
under test (1, 3 or 8). GGML_CUDA_PQ2_MMA_LEGACY=1 selects the CUDA-core weight kernel. Then
turn off one change at a time with the switches in chapter 5 to see what each does on your card.
If your numbers differ from mine, I'd like to see them.