prism-ml/Ternary-Bonsai-4B-mlx-2bit

Model

Ternary-Bonsai-4B-mlx-2bit

13

4 commits

3 linked in READMEs

updated Apr 18, 2026

See the code
1.58-bit
apple-silicon
bonsai
conversational
eval-results
on-device
prismml
qwen3
safetensors
ternary
text-generation

README

Bonsai

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

Ternary-Bonsai-4B-mlx-2bit

Ternary (1.58-bit) language model for Apple Silicon

7.1x smaller than FP16 | 4.8x faster on M4 Pro | 50 tok/s on iPhone | runs on Mac, iPhone, iPad

Highlights

  • 1.05 GiB (1.13 GB) packed 2-bit size (down from 8.04 GB FP16) — runs on any Mac or iPhone
  • Ternary weights {-1, 0, +1} across embeddings, attention projections, MLP projections, and LM head
  • 70.7 avg benchmark score across 6 categories — competitive with full-precision 4B models
  • MLX-native format with group size 128 and FP16 scaling

Pareto Frontier

Resources

  • White Paper
  • Demo repo — examples for serving, benchmarking, and integrating Bonsai
  • Discord — community support and updates
  • Kernels: MLX (Apple Silicon) · mlx-swift (iOS/macOS) — 2-bit format is supported out of the box

Model Overview

ItemSpecification
Base modelQwen3-4B
Parameters4.0B (~3.6B non-embedding)
ArchitectureGQA (32 query / 8 KV heads), SwiGLU MLP, RoPE, RMSNorm
Layers36 Transformer decoder blocks
Context length32,768 tokens
Vocab size151,936
Weight formatTernary g128: {-1, 0, +1} with FP16 group-wise scaling
Packed 2-bit size1.05 GiB (1.13 GB)
Ternary coverageEmbeddings, attention projections, MLP projections, LM head
LicenseApache 2.0

Quantization Format: Ternary 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}

The information-theoretic cost is log2(3) ≈ 1.585 bits per weight, plus FP16 group scales (16 bits per 128 weights), for a theoretical minimum of ~1.71 bits/weight. This release uses the MLX 2-bit format, which stores each ternary value in 2 bits plus group scales, for an effective ~2.125 bits/weight.

Memory

FormatSizeReductionRatio
FP168.04 GB--1.0x
MLX 2-bit g1281.05 GiB (1.13 GB)85.9%7.1x

Quickstart

MLX (Python)

pip install mlx-lm
from mlx_lm import load, generate

model, tokenizer = load("prism-ml/Ternary-Bonsai-4B-mlx-2bit")

response = generate(
    model,
    tokenizer,
    prompt="Explain quantum computing in simple terms.",
    max_tokens=256,
)
print(response)

Throughput (MLX / Apple Silicon)

PlatformBackendPP512 (tok/s)TG128 (tok/s)FP16 TG (tok/s)Speedup
M4 Pro 48 GBMLX (Python)817133284.8x

iPhone 17 Pro Max (MLX Swift)

PlatformBackendPP512 (tok/s)TG128 (tok/s)4-bit TG (tok/s)Speedup
iPhone 17 Pro MaxMLX Swift65950271.8x

Benchmarks

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

ModelSizeAvgMMLU-RMuSRIFEvalGSM8KHE+BFCLv3
Ternary Bonsai 4B0.86 GB70.769.745.172.190.578.767.8
1-bit Bonsai 4B (prior)0.57 GB62.758.741.469.687.371.348.0
Qwen 3 4B8.04 GB77.179.857.480.092.174.478.9
Ministral3 3B6.86 GB73.277.556.573.191.469.571.3
Gemma 3 4B7.76 GB67.966.046.373.089.867.165.1
Llama 3.2 3B6.43 GB64.465.548.978.380.152.460.9

Intelligence Density

density = -ln(1 - score/100) / size_GB
ModelSizeIntelligence Density (1/GB)
Ternary Bonsai 4B0.86 GB1.426
1-bit Bonsai 4B (prior)0.57 GB1.744
Ministral3 3B6.86 GB0.192
Qwen 3 4B8.04 GB0.183
Llama 3.2 3B6.43 GB0.161
Gemma 3 4B7.76 GB0.146

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

Sahin-Lale

1 commits

