DL0093 Distillation vs Serving

When is distilling a large model into a small one a better strategy than serving the large model directly, for example behind a high-traffic assistant API?

Answer

Distillation wins when the recurring cost of inference, multiplied by sustained traffic, dominates the one-time cost of teacher labeling plus student training, and when the task distribution is narrow enough that the teacher’s surplus capability is never exercised. The decision is a break-even calculation: if the teacher costs $2.00 per 1k requests and an 8B student costs $0.25, and distillation costs $1,400 once (500k teacher-labeled prompts at $1,000 plus 200 GPU-hours at $400), the crossover is 800k requests, roughly 18 hours at 12 QPS. Two other conditions make distillation the only option rather than the cheapest one: a hard latency SLO that no batching strategy can meet with a 70B decoder, and a fixed memory envelope such as a phone NPU or a single 24 GB GPU, where quantization alone cannot close a 10x parameter gap. Serve the large model directly when traffic is low, when the input distribution is open-ended, or when the win is available more cheaply through quantization, speculative decoding, prompt caching, or a small-to-large cascade, since those preserve behavior and skip a new eval and re-qualification cycle. Distillation also carries a maintenance tax: every teacher upgrade reopens the labeling job, and the student inherits the teacher’s errors without the capacity to recover from them.

(1) Break-Even Volume: divide the one-time distillation cost by the per-request savings; below that volume, serving the teacher is strictly cheaper, and the payback period, not the compression ratio, is the number that decides the project.
(2) Latency Floor, Not Throughput: autoregressive decoding is memory-bandwidth bound and sequential, so per-token latency scales with parameter count and cannot be batched away; shrinking the model is one of the few levers that moves p99 rather than QPS per GPU.
(3) Task Breadth Decides Feasibility: on a stable, narrow task a student 8x smaller typically recovers 98-99% of teacher quality, while an open-ended assistant distribution loses many points because the teacher’s broad competence is exactly what is being compressed away.
(4) Hard Deployment Constraints: on-device, air-gapped, or offline targets impose a memory and power budget that no serving trick satisfies, so distillation becomes a requirement rather than an optimization.
(5) Cheaper Alternatives First: speculative decoding is distribution-preserving and needs no re-qualification, quantization is a one-line config change, and a router that sends easy traffic to a small model keeps the teacher available for the tail; distillation is the only lever that actually reduces the footprint, and it is the most expensive to maintain.

Mathematical Formulation:
Q^{*} = \frac{C_{0}}{c_{L} - c_{S}}
C_{0} = N c_{L} + C_{\text{train}}
\mathcal{L} = (1-\lambda)\mathcal{L}_{\text{CE}} + \lambda \tau^{2} \mathcal{L}_{\text{KD}}
\mathcal{L}_{\text{KD}} = \mathrm{KL}(p^{T}_{\tau} \| p^{S}_{\tau})

Where:

  • Q^{*} is the break-even request volume, the point at which cumulative distilled-serving cost equals cumulative teacher-serving cost.
  • c_{L} and c_{S} are the marginal serving costs per request for the large teacher and the small student; the difference c_{L} - c_{S} must be positive for distillation to ever pay back.
  • C_{0} is the one-time cost, composed of teacher inference over N unlabeled prompts plus student training C_{\text{train}}; engineering and eval time belong here too and usually exceed the compute.
  • \mathcal{L} is the student objective, mixing hard-label cross-entropy \mathcal{L}_{\text{CE}} with the distillation term \mathcal{L}_{\text{KD}} under mixing weight \lambda \in [0,1].
  • \tau is the softmax temperature applied to both teacher and student logits, and the \tau^{2} factor rescales the gradient so \lambda stays meaningful as \tau changes; p^{T}_{\tau} and p^{S}_{\tau} are the tempered teacher and student distributions.
  • Required condition for the whole strategy: the student must also satisfy the latency and memory constraints, t_{S} \leq \text{SLO} and m_{S} \leq m_{\max}, which no amount of traffic volume can buy.
Line chart of cumulative serving cost in dollars against cumulative requests in millions: serving the 70B teacher rises linearly at 2 dollars per thousand requests from the origin, while the distillation path starts at 1400 dollars and rises at 0.25 dollars per thousand, crossing at 800 thousand requests with the savings region shaded beyond the crossing

Figure 1: Illustrative cost curves: the distilled path carries a $1.4k fixed intercept but an eight-times shallower slope, so the break-even sits at 800k requests and every request after that is pure savings.

The break-even math is only valid if the student actually holds quality on the traffic you will receive, and that depends far more on task breadth than on the compression ratio. A single-intent classifier, a fixed extraction schema, or one product domain compresses well because the teacher’s decision boundary in that slice is simple and you can generate unlimited soft targets for it; an open-ended assistant does not, because the surplus capacity is the product. When breadth is the problem, a cascade is usually the better answer than a bigger student: route every request to the distilled model, escalate the tail flagged by a confidence or verifier signal to the teacher, and you capture most of the cost win while keeping the quality ceiling. Whatever you choose, budget for the maintenance tax, since a teacher upgrade invalidates the student, drifting inputs silently move outside the distilled distribution, and you now own two eval suites instead of one.

Semi-log chart of percentage of teacher quality retained against student parameter count from 0.5B to 70B, showing a narrow single-domain task staying above the 98 percent floor from about 1B upward while an open-ended assistant task falls to roughly 71 percent at 1B and only reaches the floor near 20B

Figure 2: Illustrative quality retention: on a narrow task a 1B student already clears a 98% floor, while the same student on open-ended traffic gives up roughly 27 points, which is why breadth, not the compression factor, gates the decision.

PropertyDistill to a small studentServe large + quantizationServe large + speculative decoding
Memory footprint8-20x smaller, can drop from 8 GPUs to 1 or to a phone2-4x smaller weights, KV cache mostly unchangedSlightly larger, the drafter is an extra resident model
Quality guaranteeNone, must be re-measured per task; tail regressions are commonSmall measurable drift, worse at 4-bit and on long contextDistribution-preserving, output matches the teacher exactly
Typical latency gain4-6x on per-token latency, the largest available lever1.5-2.5x, bounded by bandwidth saved on weights2-3x at low batch, degrades as batch size grows
One-time costLabel generation, training runs, a new eval harnessCalibration pass plus a quality spot-checkServing-stack work, no retraining of the target model
Cost when the teacher is upgradedFull re-distillation and re-qualificationRe-run calibration onlySwap the target, optionally refresh the drafter
Wins whenHigh sustained traffic, narrow task, or a fixed device budgetYou need a fast, low-risk cost cut on broad trafficLatency matters, batches are small, and quality cannot move

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *