{"slug": "ternary-weights-compression-and-efficient-intelligence", "title": "Ternary Weights, Compression, and Efficient Intelligence", "summary": "A technical analysis of low-bit quantization for local LLM inference reports that ternary GGUF checkpoints for a 27B-parameter dense model shrink on-disk weights to 5.95 GB (PTQ1_0) and 7.21 GB (PQ2_0), versus roughly 54.0 GB in BF16 and 21.92 GB for a mixed NVFP4+FP8 build, per HIP-0904 from hanzoai. The analysis attributes the gains to batch-1 autoregressive decode being memory-bandwidth-bound, where throughput is capped by memory bandwidth divided by active model bytes, so cutting bytes per weight speeds decode directly while prefill still requires fast tiled matrix kernels. It also flags remaining kernel and accuracy limitations for 1.58-bit ternary weights and 1-bit BitDelta compression on Apple Silicon, NVIDIA GB10 and AMD Strix Halo (gfx1151).", "body_md": "# Ternary Weights, Compression, and Efficient Intelligence\n\nWhy autoregressive LLM decode is memory-bandwidth-bound, how 1.58-bit ternary weights and 1-bit BitDelta compression shrink memory traffic on Apple Silicon, GB10, and Strix Halo, and the real kernel and accuracy limits we still have to solve.\n\n## On this page\n\nIf you want to understand why frontier intelligence is escaping hyperscale datacenters onto local unified-memory workstations, ignore peak TFLOPs on GPU spec sheets and look at one number instead: **memory bandwidth**.\n\nDuring interactive token generation (batch-1 autoregressive decode), a transformer is almost never compute-bound. It is starved waiting for weights to stream out of memory. Low-bit quantization—pushing from 16-bit floats down through 4-bit formats (`NVFP4`, `MXFP4`, `Q4_K`, `AFQ4`) toward **1.58-bit ternary weights (`{-1, 0, +1}`)** and **1-bit behavioral deltas (` BitDelta`)**—directly attacks that physical bottleneck.\n\nHere is the first-principles physics, what `hanzoai/engine` and `zenlm` actually ship on local unified-memory hardware today, and an honest accounting of the kernel and accuracy limitations that remain.\n\n## 1. The roofline physics of LLM inference\n\nGenerating a single output token at batch size 1 requires reading every active weight matrix from DRAM or HBM into registers once and performing roughly **2 floating-point operations** (one multiply, one accumulate) per parameter.\n\n- In **BF16 / FP16** (2 bytes per parameter), that yields an arithmetic intensity of roughly**1 FLOP per byte** .\n- Modern accelerators—Apple Silicon unified memory, NVIDIA GB10, AMD Ryzen AI Max+ 395 (\"Strix Halo\", `gfx1151` ), and datacenter H100s—have compute-to-bandwidth ridge points of tens to hundreds of FLOPs per byte.\n\nBecause `1 FLOP/byte` sits far to the left of the hardware ridge point, decode throughput is bounded directly by:\n\n```\ndecode_tok_per_s  <=  memory_bandwidth_bytes_per_s / active_model_bytes\n```\n\nPrefill behaves differently: processing a 4,096-token prompt multiplies each weight across thousands of tokens in parallel, raising arithmetic intensity by orders of magnitude and flipping execution into the **compute-bound** regime. That split is the defining engineering tension of low-bit inference: **cutting bytes per weight speeds up decode immediately, while prefill demands fast tiled matrix kernels so unpacking does not stall compute.**\n\nLook at the real artifact sizes for a single **27B-parameter dense architecture** (`Qwen3.8-27B` family), verified directly from the file manifests in **[HIP-0904](https://github.com/hanzoai/hips/blob/main/HIPs/hip-0904-zen6.md)** (*Zen6 — Dense, Coder and Ternary Checkpoints*):\n\n| Representation | Verified checkpoint / artifact | On-disk weight size | Relative to BF16 (~54 GB) | Notes from `HIP-0904` &`hanzoai/engine` | \n|---|---|---|---|---|\n| Dense BF16 baseline | 27B params × 2 bytes | ~54.0 GB | `1.00×` | Exceeds 32–48 GB laptops; saturates decode bandwidth | \n| Mixed **NVFP4 + FP8** | `zenlm/zen6` (3 safetensors shards,`HIP-0904` §2) | **21.92 GB** | `0.41×` | 193 NVFP4 modules + 208 FP8 attention modules; packed 4-bit loads in ~31 GB RAM vs. ~104 GB dequant-at-load | \n| Ternary GGUF **`PQ2_0`** | `Ternary-Bonsai-2-27B-PQ2_0.gguf` (`HIP-0904` §4) | **7.21 GB** | **`0.13×`** | 402 GGML type-142 tensors + Walsh–Hadamard pre-rotation ( `block 1024` ) | \n| Ternary GGUF **`PTQ1_0`** | `Ternary-Bonsai-2-27B-PTQ1_0.gguf` (`HIP-0904` §4) | **5.95 GB** | **`0.11×`** | Sub-6 GB footprint for a 27B-class dense backbone | \n\nDropping a 27B backbone from ~54 GB to 6–7 GB does two things at once: it fits comfortably inside consumer unified memory with room left for long-context KV caches, and it reduces the memory bytes streamed per generated token by roughly an order of magnitude.\n\n## 2. How ternary weights (`{-1, 0, +1}`) and 1-bit deltas work\n\nA binary weight (`{-1, +1}`) carries 1 bit of information per parameter, leaving no way to zero out an inactive connection. Adding zero produces a **ternary alphabet `{-1, 0, +1}`**, carrying `log2(3) ≈ 1.585` bits of entropy per weight (popularized in BitNet b1.58).\n\nIn a ternary linear layer, each weight block is scaled by a shared high-precision factor `γ`, and each element `w_ij` takes a value in `{-1, 0, +1}`. The inner dot product with an activation vector `x` changes character completely:\n\n```\nStandard FP16 GEMV:   y_i = sum_j ( w_ij * x_j )              // multiply-accumulate\nTernary GEMV:         y_i = gamma * sum_j ( s_ij ? x_j : 0 )  // conditional add / subtract / skip\n```\n\nTwo properties make ternary compression compelling for systems engineering:\n\n1. **No floating-point multipliers in the inner loop:** Multiplication collapses into integer addition, subtraction, or zero-skipping—cutting both memory traffic and arithmetic energy per token when hardware or SIMD kernels natively exploit it.\n2. **Packing density + outlier rotation:** Five ternary trits have`3^5 = 243 < 256` states, so five weights pack cleanly into a single byte (`1.6 bits/weight` before block-scale overhead). Because real transformer weights contain outlier channels that distort aggressive quantization, modern ternary checkpoints—like`zenlm/zen6-flash` (`Ternary-Bonsai-2-27B-PQ2_0` ) documented in`HIP-0904` §4—apply an orthogonal**Walsh–Hadamard pre-rotation** (`prism.hadamard.*` , block size`1,024` ) across 401 weight matrices to spread outlier energy uniformly before quantizing.\n\nThis sits on the exact same compression continuum as **BitDelta**, which we already ship in `hanzo-quant` and documented in [BitDelta: Serving 14 Zen Models from One GPU Cluster](https://hanzo.blog/2026-02-28-bitdelta-multi-tenant/). BitDelta keeps a shared base model and compresses each fine-tuned variant's behavioral delta (`Δ = W_ft - W_base`) into 1-bit signs plus a per-matrix scale `α` (`W_ft ≈ W_base + α · sign(Δ)`)—cutting 14 fine-tuned 70B variants from ~1.96 TB to ~262 GB. Ternary weights push extreme compression down from the fine-tuning delta into the **base weights themselves**.\n\n## 3. What `hanzoai/engine` runs on unified-memory hardware today\n\nUnified-memory machines—Apple Silicon Macs, NVIDIA GB10 (`spark`), and AMD Strix Halo (` evo`, Ryzen AI Max+ 395 / Radeon 8060S iGPU, `gfx1151`)—give local models a single large pool of GPU-accessible memory (64 GB to 512 GB) without PCIe offload penalties.\n\nHere is what `hanzoai/engine` actually implements in production source today (`docs/QUANTS.md`, `hanzo-quant/src/lib.rs`, and `docs/src/content/docs/guides/perf/rocm-apu-gguf.md`):\n\n- **AMD Strix Halo (`gfx1151`, ROCm):****22 native-resident GGUF quant types** decode directly in quantized form (no dequant-to-FP16 round trip) through a single templated compute core (`qmatvec_core<WTYPE, XT>` and`qdp4a<WTYPE>` ), verified bit-exact (`nbad=0` ) against the CPU reference oracle:\n  - K-quants: `Q2_K` ,`Q3_K` ,`Q4_K` ,`Q5_K` ,`Q6_K` (`int8 dp4a` )\n  - Legacy quants: `Q4_0` ,`Q4_1` ,`Q5_0` ,`Q5_1` ,`Q8_0` ,`Q8_1`\n  - I-quants: `IQ1_S` ,`IQ1_M` ,`IQ2_XXS` ,`IQ2_XS` ,`IQ2_S` ,`IQ3_XXS` ,`IQ3_S` ,`IQ4_XS` ,`IQ4_NL` (codebook`int8 dp4a` /`sudot4` )\n  - **Ternary quants: `TQ1_0`, `TQ2_0`** (scalar native-resident decode)\n- K-quants: \n- **Apple Silicon (Metal):****AFQ** (2, 3, 4, 6, and 8-bit MLX-native affine quantization) alongside GGUF and In-Situ Quantization (ISQ).\n- **NVIDIA CUDA / GB10:** Native packed**NVFP4** (register-resident E2M1 codebook for decode, tensor cores for prefill),**MXFP4** , 4- and 8-bit Marlin kernels (GPTQ/AWQ), FP8, and GGUF.\n- **Compounding with Sparse Mixture-of-Experts (MoE):** Low-bit weights multiply directly with parameter sparsity. For example,`zenlm/zen6-coder` (`HIP-0904` §3) is a 512-expert architecture activating 10 experts per token, packaged in Unsloth imatrix`IQ4_XS` across three GGUF splits totaling**93.68 GB** —meaning a large sparse coding model fits entirely inside a 128 GB unified-memory workstation while touching only a small active parameter slice per token.\n\n## 4. Honest limitations: what ternary quantization does NOT solve yet\n\nLow-bit and ternary inference is a genuine systems breakthrough, not free lunch. Four real engineering constraints govern where we deploy it today—and where we do not:\n\n1. **Kernel maturity and decode-only gaps:** Inspecting`hanzo-quant/src/lib.rs` (line 919) and our ROCm APU docs shows the current reality plainly:`TQ1_0` ,`TQ2_0` ,`IQ*` , and`Q1_0` are**decode-only** formats (not ISQ load-time quantization targets). On`gfx1151` ,`TQ1_0` /`TQ2_0` still run through the**scalar** matvec path rather than`int8 dp4a` or`WMMA` tensor cores, and decode-only formats must**dequantize to FP16 during prefill** . Custom codecs like`HIP-0904` 's`PQ2_0` (GGML type 142 with Walsh–Hadamard pre-rotation) require explicit loader and rotation-kernel support before the weights produce valid tokens at all.\n2. **Prefill stalls without tiled kernels:** As we showed openly in[How We Benchmark Hanzo](https://hanzo.blog/how-we-benchmark-hanzo/) , a missing tiled prefill kernel caused a`0.141×` prefill slowdown on`qwen3.8-27b` ROCm FP4 (`49.4 tok/s` vs.`349.7 tok/s` ) even when the model loaded cleanly. Long-context agent prompts require fast tiled prefill*and* fast decode.\n3. **Training dynamics and post-training fragility:** Native 1.58-bit training (Quantization-Aware Training) still requires full-precision shadow master weights, Straight-Through Estimators (STE), and sensitive learning-rate schedules—you do not get 1.58-bit training memory savings automatically. Post-training ternary compression (PTQ) avoids retraining cost but degrades sharply unless paired with orthogonal rotations (Hadamard) and careful calibration.\n4. **Dense factual recall and reasoning tails:** Compressing every weight below 2 bits preserves syntax, tool-call structure, and local code transformations far better than it preserves high-entropy parametric facts (obscure API signatures, dense multilingual trivia, long multi-step formal derivations). Furthermore, as`HIP-0904` §6 states explicitly, upstream model cards for ternary checkpoints often publish unverified speedups and retention numbers without receipts. Until a ternary checkpoint passes a prospectively frozen`HIP-1403` accuracy gate and a quiet-box`dossier.sh` throughput run, we treat its headline claims as unverified hypotheses.\n\n## 5. Where ternary fits in the real stack\n\nThe right way to deploy ternary and sub-4-bit models is not as a fragile solo replacement for frontier reasoning. It is as the **high-speed local and edge execution tier** inside a hybrid system:\n\n- **Pair with hybrid retrieval (`/v1/knowledge`, `/v1/search`)** so high-entropy facts live in inspectable tenant documents rather than fighting for capacity inside 1.58-bit weights.\n- **Pair with Enso's adaptive router (`adaptive_route.go`)** so routine tool continuations and local drafts run at near-zero marginal cost on local unified memory, while genuine deadlocks, formal proofs, or hard multi-step failures escalate cleanly to deeper cloud tiers.\n- **Qualify every checkpoint through `HIP-1403` and `dossier.sh`** before it earns a production route.\n\nCompression changes the physics of who can afford intelligence. Verification ensures that cheaper intelligence stays trustworthy.\n\nRead the rest of this series:\n\n## Read more\n\n### Unfettered Intelligence: Local Hardware, Decentralized Compute, and the Open Personal & Business OS\n\nWhen a single closed provider controls the model behind your research and software, you inherit opaque rules you cannot audit or pin. Open weights on local unified memory, decentralized compute networks, and an open Personal, Business, and Creative OS put intelligence back under user control.\n\n### What a Million Tokens Actually Costs Hanzo\n\nInside Hanzo's inference unit economics: 4-class token billing, per-thread adaptive tier shifting in adaptive_route.go, NVIDIA NIM + 1M OpenRouter frontier ladders, and the honest trade-offs of upstream capacity vs. local hardware.\n\n### Kai 1: Decisions, Not Completions\n\nKai is Hanzo's decision model, served by the Hanzo API. Give it explicit state and a listed question, and it returns a typed, calibrated answer — a choice, a score, a yes/no, or a reasoned deferral.", "url": "https://wpnews.pro/news/ternary-weights-compression-and-efficient-intelligence", "canonical_source": "https://hanzo.blog/ternary-weights-and-efficient-intelligence/", "published_at": "2026-11-29 00:00:00+00:00", "updated_at": "2026-11-29 20:46:48.997132+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "machine-learning", "ai-research"], "entities": ["hanzoai", "zenlm", "HIP-0904", "Qwen3.8-27B", "Ternary-Bonsai-2-27B-PQ2_0", "Ternary-Bonsai-2-27B-PTQ1_0", "Apple Silicon", "NVIDIA GB10"], "also_reported_by": [], "takeaway": "Ternary GGUF checkpoints cut a 27B dense model from ~54.0 GB in BF16 to 5.95 GB (PTQ1_0) and 7.21 GB (PQ2_0), roughly 0.11x and 0.13x the size, which directly raises batch-1 decode throughput because tokens per second are bounded by memory bandwidth divided by active model bytes.", "recommendation": {"advice": "For bandwidth-bound batch-1 decode, quantize weights to ternary GGUF (PTQ1_0/PQ2_0) to cut streamed bytes roughly 9-10x, but keep fast tiled kernels for prefill where unpacking can stall compute.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/ternary-weights-compression-and-efficient-intelligence", "markdown": "https://wpnews.pro/news/ternary-weights-compression-and-efficient-intelligence.md", "text": "https://wpnews.pro/news/ternary-weights-compression-and-efficient-intelligence.txt", "jsonld": "https://wpnews.pro/news/ternary-weights-compression-and-efficient-intelligence.jsonld"}}