Hugging FaceAntonio Tiene, Iker García-Ferrero, Ali Hashemi, Bakbergen RyskulovProblem & solution
Making Knowledge Distillation Cheap Enough to Run at Scale
Summary
Knowledge distillation trains a smaller student to match a larger teacher's capabilities, but conventional online training keeps both models loaded and materializes full vocabulary distributions at every step, making long-context recovery expensive. The proposed system caches the teacher's top-100 logits once and introduces a fused, chunked KL-divergence loss that avoids storing the full vocabulary-by-sequence grid or the student's full logits. In benchmarks with an 8K-token context on one H200, offline fused chunked KL used 58.3GB peak memory versus 102.8GB for online training, while all four methods reached near-identical training loss. At 32K tokens, the fully chunked loss reduced isolated kernel memory from 85.2 GiB to 5.45 GiB; distilling GPT-OSS 20B at that context cut step time from 57.0 to 12.23 seconds and reduced the setup from four GPU nodes to one.
Context
Online knowledge distillation is expensive because the teacher and student must remain loaded together, the teacher is recomputed at every step, and full vocabulary-by-sequence probability tensors consume substantial VRAM. These costs make long-context recovery and large-scale experimentation difficult.
Approach / What changed
The system performs offline distillation by caching the teacher's top-100 logits per token, then trains against that reusable cache. Its fused, chunked KL loss keeps the teacher sparse, processes sequence slices incrementally, fuses the student's output projection into loss computation, discards each chunk, and recomputes chunks during backpropagation instead of storing the full logits grid.
Takeaways
Caching the teacher's top-100 logits removes the teacher from student training and allows one cache to be reused across multiple ablations.
Fused chunked KL avoids materializing the student's full vocabulary-by-sequence logits grid, reducing memory growth with sequence length; it trades this reduction for an extra output projection during backward computation.
At 32K tokens, fully chunked loss lowered isolated loss-kernel memory from 85.2 GiB to 5.45 GiB, while GPT-OSS 20B distillation fell from four GPU nodes to one and improved step time about fivefold.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.