Walk through distilling an MoE teacher into a dense student for an edge deployment.
Your product must run on device, where hosting all experts of your MoE is impossible. The team decides to distill the MoE into a dense model matching its active parameter count. Walk through the approach and the quality ceiling you should warn stakeholders about.
Distill the MoE teacher into a dense student of active-param size on soft logits plus LM loss. Expect tail-domain regressions because specialist knowledge cannot fit into active-size capacity.
Imagine a hospital with one general doctor and a hundred specialists. Each patient sees the general doctor plus the two specialists their case needs. Now you must move to a remote village where only one doctor will fit in the clinic. You can train a new general practitioner by having them shadow the whole hospital for a year, watching every case and writing notes on what the specialists do. They will get most common cases right, faster than before. But for the rare illness that needed the kidney specialist, the new doctor has only a fraction of that specialist's depth, because one head cannot hold a hundred specialties at full detail. Tell the village to expect great everyday care and occasional referrals for the unusual cases.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Distilling an MoE into a dense student is one of the most common production projects in the 2026 LLM deployment landscape. The shape of the problem is well understood, but the failure modes are subtle. The student trains cleanly, looks good on aggregate benchmarks, and ships, and then the product team starts seeing tail-domain regressions that the eval pipeline never flagged.
This walkthrough builds the project end to end: how the training loop should look, what data mix to use, why the deployment benefits matter beyond the obvious latency win, and where the quality ceiling actually shows up so you can warn stakeholders before the rollout instead of after it.
Mental model: the student inherits the teacher's voice but not the teacher's library. Conditional computation over a large parameter pool cannot losslessly compress into a single dense weight set.
Training recipe: soft targets plus hard targets
The standard recipe combines two losses. The first is the soft-target loss: KL divergence between the student's logit distribution and the teacher's logit distribution at temperature T (typically 2 to 4). This is where the bulk of the signal comes from, because the teacher's full distribution carries information about how it ranks alternatives, not just which token it picked.
The second is the hard-target loss: standard cross-entropy against the ground-truth next token, no temperature. This anchors the student to actually correct outputs rather than just teacher imitation, which matters when the teacher is occasionally wrong.
The combined loss is usually a weighted sum, with the soft-target weight decaying toward the hard target across training. Optional additions: hidden-state matching at chosen layers, attention pattern matching, on-policy distillation where the student samples and the teacher rates. Hidden-state matching tends to help most when the student is small relative to the teacher; on-policy distillation reduces train-test mismatch but adds significant inference cost during training.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Mistral has shipped distilled dense variants alongside Mixtral MoEs for edge and mobile use cases.
- DeepSeek-V3 has spawned several distilled dense students in the open-source community targeting on-device latency budgets.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you choose temperature T in the soft-target loss?
Sweep on a held-out eval. Lower T sharpens the teacher's distribution, higher T spreads it. Start at 2.0 and tune; lower T tends to help when the student is close to teacher capacity.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Sizing the dense student to active-param count and expecting full-MoE quality. The MoE's quality budget is total parameters; the active count is its compute budget.
60 second bullets to scan on the way to the call.
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.