Three more techniques to make production models smaller and faster
Pruning
Pruning zeros out weights judged unimportant (by magnitude or by a structured rule). Two flavors:
- Unstructured — zero individual weights. Theoretically reduces flops but most hardware doesn't speed up sparse matmul, so the practical wins are modest.
- Structured — remove whole channels / heads / blocks. Fewer params AND fewer flops AND smaller activations. Where the practical wins are.
Pruning + quantization compose well. Pruning + distillation (train a smaller student from the pruned teacher) compose even better.
Knowledge distillation
Train a small "student" model to match the soft predictions of a large "teacher" model. The student learns from the teacher's logits, not just the hard labels — which carry more information ("this is mostly cat but a little fox"). The standard recipe:
- Run teacher on the input — get soft logits.
- Run student on the input — get its logits.
- Loss = α · KL(student / T || teacher / T) · T² + (1 − α) · CE(student, hard_label)
where T is the "temperature" (typically 2-8) that softens both distributions, and α weights soft vs hard targets.
Benchmarking — your honest report card
Every optimization claim deserves a benchmark. Measure latency at the actual batch size you'll deploy with, on the actual hardware, with the actual input distribution. Anecdotal speedups don't survive contact with production.