# Ternary 27B Models: What the Weight Budget Really Buys

> Ternary weights can cut model storage sharply, but the production win depends on kernels, memory traffic, and the quality of the quantized model.

- **Author:** Uğur Akçıl (https://softwaredeveloper.biz/author/ugur-akcil)
- **Topic:** applied-ai-ml
- **Published:** 2025-12-10T13:11:41+00:00
- **Canonical URL:** https://softwaredeveloper.biz/p/ternary-27b-models-what-the-weight-budget-really-buys

## Key Thesis

A ternary weight uses one of three values, typically -1, 0, or +1, so a 27B model needs about 6.75 GB at a simple two-bit-per-weight packing, versus 54 GB in BF16. That is a storage bound, not a speed guarantee: deploy only after testing the real kernel, prompt mix, quality loss, and KV cache on target hardware.

---

## The useful meaning of “ternary”

A 27B model has roughly 27 billion learned parameters. If its weights are stored in BF16, each parameter takes 16 bits, so the weights alone occupy about 54 GB in decimal units. A ternary representation limits each weight to one of three values, commonly -1, 0, and +1, and can reduce that storage substantially.

The simple intuition is a coarse map from a continuous value to a small alphabet. Instead of keeping a weight such as 0.0837, the model keeps a sign or zero, plus a scale that restores some magnitude. One common form is \(w \approx \alpha q\), where \(q \in \{-1,0,+1\}\) and \(\alpha\) is a scale for a group of weights.

That approximation is lossy. The important engineering question is not whether three values can represent every original weight. They cannot. It is whether the model’s predictions remain good enough after the errors accumulate across billions of parameters and many inference steps.

The name “Ternary Bonsai 2.5 27B” signals a ternary model and a parameter count, but those labels do not establish the exact packing format, scale scheme, training method, or inference kernel. Those details determine whether the theoretical memory reduction appears in a running service.

## Two bits is a useful budget, not a full runtime estimate

Three possible values contain \(\log_2(3)\), or about 1.585 bits, of information per weight in an ideal encoding. Real systems often use a convenient two-bit code, because fixed-width fields are easier to address and decode. With that simple assumption, the weight budget looks like this:

```text
27,000,000,000 weights × 2 bits / 8
    = 6,750,000,000 bytes
    = 6.75 GB, or about 6.29 GiB

BF16 comparison:
27,000,000,000 weights × 16 bits / 8
    = 54,000,000,000 bytes
    = 54 GB
```

The raw ratio is eight to one. A deployed model will use more memory than the packed weights: group scales, metadata, temporary buffers, runtime state, and possibly a less compact representation for selected layers all add overhead. If the runtime unpacks weights into a wider format before execution, the memory budget can expand dramatically.

Weight compression also does not compress the KV cache. During generation, a transformer stores keys and values from previous tokens so it does not have to recompute them for every new token. As context and concurrent requests rise, that cache can become a major share of device memory.

For scale, consider a hypothetical 32-layer model with 8 KV heads, a head dimension of 128, BF16 cache entries, and a 4,096-token context. One sequence needs about 512 MiB of KV cache. This is an illustration, not a claim about Bonsai’s architecture. More KV heads or longer contexts increase the number.

## Why smaller weights may improve decoding

During single-sequence token generation, a model often reads a large fraction of its weights to produce each next token. If the operation is limited by memory bandwidth, reducing bytes read can improve latency. At an idealized 1 TB/s of effective bandwidth, reading 6.75 GB takes 6.75 ms. Reading 54 GB takes 54 ms.

Those are lower-bound arithmetic, not serving benchmarks. Real inference also pays for kernel launches, attention, synchronization, cache misses, and imperfect hardware utilization. At higher batch sizes, weights can be reused across multiple sequences, which changes the balance between memory traffic and compute.

Ternary arithmetic can be cheaper than general multiplication. Multiplying an activation by +1 leaves it unchanged, by -1 flips its sign, and by 0 contributes nothing. But that advantage exists only if the kernel handles packed ternary values efficiently. A generic runtime that unpacks values, branches per weight, or launches several conversion kernels can surrender much of the gain.

| Metric / Approach | BF16 weights | Ternary weights, simple 2-bit packing |
|---|---:|---:|
| Bytes per weight | 2 | 0.25 |
| Weight storage for 27B | About 54 GB | About 6.75 GB |
| Arithmetic path | General multiply and accumulate | Sign, zero, and scale operations |
| Main deployment risk | Memory capacity and bandwidth | Kernel overhead and quality loss |

The table describes storage and likely mechanics, not measured performance for a particular product. A useful benchmark reports tokens per second, time to first token, peak memory, and quality under the same prompts, batch size, context length, and hardware.

## Quality loss is an operating cost

Quantization error is not evenly distributed in its effect. A small change to one weight may barely matter, while many small changes can shift an activation enough to alter the next token. Errors can compound through layers and generation steps, so a model that answers short factual prompts well may still degrade on long reasoning chains, code, or structured output.

Training matters. A model quantized after training may behave differently from one trained or fine-tuned with quantization in the loop. In quantization-aware training, the forward pass simulates low-precision weights while the optimization process adjusts parameters to tolerate that constraint. Some implementations use a straight-through estimator: the forward path applies a discrete value, while the backward path uses an approximate gradient because the true derivative of a hard threshold is unhelpful for ordinary gradient descent.

Do not treat “27B” as a quality guarantee either. Parameter count says little about training data, post-training, evaluation coverage, or how the model behaves on the work your service actually handles. Compare against a smaller BF16 model and a stronger compressed baseline using a fixed test set, not selected demos.

## The production gate

I would ask for four measurements before routing real traffic: quality on task-specific evaluations, peak memory under expected context lengths, prefill and decode latency, and sustained throughput at realistic concurrency. I would also require the exact runtime and hardware configuration, since a benchmark without its kernel path is difficult to reproduce.

Then put a cost on the result. If a ternary model cuts GPU count but adds quality-review hours, fallback calls, or longer responses, the apparent savings may disappear. For example, saving $2,000 per month in inference capacity is not compelling if frequent human review costs another 80 hours monthly at a fully loaded $75 per hour, or $6,000.

A sound decision rule is simple: adopt the model when its measured quality clears the service threshold and its end-to-end cost per accepted result improves. The 6.75 GB estimate explains why ternary weights deserve attention. Only production measurements establish whether that memory advantage survives contact with real kernels, traffic, and users.

## References

- [Hacker News: Ternary Bonsai 2.5 27B](https://prismml.com/news/bonsai-2-5-27b)
- [Ugur Akcil — Author Research & Advisory Archive](https://ugur.io)

---

## Discussion (1 notes)

- **Liam Ramirez** (Physics & CS Undergrad · UT Austin, TX · 2025-12-10): If quantization noise behaves like an additive white source, mapping to a 1.585-bit alphabet trashes the fine-grained gradient signal in early layers. How does the cumulative error scale during backprop when you freeze the ternary backbone for downstream fine-tuning?
