prism-ml/Ternary-Bonsai-1.7B-gguf

Model

Ternary-Bonsai-1.7B-gguf

45

3 commits

2 linked in READMEs

updated Jun 10, 2026

See the code
1.58-bit
bonsai
conversational
endpoints_compatible
eval-results
gguf
llama-cpp
on-device
prismml
q2_0
ternary
text-generation

README

Bonsai

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

Ternary-Bonsai-1.7B-gguf

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

Pareto Frontier

Resources

  • 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 (prism branch, default) which adds Q2_0 support for CPU (NEON/generic) and Metal. Upstream PR coming soon.

Model Overview

ItemSpecification
Base modelQwen3-1.7B
Parameters1.72B
ArchitectureGQA, SwiGLU MLP, RoPE, RMSNorm
Context length32,768 tokens
Vocab size151,936
Weight formatGGUF Q2_0 g128: {-1, 0, +1} with FP16 group-wise scaling
Packed Q2_0 size436 MiB (0.46 GB)
Ternary coverageEmbeddings, attention projections, MLP projections, LM head
LicenseApache 2.0

Quantization Format: GGUF Q2_0 (g128)

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.

Memory

FormatSizeReductionRatio
FP163.44 GB--1.0x
GGUF Q2_0 g128436 MiB (0.46 GB)86.6%7.5x

Files in this repo

FileFormatSizeRecommended
Ternary-Bonsai-1.7B-F16.ggufFP163.44 GBbaseline / re-quantization source
Ternary-Bonsai-1.7B-Q2_0.ggufQ2_0 (g128)442 MBrecommended (lossless for ternary)

Quickstart

Build from the Prism fork

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

llama.cpp CLI

./build/bin/llama-cli \
  -m Ternary-Bonsai-1.7B-Q2_0.gguf \
  -p "Explain quantum computing in simple terms." \
  -n 256

llama.cpp server

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

Throughput (llama.cpp, Apple M4 Pro 48 GB)

BackendPP512 (tok/s)TG128 (tok/s)FP16 TG (tok/s)Speedup
Metal (GPU)2,088229603.8x
NEON CPU (10 t)508123

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

Fidelity (Q2_0 vs FP16 baseline)

Measured on wikitext-2 (20 chunks, context 512) via llama-perplexity --kl-divergence:

MetricValue
Mean KL0.000000
Top-1 agreement100.000 %
RMS Δp0.015 %
PPL ratio (Q/base)1.0048

Q2_0 is effectively lossless for ternary weights — the ternary values land exactly on three of the four 2-bit code points.

Benchmarks

Evaluated with EvalScope v1.4.2 + vLLM 0.15.1 on NVIDIA H100. Full benchmark suite:

ModelSizeAvgMMLU-RMuSRIFEvalGSM8KHE+BFCLv3
Ternary Bonsai 1.7B0.44 GB58.4752.950.870.174.251.851.0
1-bit Bonsai 1.7B (prior)0.24 GB49.6043.245.163.066.345.134.9
Qwen3 1.7B3.44 GB66.5766.850.170.383.157.371.8
Qwen3 0.6B1.19 GB48.0247.541.562.864.130.541.7
LFM2 1.2B2.34 GB46.7352.925.477.562.236.026.4
Gemma3 1B2.00 GB45.5343.237.061.964.440.226.5
Llama 3.2 1B2.47 GB39.8847.229.247.749.035.430.8

Intelligence Density

density = -ln(1 - score/100) / size_GB
ModelSizeIntelligence Density (1/GB)
Ternary Bonsai 1.7B0.44 GB2.001
1-bit Bonsai 1.7B (prior)0.24 GB2.832
Qwen3 0.6B1.19 GB0.549
Qwen3 1.7B3.44 GB0.318
Gemma3 1B2.00 GB0.304
LFM2 1.2B2.34 GB0.269
Llama 3.2 1B2.47 GB0.206

Citation

@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}
}

Contact

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

Contributors

pashak

3 commits

