Extreme Quantization: Binary, Ternary & 1-bit LLMs
Pushing quantization to the limit: binary neural networks (XNOR-Net), ternary weights, BitNet, 1.58-bit LLMs, the scaling laws for extreme quantization, and when sub-4-bit models are viable.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Binary Neural Networks
- XNOR-Net: Binary Weights and Activations
- Ternary Quantization
- BitNet: 1-bit Transformer
- BitNet b1.58: Ternary LLMs
- Scaling Laws for Extreme Quantization
- Hardware Implications
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Derive binary network forward/backward passes with sign function and STE.
- Explain why XNOR replaces multiplication for binary matmul.
- Describe BitNet's training strategy for 1-bit transformers.
- Analyze the width-vs-precision tradeoff at extreme quantization.
- Evaluate when 1-bit models are practical vs. when they fail.
Notation
- — ternary weight values
- BPW — bits per weight
Core Intuition
At 1-2 bits, we're no longer "quantizing" in the traditional sense — we're fundamentally changing what weights represent. A binary weight means matrix multiplication becomes addition/subtraction (no multiplier needed). A ternary weight adds sparsity. The key insight (BitNet): if you make the model WIDER (more parameters), you can compensate for the precision loss and match FP16 quality at the same compute budget.
Binary / Ternary Quantization
Binary Neural Networks
Binary weights: .
Forward pass:
where (mean magnitude as scaling factor).
Matmul simplification: Since :
No multiplication needed — only additions and subtractions.
Training (STE):
XNOR-Net: Binary Weights and Activations
Both weights AND activations binarized:
XNOR trick: For binary values :
where .
Matmul becomes bitwise XNOR + popcount:
Speedup: 58x theoretical speedup over FP32 matmul (single XNOR + popcount vs multiply-accumulates).
Quality: 10-15% accuracy loss on ImageNet (too much for practical use in 2016, but a landmark result).
Ternary Quantization
Ternary weights: with learned threshold :
Advantages over binary:
- Zero values introduce sparsity → skip computation.
- Three levels better approximate Gaussian weight distribution.
- Much smaller quality loss than binary (2-5% vs 10-15% on ImageNet).
Bits per weight: bits (between binary and 2-bit).
BitNet: 1-bit Transformer
BitNet (Wang et al., 2023): Replace all linear layers in a transformer with binary weights:
Key modifications:
- Binary weights with mean-absolute-value scaling.
- Activations quantized to INT8 (not binary — too much quality loss).
- LayerNorm before every linear layer (stabilizes binary training).
- Larger hidden dimensions to compensate for precision loss.
Training: Standard QAT with STE from scratch. NOT post-training quantization.
Result: At same perplexity, BitNet uses 2-3x fewer FLOPs than FP16 (because the model is wider but weights are 1-bit).
BitNet b1.58: Ternary LLMs
BitNet b1.58 (Ma et al., 2024): Ternary weights :
1.58 bits: bits per weight.
Key results (3B scale):
- Matches FP16 LLaMA perplexity at same model size.
- 3.55x memory reduction.
- 2.71x faster on specialized hardware (addition-only).
- Energy: 41.2x less for matrix multiplication.
Why ternary works better than binary: The zero value introduces explicit sparsity. Feature selection (zeroing irrelevant connections) is a powerful inductive bias.
Scaling Laws for Extreme Quantization
The width-precision tradeoff:
For a fixed compute budget :
- FP16 model with width : performance .
- 1.58-bit model with width : similar performance at same compute.
Scaling law (empirical):
where is bit-width and is parameter count. Fewer bits per parameter can be offset by more parameters.
Implication: At sufficient scale, 1.58-bit models can match 16-bit models in quality while being much more efficient for inference (memory and energy).
Hardware Implications
Binary/ternary matmul: Replace multiply-accumulate with:
- Binary: XNOR + popcount.
- Ternary: Addition + subtraction (skip zeros).
No floating-point unit needed: Entire inference with integer arithmetic. Enables deployment on:
- Edge devices without FPU.
- FPGAs with lookup tables.
- Custom ASICs optimized for ternary.
Memory: 1.58-bit 70B model: GB (vs 140 GB in FP16).
Common Pitfalls
Pitfall 1. Post-training quantization to binary/ternary. This NEVER works — always catastrophic quality loss. Must train with QAT from scratch.
Pitfall 2. Keeping model width the same as FP16. A 1-bit model with the same architecture as a 16-bit model has 4-5x less effective capacity. Must increase width.
Pitfall 3. Binarizing ALL components including embeddings and LayerNorm. Keep embeddings in higher precision (INT8/FP16); LayerNorm in FP32. Only linear layer weights should be extreme-quantized.
Summary
- Binary (1-bit): ; XNOR matmul; 58x theoretical speedup; significant quality loss.
- Ternary (1.58-bit): ; add/subtract + sparsity; matches FP16 at scale.
- BitNet b1.58: State-of-the-art ternary LLM; 3.5x smaller, 2.7x faster.
- Key principle: Compensate precision with width — more parameters at fewer bits.
- Must use QAT from scratch; post-training binarization always fails.
- Hardware: Enables multiplier-free inference (addition only).
Exercises
Exercise 1. For XNOR-Net: compute the binary matmul of and using bitwise operations.
Exercise 2. For BitNet b1.58 with : compute the model size in bytes and compare to FP16 at the same .
Exercise 3. Using the scaling law (equation 10): what width should a 1.58-bit model have to match a FP16 model in quality?
Exercise 4. Derive the energy savings of ternary matmul vs FP16 matmul (hint: energy of addition vs multiplication in 45nm CMOS).
Exercise 5. Design a BitNet-style training curriculum: specify the initialization, learning rate schedule, and warmup strategy for training a 7B ternary model from scratch.