Prism ML Website | White Paper | Demo & Examples | Discord

Ternary (1.58-bit) language model in GGUF Q2_0 format for llama.cpp

- White Paper

- Demo repo — examples for serving, benchmarking, and integrating Bonsai

- Discord — community support and updates

- Kernels: Q2_0 is not yet in mainline llama.cpp. Use our fork at PrismML-Eng/llama.cpp (prismbranch, default) which adds Q2_0 support for CPU (NEON/generic) and Metal. Upstream PR coming soon.

Each weight takes a value from {-1, 0, +1}, with one shared FP16 scale per group of 128 weights:

w_i = scale_g * t_i, t_i in {-1, 0, +1}

Q2_0 encodes each weight as a 2-bit code q in {0, 1, 2, 3}, dequantized via w = (q - 1) * scale. One 128-element block is 34 bytes (2 bytes FP16 scale + 32 bytes of packed 2-bit codes) for an effective 2.125 bits/weight. The fourth code point (q = 3, reconstructing to +2 * scale) is reserved for future extensions; for ternary weights it is unused.

git clone https://github.com/PrismML-Eng/llama.cpp

cd llama.cpp

cmake -B build -DGGML_METAL=ON # or -DGGML_CUDA=ON, -DGGML_VULKAN=ON

cmake --build build -j

./build/bin/llama-cli \

-m Ternary-Bonsai-8B-Q2_0.gguf \

-p "Explain quantum computing in simple terms." \

-n 256

./build/bin/llama-server -m Ternary-Bonsai-8B-Q2_0.gguf -c 4096

Flags: -ngl 99 -fa 1 for Metal; -ngl 0 -fa 1 -t 10 for CPU.

Evaluated with EvalScope v1.4.2 + vLLM 0.15.1 on NVIDIA H100 under identical infrastructure, generation parameters, and scoring. All models are in the 6B-9B parameter range.

Ternary Bonsai 8B ranks 2nd among all compared models despite being 1/8th the size.

density = -ln(1 - score/100) / size_GB

@techreport{ternarybonsai,

title = {Ternary Bonsai: 1.58-bit Language Models at 8B, 4B, and 1.7B Scale},

author = {Prism ML},

year = {2026},

month = {April},

url = {https://prismml.com}

}

For questions, feedback, or collaboration inquiries: contact@prismml.com

- Downloads last month

- 392,483