A ternary neural network is a neural network whose weights, and sometimes activations, are restricted to three values: minus one, zero and plus one, usually multiplied by a shared floating-point scaling factor. The technique, also called ternary quantization, stores each weight in about 1.58 bits of information and replaces most multiplications with additions, subtractions and skips.
In edge AI, ternary networks matter because memory size, memory bandwidth and energy per operation limit what phones, microcontrollers and embedded accelerators can run. Ternary weights offer a middle ground between binarized networks and 4-bit quantization: far smaller than 8-bit models, yet noticeably more accurate than networks with only two weight values, because the zero value adds sparsity and expressiveness.
How ternary quantization maps weights
Ternary quantization maps each full-precision weight to one of three levels using a threshold rule. Weights whose magnitude falls below a threshold become zero; larger positive weights become plus one and larger negative weights become minus one. A scaling factor, often computed per layer or per channel, restores the approximate magnitude of the original weights.
A widely used heuristic from early work on ternary weight networks sets the threshold to roughly 0.7 times the mean absolute weight of a layer, and sets the scale to the mean magnitude of the weights that remain nonzero. The more recent absmean scheme used in BitNet b1.58 divides weights by their mean absolute value and rounds to the nearest of the three levels.
The table below compares the main ternarization schemes and what each one learns or fixes.
| Scheme | Threshold | Scaling factors | Notes |
|---|---|---|---|
| Ternary weight networks | Fixed fraction of mean magnitude | One symmetric scale per layer | Simple, closed-form approximation |
| Trained ternary quantization | Fixed fraction of maximum weight | Separate learned positive and negative scales | Higher accuracy, extra parameters |
| Absmean ternarization | Implicit through rounding | Mean absolute value per tensor | Used for training language models from scratch |
| Per-channel ternarization | Computed per output channel | One scale per channel | Better fit for convolutional layers |
Training ternary networks
Ternary networks are almost always trained with quantization-aware training rather than converted after training, because rounding a pretrained model directly to three levels usually causes a large accuracy drop. During training, the network keeps latent full-precision weights, quantizes them in the forward pass and updates the latent copy in the backward pass.
Since the rounding function has a zero gradient almost everywhere, training relies on the straight-through estimator, which passes gradients through the quantizer as if it were the identity function within a clipping range. Practitioners often keep the first and last layers in higher precision, because these layers are small but disproportionately sensitive to quantization error.
Activation precision is a separate choice. Fully ternary networks also ternarize activations, but many practical systems pair ternary weights with 8-bit activations, which preserves accuracy while still eliminating weight multiplications.
Ternary networks compared with other low-bit formats
Ternary networks sit between binary and multi-bit integer formats on the trade-off curve of size, speed and accuracy. The comparison below assumes weight quantization with comparable training effort; exact accuracy depends strongly on architecture, task and model size.
| Format | Weight values | Storage per weight | Main arithmetic | Typical accuracy impact |
|---|---|---|---|---|
| FP16 | Continuous | 16 bits | Floating-point multiply | Reference |
| INT8 | 256 levels | 8 bits | Integer multiply | Usually negligible |
| 4-bit | 16 levels | 4 bits | Integer multiply or lookup | Small with good calibration |
| Ternary | Three levels | About 1.6 to 2 bits | Add, subtract or skip | Moderate, smaller with training |
| Binary | Two levels | 1 bit | XNOR and popcount | Often large |
The zero level is the decisive difference from binarized networks. It lets the network express that an input is irrelevant, it typically makes a substantial share of weights exactly zero, and hardware can skip those operations entirely, combining quantization with model sparsity.
Storage and hardware efficiency
The storage gain of a ternary network depends on how the three values are packed. The theoretical minimum is log base 2 of 3, or about 1.58 bits, but practical kernels use simpler encodings that trade a little space for faster decoding.
| Packing method | Bits per weight | Decoding cost | Typical use |
|---|---|---|---|
| Two-bit codes | 2.0 | Very low | General CPU and GPU kernels |
| Five trits per byte | 1.6 | Low to moderate | Memory-bound inference |
| Sparse index format | Varies with sparsity | Moderate | Highly sparse layers |
| Lookup-table kernels | About 1.6 to 2 | Low after table setup | CPU inference of large models |
On general-purpose processors, the main benefit is reduced memory traffic, which dominates energy use in many edge workloads. On custom accelerators and FPGAs, ternary arithmetic also removes multipliers, enabling much smaller and lower-power compute units. Mainstream mobile NPUs, however, are optimized for INT8 and INT4, so ternary models may need specialized kernels to realize their theoretical advantage.
Limitations and common mistakes
The most common mistake is expecting post-training ternarization to work like INT8 conversion; without retraining, accuracy often collapses. Other pitfalls concern measurement and deployment rather than the quantizer itself.
- Ignoring activations: ternary weights with 16-bit activations save memory but not most compute.
- Reporting theoretical speedups: gains vanish if the runtime unpacks weights to FP16 before computing.
- Ternarizing every layer: sensitive layers such as embeddings and classifiers often need higher precision.
- Small models suffer most: accuracy gaps tend to shrink as model size grows, but remain notable for compact networks.
- Toolchain gaps: few standard edge inference runtimes support ternary operators natively.
Understanding it simply
A normal neural network stores millions of precise numbers. A ternary neural network keeps only three choices for each one: minus one, zero or plus one. That is like replacing a detailed volume dial with a switch that says down, off or up.
This makes the model much smaller and cheaper to run. The device mostly adds and subtracts instead of multiplying. Some accuracy can be lost, so the network is trained with this limit from the start.
Applied in practice
An engineering team builds a battery-powered wildlife camera that must recognize ten animal species on a microcontroller with 512 KB of SRAM and 2 MB of flash. Their 8-bit convolutional model needs about 1.4 MB of weights and drains the battery in roughly three weeks of continuous sensing.
The team retrains the network with ternary weights and 8-bit activations, keeping the first convolution and the final classifier in 8 bits. Weights shrink to about 0.4 MB, and about 45 percent of them become zero, which the custom kernel skips.
Validation accuracy falls from 91.8 to 90.6 percent, which the team accepts. Because memory reads and arithmetic both drop sharply, measured energy per inference falls by more than half, and the camera now runs for about seven weeks on one battery pack.