Part 2 of the DDIM series. In Part 1 we diagnosed the problem: DDPM's reverse process is shackled to a Markov chain, forcing 1000 one-step-at-a-time denoising steps. Now we break the shackle — and derive DDIM's reverse distribution and its famous sampling formula by the method of undetermined coefficients, all while keeping the ability to free-load (白嫖) a pretrained DDPM model.
Where exactly was Markov used?
Recall the DDPM reverse derivation. Bayes gave us (Formula 4):
The first numerator term is unknown — until we invoke the Markov property: any depends only on its immediate predecessor, so the distant drops out, . That single move turned the unknown into the known and let us simplify Formula 4 into the solvable Formula 5.
DDIM refuses to use the Markov property. So stays unknown, and Formula 4 can no longer be simplified to Formula 5. We've lost our derivation path. We need a different strategy.
Two requirements for free-loading
DDIM wants the acceleration "for free" — reuse a DDPM-trained model with minimal cost. Beyond dropping Markov, that imposes two requirements:
Requirement 1 — don't change
Look back at the DDPM loss (Formula 8): the only distribution it actually uses is the marginal (Formula 2) — not the joint . To free-load DDPM's trained model, the loss must obey a "gradient-equivalence everywhere" principle:
The one distribution DDPM's loss depends on — — must not change at all because of DDIM's step-skipping.
"Equivalence" here is in the broad sense: a leading constant coefficient is fine. If DDIM's loss differs from DDPM's only by a constant multiplier (i.e. ), the gradient direction is unchanged — you just rescale the learning rate by and get identical optimization. A constant out front is harmless; a different functional form is fatal. So the distribution is locked.
Requirement 2 — the reverse distribution must be simple (Gaussian)
Our entire goal is to go from to . For that we must be able to sample, so the reverse distribution has to be a simple distribution — ideally a Gaussian — which we can draw from via reparameterization.
Study tip: when learning diffusion models, think simple. A lot of things are simply assumed by the authors. Don't agonize over whether the Gaussian is "optimal" or whether some fancier form would be better. The goal is to generate images — the simplest, most direct choice is often a perfectly good one. Since dropping Markov left unknown, we can't derive the reverse distribution anymore, so we assume it's Gaussian and move on.
Setting up the ansatz (undetermined coefficients)
By analogy with DDPM, assume DDIM's reverse denoising distribution is also a DDPM-like Gaussian:
- Mean — a weighted combination of and (the conditions), with as undetermined coefficients to solve for. (DDPM's mean was likewise a weighted sum of and .)
- Variance is a human-specified, known constant — exactly as DDPM's reverse variance was a constant. We're free-loading all the way: copy the mean form and assume the variance is a known constant too.
Reparameterized sampling then gives:
One equation, two unknowns () — not solvable alone. We need another equation, then solve the system.
The second equation: Requirement 1 in action
By Formula 2 and Requirement 1, the marginal of is locked to the DDPM form:
The two expressions (10) and (11) for must be equal — otherwise Requirement 1 fails:
Snag: the left side has , the right side doesn't — we can't pin down . Fix it by expanding with Formula 2 as well, :
Now both sides are organized in terms of and noise.
⚠️ Why the primes (, , )? Each is an independent standard normal. You cannot cancel them across the equals sign or treat them with ordinary algebra. The primes are a deliberate reminder.
Memorize this: random variables can only be handled by analyzing their distributions — never by elementary add/subtract/multiply/divide. (We hammered this in the SDE walkthrough.) Two independent 's don't "cancel"; if anything they combine into a new variance.
Solving by matching distributions
Since random-variable equations are solved via distributions, match the distribution on each side of (13). Prerequisite — the Gaussian variance-addition property:
Left side of (13) is Gaussian with
Right side of (13) is .
Equating the two Gaussians gives two equations in two unknowns:
Solve the variance equation for , then back-substitute for :
Plugging back into the assumed mean and collecting terms yields the paper's reverse distribution:
A small rant: the DDIM paper just states this result — it shows almost no derivation, very "look how clever I am." The undetermined-coefficients method above is the honest way to get and .
Where's the step-skipping?
The distribution (15) still looks like it relates and . So where's the acceleration?
The key: we never imposed the Markov property, so and denote the -th and -th sampling steps — which need not be consecutive in DDPM time.
Example: the -th DDIM step can correspond to DDPM's 900th timepoint, and the -th DDIM step to DDPM's 800th — a 100-step jump in one move. Allowed, precisely because no Markov assumption was used.
We never eliminated via Markov; instead we posited the whole distribution directly (in order to free-load). Both requirements are met, so the Markov shackle is now completely gone — skip away.
The DDIM sampling formula (Eq 16)
Reparameterize-sample from (15). At inference we don't have the true , so we substitute the predicted . From , solving for with the model's noise estimate gives . The result:
Reading the three terms (a geometric picture)
Take as the origin (think simple!). Then the estimated clean image, sitting some distance away.
- "predicted " — the model's estimate of the clean image, obtained by inverting Formula 2. Straightforward.
- "direction pointing to " — this term carries the opposite sign from the noise inside the predicted- term. The predicted- piece moves away from (along ); this piece pushes back toward . Net effect: it nudges the trajectory back a bit in the direction.
- random noise — a stochastic perturbation that scatters the result.
(This also connects to the earlier intuition for why DDIM can skip steps but not too many — worth revisiting alongside.)
The "I" in DDIM: Implicit
DDIM's signature move: set . Then the random-noise term in (16) vanishes — the sampling process becomes fully deterministic.
But a true diffusion process is defined by randomness — particles diffuse via Brownian motion. Kill the randomness and, strictly, it's no longer a diffusion model. Yet its underlying network is still a DDPM-trained model. So we have something that is "diffusion and not-diffusion" at once. The author's resolution:
Call it an Implicit Diffusion Model — a hidden diffusion model. Its essence comes from diffusion, but it's not literally a diffusion process, because with there's no term, no Wiener process — it's an ODE.
That deterministic, randomness-free sampler is exactly the "I" — Implicit — in DDIM. The model is rooted in diffusion, but the sampling no longer fits the strict definition of one.
Summary
- Markov was used only to drop from (Formula 4 → 5). DDIM forgoes Markov, so it must posit the reverse distribution instead of deriving it.
- Two free-loading requirements: (1) keep the marginal unchanged (gradient-equivalence), (2) make the reverse distribution a simple Gaussian.
- Assume with constant variance ; solve by matching distributions (never canceling the independent 's) ⇒ Eq (15).
- Because no Markov was used, and can be far-apart DDPM timepoints ⇒ step-skipping.
- Sampling formula (16) = predicted- + direction-toward- + random-noise.
- Setting removes randomness ⇒ deterministic ODE sampler ⇒ the Implicit in DDIM.
Notes taken from a video tutorial on DDIM (Part 2 of the series).
References
- Song, J., Meng, C., & Ermon, S. (2021). Denoising Diffusion Implicit Models. ICLR 2021. arXiv:2010.02502
- Ho, J., Jain, A., & Abbeel, P. (2020). Denoising Diffusion Probabilistic Models. NeurIPS 2020. arXiv:2006.11239