Efficiency and Compression Frontiers
local graph
Chapter 41 — Efficiency and Compression Frontiers
Section titled “Chapter 41 — Efficiency and Compression Frontiers”Efficiency is not a single technique but a frontier in its own right, pursued at both ends of the scale. At the top, researchers push the capability reachable per unit of compute ever higher — the trend that put frontier-class models within a small team’s reach. At the bottom, they push capable models onto phones, laptops, and edge devices through ever more aggressive compression. The meeting of these efforts — frontier capability that is also cheap, private, and runnable anywhere — is among the most directly democratizing forces in the field, and this chapter surveys the techniques driving it.
41.1 The Quality-per-Compute Frontier
Section titled “41.1 The Quality-per-Compute Frontier”The most consequential efficiency gains are not compression tricks but better recipes: architectures, data, and training methods that extract more capability from the same FLOPs. Mixture-of-Experts (Chapter 11) is the clearest example — activating 40B of 744B parameters per token buys the knowledge of a huge model at the compute of a small one. DeepSeek-V3 and GLM-5.2 are landmarks not because they are the largest models but because they are among the most capable per dollar of training, through MLA’s cheap KV cache, FP8 training (Chapter 18), aux-loss-free routing, and careful data curation. This frontier matters because it determines who can build at all: every doubling of training efficiency halves the capital required to reach a given capability, and that is what turned model-building from the exclusive domain of a few labs into something a competent team can attempt.
41.2 Quantization Beyond 4 Bits
Section titled “41.2 Quantization Beyond 4 Bits”Chapter 26 showed 4-bit quantization as the practical floor for serving. The frontier pushes lower. Research into 3-bit, 2-bit, and even binary and ternary weights asks how far precision can fall before quality collapses, and the answer keeps improving through better techniques. Quantization-aware training (QAT) — simulating low precision during training so the model learns to tolerate it — reaches lower bit-widths than post-training quantization alone, because the weights adapt to the coarser grid rather than being forced onto it afterward:
def quantize_ste(w, bits=2): # forward: round to the low-bit grid; backward: pass gradient through levels = 2 ** bits scale = w.abs().max() / (levels / 2 - 1) w_q = (w / scale).round().clamp(-(levels//2), levels//2 - 1) * scale return w + (w_q - w).detach() # identity gradient (straight-through)Python — the straight-through estimator behind quantization-aware training
The straight-through estimator is the key trick: the model sees quantized weights in the forward pass but receives gradients as if quantization were the identity, letting training adapt around the rounding. Some recent models are trained natively at very low precision from the start, suggesting the future floor is lower than today’s 4-bit norm — with enormous consequences for what runs on small hardware.
41.3 Compressing the KV Cache and the Compute
Section titled “41.3 Compressing the KV Cache and the Compute”For long contexts, the KV cache (Chapter 27) dominates memory, so compressing it is its own frontier. MLA (Chapter 12) attacks it architecturally by caching a small latent; complementary methods quantize the cache to low precision, evict tokens judged unimportant, or merge similar entries. On the compute side, speculative decoding (Chapter 28) — a small draft model proposing tokens that the large model verifies in parallel — is being pushed further through multi-token prediction (the MTP heads of Chapter 13, which GLM-5.2 improved for 20% longer acceptance) and tree-structured drafting. The unifying goal is to break the strict one-token-per-forward-pass cost of autoregressive generation, which is the single largest inefficiency in serving.
| Frontier | Lever | Payoff |
|---|---|---|
| Quality per compute | MoE, MLA, FP8, better data | cheaper to train at all |
| Sub-4-bit weights | QAT, native low precision | smaller, faster serving |
| KV-cache compression | latent cache, quantize, evict | longer context, less memory |
| Speculative decoding | draft-and-verify, MTP | faster generation |
| Distillation | small model learns from large | capability on edge devices |
| Frontier | Lever | Payoff |
|---|---|---|
| Table 41.1 — Efficiency frontiers, top to bottom | ||
41.4 The Edge Frontier
Section titled “41.4 The Edge Frontier”At the far bottom, the goal is capable models on the smallest hardware. Distillation (Chapter 26) — training a small model on a large one’s outputs, as DeepSeek-R1 did to put reasoning into dense models a fraction of its size — combines with aggressive quantization and architecture search to fit useful models on phones and single-board computers. The llama.cpp and GGUF ecosystem (Chapter 33) is the practical engine of this frontier, and the research question is how small a model can be while remaining genuinely useful — a number that keeps falling as chips improve. The stakes are not merely convenience: models that run locally are private (no data leaves the device), available offline, and free to run, which changes who can use them and for what.
Two directions, one goal Efficiency research runs in opposite directions toward the same end. Upward, better recipes raise the capability reachable per unit of compute, deciding who can build frontier models at all. Downward, compression squeezes those models onto ever-smaller hardware, deciding who can run them and where. Both have moved astonishingly fast — the same capability costs a fraction of what it did a year ago to train and to serve — and their convergence, frontier intelligence that is also cheap and local, is the quiet trend doing the most to put this technology in everyone’s hands.
41.5 Worked Example: The Speculative Decoding Speedup
Section titled “41.5 Worked Example: The Speculative Decoding Speedup”Speculative decoding (Section 27.3) is the rare optimization that is nearly free, and the arithmetic of its speedup is worth carrying. A small, cheap draft model proposes the next tokens; the large model then verifies all in a single forward pass, keeping the longest prefix that matches what it would have generated itself. Every accepted token is one the expensive model did not have to produce sequentially:
draft = small_model.generate(context, k=4) # 4 proposed tokensaccepted = big_model.verify_prefix(context, draft)context = context + accepted # keep the matching prefix# +1 free token: the big model's own next token comes with the checkPython — infer/speculative.py: draft, verify, keep prefix
Put numbers on it. If the draft model’s proposals are accepted 70% of the time over a window of four, the expected run of accepted tokens per verification is roughly 2.5, plus the one token the big model produces as part of verifying — about 3.5 tokens per expensive forward pass instead of one. That is close to a 3× reduction in large-model passes, and because the output is verified against the big model token by token, the generated text is identical to what greedy decoding would have produced: the speedup is exact, not approximate. This is why every serious serving stack (Chapter 28) and the MTP modules of DeepSeek-V3 and GLM-5.2 (Chapter 13) build speculation in.
Free speed, identical output Speculative decoding trades cheap draft-model passes for expensive target-model passes without changing the result. The speedup is set by the draft’s acceptance rate — a better-matched draft model is worth more than a faster one.
41.6 Mixture-of-Depths and Adaptive Compute
Section titled “41.6 Mixture-of-Depths and Adaptive Compute”A standard transformer spends the same compute on every token —the word “the” passes through all the layers that a hard reasoning step does. This is obviously wasteful, and mixture-of- depths attacks it by letting a router decide, per layer, which tokens are worth processing and which may skip it, allocating compute to difficulty rather than spreading it uniformly:
keep = router(x).topk(capacity).indices # tokens worth this layerout = x.clone()out[keep] = x[keep] + layer(x[keep]) # others skip the layerPython — efficiency/mod.py: per-layer token routing (illustrative)
The router selects a fixed capacity of tokens to run through each layer; the rest pass through unchanged, carried by the residual stream (Section 8.5) without paying that layer’s cost. Because the capacity is fixed, the compute per layer is bounded and predictable, but it is now directed — spent on the tokens a learned
router judges to need it. This is one of a family of adaptive-compute ideas, alongside early-exit schemes that stop processing a token once the model is confident, all chasing the same intuition: that inference cost should scale with the difficulty of what is being computed, not with a uniform architectural constant. The challenge, as ever, is training a router that allocates compute well without destabilizing the model that depends on its choices.
Spend compute where it is needed Mixture-of-depths lets easy tokens skip layers while hard ones use them all, directing a fixed compute budget by difficulty. It is the inference-time cousin of mixture-of-experts: route, don’t spread.
41.7 Extreme Low-Bit and Quantization-Aware Training
Section titled “41.7 Extreme Low-Bit and Quantization-Aware Training”Standard quantization (Chapter 26) takes models to 8 or 4 bits; the efficiency frontier pushes toward the floor — 2-bit, ternary weights restricted to {−1, 0, +1}, even 1-bit binary weights. The motivation is the enormous saving: a ternary weight carries a fraction of the memory and turns expensive multiplications into additions, which would transform the economics of both training and serving if quality survived.
At these extremes, the post-training quantization that works at 4 bits breaks down — rounding a fully-trained model to ternary loses too much. The answer is quantization-aware training (Section 26.4): build the quantization into the training loop so the model learns weights that are robust to it, adapting to the coarse representation rather than being forced into it after the fact. The surprising result from this line of work — the “BitNet”-style ternary models around 1.58 bits per weight — is that capability can hold up remarkably well when the model is trained this way from the start, far better than rounding a standard model would suggest. Whether extreme low-bit training scales to frontier sizes without unacceptable quality loss remains open, but it is among the highest-leverage bets on the efficiency frontier: if it works, it shrinks the memory and compute of every model by a large constant factor, attacking the inference cost (Section 34.6) that dominates deployment.
Train for the low bits, do not round to them Below 4 bits, post-training quantization fails; quantization-aware training learns weights robust to ternary or binary representation. BitNet-style models show capability can survive — a large-constant-factor saving if it scales.
41.8 Cross-Layer KV Sharing
Section titled “41.8 Cross-Layer KV Sharing”The KV cache that dominates long-context memory has been attacked by compression (MLA, Chapter 12) and by quantization (Section 27.10); a third lever exploits redundancy across layers. The observation is that the keys and values different layers compute are often similar to one another, which means storing a separate cache for every layer is partly wasteful. Cross-layer KV sharing computes the cache once for a group of layers and reuses it across them.
The saving is direct: share the cache across a group of layers and the cache memory for that group falls by roughly a factor of , since one set of keys and values serves where there were many. As with the other cache techniques, the trade is a modest quality cost — forcing layers to share a cache constrains them slightly — in exchange for memory that buys longer context or larger batches (Section 28.2). And crucially it composes with the others: a model can use MLA’s latent compression, quantize that latent, and share it across layers, each technique attacking the cache along a different axis and the savings multiplying. Cross-layer sharing is one more instance of the efficiency frontier’s recurring method — find a redundancy and eliminate it — applied here to the observation that depth, like sequence length and precision, contains slack that careful engineering can reclaim. The cache that once seemed an irreducible cost of long context turns out to be compressible along every dimension at once.
Adjacent layers can share one cache Different layers compute similar keys and values, so sharing the KV cache across a group of layers cuts its memory by roughly the sharing factor. It composes with MLA and quantization — each shrinking the cache along a different axis, the savings multiplying.