skip to content

Search

← From Noise to Image

Part II — The Diffusion Revolution (2015–2022)

Scores, SDEs, and Faster Sampling

The SDE/ODE unification, probability flow, and DDIM's deterministic shortcut.

2020–2021 14 min read 3 papers

It is the last quarter of 2020. DDPM (Ho et al., 2020) has just shown that a stack of learned denoising steps can match the image quality of adversarial networks, but the mechanism is expensive to run: generating one sample means simulating a Markov chain of up to a thousand sequential network evaluations. Within eight weeks of each other, two papers reframe what a diffusion model actually is — one as a family of non-Markovian processes that share DDPM’s training objective but not its slow sampler, the other as a single continuous-time stochastic differential equation that DDPM and an earlier line of score-based models both turn out to be discretizations of. A third paper, arriving a few months later, tightens the noise schedule and loss itself. Together they turn diffusion from a proof of concept into something a product team could plausibly ship.

Where We Were

DDPM’s generative process is a fixed, Markovian chain: to produce an image, the model starts from pure noise and takes a reverse step at every one of TT timesteps, each step calling the same denoising network once. The paper that established this — covered in Chapter 8, which owns the forward-noising construction and the simplified denoising loss LsimpleL_{\mathrm{simple}} that DDPM trains on — used T=1,000T = 1{,}000. That is not a rounding choice; the reverse process is only accurate when each step removes a small enough amount of noise that a Gaussian approximation holds, and DDPM’s ablations showed sample quality degrading sharply once fewer steps were used with the same sampler. A thousand sequential network calls per image is a real cost: no caching, no batching across steps, and no way around it, because step t−1t-1‘s input is step tt‘s output.

This was not the first time score functions and iterative denoising had been connected. A separate line of work, noise-conditional score networks (Song and Ermon, 2019) — also covered in Chapter 8 — trained a network to estimate the gradient of the log data density (the score) at several noise levels and used that gradient in Langevin dynamics to sample, arriving at image quality comparable to early GANs without adversarial training. DDPM and this score-based line looked, on the surface, like two separate research programs: one derived from a variational bound on a probabilistic model, the other from score matching and Langevin sampling. Both were slow for the same underlying reason — both needed many small, sequential steps — but neither paper had shown the other why.

DDPM's bottleneck lasted five months before two fixes arrived at once The slow card and the two fast cards are the same trained model, sampled two different ways. Grey monospace text is each result's step count or headline claim. 2015-03 Nonequilibrium thermodynamics frames diffusion as denoising 2019-07 NCSN connects diffusion to score matching 2020-06 DDPM Reaches GAN-level images, but slowly 1000 sequential steps 2020-10 DDIM Removes the Markov assumption 10x to 50x faster 2020-11 Score-SDE Unifies both lines as one continuous process one framework, both fixes foundational, not the bottleneck itself the bottleneck this chapter opens on removes it, eight weeks apart
Two fixes for the same bottleneck landed within eight weeks of each other, sampling the same trained model two different ways. PNG ↓

By late 2020, the bottleneck was well understood even if the fix was not: whatever made diffusion sampling slow was tied to the assumption that the reverse process had to retrace the exact same discrete chain used in training, one small step at a time, with no way to skip ahead.

The Breakthrough

Denoising diffusion implicit models (Song, Meng, and Ermon, 2020) — DDIM — attacked the Markov assumption directly. The authors observed that DDPM’s training objective depends only on the marginal noising distribution at each timestep, not on the specific Markovian chain used to reach it. That leaves room to construct an entire family of non-Markovian forward processes that produce the exact same marginals, and therefore train with the exact same objective as DDPM, while having a different — and much more flexible — reverse process. One member of that family has a fully deterministic reverse map: given a noisy image at step tt, there is a unique output at any earlier step t′t', with no added noise in between. Because the reverse process no longer has to retrace every intermediate step to stay valid, it can jump across large gaps in the timestep sequence, generating a comparable image in a few dozen network calls instead of a thousand — the paper reports 10x to 50x wall-clock speedups over DDPM at matched quality. Determinism carries a second consequence: an image now has a single, fixed noise seed as its latent code, so two seeds can be interpolated and decoded into a smooth, semantically coherent path between two images — a capability the stochastic DDPM sampler does not offer.

