Samplers and Schedulers: Diffusion Sampling Is Numerical Integration
Published:
The reverse process is an ODE
Song et al. showed the forward corruption is a stochastic differential equation \(d\mathbf{x} = f(\mathbf{x},t)\,dt + g(t)\,d\mathbf{w}\), and that it can be reversed in two ways. Either as an SDE,
or as a deterministic probability-flow ODE with the same marginals at every \(t\):
The score \(\nabla_{\mathbf{x}}\log p_t\) is what the network supplies, up to the fixed rescaling \(\boldsymbol{\epsilon}_\theta = -\sqrt{1-\bar{\alpha}_t}\,\nabla_{\mathbf{x}}\log p_t\). So a sampler is a choice of integrator, and the number of function evaluations (NFE) is the number of times the U-Net runs. The “1000 steps” of vanilla DDPM is not a property of the model; it is Euler’s method with a very small step.
In Karras et al.’s cleaner variance-exploding coordinates, where \(\mathbf{x}_\sigma = \mathbf{x}_0 + \sigma\boldsymbol{\epsilon}\) and \(D_\theta(\mathbf{x};\sigma)\) is the denoiser’s estimate of the clean image, the whole ODE collapses to
Read it literally: at every noise level, move away from the current point in the direction of the denoised estimate, scaled by how noisy you currently are.
Euler, Heun, and why order helps
Euler takes one derivative evaluation and steps along the tangent: \(\mathbf{x}_{i+1} = \mathbf{x}_i + (\sigma_{i+1}-\sigma_i)\,\mathbf{d}_i\). Because the true trajectory curves, the tangent leaves it, and the error per step is \(O(h^2)\).
Heun’s method corrects this. Take the Euler step to a provisional point, evaluate the derivative there, and re-step using the average of the two slopes. Two network calls per step, local error \(O(h^3)\). That trade is usually worth it: at a fixed NFE budget, halving the number of steps to double their accuracy wins once the steps are large.
DPM-Solver: solve the easy part exactly
The diffusion ODE is not a generic black box. Written in terms of \(\alpha_t\) and \(\sigma_t\), it is semi-linear: a linear term in \(\mathbf{x}\) plus a nonlinear term that is entirely the network. Variation of constants handles the linear part in closed form, leaving one integral to approximate. With the half-log-SNR variable \(\lambda_t = \log(\alpha_t/\sigma_t)\),
Ancestral or deterministic
Integrating the SDE means adding fresh noise at every step; integrating the ODE means not. The stochastic variants (DDPM ancestral, “Euler a”, DPM++ SDE) have a genuine benefit Karras et al. identified: injected noise acts as error correction, dragging the sample back towards the correct marginal after solver drift. The cost is that the seed no longer determines the image — change the step count and you get a different picture — and at high step counts the churn can erase fine detail.
Deterministic samplers give a fixed, invertible-ish map from noise to image, which is what makes latent interpolation, inversion and reproducible seeds work at all.
| Sampler | Order | NFE per step | Noise injected | Typical step count |
|---|---|---|---|---|
| DDPM (ancestral) | 1 | 1 | yes | several hundred |
| DDIM | 1 | 1 | no | 20–50 |
| Euler | 1 | 1 | no | 20–50 |
| Euler ancestral | 1 | 1 | yes | 20–40 |
| Heun (EDM) | 2 | 2 | optional | 15–30 steps |
| DPM-Solver-2 | 2 | 2 | no | 15–25 |
| DPM-Solver++ (2M, multistep) | 2 | 1 | no | 15–25 |
| UniPC | 2–3 | 1 | no | 10–20 |
Step counts here are the ranges people reach for in practice, not measured equal-quality points; the honest comparison is always at matched NFE on your own model.
The schedule is half the sampler
A sampler needs a list of noise levels, and spacing them uniformly in \(t\) is a poor choice: it wastes evaluations at high \(\sigma\), where the trajectory is nearly straight, and starves the low-\(\sigma\) region where detail is decided. Karras et al. propose
which concentrates steps at low noise. At 50 steps the choice barely registers; at 10 it can dominate the choice of solver.
Solvers get you to roughly 10–20 evaluations. Below that, no integrator helps, because the trajectory genuinely is curved — you have to change the model, which is what distillation and consistency models do.
References
- Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., & Poole, B. Score-Based Generative Modeling through Stochastic Differential Equations. ICLR 2021.
- Song, J., Meng, C., & Ermon, S. Denoising Diffusion Implicit Models. ICLR 2021.
- Lu, C., Zhou, Y., Bao, F., Chen, J., Li, C., & Zhu, J. DPM-Solver: A Fast ODE Solver for Diffusion Probabilistic Model Sampling in Around 10 Steps. NeurIPS 2022.
- Karras, T., Aittala, M., Aila, T., & Laine, S. Elucidating the Design Space of Diffusion-Based Generative Models. NeurIPS 2022.
- Zhao, W., Bai, L., Rao, Y., Zhou, J., & Lu, J. UniPC: A Unified Predictor-Corrector Framework for Fast Sampling of Diffusion Models. NeurIPS 2023.
