Local & Offline
~9 min readUpdated: November 2026

Ternary Bonsai 2.5 27B: 1.76-Bit Local Agent Architecture & Benchmarks

Ternary Bonsai 2.5 27B cybernetic prism bonsai banner showing 1.76 bpw 5.93 GB edge ternary quantization and MTP speculative decoding

Ternary Bonsai 2.5 27B compresses the 53.8 GB Qwen3.8-27B hybrid-attention architecture into a 5.93 GB Apache-2.0 GGUF at 1.76 bits per weight while matching FP16 tool calling (77.2 vs 77.7) and retaining 90% of FP16 agentic coding performance. Paired with Multi-Token Prediction (MTP) draft heads and Smoke Monkey Harness, it serves autonomous workflows at up to 312 tok/s on single consumer and datacenter GPUs.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

Ternary Bonsai 2.5 27B: 1.76-Bit Local Agent Architecture & Benchmarks: Ternary Bonsai 2.5 27B compresses the 53.8 GB Qwen3.8-27B hybrid-attention architecture into a 5.93 GB Apache-2.0 GGUF at 1.76 bits per weight while matching FP16 tool calling (77.2 vs 77.7) and retaining 90% of FP16 agentic coding performance. Paired with Multi-Token Prediction (MTP) draft heads and Smoke Monkey Harness, it serves autonomous workflows at up to 312 tok/s on single consumer and datacenter GPUs. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleternary-bonsai-2-5-27b-agent.ts
ternary-bonsai-2-5-27b-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Connect Smoke Monkey Harness to a local PrismML llama-server serving Ternary Bonsai 2.5 27B
const agent = createAgent({
provider: 'openai',
baseUrl: process.env.BONSAI_BASE_URL ?? 'http://127.0.0.1:8080/v1',
apiKey: process.env.BONSAI_API_KEY ?? 'local-bonsai',
model: 'Ternary-Bonsai-2.5-27B-PTQ1_0-mtp',
agentId: 'build',
workspacePath: process.cwd(),
tools: ['filesystem', 'terminal', 'search', 'git', 'agent'],
permission: 'ask-default',
mcp: [
{
id: 'github',
name: 'GitHub MCP',
description: 'Inspect repository pull requests, CI checks, and issues',
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-github'],
enabled: true,
},
],
});
// Gate mutating commands while auto-allowing read-only inspection and test verification
agent.on('permission.required', (event) => {
const safeTools = ['read_file', 'grep', 'glob', 'git_diff', 'git_status', 'run_test'];
const decision = safeTools.includes(event.data.toolName) ? 'allow' : 'deny';
agent.resolvePermission(event.data.toolCallId, decision);
});
agent.on('phase.changed', (event) => {
console.log(`[Bonsai-2.5-27B] Phase -> ${event.data.phase}`);
});
async function main() {
const result = await agent.run(
'Profile src/runtime/scheduler.ts for lock contention, apply a minimal patch, and verify with npm test.'
);
console.log('Status:', result.status, 'Session:', result.sessionId);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

Ternary Bonsai 2.5 IS HERE! 27B AI Model Under 9GB – Tested Locally on M5! Prism ML

Bonsai 2.5 First Look. Strong quant; not up to the hype.

What Is Ternary Bonsai 2.5 27B? Architecture & Rotated g128 Format

Ternary Bonsai 2.5 27B is an Apache-2.0 agentic release from PrismML built on Qwen3.8-27B that constrains every linear weight to {-1, 0, +1} trits in a blockwise Hadamard-rotated basis. At 1.76 bits per weight and 5.93 GB (5.58 GiB in PTQ1_0), it reduces FP16 storage by ~9x while preserving 262,144-token context and FP16-level tool calling.

Unlike Bonsai 2, which kept only 63% of FP16 agentic coding performance and scored 0.0 on DeepSWE, Bonsai 2.5 targets multi-turn, long-horizon agent trajectories. Total parameter distribution across the underlying Qwen3.8-27B hybrid-attention graph remains unchanged (27.36B total): 24.35B language parameters across 64 decoder blocks (~75% linear attention and ~25% full attention with SwiGLU MLP, RoPE, and RMSNorm), 0.47B across a 27-block vision tower, and 2.54B in embeddings and the output head.

Ternary g128 Weight Math & Hadamard Rotation

Each ternary weight carries theoretical log2(3) ≈ 1.585 bits of entropy. PrismML groups 128 weights (g128) under a single shared FP16 scale factor, bringing packed overhead to 1.76 bits per weight in PTQ1_0. To suppress outlier distortion before quantization, every matrix undergoes an offline blockwise orthogonal Hadamard rotation folded directly into the stored trits—costing zero extra storage bits—while the inference engine applies the matching Fast Walsh-Hadamard Transform (FWHT) to activations on the fly.

Packing FormatFile Size (Base / +MTP)Bits/WeightRuntime Support & Primary Hardware Target
`PTQ1_0`5.58 GiB (5.93 GB) / 5.80 GiB1.76 bpwPrismML llama.cpp fork (upstream PRs #29672, #29676); fastest decode on all NVIDIA GPUs
`PQ2_0`6.76 GiB / 6.98 GiB~2.00 bpwPrismML llama.cpp fork; benchmarked packing for Apple Silicon Metal and MLX export
`Q2_0`7.15 GiB / 7.37 GiB~2.00 bpwStock upstream llama.cpp b11556+ (#29600); also tested on Hexagon NPU
`mmproj-BF16` / `Q8_0`0.87 GiB / 0.59 GiB16 / 8 bpwOptional decoupled vision projector; omitted for text-only serving to save VRAM

Stock llama.cpp Build Requirement for Q2_0

Q2_0 weights require upstream llama.cpp release b11556 or newer (which merged the FWHT activation runtime). Older stock builds load Q2_0 silently without errors and emit corrupted tokens. PTQ1_0 and PQ2_0 require binaries from the PrismML-Eng/llama.cpp fork.

Agentic Tool Calling, Coding & General Capability Benchmarks

Evaluated in thinking mode at default xhigh reasoning effort (temperature=1.0, top_p=0.95, top_k=20, min_p=0.0), Ternary Bonsai 2.5 27B averages 77.2 across five tool-calling benchmarks versus 77.7 for 53.8 GB Qwen3.8 FP16, and recovers 90% of FP16 agentic coding capability across Terminal-Bench 2.1, SWE-bench Verified, and DeepSWE.

Conventional sub-3-bit GGUF baselines suffer catastrophic trajectory collapse on multi-step APIs even when single-turn benchmarks look acceptable. For example, GSQ-RCO IQ2_XS (8.4 GB, 1.4x larger than Bonsai 2.5) scores 79.5 on tau2-Bench yet crashes to 46.5 on AppWorld because it frequently fabricates long scripts guessing API calls without waiting for tool output. Bonsai 2.5 eliminates that failure mode, finishing complete AppWorld scenarios 89.3% of the time (versus 80.4% for 10.1 GB IQ3_XXS and 75.0% for IQ2_S).

Agentic Tool Calling & Coding Comparison (Under 10.1 GB)

Benchmark SuiteQwen3.8 FP16 (53.8 GB)GSQ-RCO IQ3_XXS (10.1 GB)GSQ-RCO IQ2_S (9.3 GB)Unsloth UD-IQ2_XS (7.6 GB)Bonsai 2 27B (5.93 GB)Bonsai 2.5 27B (5.93 GB)
tau2-Bench80.677.778.882.080.282.0
tau3-Bench72.870.769.667.269.173.9
BFCL v3 (native)71.271.671.871.570.372.6
BFCL v470.870.667.766.264.467.2
AppWorld93.286.182.889.651.290.5
Tool Calling Avg (5)77.775.374.175.367.077.2
Terminal-Bench 2.170.866.359.653.952.860.1
SWE-bench Verified80.673.275.471.860.875.6
DeepSWE30.127.022.617.70.027.0
Agentic Coding Avg (3)60.555.552.547.837.954.2

General Capability Retention (16 Benchmarks Across 5 Categories)

Across 16 non-agentic evaluations in thinking mode, Bonsai 2.5 averages 82.12 against 84.32 for FP16—outperforming IQ3_XXS (81.72), IQ2_S (80.58), UD-IQ2_XS (77.45), and Bonsai 2 (81.55):

  • Knowledge & Reasoning (`84.27` vs `86.67` FP16): MMLU-Redux 89.1, GPQA Diamond 87.7, AA-LCR 76.0.
  • Math (`90.10` vs `93.15` FP16): AIME26 94.2, HMMT26 86.0—ahead of every conventional compressed build.
  • Single-Turn Coding (`71.65` vs `74.55` FP16): LiveCodeBench v6 83.0, BigCodeBench 60.3.
  • Instruction Following (`80.90` vs `81.15` FP16): IFBench 71.0, IFEval 90.8.
  • Multimodal Vision (`83.66` vs `86.07` FP16): OmniDocBench v1.6 90.1, A-OKVQA 88.6, MathVision 84.5, RealWorldQA 81.7, CharXiv 81.6, HallusionBench 81.5, MMMU-Pro 77.6.

MTP Speculative Decoding, Kernel Throughput & Hardware Benchmarks

Ternary Bonsai 2.5 -mtp.gguf checkpoints bundle a lightweight single-layer Multi-Token Prediction (MTP) draft head that predicts 1–3 candidate tokens per step and verifies them in one target forward pass. Across 36 real-world agent, code, and reasoning prompts in llama-server, MTP delivers a 1.5x to 1.83x decode speedup on NVIDIA GPUs (up to 312 tok/s on RTX 5090 and 309 tok/s on B200) and 1.1x to 2.21x on Apple Silicon and laptop GPUs.

Because speculative verification accepts only tokens the target model would have sampled natively, output distributions remain mathematically aligned: on an NVIDIA H200 running PTQ1_0 with MTP (3, 0.1), mean KL divergence against un-drafted decoding measured just 5.2 × 10^-5. While the draft head adds a 9%–23% prefill pass overhead on stock release binaries, PrismML’s testing kernels eliminate that penalty and push 2K-prompt prefill rates above plain decoding on every NVIDIA GPU.

Plain Decoding vs MTP Speculative Throughput (Tokens/s)

Device / AcceleratorPackingPlain Decode (tg128)MTP Decode (Release / +Kernels)MTP Settings (n_max, p_min)Speedup vs Bonsai 2 Launch
NVIDIA B200PTQ1_0192 tok/s296 / 309 tok/s3, 0.12.98x (104 -> 309)
NVIDIA H200PTQ1_0189 tok/s296 / 306 tok/s3, 0.12.69x (114 -> 306)
NVIDIA H100PTQ1_0186 tok/s282 / 291 tok/s3, 0.12.60x (112 -> 291)
NVIDIA RTX 5090PTQ1_0163 tok/s305 / 312 tok/s3, 0.12.31x (135 -> 312)
NVIDIA RTX PRO 6000PTQ1_0158 tok/s277 / 283 tok/s3, 0.12.36x (120 -> 283)
NVIDIA RTX 4090PTQ1_0112 tok/s204 / 204 tok/s3, 0.01.92x (106 -> 204)
NVIDIA A100PTQ1_0107 tok/s171 / 175 tok/s3, 0.12.39x (73 -> 175)
Apple M5 Pro / M4 ProPQ2_030.2 (M5 Pro)25.3 / 29.2 tok/s (M4 Pro)1, 0.61.44x (20.3 -> 29.2)
Core Ultra Laptop (SYCL)PTQ1_0–23.1 / 24.5 tok/s8, 0.62.00x (11.5 -> 22.9)
Galaxy S26 Ultra (NPU)Q2_0–8.79 tok/s (unreleased fix)1, 0.0Edge NPU baseline

On Apple Silicon, PQ2_0 on the PrismML llama.cpp Metal fork (30.2 tok/s decode, 416 tok/s pp512 prefill on M5 Pro) also outpaces the exported 2-bit MLX build (Ternary-Bonsai-2.5-27B-mlx-2bit at 21.7 tok/s decode and 348 tok/s prefill).

Local Serving Commands, VRAM Slot Tuning & Sampling Controls

Deploying Ternary Bonsai 2.5 27B locally requires matching the GGUF packing to your accelerator (PTQ1_0 for NVIDIA CUDA, PQ2_0 for Apple Metal, Q2_0 for upstream llama.cpp b11556+), passing --min-p 0 explicitly, and setting -np 1 on 8 GB–12 GB GPUs to prevent multi-slot KV cache OOM.

Memory & Parallelism Trap on 10 GB GPUs

By default, llama-server auto-allocates four request slots sharing a unified KV cache. On a 10 GB NVIDIA RTX 3080 running desktop compositing, automatic parallelism pushes total GPU memory consumption to 9.5 GB, risking out-of-memory eviction during multi-turn tool trajectories. Passing -np 1 locks the server to a single slot and drops total GPU memory usage to 7.8 GB.

Sampling & Reasoning Effort Configuration

  1. Thinking Mode (Default for Coding & Tool Agents): Use temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0. Pass --min-p 0 explicitly because llama.cpp defaults to min_p=0.05. Allocate -n 16384 and -c 32768 (up to 262144) so xhigh reasoning traces do not truncate mid-thought.
  2. Instruct / Non-Thinking Mode: For fast deterministic routing subagents, set temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=1.5.
  3. Reasoning Effort Granularity: Defaults to xhigh for peak coding accuracy; set medium to shorten traces. Note that low reasoning effort is not supported and falls back near xhigh behavior.

Reproducible Serving Commands (CUDA, Apple Metal & Upstream Q2_0)

bash
# 1. Download NVIDIA PTQ1_0 + MTP checkpoint and CUDA preset
hf download prism-ml/Ternary-Bonsai-2.5-27B-GGUF \
  Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf \
  presets/llama.cpp/mtp-cuda.json --local-dir .

# Inspect verified profile flags for datacenter / RTX 5090 GPUs
jq -r '.profiles[] | select(.id == "cuda-datacenter-and-blackwell") | .released_build.command' presets/llama.cpp/mtp-cuda.json

# 2. Launch PrismML llama-server on CUDA with MTP speculative decoding & single-slot VRAM cap
./bin/llama-server -m Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf \
  -ngl 99 -fa on -c 32768 -np 1 --jinja \
  --spec-type draft-mtp --spec-draft-n-min 0 --spec-draft-n-max 3 --spec-draft-p-min 0.1 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --port 8080

# 3. Apple Silicon Metal alternative (PQ2_0 + MTP)
hf download prism-ml/Ternary-Bonsai-2.5-27B-GGUF Ternary-Bonsai-2.5-27B-PQ2_0-mtp.gguf --local-dir .
./bin/llama-server -m Ternary-Bonsai-2.5-27B-PQ2_0-mtp.gguf \
  -ngl 99 -fa on -c 32768 -np 1 --jinja \
  --spec-type draft-mtp --spec-draft-n-min 0 --spec-draft-n-max 1 --spec-draft-p-min 0.6 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --port 8080

# 4. Stock upstream llama.cpp (requires release b11556+ for FWHT kernels)
llama-cli --version
llama-server -hf prism-ml/Ternary-Bonsai-2.5-27B-GGUF:Q2_0 \
  -ngl 99 -fa on -c 32768 -np 1 --jinja \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --port 8080

CUDA Toolkit Requirement for Blackwell GPUs

PrismML released CUDA 12.4 binaries for Hopper/Ampere/Ada GPUs, whereas Blackwell GPUs (NVIDIA B200, RTX PRO 6000, and RTX 5090) require the PrismML llama.cpp release compiled with CUDA 12.8.

Orchestrating Ternary Bonsai 2.5 Agents in Smoke Monkey Harness & Canvas

Smoke Monkey Harness connects directly to llama-server on http://127.0.0.1:8080/v1, pairing Ternary Bonsai 2.5 27B’s 77.2 tool-calling fidelity and 262K context with a deterministic 6-phase engineering state machine (Explore -> Plan -> Edit -> Verify -> Recover -> Complete) and zero-cloud-lock-in MCP execution.

Because sub-6 GB weights leave ample headroom on 16 GB–24 GB developer workstations or M4/M5 MacBooks, teams can run autonomous multi-agent loops entirely offline without leaking repository ASTs or credentials to external APIs:

  1. Permission-Gated Tool Groups: Configure @smoke-monkey/harness with permission: "ask-default" so read-only filesystem, search, and git inspection tools run autonomously while mutating shell commands pause at permission.required for operator approval.
  2. Visual Multi-Agent Routing on Canvas: Launch npx @smoke-monkey/canvas start to pair a build agent backed by PTQ1_0-mtp on a local GPU node with specialized MCP servers (GitHub, Postgres, Playwright) and live phase telemetry.
  3. Context Compaction Across Long Horizons: With native 262K context support and automatic token-budget compaction inside @smoke-monkey/harness, agents sustain 100+ tool-call debugging episodes without losing session state.
Google Search Questions & Answers

Frequently Asked Questions

Q:Can I run Ternary Bonsai 2.5 27B on stock upstream llama.cpp?

Yes, using the Ternary-Bonsai-2.5-27B-Q2_0.gguf (or -mtp) file on upstream llama.cpp release b11556 or newer, which merged PR #29600 and the blockwise Fast Walsh-Hadamard (FWHT) kernels. Older stock builds load Q2_0 silently and produce garbage output. The smaller 5.93 GB PTQ1_0 and Apple Metal PQ2_0 packings currently require the PrismML-Eng/llama.cpp fork.

Q:Which packing should I pick: PTQ1_0, PQ2_0, or Q2_0?

Pick PTQ1_0 (5.58 GiB / 1.76 bpw) for NVIDIA CUDA GPUs, where it achieves the fastest decode across H200, H100, B200, RTX 5090, and RTX 4090. Pick PQ2_0 (6.76 GiB) on Apple Silicon Metal, where it hits 30.2 tok/s on M5 Pro and 29.2 tok/s with MTP on M4 Pro. Pick Q2_0 (7.15 GiB) only when you must run unmodified upstream llama.cpp b11556+.

Q:Why does llama-server use 9.5 GB VRAM on a 10 GB GPU and how do I fix it?

In automatic mode, llama-server initializes four parallel request slots sharing a unified KV cache, pushing total GPU memory on a 10 GB RTX 3080 to ~9.5 GB. Adding -np 1 restricts the server to one request slot and lowers total VRAM usage to ~7.8 GB including desktop display overhead.

Q:How fast is MTP speculative decoding on Ternary Bonsai 2.5 27B?

The -mtp.gguf variants include a Multi-Token Prediction draft head that accelerates real-prompt decode by 1.5x–1.83x on NVIDIA GPUs (reaching 312 tok/s on RTX 5090, 309 tok/s on B200, and 306 tok/s on H200 with 5.2e-5 KL divergence) and 1.27x on Apple M4 Pro (29.2 tok/s).

Q:How does Ternary Bonsai 2.5 27B compare to Bonsai 2 and IQ2/IQ3 GGUFs?

While keeping the exact 5.93 GB size of Bonsai 2, Bonsai 2.5 raises average tool-calling score from 67.0 to 77.2 (virtually matching 53.8 GB FP16 at 77.7) and agentic coding average from 37.9 to 54.2 (90% of FP16), jumping from 0.0 to 27.0 on DeepSWE and 51.2 to 90.5 on AppWorld while beating larger IQ2_S and IQ3_XXS builds on tool use.

Q:How do I wire Ternary Bonsai 2.5 27B into Smoke Monkey Harness?

Start llama-server with --jinja, --min-p 0, and your hardware MTP flags on port 8080, then initialize createAgent from @smoke-monkey/harness with provider: "openai", baseUrl: "http://127.0.0.1:8080/v1", model: "Ternary-Bonsai-2.5-27B-PTQ1_0-mtp", and your workspacePath and MCP server configurations.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness