DEV Community

Cover image for Ternary Bonsai 2.5 27B: a 6 GB agent model, and why the 262K KV cache is now three times the weights
ai maya
ai maya

Posted on

Ternary Bonsai 2.5 27B: a 6 GB agent model, and why the 262K KV cache is now three times the weights

TL;DR

  • Ternary Bonsai 2.5 27B is an Apache-2.0 ternary (1.76 bits per weight) rebuild of Qwen3.8-27B, published on Hugging Face on November 24, 2026. The GGUF file is 5.99 GB on disk (5.58 GiB) against 53.8 GB for the FP16 original.
  • The card's headline: tool-calling average 77.2 against 77.7 for FP16 across five benchmarks, and agentic coding at 54.2 against 60.5 (90% of FP16). These are the publisher's own measurements, taken from the model card and not rerun by me.
  • My arithmetic from the base model's config: the cache for the 16 full-attention layers costs 64 KiB per token. At the full 262,144-token context that is 16 GiB, almost three times the 5.58 GiB of weights. The file size is a headline, but context length is what decides whether your GPU is big enough.
  • Two practical traps from the card: Q2_0 files load on stock llama.cpp builds older than b11556 and silently produce garbage, and the default server settings can inflate VRAM use unless you pass -np 1.

What is Ternary Bonsai 2.5 27B?

Ternary Bonsai 2.5 27B comes from PrismML. It keeps the architecture of Qwen3.8-27B, a 27.36B-parameter hybrid-attention model, and stores each weight as one of three values (-1, 0, +1) with a shared FP16 scale for every group of 128 weights. A ternary value carries log2(3), about 1.585 bits, and the group scales bring the effective figure to the card's 1.76 bits per weight.

Two details matter for engineers:

  1. Rotated basis. Each weight matrix is rotated blockwise with a Hadamard transform before the ternary assignment, and the runtime applies the matching transform to the activations. This is the part that makes stock runtimes unsafe on old builds, which I come back to below.
  2. This release targets agents. The previous release, Bonsai 2 (September 17, 2026), kept the format. What changed in 2.5 is the agentic behavior, plus an optional multi-token-prediction (MTP) draft head that speeds up decoding.

The model is a reasoning model. Its default reasoning effort is xhigh, and the card warns that a small generation cap such as 256 tokens ends the output in the middle of the thinking trace, before any answer. The suggested command uses -n 16384.

How big is the file, really?

I pulled the file list from the Hugging Face API instead of trusting the summary line.

File Bytes GB (decimal) GiB
PTQ1_0 5,993,834,848 5.99 5.58
PQ2_0 7,253,354,848 7.25 6.76
Q2_0 7,673,194,848 7.67 7.15
PTQ1_0 + MTP head 6,232,818,944 6.23 5.80
Vision projector (Q8_0) 629,246,976 0.63 0.59

Two observations. The card says 5.93 GB for the PTQ1_0 file and the listing says 5.99 GB, so the card is rounding or counting slightly differently, and the difference is small. And the "9x smaller" claim holds for the densest packing only: 53.8 / 5.99 is 8.98, but the Q2_0 file that runs on stock llama.cpp is 7.67 GB, a 7.0x reduction. If you want the upstream-compatible path, budget for the larger file.

The vision tower ships separately, so a text-only deployment never loads the extra 0.63 GB.

What do the benchmarks say?

All numbers in this section are the model card's. The publisher compares thinking mode at xhigh against conventional low-bit builds of the same base model (GSQ-RCO and Unsloth Dynamic quantizations).

Chart: file size in GB for FP16 and four low-bit builds of Qwen3.8-27B, plus Bonsai 2.5

Benchmark group FP16 IQ3_XXS (10.1 GB) UD-IQ2_XS (7.6 GB) Bonsai 2 Bonsai 2.5 (5.93 GB)
Tool calling, avg of 5 77.7 75.3 75.3 67.0 77.2
Agentic coding, avg of 3 60.5 55.5 47.8 37.9 54.2
General, avg of 5 categories 84.3 81.7 77.5 81.6 82.1

Chart: tool-calling and agentic-coding averages for FP16, IQ3_XXS, UD-IQ2_XS, Bonsai 2 and Bonsai 2.5

