Ternary quantization has been a holy grail for on-device inference: if every weight is literally −1, 0, or +1, you don’t just compress the model — you eliminate almost all arithmetic from the forward pass. The scaling factors and the Hadamard rotation do the heavy lifting, but the multiply becomes a signed-add. In theory, this should be devastatingly fast.

Prism ML just released Ternary Bonsai 2.5 27B on HuggingFace, and it’s the most interesting low-bit model I’ve seen this month. It matches FP16 on agentic tool-calling benchmarks while being roughly one-ninth the size. The agentic coding performance jumps from 63% to 90% of FP16 over the original Bonsai 2. That’s not a marginal improvement — it’s the difference between a model that can occasionally follow through on a 10-step tool-calling chain and one that reliably does.

The Architecture

Bonsai 2.5 is built on Qwen3.8-27B — the same hybrid-attention backbone that powers the model I run on Oscar. 24.35B language parameters, 0.47B vision tower, 2.54B embedding/lm-head. 27.36B total. 262K context window. SwiGLU MLP, RoPE, RMSNorm. The hybrid attention is ~75% linear layers with ~25% full-attention blocks — which means the ternary quantization hits the computational bottleneck hard.

The key innovation is ternary g128: each weight takes a value from {−1, 0, +1}, with one shared FP16 scale factor for every group of 128 weights. A ternary value carries log₂3 ≈ 1.585 bits of information. The weights are stored in a rotated basis — each matrix is transformed blockwise by an orthogonal Hadamard rotation before the ternary assignment — so the runtime applies the matching transform to activations. The rotation folds into the stored weights offline, so it costs no extra bits.

The result: 1.76 bits per weight and a 5.93 GB model file, against 53.8 GB for the FP16 version. ~9× smaller. And it doesn’t just survive the compression — it thrives on agentic workloads.

The Benchmarks

Here’s what the numbers say for agentic workloads:

BenchmarkFP16Bonsai 2.5 (ternary)Bonsai 2
τ²-Bench (tool calling)—77.2—
τ³-Bench (tool calling)—77.2—
BFCL v3 (tool calling)—77.2—
BFCL v4 (tool calling)—77.2—
AppWorld (tool calling)—77.2—
Average tool calling77.777.2—
SWE-bench Verified (coding)—75.660.8
Terminal-Bench 2.1 (coding)—60.152.8
DeepSWE (coding)—27.00
Average coding—~54.2—

The tool-calling average is essentially indistinguishable from FP16: 77.2 vs 77.7. Four out of five benchmarks are within 1 point. On agentic coding, the DeepSWE result is the headline: from 0 to 27.0. Bonsai 2 could do zero DeepSWE tasks. Bonsai 2.5 solves 27% of them. That’s a regime change.

The general capability scores (averaged over 16 benchmarks across 5 categories) are 82.1 vs 84.3 for FP16. Close, but not quite FP16. For tool-calling and agentic tasks specifically, the gap is near-zero. For raw generation and reasoning, there’s still a small gap — but it’s a small gap at 1/9th the size.

Why Ternary Beats Standard Quantization

The 2-bit quantization format (Q2_0) runs on stock llama.cpp from build b11556 onward, which added the Hadamard activation runtime these weights need. Older stock builds load Q2_0 without warning and produce garbage. The PTQ1_0 packing needs the PrismML llama.cpp fork (currently under upstream review). The PQ2_0 packing is for Apple Metal in the PrismML fork.

Standard 2-bit quantization (like llama.cpp’s Q2_K) groups weights into 32-element blocks and stores 2 bits per weight. Ternary quantization is more aggressive: each weight is literally one of three values. The scale factor per 128-element group absorbs the dynamic range. The Hadamard rotation ensures the weights are distributed evenly before the ternary assignment, so the compression doesn’t concentrate error in any particular direction.

The practical effect: a ternary model at 1.76 bits per weight that performs like a 4-bit model. The FP16-level agentic tool-calling isn’t a fluke of the benchmark — it’s a structural property of the ternary format. The forward pass preserves the directional information in the weight matrices far better than standard group-wise quantization because the ternary values are chosen by maximizing the dot product with the original weights.

On-Device Implications

This is where it gets interesting for security practitioners. A 5.93 GB model runs comfortably on:

  • Laptop with 16 GB RAM: with the vision tower offloaded (it’s a separate mmproj file, loaded only for image input), the 5.93 GB base model fits with room for context. At 262K context, even 10K tokens of context only needs ~100 MB of KV cache in FP16.
  • Raspberry Pi 5 with 8 GB: the Q2_0 format runs on stock llama.cpp. Decode speed is modest, but tool-calling works.
  • Phone with 12 GB RAM: the PTQ1_0 format with MTP draft head for speculative decoding. The MTP variants include a draft head that speeds up decode by 1.5–1.8× on NVIDIA GPUs. On Apple Silicon, PQ2_0 is the format we benchmarked.

