TL;DR
Diffusion models generate images by starting from pure noise and removing it in many small steps. Many variants existed, each derived from a different theory, and they were hard to compare. EDM writes all of them in one framework, then makes three kinds of change: a better sampler for the noise-removal steps, a preconditioned network that is easier to train, and a better distribution of training noise levels. The result is state-of-the-art image quality on CIFAR-10 with 35 network evaluations per image.
Builds on: Diffusion Model, Score Matching, Stochastic Differential Equation, Langevin Dynamics · Leads to: DDIM Sampler
Why it mattered
Diffusion models had become a leading approach to high-quality image generation, and each generated image needs many network evaluations, so sampling speed matters. EDM's sampler reached a given image quality with far fewer evaluations than the original samplers of the models it studied: for a pretrained VP model on CIFAR-10, the original sampler needed 256 evaluations, while the paper's schedule and second-order solver reached a similar FID with 35. The paper also set records on CIFAR-10 (FID 1.79 class-conditional, 1.97 unconditional) and on class-conditional ImageNet at 64 by 64 (FID 1.36). The design-space framing lets a team change one component and keep the rest fixed.
The problem
Diffusion theory is dense, and the papers that introduced the main model families, variance-preserving (VP), variance-exploding (VE) and the improved DDPM (iDDPM) line, each derived their training and sampling from a different framework. The parts that make a model work were tangled together: the noise schedule, the solver, the network scaling, the loss weighting and the training noise distribution all looked like parts of one theory, so a change to one seemed to require changes to the others.
The authors' point is that most of these choices are independent. The sampler is a numerical method for an ordinary differential equation (ODE). The network is a denoiser that can be scaled in known ways. The loss and training noise can be set from measured error. If so, each part can be tuned on its own, and the question becomes which choice gives the best result for the cost, measured in network evaluations and in Fréchet inception distance (FID), a score that compares the statistics of generated images with real ones (lower is better).
Background on the core object: a diffusion model learns to denoise. Given a noisy image, the network predicts the clean image. The authors call this predictor the denoiser. Its output, combined with the noisy input, gives the score function that drives sampling (see Score Matching).
How it works
The paper's pipeline has three stages. Here is the flow, with one tiny case traced through the sampler.
flowchart LR A[Pick a noise schedule sigma of t] --> B[Denoiser D of x and sigma] B --> C[ODE dx/dt = x minus D over t] C --> D[Heun steps on a rho-spaced time grid] D --> E[Optional churn: add and remove noise] E --> F[Clean image after N steps] G[Training: preconditioned network F] --> B
- Pick the noise schedule. The noise level at time is . The paper argues this is the best choice, not just the mathematically natural one, because the sampling trajectories then become close to straight lines at both large and small noise levels.
- Write the denoiser. The network is not used as the denoiser directly. It is wrapped in a skip connection with scale factors, . The scale factors keep the network's input and output at unit variance at every noise level.
- Get the ODE. With , the probability flow ODE becomes . Read it as: the sample moves in the direction of the denoised image, at a speed set by how far away it is. Example: at and , if the denoiser outputs , the slope is . A single step of size in gives , which is the denoised image itself. A full sampler is a sequence of such steps.
- Space the time steps. Choose noise levels with . This puts most steps at low noise, where errors hurt the image most.
- Take Heun steps. Heun's method (also called improved Euler or the trapezoidal rule) takes an Euler step, evaluates the slope at the new point, then averages the two slopes. It costs one extra denoiser evaluation per step and has a smaller error than Euler's method for the same step size. Tiny case below.
- Optionally add noise (stochastic sampling). For a chosen range of noise levels, the sampler raises the noise level slightly, adds fresh noise, then takes the same kind of step back down. This corrects earlier errors, but too much removes detail, so the paper limits the range and tunes the amount per model.
- Train the preconditioned network. The training loss is weighted so that every noise level has equal initial influence, noise levels are drawn from a log-normal distribution concentrated in the useful middle range, and augmentations are applied to the training images with their parameters given to the network as input.
Two sanity checks. After step 3, a single Euler step from any to returns ; this follows directly from the ODE above. After step 5 the Heun result should differ from the Euler result by a small amount for the same step size.
The math
Let be the data distribution with Gaussian noise of standard deviation added. The score function is , and the paper's identity connects it to the denoiser. Denoising score matching gives , which is the link described in Score Matching.
Step 3 in symbols: the probability flow ODE
Substituting the identity into the probability flow ODE gives
where the dot is a time derivative. With , and this is . The one-step property in the walkthrough follows: an Euler step from to uses , so .
Step 4 in symbols: the time grid
The paper uses , and for its CIFAR-10 setting. Read the exponent as a dial: a larger spends more steps near .
Step 5 in symbols: Heun's update
Let be the slope at . The Euler predictor and the corrected step are
where is the slope at the predicted point . The paper's local error is for Heun against for Euler, at the cost of one extra denoiser call per step.
Step 2 in symbols: the preconditioning
With the paper's scale factors are
Each is chosen so that the network input and training target have unit variance, and so that errors in are amplified as little as possible. The skip term passes the noisy input straight through at low noise, where the input is nearly the answer, and leaves the network to do the work at high noise.
Step 7 in symbols: the loss and noise distribution
The training loss weights each noise level by , which is . Training noise levels are drawn as . The effective weight on the raw network output is then , so every level contributes equally at the start of training.
Results
On unconditional and class-conditional CIFAR-10 at 32 by 32, EDM reached FID 1.97 and 1.79 with 35 network evaluations. On class-conditional ImageNet at 64 by 64, a retrained model reached FID 1.36, a new record for that benchmark.
Two limits matter. First, the stochastic sampler needs several heuristic parameters that the authors tuned by grid search for each model, which the paper flags as a concern for evaluating model changes. Second, the paper's numbers are for 64 by 64 and 32 by 32 images, and many parameter values may need retuning for larger resolutions. The authors also note the risks of higher-quality generators, such as disinformation.
Worked examples
A point is at with . The denoiser outputs .
- The slope is .
- Step from to , so the step size is .
- The new point is .
Interpretation: one Euler step to zero returns the denoiser's output exactly, the one-step property from the walkthrough.
The same point, at , steps to . We have , so .
- Euler predictor: .
- Evaluate the denoiser at the predicted point. Suppose .
- Slope there: .
- Average the two slopes: .
- Heun step: .
Interpretation: Euler alone ends at 2.75, Heun corrects to 2.5 by using the slope at the far end. Heun spends one more denoiser call, which the paper accepts because it reaches the same FID in fewer steps overall.
A pretrained VP model for CIFAR-10 at 32 by 32 is sampled with the original sampler, which uses 256 network evaluations per image, and with the paper's schedule and Heun solver, which uses 35.
- Original sampler: 256 evaluations per image.
- Paper's sampler: 35 evaluations per image.
- The ratio is , so each image needs about seven times fewer network calls.
Interpretation: fewer evaluations per image is a direct saving in time, and the paper reports that this saving comes with image quality comparable to the original sampler, not a loss of it.
Try it: a VP model's original sampler uses 256 evaluations and the new one uses 35. If a batch of 1000 images takes 256 evaluations each under the original sampler, how many fewer evaluations are needed in total? Answer: fewer evaluations.
Common mistakes and tradeoffs
It is tempting to think that a better sampler can make any model good. In fact the paper shows that the sampler and the training setup interact: stochastic sampling helped the original CIFAR-10 training but hurt the improved one, because the improved model already removes noise accurately. Compare samplers only on the same trained model.
It is tempting to think that a higher-order solver always wins. In fact each Heun step costs an extra denoiser call, so it pays off only if it reduces the total number of evaluations for the same quality. Compare solvers at equal evaluation counts.
It is tempting to think that the theory fixes the schedule. In fact the schedule has large practical effects, and the paper chose it by measured FID, not by theoretical convenience.
Tradeoffs. Deterministic sampling is reproducible and lets you invert a real image into its latent noise, which is useful for editing. Stochastic sampling can reach better quality but needs tuned parameters for each model. Use the paper's preconditioning and loss weighting when you train a diffusion model, since they made training more robust in the paper's experiments. Use the pretrained-model sampler improvements whenever you can change the sampler without retraining.
Reading guide
Read the paper in its own order, with these prerequisites:
- The common framework. The probability flow ODE and the denoiser. Needs Score Matching and Ordinary Differential Equation.
- Deterministic sampling. Heun's method, the time grid and the schedule. Needs Euler Method and DDIM Sampler for context.
- Stochastic sampling. The Langevin view of noise injection. Needs Langevin Dynamics and Stochastic Differential Equation.
- Preconditioning and training. The scale factors, loss weighting and augmentation. Needs U-Net for the architecture background.
Recap of the chain of ideas in the paper: a diffusion model is a denoiser; the denoiser defines an ODE; the schedule and the solver decide how many steps the ODE needs; a stochastic term can fix errors but needs tuning; the network is preconditioned so training works at every noise level; and the training noise and loss are chosen from measured error. Read next: DDIM Sampler for the sampler EDM builds on, and Neural Ordinary Differential Equation for the ODE view of generation.
Check yourself
QuestionWhy does the paper use the scale factors c_skip, c_out and c_in instead of training the network to output the denoised image directly?Show answer
The network input is a mix of clean signal and noise whose size changes a lot with the noise level, and the output has to cancel noise exactly at large noise levels, where any error gets amplified. The scale factors keep the input and output at unit variance, and the skip term lets the network predict either the signal or the noise, whichever is easier at that level. The network therefore learns a target with a steady size at every noise level.
QuestionWith x = 3 at t = 2 and denoiser output D = 1, what is the slope of the probability flow ODE with sigma of t equal to t, and what is one Euler step from t = 2 to t = 1?Show answer
The slope is . One Euler step to has step size , so the new point is .
QuestionHeun's method costs one more denoiser call per step than Euler's method. Why does the paper still prefer it?Show answer
Its local error is against for Euler, so for the same accuracy it needs far fewer steps. The paper's tables show Heun reaching the same FID as Euler with considerably fewer total evaluations, which more than pays for the extra call in each step.
QuestionThe paper sets rho to 7 for the time grid. What does a larger rho do, and why does the paper want more steps at low noise?Show answer
A larger makes steps near shorter and steps near longer. Errors near low noise have a large effect on image quality, so the paper spends more steps there with .
QuestionA team retrains a diffusion model on a new dataset and sees FID improve with stochastic sampling on the old model but get worse after retraining with the EDM training setup. What does the paper suggest they should do?Show answer
The paper found the same pattern on CIFAR-10: stochastic sampling helps the original training but is harmful after the EDM training improvements, because the better model already removes noise accurately. They should re-tune the stochastic parameters for the new model and compare samplers on that model. The best choice can depend on the model and the data, so the comparison has to be repeated for the new model.
Sources
- Karras, T., Aittala, M., Aila, T., and Laine, S. (2022). Elucidating the Design Space of Diffusion-Based Generative Models. arXiv:2206.00364. arxiv.org/abs/2206.00364
- Official implementation and pretrained models: github.com/NVlabs/edm