The shape of the result is more interesting than the averages:

  • Bonsai 2 to 2.5 is a repair, not a small step. DeepSWE went from 0.0 to 27.0, SWE-bench Verified from 60.8 to 75.6, and AppWorld from 51.2 to 90.5. A model that solves zero tasks on a long-horizon coding benchmark has a failure mode that the general-capability average (81.6) did not show.
  • The card makes the same point about another build. GSQ-RCO IQ2_XS scores 79.5 on tau2-Bench but 46.5 on AppWorld. Short multi-turn tool use and long script-writing episodes break at different bit widths, so a single average can hide the break.
  • Against FP16 the gaps are uneven. Bonsai 2.5 is above FP16 on tau2-Bench (82.0 vs 80.6) and tau3-Bench (73.9 vs 72.8), and below it on Terminal-Bench 2.1 (60.1 vs 70.8) and on HMMT26 (86.0 vs 91.7).

How much weight should you give these? They are a publisher's numbers, measured with the publisher's harness, and the card points to a whitepaper for setup. They are a good reason to test the model on your own tasks, and not a substitute for doing so. If you do, test the long-episode cases first, because that is where the previous release failed.

How much memory does it actually need?

This is the part the headline does not cover. I read the base model's config.json for Qwen3.8-27B:

  • 64 layers, of which 16 are full attention and 48 are linear attention (full_attention_interval is 4)
  • 4 key-value heads, head dimension 256
  • linear-attention state kept in float32 (mamba_ssm_dtype), 48 value heads with 128-dimensional keys and values

Only the full-attention layers keep a per-token KV cache. My arithmetic, with a BF16/FP16 cache:

layers_full_attn = 16
kv_heads, head_dim, bytes_per = 4, 256, 2
per_token = layers_full_attn * 2 * kv_heads * head_dim * bytes_per
print(per_token)                      # 65536 bytes = 64 KiB per token

for ctx in (8192, 32768, 131072, 262144):
    print(ctx, per_token * ctx / 2**30, "GiB")
# 8192 0.5 | 32768 2.0 | 131072 8.0 | 262144 16.0

# linear-attention state, fp32, per sequence (does not grow with context)
state = 48 * (48 * 128 * 128) * 4     # layers * heads * k_dim * v_dim * 4 bytes
print(state / 2**30, "GiB")           # about 0.14 GiB
Enter fullscreen mode Exit fullscreen mode

Chart: weights plus KV cache in GiB at four context lengths for the 5.58 GiB file

Context KV cache (GiB) Weights (GiB) Linear state (GiB) Total before compute buffers (GiB)
8,192 0.5 5.58 0.14 6.2
32,768 2.0 5.58 0.14 7.7
131,072 8.0 5.58 0.14 13.7
262,144 16.0 5.58 0.14 21.7

These totals leave out compute buffers, the vision projector and desktop use, and they assume an unquantized cache. A quantized KV cache would shrink the middle column, at a cost in accuracy that I have not measured for this model.

The consequence: at 32K context, a 10 GB card is plausible. The card's own known-issues section reports about 7.8 GB of total GPU memory use on an RTX 3080 10 GB with -np 1, in line with my 7.7 GiB estimate. At the advertised 262K context, you need a 24 GB-class card. The card's use-case list mentions full-repository work with the 262K context, and that is true, but it is also the reason "fits in 6 GB" is not the full answer. Past roughly 100K tokens, the cache is larger than the model.

I covered the same hybrid layout in an earlier note on this base model, linked at the end, if you want the layer-by-layer reasoning.

How fast is it, and is the speed bandwidth-bound?

The card reports plain decode in tokens per second from llama-bench, and a faster MTP setting measured with llama-server on 36 real prompts. A selection:

GPU Plain decode, PTQ1_0 With MTP head (no new kernels) Speedup
NVIDIA H200 189 296 1.53x
NVIDIA H100 186 282 1.53x
RTX 5090 163 305 1.75x
RTX 4090 112 204 1.83x
NVIDIA L40S 95 not listed n/a

The MTP table's "decode off" baseline differs slightly from the llama-bench column (for example 194 versus 189 on H200) because the two tools time different things, so the speedups above are the card's, computed against its own baseline.

