The efficiency problem
Training GPT-3 cost approximately $4.6 million in compute at 2020 prices. A single inference call on a 175B parameter model requires about 350 GB of GPU memory to hold the weights in FP16. Deploying a frontier model naively means either renting a server with eight A100s per user session or waiting seconds per token.
The efficiency research field emerged to solve this. Its central question: can we achieve 90% of a large model’s quality at 10% of its cost? The answer, increasingly, is yes — through a combination of knowledge distillation, quantization, pruning, parameter-efficient fine-tuning, and inference-time optimizations.
Knowledge distillation: teacher to student
The key insight behind knowledge distillation is that a large model’s output probabilities contain more information than one-hot hard labels.
When a teacher model assigns probabilities [cat: 0.7, lynx: 0.2, dog: 0.05, fish: 0.03, car: 0.02] to an image of a cat, those soft probabilities reveal something hard labels cannot: that cats and lynxes are more similar than cats and cars. A student model trained on these soft targets learns class relationships, not just the correct label.
The distillation loss combines:
- Hard loss — cross-entropy with the true one-hot labels (standard supervised loss)
- Soft loss — KL divergence between student and teacher outputs at temperature T, scaled by T²
L = (1−α)L_hard + αT²L_soft
The temperature T controls how much the soft targets spread. At T=1 the teacher’s softmax is used directly. At T=5 the distribution flattens, exposing more inter-class similarity information. At T=10 the distribution is nearly uniform — useful entropy but weaker signal about the most likely class.
DistilBERT compressed BERT by 40% while retaining 97% of its performance on GLUE benchmarks. Llama 3 8B, trained on more data, distils the understanding of Llama 3 70B into a model that runs on a MacBook.
Quantization: fewer bits per weight
Quantization reduces the numerical precision used to store model weights, reducing memory and often improving inference throughput.
Standard training uses FP32 (32-bit float) or BF16 (16-bit bfloat). Quantization compresses these to:
- INT8 — 8-bit integer; 4× smaller than FP32; near-zero accuracy loss for most models when done carefully.
- INT4 — 4-bit integer; 8× smaller; requires careful calibration. Llama 3 70B in 4-bit fits on two consumer GPUs (48GB total).
- 2-bit/1-bit — research territory; significant accuracy degradation for most tasks.
Two approaches dominate:
- Weight-only quantization (GPTQ, AWQ) — weights are stored as INT4/INT8 and dequantized to FP16 before matrix multiplication. Memory is saved; compute is not reduced (the GPU still multiplies in FP16). Minimal accuracy loss because weights are relatively smooth.
- Activation quantization (SmoothQuant, LLM.int8()) — both weights and runtime activations are quantized. Faster inference (INT8 matrix multiplication) but harder to calibrate, because activations have outlier channels that compress poorly without normalization tricks.
The practical recipe for deployment: GPTQ or AWQ for 4-bit weight quantization, with per-channel scaling. This makes a 70B model accessible on a consumer workstation.
Pruning: removing redundant parameters
Pruning removes parameters that contribute little to the model’s output. The two flavors differ in what gets removed:
- Unstructured pruning — zero out individual weights below a threshold. Up to 90% of weights can be zeroed without significant accuracy loss (the “lottery ticket hypothesis” shows that most weights are redundant). But sparse weight matrices are hard to accelerate on modern GPUs, which are optimized for dense matrix multiplication.
- Structured pruning — remove entire attention heads, layers, or feed-forward neurons. The resulting model is smaller and genuinely faster. Removing the bottom 20% of attention heads (by importance score) typically costs 1–3% accuracy. Removing entire transformer layers (layer dropping) can reduce inference latency 30–40% at 5–10% accuracy loss.
The lottery ticket hypothesis (Frankle & Carlin, 2019): a randomly initialized dense network contains a sparse sub-network that, if trained in isolation from the start, would match the full network’s accuracy. This suggests most of the capacity in large models is never needed.
LoRA: low-rank adaptation
LoRA (Hu et al., 2021) makes fine-tuning feasible on consumer hardware by freezing the pre-trained weight matrix W⊂0; and learning only a low-rank update:
W = W⊂0; + BA where B ∈ ℜd×r, A ∈ ℜr×k, r ≪ min(d,k)
For a 4096×4096 weight matrix with r=8, LoRA trains 2×4096×8 = 65,536 parameters instead of 4096² = 16.7M — a 256× reduction in trainable parameters.
The hypothesis is that weight updates during fine-tuning lie in a low-dimensional subspace (low intrinsic rank). LoRA exploits this: the full matrix update is approximated by the product of two small matrices that together capture the task-relevant adaptation.
At inference time, BA is added to W⊂0; once and the merged matrix is used normally — no overhead versus the base model. Multiple LoRA adapters for different tasks can be hot-swapped by subtracting one BA and adding another.
Parallel training
Training a 70B model on a single GPU would take centuries. Modern training distributes work across hundreds or thousands of GPUs using three forms of parallelism:
- Data parallelism — each GPU holds a complete model copy and processes a different mini-batch. Gradients are averaged across GPUs with AllReduce. Scales to thousands of GPUs but requires fitting the full model on each.
- Tensor parallelism — split individual weight matrices across GPUs. Each GPU computes a shard of each matrix multiplication. Communication happens within every forward pass (expensive for small batch sizes).
- Pipeline parallelism — split the model across GPUs by layer group. GPU 0 runs layers 0–15, GPU 1 runs 16–31, etc. Communication happens between stages (bubbles in the pipeline reduce efficiency).
The ZeRO optimizer (Zero Redundancy Optimizer) eliminates redundancy in data-parallel training by sharding optimizer states, gradients, and parameters across GPUs instead of replicating them. ZeRO-3 reduces per-GPU memory proportional to the number of GPUs, enabling 175B model training on commodity clusters.
Inference optimization
Even after compression, the autoregressive generation loop is slow: each token requires a full forward pass through the model. Three techniques attack this:
- KV-cache — attention keys and values computed for previous tokens are cached and reused. Without it, every generation step recomputes keys and values for the entire context. The KV-cache trades memory for speed; at 128K context length in a 70B model, the cache itself can be 60+ GB.
- Flash Attention — reorders matrix multiplication and softmax to minimize reads from slow GPU global memory. Identical numerical output to standard attention but 2–4× faster and O(n) memory versus O(n²). Standard in all modern LLM training and inference.
- Speculative decoding — a small fast draft model generates k tokens, then the large model verifies all k in one parallel forward pass. Accepted tokens are kept; rejected tokens are resampled. Achieves 2–4× speedup when the draft model is accurate, with mathematically identical output distribution to the target model alone.
The efficiency frontier
The combination of these techniques has dramatically moved what is possible on commodity hardware:
| Model | Params | MMLU Score | Runs on |
|---|
| GPT-3 | 175B FP16 | 70.1 | 8× A100 80GB |
| Llama 3 70B (INT4) | 70B INT4 | 79.5 | 2× RTX 4090 |
| Mistral 7B | 7B BF16 | 64.2 | RTX 3090 (single) |
| Phi-3 Mini | 3.8B BF16 | 69.0 | RTX 3060 (single) |
The frontier is not GPT-4 versus GPT-2. It is a well-trained 7B model versus an early 175B model — and the 7B wins on several benchmarks while fitting on a laptop GPU.
Recap
- Distillation transfers knowledge from a large teacher to a small student via soft probability targets at temperature T.
- Quantization (GPTQ, AWQ) stores weights in INT4 — 8× memory reduction with minimal accuracy loss.
- Pruning removes redundant weights or entire attention heads; structured pruning is hardware-friendly.
- LoRA fine-tunes with a low-rank matrix product, reducing trainable parameters by 100–1000×.
- Speculative decoding uses a draft model to batch-verify token sequences, achieving 2–4× inference speedup.