Few-Step Generation: Consistency Models and Distillation
After this lesson, you will be able to:
- Count what a diffusion image costs: steps times network passes per step, and say why fewer steps need more than a better solver
- Place progressive distillation, consistency distillation, consistency training, latent consistency models, adversarial distillation, distribution matching and guidance distillation on one map by what the student learns from
- Explain the consistency idea (every point on one noise-to-image path maps to the same clean image) and read the self-consistency loss on a worked number
- Run a small toy that prints one-step and multi-step error, and say what it does and does not show about real models
- Choose a method for a real need, and name the quality and diversity you give up
Before you start
One move of the sampler from a noisier picture to a cleaner one. Each step calls the network at least once.
One run of the image network from input to output. Cost is counted in passes.
The teacher is the slow model we already have. The student is the fast model we train to match it.
Training a student to reproduce what a teacher produces, with fewer steps or less compute.
The path one noisy picture follows as noise is removed, from pure noise to a clean image.
The rule that every point on one trajectory leads to the same clean image.
A second network that judges whether a picture looks real. It pushes the student toward sharp detail.
How different the pictures are when you ask the same prompt many times with different noise.
#Why Diffusion Is Slow
Picture a long walk down a foggy hill. You start at the top, which is pure noise. You take about fifty small steps, and each step is one run of a large neural network. At the bottom is a clean image.
The cost of one image is a product of three numbers. First, the number of steps. Second, the passes per step. Third, the size of the network. Steps and passes per step are the two numbers this lesson attacks. The size of the network stays fixed.
Fast solvers such as DDIM take bigger steps without any new training. They help, and the slider below shows the limit. Fewer steps mean longer jumps, and a long jump trusts one noise guess over a long distance.
Do: Slide the step count from 2 up to 200.Notice: With very few steps the histogram misses the true shape. More steps close the gap.Why: One long straight jump cannot follow a curved path. A better solver bends less, but it still needs a handful of steps.
A solver only follows the teacher's path more cheaply. It cannot teach the network anything new. To go below about ten steps, the usual route is to train a second network that is built to take big jumps. That is distillation: the slow model is the teacher, and the fast model is the student.
The price of the student is training. You spend compute once, up front, and save it on every image afterward. The sections below show the different ways to run that training, and what each one gives up.
A teacher makes one image with 50 steps, and guidance makes each step two passes. A student has guidance built in and uses 4 steps with one pass each. About how many times fewer network passes does the student use?
#The Distillation Family on One Map
Every method in this lesson turns a slow many-step model into a fast few-step one. They differ in one question: what does the student learn from? The answer decides the cost, the speed and what is lost.
The table puts all of them side by side in general terms. Step counts and quality costs are typical tendencies, not guarantees. Your model, prompts and settings can move every entry.
| Method | What the student learns from | Typical steps | Cost in quality and diversity | Training needs |
|---|---|---|---|---|
| Progressive distillation | A teacher. Each round, the student learns to do two teacher steps in one, then becomes the next teacher | 4 to 16 after several rounds | Quality drops most at the lowest step counts. Diversity stays close to the teacher because it copies the teacher's sampler | A teacher and one full training run per halving |
| Consistency distillation | A teacher's path. The student must give the same answer for neighbouring points on one path | 1 to 4 | One step tends to be soft. Extra steps recover detail. Variety tends to stay fairly close to the teacher | A teacher, one run, and a slowly updated copy of the student as a stable target |
| Consistency training | Real data only. Two noisy versions of one picture must give the same answer | 1 to 4 | Usually needs more training to match what distillation reaches. No teacher biases are inherited | Data and a long run. No teacher |
| Latent consistency (LCM style) | Consistency distillation applied inside the compressed space of a latent diffusion model. The adapter version trains only a small add-on file | 2 to 8 | Fine detail and small text suffer first. Works best with a low guidance value | Adapter version: small. Full version: medium |
| Adversarial distillation (ADD style) | The teacher's one-step denoising of the student's own output, plus a discriminator that judges real or fake | 1 to 4 | Sharp pictures. Variety can fall, because the judge rewards the most typical realistic look. Odd artifacts are possible | A teacher, a discriminator and careful balancing of the two. The hardest to tune |
| Distribution matching (DMD style) | The whole spread of teacher pictures, using the difference between two score estimates, not single pairs | 1 to 4 | Sharp pictures. The objective is mode-seeking, so rare modes can be dropped | A teacher plus an extra network trained alongside the student |
| Guidance distillation | The teacher's blended guided answer, learned directly | Same steps, half the passes per step | The guidance strength is fixed, so you cannot change it at run time | A teacher and one run. Combines with any row above |
Two rows need a clear statement of what the teacher does, because it is easy to get wrong. In adversarial diffusion distillation, the teacher is used for a single denoising step on the student's own noised output. It does not run its full sampler. The discriminator works on features from a pretrained image network called DINOv2. The released SDXL Turbo model generates pictures at 512 by 512 pixels, which is smaller than the base model it was distilled from.
#The Consistency Idea in Pictures
Go back to the foggy hill. Every noisy picture lies on exactly one path down to a clean image. A path never splits and never crosses another path. So if you stand anywhere on a path, you can name where it ends.
A consistency model learns to name that end point from any spot on the path, in one jump. Stand near the top, where the picture is almost pure noise: one jump. Stand near the bottom, where it is almost clean: one jump to the same place.
Do: Pick different points on the curve, one near the noise and one near the end, and press the jump.Notice: Every jump lands on the same clean image.Why: One path has only one end, so every point on it gives the same answer. Drawn stand-in, not a trained model.
Two cautions keep the picture honest. First, a "path" here means the one that the noise-free sampling rule, called the probability-flow ODE, draws from a single starting noise. An ODE is a rule that says which way to move from each point, and following it exactly gives one fixed path with no randomness.
Second, two independent noise draws added to the same clean picture are not on one path. They are two different paths that happen to be built from the same image. A consistency model does not have to send them to the same output, and in general it will not. The property holds along one path only.
The formula says the same thing. Write the model as f, the noisy picture as x, and the noise level as t. For two points on one path:
The property follows from how a path is defined. Open the derivation to see why one end point can be shared by every point on a curve.
Why can a single network learn this? A plain solver that tries one long step from noise lands near the average of all pictures, because it follows the local slope for too far. The toy below shows this: one plain step collapses the spread of samples to almost nothing. A consistency model is trained for a different job. It is asked for the end of the path, not for the next small move, so a long jump is its normal task.
#The Self-Consistency Loss, With a Number
How do you teach a network to give the same answer along a whole path? You never show it the whole path at once. You show it two neighbouring points and ask for equal answers. Equal answers on every neighbouring pair chain into equal answers along the full path, like links in a chain.
Here is one pair, using the toy from the next section. The data is a bell curve with spread 1.5. In this toy the end point of a path has a closed form, so we can check the numbers by hand.
-
Take a noisy value x = 5.0 at noise level 2. The exact consistency function gives f(5.0, 2) = 5.0 * 1.5 / sqrt(2.25 + 4) = 3.0.
-
Make the neighbour. In consistency distillation, the teacher takes one small step down its own path from level 2 to level 1. Here the rule says the slope is t * x / (s^2 + t^2) = 2 * 5 / 6.25 = 1.6, so the new point is 5.0 - 1.6 = 3.4.
-
Ask the model about the neighbour. The exact answer at (3.4, level 1) is 2.829, not 3.0. The gap of 0.17 is the error of one coarse step, which is why the real method uses a fine grid of levels. Finer steps shrink the gap.
-
Suppose a half-trained student answers 3.40 at the first point. A slowly updated copy of the student answers 3.10 at the neighbour. This copy is the target. It is held fixed during the update, so the student cannot cheat by moving both answers together.
-
The loss is the squared gap: (3.40 - 3.10)^2 = 0.09. Training nudges the student's first answer toward 3.10. Repeat over millions of pairs, and the answers along the path agree.
Why does zero loss on pairs give consistency everywhere? The chain argument has one more piece. At the lowest noise level, the model must return its input, because there is no distance left to travel. Real models build that rule into the network by mixing the input with the network output using weights fixed at 1 and 0 at that level. The chain then ends at a known answer, so equal neighbours link all the way down. The coarse step in the worked pair is the one weak link: the finer the grid of levels, the smaller its error, and the pair becomes an exact consistency pair in the limit.
Consistency training uses the same loss with one change. Without a teacher there is no teacher step. Instead, the same clean picture is noised twice with the same random draw at two neighbouring levels, and the two answers must match. The pair is cheaper to make, but it is a rougher stand-in for a true path, so training usually takes longer.
The adversarial and distribution-matching rows use different losses. Plain matching tends to average away detail, so the picture comes out soft. Adversarial distillation adds a discriminator that rewards sharp, real-looking output. Distribution matching compares whole spreads of pictures instead of single pairs. Both can be sharper at one step than a pure consistency loss, and both can narrow the variety of pictures. The next sections return to that cost.
#Try It Yourself
This section has two cells. The first needs a GPU, so it is a read-only copy for Google Colab. The second runs here in your browser.
# Copy to Colab (needs a GPU, torch and diffusers; it cannot run in the browser)
# Run LCM-SDXL via diffusers: 4 inference steps, then a 30-step SDXL baseline
from diffusers import DiffusionPipeline, EulerDiscreteScheduler, LCMScheduler
import torch
import time
# Load base SDXL
pipe = DiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
variant="fp16"
).to("cuda")
# Keep the original sampler settings so the baseline can use them later
orig_config = pipe.scheduler.config
# Swap in the LCM scheduler: this is half the trick
pipe.scheduler = LCMScheduler.from_config(orig_config)
# Load the LCM-LoRA adapter: the other half
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
prompt = "a vintage motorcycle parked in a desert canyon at golden hour, cinematic"
# 4 steps with LCM
t = time.time()
image_lcm = pipe(
prompt,
num_inference_steps=4,
guidance_scale=1.0, # LCM uses low CFG
).images[0]
print(f"LCM 4-step: {time.time() - t:.2f}s")
# Restore a normal sampler (not LCM) and drop the LoRA for the 30-step baseline
pipe.scheduler = EulerDiscreteScheduler.from_config(orig_config, use_karras_sigmas=True)
pipe.unload_lora_weights()
t = time.time()
image_full = pipe(
prompt,
num_inference_steps=30,
guidance_scale=7.5,
).images[0]
print(f"SDXL 30-step: {time.time() - t:.2f}s")
# CHALLENGE: generate 8 images per setting with different seeds and compare how
# varied they are, not only how sharp. Few-step settings often vary less.The second cell is a one-dimensional toy where the path and the perfect consistency function are known exactly. It prints a one-step versus multi-step error. The stand-in model in the cell is a hand-made function, not a trained network, and its mistakes are chosen to grow with the noise level. That choice is an assumption, and the result depends on it.
In the toy, a pretend model makes bigger mistakes when its input is very noisy and smaller mistakes when its input is nearly clean. After its first answer, extra calls add fresh noise to a middle level and ask the model again. How does the average error change from 1 call to 2 calls to 4 calls?
Tests: Verify that five points on one ODE curve give the same endpoint, that two independent noise draws do not, that the exact function has near-zero error, that the stand-in model's error falls from 1 to 2 to 4 calls, and that a plain Euler solver with one call collapses the spread of samples.
Read the printed table as follows. The exact function gets near-zero error with one call, so in this toy one step is enough when the function is perfect. The stand-in model has an error of about 0.30 with one call, about 0.10 with two and about 0.07 with four. The error falls because the stand-in model is least accurate at the highest noise level, and later calls happen at lower levels. The last block shows why a plain solver cannot just take one long step: its samples collapse to a spread of about 0.03 against a target of 1.50.
#Quality Versus Steps, and Why Diversity Drops
In a diffusion model, large layout decisions are made early, at high noise. Fine detail is added late, at low noise. A student with one step has to make every decision at once, and it has no chance to correct itself. Extra steps give it that chance, as the toy showed.
So there is a curve: more steps, better quality, higher cost. A distilled student moves the whole curve left. At one to four steps it can reach quality that an ordinary solver reaches only at many more steps. It still sits below its teacher at the same number of steps, and its best quality is usually below the teacher's best.
Quality is only half of the story. Diversity also drops, and it drops for several separate reasons.
-
Guidance is baked in. Large guidance pushes every sample toward the most typical look of the prompt, which cuts variety. A guidance-distilled student has that push fixed in its weights.
-
The judge rewards typical pictures. A discriminator is happiest with the most realistic-looking output, so the student learns to avoid unusual outputs. Distribution matching has a related effect: it is mode-seeking, so rare modes can be dropped to stay near the main ones.
-
Regression averages. If the student is trained to match one target per input, and several valid targets exist, the best single answer is their average. That is soft, and it is also the same every time.
-
All variety must come from the starting noise. A multi-step sampler can add fresh noise at each step, which gives many chances for variety. A one-step student maps the starting noise to a picture with a fixed function, so any variety must already be in that noise.
Do: Drag the guidance scale s from 1 to 15 and press reseed.Notice: At a large s the four samples look alike. A distilled student with guidance built in sits at one fixed point on this slider.Why: A large s pushes every sample toward the most typical look of the prompt, which is the same variety loss that guidance distillation fixes in place.
#Which Method to Use When
Start from what you have and what you need. This list is a practical starting point. Test every choice on your own prompts and hardware.
-
You have a latent diffusion checkpoint and little training budget. Use an adapter-style latent consistency model. It trains a small add-on, and it is the cheapest way to reach about four steps.
-
You need the sharpest possible picture at one or two steps, and you can afford a hard training run. Use adversarial distillation or distribution matching. Check variety and artifacts closely.
-
You have no teacher in your domain. Use consistency training. Expect a longer run and a lower ceiling than distillation.
-
You want the teacher's look at about half the cost, with no loss of step count. Use guidance distillation. You give up the freedom to change guidance at run time.
-
You want simple, stable training and can accept more steps. Use progressive distillation to go from many steps to somewhere between 4 and 16.
-
You need many varied candidates from one prompt. Prefer more steps with moderate guidance, or the teacher itself. Measure variety before you ship a one-step model.
-
The picture is final, goes to a client, or contains small text or fine patterns. Use the multi-step teacher, or use a few-step draft followed by a multi-step refinement of the keeper.
-
The product is a live slider or a live canvas. A few-step model is the right tool. Draft with it, then render the final picture another way.
A common pattern is a hybrid. Use the fast model for exploration, where the user is choosing, and the slow model for the keeper. This puts the quality cost only where it does not matter.
#Honest Limits
Be clear about what this lesson does and does not show.
- The student is bounded by the teacher. Distillation copies. Mistakes, biases and gaps in the teacher usually transfer to the student.
- Training is real cost. The saving is at inference. You pay in training compute, tuning time and, for adversarial methods, instability.
- Fine detail is where steps matter most. Small text, hands, small repeated patterns and fine texture are where fewer steps are most likely to show errors. Test on your own prompts.
- Other tools may need retesting. Negative prompts, control inputs and fine-tuning adapters were built for the teacher. Check that they still behave on the student.
- Numbers in the table are tendencies. Step counts, costs and diversity effects change with the model, the data and the settings. Treat them as questions to test, not facts to quote.
- The toy is a stand-in. It shows the idea in one dimension with a hand-made model. It cannot show how a real network behaves on images.
- Evaluation is hard. A single score such as FID can hide a loss of variety, and human preference is its own measure. Use several views.
#Key Takeaways
- Cost is steps times passes per step. Guidance usually doubles the passes, and distillation can cut both factors
- One map covers the family. Progressive, consistency, latent consistency, adversarial, distribution matching and guidance distillation differ in what the student learns from
- Every point on one path gives the same clean image. Independent noise draws are not on one path
- The loss compares neighbours. A student's answer at one point is matched to a slowly updated copy's answer at the next point, and agreement chains along the path
- Extra steps buy quality. Later steps happen at lower noise, where a model tends to be more accurate
- Diversity is the hidden cost. Fixed guidance, mode-seeking objectives, averaging and one-shot mapping all narrow the variety
- Choose by need. Draft and explore with few steps, finalize with many, and measure variety, not only sharpness
#Quick Check
A teacher uses 50 steps with guidance on every step. A student has guidance built in and uses 5 steps. How many network passes does each use?