Part 3 of the DDIM series. In Part 2 we removed the Markov shackle and derived DDIM's step-skipping sampler under two free-loading requirements. But "it looks like the noising process is untouched" isn't a proof. Here we prove it rigorously: under DDIM's setup, the loss is equivalent to DDPM's — which is what licenses free-loading a pretrained DDPM model.
What "equivalent" means — Theorem 1
The DDIM paper states this as Theorem 1:
Theorem 1. For all , there exists and such that .
Decoding it:
- — the DDIM loss (under DDIM's sampling setup, variance vector ).
- — the DDPM loss (the -weighted noise-prediction MSE we derived in Part 1 / the DDPM series).
- They differ by only a constant . (And note: strictly — remember this, it matters at the end.)
Two losses that differ by a constant (and a constant scale) have the same gradient direction, so optimizing one optimizes the other. That's the whole point: train once with DDPM, sample with DDIM.
Which process does DDIM actually change?
DDPM's loss derivation starts from two joint distributions:
Formula 17 is the forward (noising) joint (Markov chain). Formula 18 is the reverse (denoising) joint — what the neural network models.
Quiz: DDIM changes one of these. Which — the forward (17) or the reverse (18)?
Answer (surprising): DDIM changes the forward process, Formula 17.
Why? In Part 2, the term in the Bayes expansion would normally have an that Markov lets us drop. But DDIM is non-Markovian, so cannot be dropped — the forward transition is really . That extra is exactly what changes Formula 17.
Picture the DDIM graphical model: is determined jointly by and (arrows into from both). So:
DDIM modifies the forward noising joint distribution . The reverse model is left untouched — to free-load, you change , not .
Rebuilding the forward joint (Formula 19)
So each factor in Formula 17 picks up an : . The paper then "shows off" by jumping straight to the answer — but the honest path is Bayes plus a telescoping product:
(That first step is just Bayes applied to each factor — note the swap of and between condition and main variable, the tell-tale sign of Bayes.) Split the product:
The second product telescopes — write out and watch the middle factors cancel:
By the Kunkun rule ("given Kunkun practiced two and a half years, the probability he practiced two and a half years is 1"), the denominator is . Hence:
Finally, tag on the human-set variance subscript (the distribution is controlled by the variance), giving the form of Eq. 6 in the original DDIM paper (an external reference — not our lecture-numbered Eq 6):
Why does the product start at , not ? Just like DDPM, the term can be folded into the terms (Kunkun rule again), so we don't split out as a special case — handling one fewer special term makes the rest of the derivation much cleaner.
Why does a "forward" joint look like a sum of "reverse" conditionals ? Because Formula 20 is the result after applying Bayes. It looks incongruous (one side forward-noising, the other reverse-conditioned), but that's exactly the Bayes-rewritten form — and crucially, this DDIM forward step relates to its previous step (which need not be the strictly-adjacent DDPM timestep) plus an . The price of non-Markovianity is carrying that along.
Deriving and reducing it
The DDIM loss follows the DDPM recipe: maximum likelihood, then with a and a minus sign. Using Formula 20 for and Formula 18 for :
Flip the minus sign into the ratio (invert numerator/denominator) and turn products into sums of logs:
- The first term involves only (known: is data, the endpoint is the approximate standard normal) and — no network, so it's a constant we drop.
- Each summand is a ratio under an expectation → a KL divergence:
Why the outer survives the KL
A natural worry: doesn't become the KL, consuming the expectation? Not fully. The ratio concerns the conditional, but the outer expectation is over the full joint . Writing it out:
Forming the KL only "uses up" the single conditional pulled from the joint — the marginals over the other latents ( except ) are still being integrated. So the outer cannot be cancelled; it persists. (Recall the KL identity .)
Why we may write as
Next subtlety: in the KL we replace with . Is that legal? Yes — because the functional form is already fixed. In DDPM, the model predicts (equivalently — the two are interchangeable), and the reverse distribution is a Gaussian with a known mean form (a weighted combo of ) and a fixed variance. In DDIM we worked hard in Part 2 to pin down exactly that form. So is a — the only difference is that its is the model's estimate rather than the dataset's true :
Here "" means equal up to constant terms.
Collapsing the Gaussian KL to MSE
Both arguments of the KL are the same Gaussian, differing only in vs. . Plug into the two-Gaussian KL formula (derived in the DDPM loss post):
Drop all constant terms:
- — both variances are the same human-specified .
- — cancels the .
Only the mean-difference survives. The two means differ only through vs (the form, same ), so :
Now substitute (invert Formula 2) for both the true and predicted , and fold all the constants into a per-step coefficient :
This is identical in form to DDPM's loss (Formula 8) — same out front, same noise-prediction MSE. The two 's might differ, but we may force them equal; and even if they didn't match, a constant scale is absorbed by the learning rate ( tripled ⇔ learning rate ). To be rigorous the paper sets the in equal to DDPM's, yielding exactly
QED. DDIM's change to the forward process does not change the gradient of the DDPM training loss — so a DDPM-trained model can be free-loaded by DDIM's sampler.
The fine print: vs. DDIM's
One catch: Theorem 1 requires strictly. Why? Look at the denominators — at they blow up (division by zero). But DDIM's headline trick is exactly (the deterministic, Implicit sampler from Part 2). The paper patches this by continuity: the equality holds as (i.e. for arbitrarily small ), so we may treat as the limiting case where Theorem 1 still holds.
Summary
- Theorem 1: — DDIM's loss equals DDPM's up to a constant, so their gradients agree and the pretrained DDPM model is reusable.
- DDIM changes the forward joint (Formula 17 → 19/20), not the reverse model — because non-Markovianity forbids dropping from .
- Rebuild the forward joint via Bayes + a telescoping product + the Kunkun rule (Eq 20).
- Derive by max-likelihood → drop the model-free term → recognize KL divergences (the outer survives; rewrites as with ).
- The Gaussian KL collapses (equal variances, constants dropped) to the noise-prediction MSE — identical to DDPM's loss.
- Theorem 1 needs ; DDIM's is justified as the limit.
This closes the loop opened in Part 2: changing the forward noising process to allow step-skipping is precisely what lets the reverse sampling skip steps — for free.
Notes taken from a video tutorial on DDIM (Part 3 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