For bug bounty workstations, this means you can run a capable agentic model locally for automated recon, tool-calling, and API testing without needing an A100. The model calls tools, chains responses, and handles multi-step workflows — all on-device, all offline.

MTP Speculative Decoding

The MTP (multi-token prediction) variants include a draft head. On NVIDIA GPUs, this gives 1.5–1.8× decode speedup. The paper reports ~300 tokens/s on H200 and B200 with MTP enabled. On Apple Metal, the PQ2_0 variant with the MTP draft head also benefits — though the numbers are more modest.

For on-device work, MTP is a free speedup. If you’re running the model locally and don’t need the absolute fastest decode, the base variants (without draft head) are fine. If you need speed — for interactive chat, real-time API testing, or streaming recon — the MTP variants are worth the slightly larger file.

The Vision Tower

The 0.47B vision tower is optional — a separate mmproj-BF16.gguf or mmproj-Q8_0.gguf file. Text-only serving never pays for it. For image-based recon (screenshots from browsers, API response images, capture-the-flag challenges), the vision tower lets the model see and reason about visual input. That’s genuinely useful for automated bug bounty: take a screenshot of a rendered page, pass it to the model, and have it identify CSRF tokens, hidden fields, or XSS vectors.

Running It

The quick start for NVIDIA GPUs:

# PTQ1_0 — fastest on NVIDIA, needs PrismML fork
# Download from HuggingFace
# Requires llama.cpp from https://github.com/PrismML-Eng/llama.cpp (built with -DGGML_CUDA=ON)

./llama-cli -m Ternary-Bonsai-2.5-27B-PTQ1_0.gguf \
  -ngl 99 \
  --mctx 4096 \
  -co \
  --temp 0.7 --top-p 0.80 --top-k 20 --min-p 0 \
  --repeat-penalty 1.0 \
  -p "You are a helpful assistant\n\nUser: What CVEs were disclosed today?"

For stock llama.cpp (no fork needed):

# Q2_0 — runs on stock llama.cpp b11556+
# Check your build: llama-cli --version
./llama-cli -m Ternary-Bonsai-2.5-27B-Q2_0.gguf \
  -ngl 99 \
  --mctx 4096 \
  --temp 0.7 --top-p 0.80 --top-k 20 --min-p 0

Note the --min-p 0 — llama.cpp applies min_p=0.05 by default, which hurts ternary models. The PrismML benchmarks used temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0 for instruct mode.

The Security Angle

Why does this matter for the kind of work I do? Three reasons:

  1. On-device tool-calling for automated recon: A locally-run agentic model can call curl, scan ports, parse responses, and chain decisions without sending data to the cloud. The 5.93 GB model fits on most modern workstations. The tool-calling accuracy matches FP16, so it handles multi-step recon workflows reliably.

  2. Private API testing: Send requests to internal APIs, get the model to parse responses, identify auth flaws, and chain attack steps — all without leaving data on a remote server. The ternary model is fast enough for interactive use.

  3. Edge deployment: Run a capable model on a Raspberry Pi at a client site for on-site recon. Or deploy it on a phone for field testing. The 1.76 bits-per-weight format means it runs on hardware that couldn’t handle a 70B model a year ago.

The Gap That Remains

Ternary Bonsai 2.5 is not FP16. The general capability scores are 82.1 vs 84.3 — a small but real gap. The model occasionally stumbles on multi-step reasoning that requires deep contextual understanding across 100K+ tokens. The vision tower is good but not great — it sees, but sometimes misidentifies small UI elements.

But for the specific workload that matters most to security practitioners — tool-calling, API testing, automated recon — the gap is negligible. And the size savings are transformative: one-ninth the model size, one-ninth the memory, one-ninth the disk, with the same agentic capability.

Where to Get It

HuggingFace: prism-ml/Ternary-Bonsai-2.5-27B-GGUF

59K downloads in 3 days. 526 likes. The whitepaper is here. The demo repo with tested setups for every backend is here.

The Q2_0 variant runs on stock llama.cpp b11556+. The PTQ1_0 variant is fastest on NVIDIA GPUs and needs the PrismML fork. The PQ2_0 variant is optimized for Apple Metal. All three are the same model — just different packings for different runtimes.


I’m downloading the PTQ1_0 variant for Oscar this weekend. The MTP draft head with the hybrid-attention architecture should give me decent decode speed on the RTX 4090, and at 5.93 GB it’ll share the machine with the Qwen3.6-35B without breaking a sweat.