Score-based generative modeling through stochastic differential equations (Song et al., 2020) — Score-SDE — took a different route to a related destination. Rather than starting from DDPM’s discrete Markov chain, it modeled the forward noising process as a continuous-time stochastic differential equation (SDE): noise is injected continuously as time flows from 00 to 11, not in a fixed number of discrete jumps. Every SDE has a corresponding reverse-time SDE that runs the noising process backward, and that reverse SDE depends on exactly one unknown quantity: the score of the noisy data distribution at each point in time — the same score that noise-conditional score networks had already been trained to estimate, and the same quantity DDPM’s noise-prediction network turns out to compute in disguise. That single observation unified both prior research programs: DDPM, DDIM, and score-based models are all discretizations of the same underlying object, differing only in the noising schedule and the sampler applied to it. The continuous-time view also produces a companion object with no randomness at all, the probability flow ODE, whose deterministic trajectories share the same marginal distributions as the stochastic reverse SDE — DDIM’s deterministic sampler is, in this framing, one particular discretization of this ODE.

One score, three samplers Score-SDE reframes DDPM's discrete chain as one continuous process with a single learned quantity. Grey monospace text names the sampler each path yields. Data x0 a real training image t = 0 Forward SDE noise injected continuously t runs 0 to 1 Score network estimates the score at t same fn as DDPM's noise predictor Reverse-time SDE stochastic, ancestral many steps, sampler A Probability flow ODE deterministic, no randomness few steps, DDIM style Predictor-corrector alternates both samplers a tunable middle ground input and forward process the one learned quantity a sampler built from the score DDPM, DDIM and NCSN are all discretisations of this single continuous-time object.
One learned score function supports three samplers. DDPM, DDIM and NCSN are all discretisations of the same continuous-time object. PNG ↓

Improved denoising diffusion probabilistic models (Nichol and Dhariwal, 2021) came at the same problem from inside DDPM’s own discrete framework rather than by generalizing it. The paper made three changes: it let the reverse process learn its per-step variance instead of fixing it to a hand-set constant, it replaced DDPM’s linear noise schedule with a cosine schedule that destroys information more gradually near the end of the forward process, and it trained on a hybrid objective that mixes DDPM’s simple denoising loss with a small amount of the full variational bound, specifically to make the learned variances trainable without the noisy gradients that optimizing the full bound alone produces. The combined effect, per the paper’s own claim, was that learning the reverse-process variances allowed sampling with an order of magnitude fewer forward passes than the original fixed-variance sampler, at a negligible cost in sample quality — a result obtained without leaving DDPM’s discrete-time, Markovian formulation at all.

The Mathematics

DDIM’s deterministic sampling step reuses DDPM’s noise-prediction network ϵθ\epsilon_\theta but changes how successive steps are combined. Following DDIM’s own notation, where αt\alpha_t denotes the cumulative noise-retention product Ho et al. call αˉt\bar\alpha_t — the same quantity Chapter 8 writes with the bar; DDIM drops it:

xt−1=αt−1(xt−1−αt ϵθ(xt,t)αt)+1−αt−1  ϵθ(xt,t)x_{t-1} = \sqrt{\alpha_{t-1}}\left(\frac{x_t - \sqrt{1-\alpha_t}\,\epsilon_\theta(x_t, t)}{\sqrt{\alpha_t}}\right) + \sqrt{1-\alpha_{t-1}}\;\epsilon_\theta(x_t, t)
SymbolMeaning
xtx_tnoisy image at timestep tt
xt−1x_{t-1}image at an earlier, not necessarily adjacent, timestep
αt,αt−1\alpha_t, \alpha_{t-1}cumulative noise-retention product at each timestep (DDIM’s notation for DDPM’s αˉt\bar\alpha_t)
ϵθ(xt,t)\epsilon_\theta(x_t, t)network’s predicted noise, given the current noisy image and timestep

