Every Weight Is a Path of Shared Discrete Decisions
Organizations: LEAD Lab, ITMO University
Abstract
We introduce TWIG (Tree-structured Weights with Inherited Gates), a representation in which every weight of a neural network is the end of a path of small discrete decisions: a sign, a shift by a power of two, a zero gate, an index into a shared table. Weights that belong together share the upper part of their paths, and each decision is inherited by every weight below it, so it is stored once and applied once. This simple change has three consequences. Any trained network can be written as a TWIG, and when the decisions are powers of two its weight layers become circuits made almost entirely of wires and adders, suited to chips whose weights are fixed at fabrication. Pruning, quantization, low-rank factorization, codebooks and weight sharing become edits of one object, so a single optimizer can choose among all of them for a whole network. And choosing the decisions is the ground-state problem of a higher-order Boltzmann machine whose interactions follow the paths of the tree, the problem class that annealers and quantum optimizers are built to solve. Today these questions are handled apart: each compression method brings its own format and solver, a circuit with fixed weights needs a dedicated constant multiplier for every weight, and discrete solvers reach only narrow subproblems such as rounding. Weight formats have long been moving toward shared decisions, through group scales, shared exponents, microexponents and sparse weights; TWIG takes this trend to its end, and every common format is a shallow TWIG at no extra cost. On five weight matrices of a large language model, a flat tree whose signed power-of-two terms are chosen per weight for circuit cost, with no group scales, needs 9--15% fewer additions than GPTQ at equal layer error at 3- and 4-bit accuracy on typical matrices, and 20--55% fewer on matrices with strong outliers.
Figures & tables
| Part of the tree | In compression | In a circuit | In a Boltzmann machine |
|---|---|---|---|
| Shift state | shared exponent or scale, as in Figure 2 | a re-routing of wires | one binary unit |
| Zero state (gate) | pruning, from single weights to whole heads | a missing wire | a unit that switches off its subtree |
| Leaf alphabet | quantization grid | a sign and a shift at an adder input | a one-hot group of units |
| Sum of trees | residual correction, extra precision | one more term, one more addition | one more term in each weight |
| Product of trees | low rank, fixed rotations | two smaller circuits in sequence | units of two factors coupled together |
| Shared subtree | codebook, dictionary, cross-layer sharing | stored once; computed once when its input is shared | units shared by many weights |
| Format | Shared decisions (nodes) | Private decisions (leaves) |
|---|---|---|
| FP32, FP16, BF16, FP8 † | — | sign, exponent, mantissa (a chain of three) |
| Integers with group scale | scale per group | -bit code |
| with zero point † | scale and zero point per group | -bit code, read relative to the zero point |
| Block FP, microscaling (MX) | exponent per block | small float or integer |
| Shared microexponents (MX6, MX9), HiFloat4 | scale per block, then one or two levels of 1-bit shifts per sub-block | small float or integer |
| Ternary (BitNet b1.58) | one scale |
| Edit | What changes in the tree | Familiar name |
|---|---|---|
| Zero a state | a leaf or node state takes the value | unstructured, and structured pruning [ 43 , 29 , 23 , 70 , 54 , 95 ] |
| Shrink an alphabet | fewer states at the leaves or nodes | quantization [ 22 , 47 , 37 ] , ternarization [ 51 ] |
| Insert a shared node | a new group with a scale, shift or sign | group scales, shared exponents [ 66 ] |
| Split into a sum | low rank plus residual, additive codebooks [ 16 ] | |
| Factor into a product | or | low rank [ 84 , 74 , 91 , 93 ] , rotations [ 77 ] , butterfly [ 13 ] |
| Reference a shared part | a subtree is stored once and used many times | codebooks [ 79 , 77 , 76 ] , sparse dictionaries [ 92 ] , cross-layer sharing [ 41 , 83 , 96 , 94 ] |
| Component | As a state tree | In a circuit |
|---|---|---|
| Fully connected | a tree (or graph) for | shifts and adders; the bias is a constant input |
| Convolution | one shared subtree, referenced per position | replicated per position, or reused over time |
| Winograd / fast convolution | products with fixed shift-tree transforms | shifts and adders only |
| Attention projections | four trees; share their input | shared partial sums across |
| Attention scores, context | products of two activations | multipliers, or a separate treatment |
| Gated MLP | two trees that share their input | shared partial sums; a multiplier for the gate |
| Matrix | at GPTQ-4 error | at GPTQ-3 error | at GPTQ-2 error |
|---|---|---|---|
| layer 1, gate projection | 1.17 1.05 ( ) | 0.80 0.69 ( ) | 0.42 0.29 ( ) |
| layer 15, gate projection | 1.16 1.05 ( ) | 0.80 0.69 ( ) | 0.42 0.29 ( ) |
| layer 15, down projection | 1.16 1.05 ( ) | 0.79 0.67 ( ) | 0.41 0.27 ( ) |
| layer 30, down projection | 1.15 0.93 ( ) | 0.79 0.56 ( ) | 0.40 0.16 ( ) |
| layer 1, down projection | 1.16 0.79 ( ) | 0.80 0.36 ( ) | 0.41 0.15 ( ) |
| Reading | Setting and metric | Baseline | State tree |
| Storage and serving | BF16 weights stored exactly; bits per weight | BF16: 16 bits | 12.13 bits ( ), bit-exact |
| LLaMA-3-8B, layer 15; matrix–vector speed-up, batch 1–8 | cuBLAS (A100); PyTorch (CPU) | 1.05–1.51 ; 1.24–1.27 | |
| same matrices and batches, format alone (bound ) | our kernel on BF16 (A100) | 1.03–1.27 | |
| vLLM end-to-end serving, Llama-3.2-1B and Qwen3.5-9B; speed-up at batch 1 / 8 / 32 | vLLM, BF16 | 1.23 / 1.17–1.21 / 1.0 | |
| Compression | LLaMA-3-8B at 3.25 bits per weight, no training; perplexity on WikiText-2 / C4 / FineWeb | strongest GPTQ: 8.09 / 12.72 / 11.81 | 6.95 / 10.93 / 9.76 |
| Discrete optimization | Qwen2.5-1.5B-Instruct at 2.44 bits per weight, only states change; validation KL, GSM8K, MMLU | before tuning: 0.491, 13.95, 48.3 | 0.371, 21.83, 49.6 |
| Matrix | Batch | cuBLAS | own BF16 | tree | kernel | format | total |
|---|---|---|---|---|---|---|---|
| ( s) | ( s) | ( s) | own BF16 vs cuBLAS | tree vs own BF16 | tree vs cuBLAS | ||
| gate | 1 | 106.0 | 85.6 | 70.3 | 1.24 | 1.22 | 1.51 |
| 8 | 107.8 | 84.7 | 72.4 | 1.27 | 1.17 | 1.49 | |
| 16 | 108.9 | 86.6 | 78.4 | 1.26 | 1.10 | 1.39 | |
| 32 | 117.2 | 98.3 | 113.7 | 1.19 | 0.86 | 1.03 | |
| down | 1 | 102.8 | 89.8 | 70.9 | 1.14 | 1.27 | 1.45 |
| Codec | Implementation | Bits per pixel | Decoding (Gpixel/s) |
|---|---|---|---|
| JPEG XL, effort 9 [ 3 ] | libjxl 0.11.2, CPU | 8.66 | — |
| Ours (tree analogue) | GPU (A100), batched | 9.47 | 2.9 |
| WebP, lossless [ 64 ] | libwebp 1.6.0, CPU | 9.50 | — |
| JPEG 2000 [ 72 ] | OpenJPEG 2.5.4; GPU / CPU | 9.57 | 0.10 / 0.04 |
| HTJ2K [ 73 ] | OpenJPH 0.26.3; GPU decoding | 10.53 | 0.45 |
Neural Network Compression
Neural network compression reduces model size, memory, communication, or computation while preserving useful accuracy.
See all 217 papers