TL;DR
A diffusion model is trained once, on a schedule of 1000 noise levels. The sampler is the rule that turns the trained network into a generator, and the DDIM sampler is a rule that removes the random draw at each step. The path from noise to image becomes deterministic, which means the walk can skip most of the steps and still land on a good image. On CIFAR-10, the paper reports samples of comparable quality to the 1000-step sampler in 20 to 100 steps, with no retraining.
Where you'll see it: as a fast sampler option in image generation libraries, and in image editing, where a real photo is first mapped to its noise and then regenerated with a changed prompt.
Intuition
Same destination, shorter walk
The original sampler for a diffusion model, the DDPM sampler, walks from pure static to an image through every one of the training steps. At each step it adds a fresh random draw. That randomness is part of the model's assumptions: the reverse step is a Gaussian guess, and the guess is only accurate when the step is small. So you cannot stride over steps without the path wandering off.
DDIM rewrites the same walk. At each step the network says how much of the current input is noise. From that, the sampler computes a guess of the clean image, then places the next point at a less noisy level along a fixed direction defined by the same noise estimate. No new randomness is needed, so the path is a fixed function of the starting noise. Choosing a coarser set of noise levels gives a coarser version of the same path, not a different random sample.
flowchart LR
A[start from noise x_T] --> B[network estimates the noise]
B --> C[compute a guess of the clean image]
C --> D[move to the next, less noisy level along the same noise direction]
D --> E{more steps in the chosen subset?}
E -->|yes| B
E -->|no| F[sample x_0]
The DDPM sampler differs in one box: it adds a fresh random draw at each move. That draw is what forces the sampler to use every step.
- DDIM (deterministic)
- DDPM (stochastic)
The math
Notation
Let be the product of over the schedule up to step . It lies in and decreases as grows. The DDIM paper writes this quantity as ; this lesson uses to match the Diffusion Model lesson. Training gives a network that predicts the noise mixed into the clean data to make the noisy input
The sampler does not change this network. It only decides how to use its output.
Step 1: estimate the clean image
Solve the equation above for , and replace the true noise by the network's prediction. The result is an estimate of the clean image given the current point:
Step 2: move to an earlier noise level
Pick an earlier, less noisy level (in the sampling schedule, the next step down). The DDIM update places the new point at that level, using the estimate for the signal and the same noise estimate for the direction:
The three terms are the estimated signal, a deterministic push along the noise direction, and a fresh Gaussian draw scaled by . The Gaussian (Normal) Distribution term is the only source of randomness, and its size is set by .
The family indexed by eta
The DDIM paper parameterises the size of that random term with a single number . For consecutive steps of the chosen subsequence,
Setting gives , and the update is deterministic: this is DDIM. Setting reproduces the stochastic DDPM sampler when all steps are used. Intermediate values interpolate between them. The paper's central observation is that all members of this family use the same trained . Only changes, so none of them needs retraining.
Skipping steps
Let be a subsequence of the training steps . The sampler visits only these steps, in reverse order, and applies the update above between each consecutive pair. Training used all steps, but the update only needs the noise levels , so the same network can be queried at the subsequence. The cost is network calls instead of .
The paper justifies this by showing that the training objective depends only on the marginals , not on the particular chain of intermediate steps that connects them. Many forward processes share those marginals, and DDIM picks one that is deterministic in reverse. That is why a model trained with the ordinary objective can be sampled along a different path.
The ordinary differential equation view
With , define the noise-to-signal ratio (a different quantity from the random-term scale above) and rescale the state as . The DDIM step becomes
which is one Euler step for the Ordinary Differential Equation
This is why fewer steps still work: a coarser Euler step follows the same curve with larger error. The paper notes that the ODE can also be run forward, from an image back to noise, which is the basis of the editing use above. A continuous-time version of the same idea appears in Neural Ordinary Differential Equation models.
Worked examples
Take a point at a level with , a previous level with , and a network output . Use .
- Coefficients at the current level: and .
- Remove the predicted noise: .
- Estimate the clean image: .
- Signal term at the earlier level: .
- Direction term: .
- Sum: .
- Interpretation: the point moved from toward the estimated clean value , and no random number was drawn. Running the same step twice with the same inputs gives the same answer.
These are the reported FID values from Table 1 of the DDIM paper, not results from a run of this lesson's code.
- Full schedule, 1000 network calls: DDIM gives FID 4.04, and the stochastic DDPM () gives 4.73 on CIFAR-10.
- Reduced schedule, 20 network calls: DDIM gives FID 6.84, and DDPM gives 18.36.
- Speed-up of the sampler: times fewer network calls, so sampling takes about of the time.
- Quality cost: DDIM loses FID points. DDPM loses points.
- Interpretation: at the same network and the same 20 steps, the deterministic path keeps most of its quality, while the stochastic path falls apart. The gap is the reason to choose the deterministic sampler when the step budget is small.
Tradeoffs and failure modes
DDIM is a sampler, so it trades quality against step count and gives up randomness. The table lists the usual situations.
| Situation | Problem | Better choice |
|---|---|---|
| Interactive generation with a budget of 20 to 50 steps | The full 1000-step DDPM is too slow | DDIM on a subsequence of steps |
| Want several different samples from one starting point | A deterministic sampler gives one output per starting noise | Set , or use the stochastic DDPM sampler |
| Very few steps, under about 10 | Discretisation error grows and details blur | A higher-order ODE solver, or a distilled model |
| Edit or encode an existing image | Need a starting noise that reproduces the image | Run the ODE forward (DDIM inversion); reconstruction error drops as steps increase |
Two failure modes are common. First, the choice of subsequence matters: evenly spaced steps are not always the best, and the same network can give noticeably different quality under different subsequences. Second, the update above assumes the network predicts noise. A model trained to predict a different quantity needs the same update rewritten in terms of that quantity, and using the noise formula on it gives wrong estimates without any error message.
History
Sohl-Dickstein and colleagues introduced diffusion-style generative models in 2015. Ho, Jain and Abbeel made them competitive for images in 2020 with a simple training objective, and that model was sampled with the slow stochastic DDPM sampler. Song, Meng and Ermon, working at Stanford, showed in late 2020 that the same trained network could be sampled deterministically, along a path that can skip steps. The paper was published at ICLR 2021. It appeared alongside the score-based SDE work of Song and colleagues, which gave the continuous-time view of the same sampler. The result caught on because it made large speed-ups available without retraining, and because the deterministic path made interpolation and encoding of images possible.
Check yourself
QuestionRecall: what value of the parameter makes the update deterministic, and what does the sampler then reduce to?Show answer
gives , so the random term vanishes and the update is a fixed function of and the network output. This is DDIM. With all training steps used, gives the stochastic DDPM sampler.
QuestionCompute: , , , , and . What is ?Show answer
First, , so . Next, , and . Adding gives .
QuestionWhy: why can the DDIM sampler skip steps that the DDPM sampler cannot skip without losing quality?Show answer
The DDPM reverse step adds a fresh random draw at every step, and its Gaussian guess is only accurate when the step is small. Each skipped step therefore makes a larger error that the sampler cannot correct. DDIM removes the random draw, so the path is a smooth deterministic curve. Skipping steps then just means taking a coarser Euler step along that curve, and the error grows more slowly.
QuestionApplied: you have a photo and want a version with a different style, using the same diffusion model. Outline the steps with DDIM and say what you give up.Show answer
Run the deterministic update forward, from the photo to a noise level, to get a starting noise that encodes the photo. Change the conditioning, such as the text prompt, and run the update backward from the same . Because the path is deterministic, the output keeps the overall layout of the photo. What is given up is exact reconstruction: with few steps the round trip is approximate, and the edit can drift from the original in fine details. Using more steps reduces that error.