prism-ml/Ternary-Bonsai-1.7B-gguf

Model

Ternary-Bonsai-1.7B-gguf

45

3 commits

2 linked in READMEs

updated Jun 10, 2026

See the code
1.58-bit
bonsai
conversational
endpoints_compatible
eval-results
gguf
llama-cpp
on-device
prismml
q2_0
ternary
text-generation

README

Bonsai

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

Ternary-Bonsai-1.7B-gguf

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

Pareto Frontier

Resources

  • 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 (prism branch, default) which adds Q2_0 support for CPU (NEON/generic) and Metal. Upstream PR coming soon.

Model Overview

ItemSpecification
Base modelQwen3-1.7B
Parameters1.72B
ArchitectureGQA, SwiGLU MLP, RoPE, RMSNorm
Context length32,768 tokens
Vocab size151,936
Weight formatGGUF Q2_0 g128: {-1, 0, +1} with FP16 group-wise scaling
Packed Q2_0 size436 MiB (0.46 GB)
Ternary coverageEmbeddings, attention projections, MLP projections, LM head
LicenseApache 2.0

Quantization Format: GGUF Q2_0 (g128)

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.

Memory

FormatSizeReductionRatio
FP163.44 GB--1.0x
GGUF Q2_0 g128436 MiB (0.46 GB)86.6%7.5x

Files in this repo

FileFormatSizeRecommended
Ternary-Bonsai-1.7B-F16.ggufFP163.44 GBbaseline / re-quantization source
Ternary-Bonsai-1.7B-Q2_0.ggufQ2_0 (g128)442 MBrecommended (lossless for ternary)

Quickstart

Build from the Prism fork

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

llama.cpp CLI

./build/bin/llama-cli \
  -m Ternary-Bonsai-1.7B-Q2_0.gguf \
  -p "Explain quantum computing in simple terms." \
  -n 256

llama.cpp server

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

Throughput (llama.cpp, Apple M4 Pro 48 GB)

BackendPP512 (tok/s)TG128 (tok/s)FP16 TG (tok/s)Speedup
Metal (GPU)2,088229603.8x
NEON CPU (10 t)508123

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

Fidelity (Q2_0 vs FP16 baseline)

Measured on wikitext-2 (20 chunks, context 512) via llama-perplexity --kl-divergence:

MetricValue
Mean KL0.000000
Top-1 agreement100.000 %
RMS Δp0.015 %
PPL ratio (Q/base)1.0048

Q2_0 is effectively lossless for ternary weights — the ternary values land exactly on three of the four 2-bit code points.

Benchmarks

Evaluated with EvalScope v1.4.2 + vLLM 0.15.1 on NVIDIA H100. Full benchmark suite:

ModelSizeAvgMMLU-RMuSRIFEvalGSM8KHE+BFCLv3
Ternary Bonsai 1.7B0.44 GB58.4752.950.870.174.251.851.0
1-bit Bonsai 1.7B (prior)0.24 GB49.6043.245.163.066.345.134.9
Qwen3 1.7B3.44 GB66.5766.850.170.383.157.371.8
Qwen3 0.6B1.19 GB48.0247.541.562.864.130.541.7
LFM2 1.2B2.34 GB46.7352.925.477.562.236.026.4
Gemma3 1B2.00 GB45.5343.237.061.964.440.226.5
Llama 3.2 1B2.47 GB39.8847.229.247.749.035.430.8

Intelligence Density

density = -ln(1 - score/100) / size_GB
ModelSizeIntelligence Density (1/GB)
Ternary Bonsai 1.7B0.44 GB2.001
1-bit Bonsai 1.7B (prior)0.24 GB2.832
Qwen3 0.6B1.19 GB0.549
Qwen3 1.7B3.44 GB0.318
Gemma3 1B2.00 GB0.304
LFM2 1.2B2.34 GB0.269
Llama 3.2 1B2.47 GB0.206

Citation

@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}
}

Contact

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

Contributors

pashak

3 commits