prism-ml/Ternary-Bonsai-4B-mlx-2bit

Model

Ternary-Bonsai-4B-mlx-2bit

13

4 commits

3 linked in READMEs

updated Apr 18, 2026

See the code
1.58-bit
apple-silicon
bonsai
conversational
eval-results
on-device
prismml
qwen3
safetensors
ternary
text-generation

README

Bonsai

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

Ternary-Bonsai-4B-mlx-2bit

Ternary (1.58-bit) language model for Apple Silicon

7.1x smaller than FP16 | 4.8x faster on M4 Pro | 50 tok/s on iPhone | runs on Mac, iPhone, iPad

Highlights

  • 1.05 GiB (1.13 GB) packed 2-bit size (down from 8.04 GB FP16) — runs on any Mac or iPhone
  • Ternary weights {-1, 0, +1} across embeddings, attention projections, MLP projections, and LM head
  • 70.7 avg benchmark score across 6 categories — competitive with full-precision 4B models
  • MLX-native format with group size 128 and FP16 scaling

Pareto Frontier

Resources

  • White Paper
  • Demo repo — examples for serving, benchmarking, and integrating Bonsai
  • Discord — community support and updates
  • Kernels: MLX (Apple Silicon) · mlx-swift (iOS/macOS) — 2-bit format is supported out of the box

Model Overview

ItemSpecification
Base modelQwen3-4B
Parameters4.0B (~3.6B non-embedding)
ArchitectureGQA (32 query / 8 KV heads), SwiGLU MLP, RoPE, RMSNorm
Layers36 Transformer decoder blocks
Context length32,768 tokens
Vocab size151,936
Weight formatTernary g128: {-1, 0, +1} with FP16 group-wise scaling
Packed 2-bit size1.05 GiB (1.13 GB)
Ternary coverageEmbeddings, attention projections, MLP projections, LM head
LicenseApache 2.0

Quantization Format: Ternary 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}

The information-theoretic cost is log2(3) ≈ 1.585 bits per weight, plus FP16 group scales (16 bits per 128 weights), for a theoretical minimum of ~1.71 bits/weight. This release uses the MLX 2-bit format, which stores each ternary value in 2 bits plus group scales, for an effective ~2.125 bits/weight.

Memory

FormatSizeReductionRatio
FP168.04 GB--1.0x
MLX 2-bit g1281.05 GiB (1.13 GB)85.9%7.1x

Quickstart

MLX (Python)

pip install mlx-lm
from mlx_lm import load, generate

model, tokenizer = load("prism-ml/Ternary-Bonsai-4B-mlx-2bit")

response = generate(
    model,
    tokenizer,
    prompt="Explain quantum computing in simple terms.",
    max_tokens=256,
)
print(response)

Throughput (MLX / Apple Silicon)

PlatformBackendPP512 (tok/s)TG128 (tok/s)FP16 TG (tok/s)Speedup
M4 Pro 48 GBMLX (Python)817133284.8x

iPhone 17 Pro Max (MLX Swift)

PlatformBackendPP512 (tok/s)TG128 (tok/s)4-bit TG (tok/s)Speedup
iPhone 17 Pro MaxMLX Swift65950271.8x

Benchmarks

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

ModelSizeAvgMMLU-RMuSRIFEvalGSM8KHE+BFCLv3
Ternary Bonsai 4B0.86 GB70.769.745.172.190.578.767.8
1-bit Bonsai 4B (prior)0.57 GB62.758.741.469.687.371.348.0
Qwen 3 4B8.04 GB77.179.857.480.092.174.478.9
Ministral3 3B6.86 GB73.277.556.573.191.469.571.3
Gemma 3 4B7.76 GB67.966.046.373.089.867.165.1
Llama 3.2 3B6.43 GB64.465.548.978.380.152.460.9

Intelligence Density

density = -ln(1 - score/100) / size_GB
ModelSizeIntelligence Density (1/GB)
Ternary Bonsai 4B0.86 GB1.426
1-bit Bonsai 4B (prior)0.57 GB1.744
Ministral3 3B6.86 GB0.192
Qwen 3 4B8.04 GB0.183
Llama 3.2 3B6.43 GB0.161
Gemma 3 4B7.76 GB0.146

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

Sahin-Lale

1 commits