Score-SDE describes the forward noising process as a general Itô stochastic differential equation, of which DDPM’s discrete chain is one specific discretization:

dx=f(x,t) dt+g(t) dw\mathrm{d}x = f(x,t)\,\mathrm{d}t + g(t)\,\mathrm{d}w
SymbolMeaning
xxthe state (image) at time tt, evolving continuously
ttcontinuous time, running from data (t=0t=0) to noise (t=1t=1)
f(x,t)f(x,t)drift term, the deterministic part of the evolution
g(t)g(t)diffusion coefficient, scaling how much noise is injected
wwstandard Wiener process supplying the randomness

Every such forward SDE has a corresponding reverse-time SDE that undoes the noising, and it depends on exactly one learned quantity — the score:

dx=[f(x,t)−g(t)2 ∇xlog⁡pt(x)]dt+g(t) dwˉ\mathrm{d}x = \left[f(x,t) - g(t)^2 \,\nabla_x \log p_t(x)\right]\mathrm{d}t + g(t)\,\mathrm{d}\bar{w}
SymbolMeaning
x,t,f,gx, t, f, gsame roles as in the forward SDE, evaluated in reverse
∇xlog⁡pt(x)\nabla_x \log p_t(x)the score: gradient of the log density of noisy data at time tt
wˉ\bar{w}Wiener process running backward in time

Setting the noise term to zero gives a deterministic companion with the same marginal distributions at every tt — the probability flow ODE:

dx=[f(x,t)−12g(t)2 ∇xlog⁡pt(x)]dt\mathrm{d}x = \left[f(x,t) - \tfrac{1}{2}g(t)^2 \,\nabla_x \log p_t(x)\right]\mathrm{d}t
SymbolMeaning
x,t,f,gx, t, f, gsame roles as in the forward SDE
∇xlog⁡pt(x)\nabla_x \log p_t(x)the score, here weighted by 12g(t)2\tfrac{1}{2}g(t)^2 instead of the full g(t)2g(t)^2 in the reverse SDE

The unification also explains why DDPM’s own noise-prediction network already had everything needed for a score-based sampler:

∇xlog⁡pt(xt)≈−ϵθ(xt,t)1−αˉt\nabla_x \log p_t(x_t) \approx -\frac{\epsilon_\theta(x_t, t)}{\sqrt{1-\bar\alpha_t}}
SymbolMeaning
∇xlog⁡pt(xt)\nabla_x \log p_t(x_t)the score at noise level tt
ϵθ(xt,t)\epsilon_\theta(x_t, t)DDPM’s trained noise-prediction network
αˉt\bar\alpha_tcumulative noise-retention product at timestep tt

Improved DDPM’s cosine noise schedule replaces DDPM’s linear schedule for αˉt\bar\alpha_t:

αˉt=f(t)f(0),f(t)=cos⁡2 ⁣(t/T+s1+s⋅π2),s=0.008\bar\alpha_t = \frac{f(t)}{f(0)}, \qquad f(t) = \cos^2\!\left(\frac{t/T + s}{1+s}\cdot\frac{\pi}{2}\right), \qquad s = 0.008
SymbolMeaning
αˉt\bar\alpha_tcumulative signal-retention fraction at timestep tt
f(t)f(t)unnormalized cosine schedule function
t,Tt, Tcurrent timestep and total number of timesteps
sssmall offset preventing near-zero noise at t=0t=0

Finally, the hybrid loss that makes learned variances trainable without destabilizing the mean prediction:

Lhybrid=Lsimple+λ Lvlb,λ=0.001L_{\mathrm{hybrid}} = L_{\mathrm{simple}} + \lambda\, L_{\mathrm{vlb}}, \qquad \lambda = 0.001
SymbolMeaning
LhybridL_{\mathrm{hybrid}}combined training loss
LsimpleL_{\mathrm{simple}}DDPM’s original simplified denoising loss
LvlbL_{\mathrm{vlb}}full variational lower bound, supplies the variance gradient
λ\lambdasmall weight preventing LvlbL_{\mathrm{vlb}} from dominating training

