Samplers: DDPM, DDIM and Higher-Order Solvers
Why sampling is numerical integration of an ODE or SDE rather than a fixed algorithm, how DDIM makes the process deterministic and skippable, and what higher-order solvers buy at the cost of stability.
A trained diffusion model is not a sampler. It is a function that estimates, for any noise level, the direction from a noisy point toward the data manifold. Turning that into an image is a numerical integration problem, and the choice of integrator is a free variable you can change at inference time without retraining. This is why a two-year-old checkpoint can suddenly become four times faster: the weights did not improve, the solver did.
From 1,000 steps to a differential equation
The DDPM ancestral sampler walks the reverse chain one trained timestep at a time, injecting fresh noise at each step:
It is faithful to the training objective and it is slow, because each of the 1,000 steps is a full forward pass of a large UNet or transformer.
The reframing that unlocked fast sampling is that this chain discretises a stochastic differential equation, and every SDE of this form has a corresponding probability flow ODE with identical marginal distributions at every \(t\) (Song et al., 2021, Score-Based Generative Modeling through SDEs, arXiv:2011.13456). Sampling the ODE instead of the SDE gives up stochasticity and gains everything numerical analysis knows about integrating smooth trajectories: larger steps, higher-order methods, adaptive step size.
DDIM: determinism and step skipping
DDIM (Song et al., 2020, arXiv:2010.02502) constructs a non-Markovian forward process with the same marginals as DDPM, whose reverse process can be run with \(\sigma_t = 0\). Two consequences follow.
The map from initial noise to image becomes deterministic and invertible. The same seed always gives the same image, interpolation between two seeds produces a smooth morph rather than a crossfade, and running the ODE backwards recovers the latent for a real image, which is what inversion-based editing relies on.
Steps become skippable. Because the update depends only on \(\bar{\alpha}\) at the current and next chosen timestep, you can jump from \(t=1000\) to \(t=980\) to \(t=960\) and the arithmetic stays consistent. Fifty steps of DDIM is a standard operating point and lands close to 1,000-step DDPM quality.
The tradeoff is that determinism removes the stochastic correction ancestral sampling provides. At high step counts, SDE samplers usually edge out ODE samplers on fidelity, because injected noise repeatedly pushes the trajectory back toward the true distribution and washes out accumulated discretisation error. ODE samplers win decisively at low step counts, where that error dominates.
Higher-order solvers
A solver's accuracy is governed by its order. Euler's method, which is what DDIM reduces to, has error \(O(h)\) per step in the step size \(h\). Second-order methods such as Heun's evaluate the derivative twice per step for \(O(h^2)\); DPM-Solver (Lu et al., 2022, arXiv:2206.00927) exploits the semi-linear structure of the diffusion ODE so the linear part is integrated exactly and only the neural part is approximated, which is why it reaches usable quality in 10 to 20 steps.
Multistep variants reuse previous model evaluations instead of taking extra ones, so a second-order multistep step costs the same single forward pass as Euler. That is why DPM-Solver++ and its relatives, rather than Heun, are the default in production image pipelines: the accuracy is nearly free.
When it breaks
Guidance breaks the smoothness assumption. Higher-order solvers assume the trajectory is smooth enough for a Taylor expansion to hold over the step. Classifier-free guidance with a large scale makes the effective velocity field much stiffer, and second-order solvers can overshoot into oversaturation and clipping. DPM-Solver++ specifically addresses this by working in the \(x_0\) parameterisation, where the guided trajectory is better behaved, and it is why guidance scale and solver choice must be tuned together.
Step count is not a quality dial past a point. Beyond roughly 50 steps for a good ODE solver, additional steps change the image imperceptibly while costing linearly more compute. Teams routinely ship at 100 or 150 steps because the number felt safer, paying double for nothing measurable.
Timestep spacing matters as much as count. Uniform spacing in \(t\) is rarely optimal; spacing uniform in \(\log \text{SNR}\) concentrates steps where the trajectory curves most. Two implementations reporting "20 steps" can differ substantially in quality for this reason alone, which makes cross-library step-count comparisons unreliable unless spacing is stated.
Determinism is only as good as the arithmetic. DDIM's reproducibility guarantee assumes bit-identical model evaluations. Change batch size, attention kernel, or GPU generation, and non-associative floating-point reduction produces slightly different results that the sampler amplifies over dozens of steps. Seeds are portable across runs on one configuration, not across configurations.
14 flashcards for this concept
Click a card to reveal the answer.