Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Teaching a fast student
A diffusion model is a slow, careful artist that needs dozens of passes to finish a picture. Distillation trains a quick student to produce a similar picture in one or a few strokes. The student can copy exactly what the teacher drew from the same starting noise, or just learn to draw pictures the teacher would find realistic. The demo shows why a one-stroke student is hard: it must cut noise space sharply into regions that become different pictures.
SDXL-Turbo, FLUX.1-schnell and distilled video models generate in 1–4 steps; distillation is what makes diffusion fast enough for real-time robot control and on-board processing.
- 1. Distillation makes sampling…
- 2. A distilled student usually uses…
- 3. The teacher is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Knowledge distillation (Luhman and Luhman, 2021): run the teacher’s deterministic ODE from many noise samples; train a one-step student to regress the endpoints. It is simple, but the pair dataset is expensive and the student must fit a sharp map.
- Progressive distillation (Salimans and Ho, 2022): the student learns to match two DDIM teacher steps with one; it then becomes the teacher and the process repeats, halving the steps each round (1024 → 4 in 8 rounds).
- Guidance distillation (Meng et al., 2023): the student learns the guided output (1 + w) x_c − w x_u in one pass, removing the doubled cost of classifier-free guidance.
- Consistency and rectified-flow distillation: LCM, InstaFlow and CTM (H7-13, H7-14).
- Distribution matching: DMD (Yin et al., 2024) and DMD2 move generated samples along s_real − s_fake, the difference between the teacher’s score and the score of a model trained on the student’s outputs (reverse-KL gradient, related to variational score distillation in ProlificDreamer). DMD adds a regression loss on teacher pairs; DMD2 replaces it with a GAN loss.
- Adversarial distillation: ADD (SDXL-Turbo, 2023) combines a discriminator on pretrained features with score distillation; LADD (SD3-Turbo, 2024) puts the discriminator in latent space.
- 2025–2026 practice: most deployed image and video models ship a few-step distilled variant (FLUX.1-schnell, SD3.5 Turbo, Wan and Hunyuan distilled or CausVid-style causal students), usually combining several of these losses.
- 1. Progressive distillation halves…
- 2. DMD's gradient uses…
- 3. Guidance distillation removes…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Distilling a sampler
Exercise 1.
- One deterministic DDIM step.
- The progressive-distillation target.
- Rounds needed to reach a step count.
- The knowledge-distillation loss.
Practice.
- First decide the target: 4–8 steps keep diversity and are easy; 1 step needs adversarial or distribution-matching losses.
- Initialise the student from the teacher’s weights; distil guidance at the same time (guidance scale as an input).
- Use the teacher’s own sampler and guidance to make pairs or targets; mix real data in to avoid copying teacher errors.
- Evaluate diversity (recall, mode coverage) as well as FID or human preference; mode-seeking losses reduce diversity.
- Ready-made: LCM-LoRA, Hyper-SD, DMD2 and SDXL-Lightning checkpoints in diffusers.
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16).to("cuda")
img = pipe("a rover on a red rocky plain, photo", num_inference_steps=1, guidance_scale=0.0).images[0]
# adversarial diffusion distillation: one step, no classifier-free guidance pass- 1. One-step students usually need…
- 2. A student is usually initialised from…
- 3. Besides FID, check…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why pairs must come from the ODE. Regressing data on independent noise gives E[x | z] = E[x]: every output is the mean. The teacher’s deterministic ODE couples each noise value to one sample, so the regression target is a function of z.
Why one step is hard. The ODE map sends a connected Gaussian onto disconnected modes, so it changes sharply at the borders between basins. A smooth student of limited capacity averages across a border and lands between modes. Distribution-matching and adversarial losses penalise off-manifold samples directly; trajectory losses penalise them only through the regression error.
Progressive distillation target. With z_t = α_t x + σ_t ε and two teacher DDIM steps to z_t″, the student needs the clean estimate x̃ such that one DDIM step lands on z_t″: x̃ = (z_t″ − (σ_t″/σ_t) z_t) / (α_t″ − (σ_t″/σ_t) α_t).
Distribution matching. The gradient of KL(p_student ∥ p_teacher) with respect to a generated sample is s_fake − s_real (averaged over noise levels). Weighted by σ², this is D_fake − D_real, the difference of two denoisers. It matches distributions, not pairs, so the student’s noise-to-sample map is free; reverse KL is mode-seeking, so regression or GAN terms are added to keep coverage.
- 1. Regression on independent pairs gives…
- 2. Smooth one-step students put samples…
- 3. Reverse KL (DMD) is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How do one-step students trained with different losses compare with a few-step teacher?
History.
- E. Luhman and T. Luhman, “Knowledge distillation in iterative generative models for improved sampling speed” (2021).
- T. Salimans and J. Ho, “Progressive distillation for fast sampling of diffusion models” (2022).
- C. Meng et al., “On distillation of guided diffusion models” (2023).
- A. Sauer, D. Lorenz, A. Blattmann and R. Rombach, “Adversarial diffusion distillation” (SDXL-Turbo, 2023).
- T. Yin et al., “One-step diffusion with distribution matching distillation” (2024) and “Improved distribution matching distillation” (DMD2, 2024).
Exercise 2. 2-D data: 8 Gaussians (std 0.15) on a circle of radius 2.
- Teacher: the exact flow-matching ODE (linear path) of the mixture; 100 Euler steps from 2000 noise points give the distillation pairs.
- Students: one-step MLPs g(z) (two tanh layers of 32, Adam): KD, regression on the teacher pairs (700 steps, batch 256); DM, distribution matching with gradient D_fake − D_real at a random noise level, D_real exact and D_fake from a fresh batch of student samples (500 steps, batch 128, no pairs); random pairs, regression on independent noise (200 steps).
- Measures: on 1000 new noise samples, off-mode share, spread (1 = data), rarest mode’s share relative to 1/8, and RMS distance to the teacher’s 100-step output for the same noise.
| sampler | NFE | off-mode | spread | rarest mode | RMS to teacher |
|---|---|---|---|---|---|
| teacher | 1 | 1.0 | 9.43 | 0.0 | – |
| teacher | 2 | 0.631 | 3.8 | 0.3 | – |
| teacher | 4 | 0.087 | 1.42 | 0.77 | – |
| teacher | 8 | 0.011 | 0.99 | 0.88 | – |
| KD student | 1 | 0.138 | 1.82 | 0.73 | 0.24 |
| DM student | 1 | 0.25 | 2.32 | 0.55 | 2.865 |
| random-pairs student | 1 | 1.0 | 9.02 | 0.0 | – |
- One step ≈ three to four teacher steps: the KD student (13.8% off-mode) sits between the 2- and 4-step teacher, at a fraction of the cost.
- KD copies the map: its outputs are 0.24 from the teacher’s for the same noise. DM learns its own map (RMS 2.9, about the distance between unrelated samples) and only the distribution is matched.
- Negative result: distribution matching alone was worse than KD here (25% off-mode, rarest mode at 0.55), with a smaller training budget; DMD in practice adds a regression or GAN term.
- Random pairs collapsed to the mean (all outputs within 0.17 of the origin), as the theory says.
- Seeds 1 and 2: KD off-mode 0.167 and 0.13 (RMS 0.267 and 0.227); DM 0.242 and 0.232 (RMS 3.953 and 2.781); 4-step teacher 0.101 and 0.083.
- Caveat: tiny MLPs and short training to fit the browser; the ‘fake score’ is a kernel estimate, not a trained network as in DMD.
Few-step distillation in AI, robotics and aerospace
- Interactive generation: SDXL-Turbo, SD3.5 Turbo and FLUX.1-schnell produce images in 1–4 steps; CausVid and Self Forcing make streaming video generation real-time.
- Robotics: Consistency Policy and one-step flow policies distil diffusion policies to run at control rates on embedded GPUs.
- Earth observation and weather: distilled samplers make large diffusion ensembles affordable for forecasting and downscaling.
References
- E. Luhman and T. Luhman (2021). “Knowledge distillation in iterative generative models for improved sampling speed.” arXiv.
- T. Salimans and J. Ho (2022). “Progressive distillation for fast sampling of diffusion models.” ICLR.
- C. Meng et al. (2023). “On distillation of guided diffusion models.” CVPR.
- A. Sauer et al. (2024). “Adversarial diffusion distillation.” ECCV.
- T. Yin et al. (2024). “One-step diffusion with distribution matching distillation.” CVPR.
- T. Yin et al. (2024). “Improved distribution matching distillation for fast image synthesis.” NeurIPS.