What It Enabled

The immediate effect was that diffusion stopped requiring a choice between “slow and stochastic” and “fast and low quality.” A single trained DDPM checkpoint could now be sampled with an ancestral sampler for maximum fidelity, or with DDIM for a fast preview, or with a predictor-corrector scheme for a middle ground — and Improved DDPM’s schedule and hybrid loss made the underlying network itself more sample-efficient no matter which sampler ran on top of it.

DDPM samplerDDIM samplerScore-SDE (continuous)
Underlying processdiscrete Markov chainnon-Markovian, same training loss as DDPMcontinuous-time SDE / ODE
Typical steps to a good sampleup to 1,000tens (10x–50x faster wall-clock than DDPM)flexible; ODE solvers can adapt step size
Stochastic or deterministicstochasticdeterministic (or a tunable blend)either, via SDE or probability-flow ODE
Latent-space interpolationnot well-definedyes, directlyyes, via the ODE
Reported resultGAN-competitive images (2020-06)10x–50x speedup at matched qualityCIFAR-10 FID 2.20, Inception Score 9.89, 2.99 bits/dim; first 1024×1024 score-based samples

Score-SDE’s probability flow ODE also made exact likelihood computation tractable for the first time in this model family, via the standard change-of-variables formula for continuous normalizing flows — a capability score-based and DDPM-style models had lacked, and one that let researchers report bits-per-dimension numbers directly comparable to earlier likelihood-based generative models.

Two 2020 fixes feed everything this book's rest of Part II builds on DDPM forks into DDIM and Score-SDE, both feed Improved DDPM, and each thread reaches a different later chapter. Grey monospace text names where each result is covered. DDPM, 2020-06 1000-step Markov chain chapter 8 DDIM, 2020-10 deterministic, fewer steps this chapter Score-SDE, 2020-11 continuous-time unification this chapter Improved DDPM, 2021-02 learned variance, cosine schedule this chapter Guided diffusion classifier guidance, 2021 covered in chapter 10 Progressive distillation fewer steps still, 2022 covered in chapter 18 Flow matching straight-line objectives, 2022 covered in chapter 19 the bottleneck this chapter's three fixes a later chapter that builds on one
This chapter's three fixes are not a dead end. Guidance, few-step distillation and flow matching each pull a different thread forward. PNG ↓

The downstream lineage runs in two directions. Guided diffusion built directly on Improved DDPM’s architecture and added classifier guidance to trade diversity for fidelity, a technique generalized shortly after into classifier-free guidance — both covered in Chapter 10. Separately, DDIM’s demonstration that a fixed model tolerates a much shorter, custom sampling trajectory became the starting assumption for an entire later research thread on cutting sampling down further still, from tens of steps to a handful or to one, covered in Chapter 18. The probability flow ODE’s framing of generation as following a deterministic path from noise to data also generalizes into a broader family of straight-line and simulation-free training objectives, covered in Chapter 19. And once diffusion moved off pixels entirely, into the compressed latent spaces covered in Chapter 13, DDIM-style samplers became the default choice precisely because the per-step cost of an already-fast latent-space model made every additional step count.

Key Papers

PaperAuthorsYearLinkWhy it matters
Denoising Diffusion Implicit ModelsSong, Meng, and Ermon2020arXiv:2010.02502Removed the Markov assumption from DDPM’s sampler, cutting wall-clock sampling time 10x–50x and enabling deterministic latent-space interpolation
Score-Based Generative Modeling through Stochastic Differential EquationsSong et al.2020arXiv:2011.13456Unified DDPM and score-based models as discretizations of one continuous-time SDE; introduced the probability flow ODE and exact likelihood computation
Improved Denoising Diffusion Probabilistic ModelsNichol and Dhariwal2021arXiv:2102.09672Learned variances, a cosine noise schedule, and a hybrid loss cut required sampling steps by roughly an order of magnitude within DDPM’s own framework

PM Lens

Papers referenced