Here is a quick check that I find useful. If decoding were limited only by memory bandwidth, tokens per second times the bytes read per token would approach the GPU's peak bandwidth. Treating every byte of the 5.99 GB file as read once per token (an overestimate, since the embedding table is not fully read) and using public peak bandwidth figures:

GPU Decode (tok/s) Implied traffic Peak bandwidth Share of peak
H200 189 1.13 TB/s 4.8 TB/s 24%
RTX 5090 163 0.98 TB/s 1.79 TB/s 55%
RTX 4090 112 0.67 TB/s 1.01 TB/s 67%
L40S 95 0.57 TB/s 0.86 TB/s 66%

My reading, and it is an inference and not a measurement: on the fast-memory parts the ternary kernels are not bandwidth-bound at this size. The H200 uses about a quarter of its bandwidth, and an H200 is only about 1.7x faster than an RTX 4090 in plain decode (189 vs 112) while having 4.8x the bandwidth. Extra bandwidth would not help much here, while fewer sequential passes, which is what the MTP draft head provides, does.

What breaks when you run it?

The card is candid about two operational problems, and both are worth knowing before you deploy.

1. Old llama.cpp loads the file and produces garbage. The Q2_0 files need the Hadamard activation runtime that landed in llama.cpp release b11556. The card states that older stock builds load Q2_0 without any warning and produce garbage output. The PTQ1_0 and PQ2_0 packings are rejected by stock llama.cpp as unknown types, so they need the PrismML fork. A cheap guard for any pipeline:

llama-cli --version            # confirm the build is b11556 or newer
llama-cli -m Ternary-Bonsai-2.5-27B-Q2_0.gguf \
  -ngl 99 -fa on -c 32768 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  -p "Explain quantum computing in simple terms." -n 16384
Enter fullscreen mode Exit fullscreen mode

Bundled apps that embed their own llama.cpp need an engine from b11556 or newer. A silent failure like this is why I would add a short known-answer smoke test to deployment, for example a fixed arithmetic prompt with a deterministic expected string.

2. Automatic server parallelism inflates VRAM. In automatic mode the server can start four slots that share a unified KV cache. A community report on an RTX 3080 10 GB measured about 9.5 GB before -np 1 and about 7.8 GB after. If you serve one request at a time, set -np 1.

Also note --min-p 0. llama.cpp applies 0.05 by default, while the sampling the benchmarks used (temperature 1.0, top-p 0.95, top-k 20) assumes it is off.

Should you use it?

A short decision guide, based on the card's numbers plus my memory arithmetic:

  • Local coding or tool-calling agent on a 10 to 24 GB card: the numbers justify a trial. Keep the context at 32K to start, and measure your own tasks.
  • Whole-repository prompts at 128K to 262K: budget 14 to 22 GiB, not 6.
  • Stock llama.cpp only: use the 7.67 GB Q2_0 file and check the build version.
  • Phones and laptops: the card lists Apple M4 Pro at 29.2 tokens per second and a Galaxy S26 Ultra at 8.79 tokens per second with MTP, so these are for interactive use, not bulk jobs.

FAQ

What does "ternary" mean for a language model?
Each weight is limited to -1, 0 or +1, with a shared scale per group of 128 weights. That is about 1.585 bits of information per weight, and 1.76 bits per weight counting the scales.

How much VRAM does Ternary Bonsai 2.5 27B need?
The weights are 5.58 GiB for the densest file. By my estimate, add 0.5 GiB of KV cache at 8K tokens, 2 GiB at 32K and 16 GiB at 262K, plus a small linear-attention state and runtime buffers.

Does it run on stock llama.cpp?
Only the Q2_0 file, and only on release b11556 or newer. The other two packings need the PrismML fork.

Is it as good as the FP16 model?
On the card's tool-calling average it is level (77.2 vs 77.7). On agentic coding it keeps 90% (54.2 vs 60.5). These are the publisher's measurements, so test your own workload.

What is the MTP variant for?
It adds a one-layer draft head that proposes several tokens per pass, which the full model verifies. The card reports 1.5x to 1.8x faster decode on NVIDIA GPUs, with 9 to 23% slower prefill before the kernels in testing.

Links

Further reading

Top comments (0)