A hand-holding deep dive into DDIM (Denoising Diffusion Implicit Models). This first part lays out the big picture — what problem DDIM solves and why — then quickly recaps the DDPM machinery we'll build on. Prerequisite: you must already know DDPM. If you don't, read the zero-barrier DDPM series first; otherwise this will go over your head.
The whole thesis in one letter
DDIM and DDPM differ by exactly one letter: the I, for Implicit. You read that right — one letter. But that letter is the core of DDIM. If you can't pin down what "implicit" means here, you haven't really grasped DDIM.
Here's the headline:
- DDPM is slow. The number of sampling (denoising) steps equals the number of noising steps — typically 1000. Generating one image means running 1000 reverse steps. Painful.
- Why so slow? Because of the Markov property. DDPM's reverse process is shackled to a Markov chain, which forces one-step-at-a-time denoising.
- DDIM's move: de-Markovianize. By removing the Markov shackle, DDIM slashes the number of sampling steps while keeping image quality essentially unchanged.
The mathematical essence
When you study a diffusion model, always nail down its mathematical nature. Here it is:
DDIM turns DDPM's reverse-time stochastic differential equation (SDE) into an ordinary differential equation (ODE). In the "experienced-driver" picture, it upgrades the car from an SDE-car to an ODE-car.
Why is an SDE worse than an ODE for fast sampling? Intuitively: the moment you see the word stochastic, your heart should sink a little. Recall from the SDE walkthroughs that the reverse SDE carries a term , where is a Wiener process — a random perturbation. With randomness baked into every step, the numerical solution is hard to take in big jumps. An ODE has no such randomness: over a stretch of time it marches in a single, definite direction, so you can confidently skip steps. (Flow matching, an ODE method, is fast for exactly this reason.)
The killer feature: free-loading (白嫖)
If DDIM required retraining a model, it'd be a non-starter. Its strongest selling point is that its sampling algorithm can free-load directly off a model trained with DDPM:
Take any pretrained DDPM model, apply DDIM's sampling procedure, and get high-quality images — no retraining needed.
That constraint — "must reuse the DDPM model as-is" — will turn out to drive the entire derivation.
DDPM recap (the loot we carry in)
Since DDIM free-loads off DDPM, let's quickly reassemble what we already know. (All of this is derived in detail in the DDPM series — we'll move fast.)
Notation convention: every in this writeup — regardless of sub/superscripts — denotes a standard normal unless explicitly stated otherwise.
Formula 1 — one-step noising
The forward process is a Markov chain with Gaussian transitions:
Formula 2 — the closed-form "skip" (老司机 jump)
Via the Markov property plus the nesting-dolls substitution (), we get the experienced-driver formula that stands at and reaches any in one shot:
⚠️ Notation difference vs. DDPM. The DDIM paper drops the bar: what DDPM writes as (a cumulative product), DDIM simply writes as . They are the same quantity — DDIM's is DDPM's . We follow the DDIM (bar-less) convention from here on.
An important aside: the endpoint is never actually reached
The noising target is to travel from the data distribution to the prior . But reaching the prior exactly requires infinitely many steps. So as , only in the limit, which means
The endpoint is an approximation that is never truly attained. In experienced-driver terms, the planned route is slightly "off." With the error is tiny — but it's nonzero, and this approximation can subtly hurt generation quality.
Formulas 3–6 — the reverse posterior
We want the reverse (denoising) distribution , but we only know the forward direction. The standard recipe: Bayes' rule to turn unknown into known.
The marginals are unknown data distributions — dead end. Fix: condition on .
Adding made the numerator's first term unknown again — but the Markov property rescues us: depends only on its neighbor , not on the distant , so (the vanishes), leaving a fully-known fraction:
Now all three pieces are known (Formulas 1 and 2). Plug in the Gaussian density , grind through elementary algebra, and the reverse posterior comes out Gaussian too:
By reparameterized sampling, knowing and gives ; iterating produces the final image. At inference is unknown, so a model predicts it — equivalently predicting the noise (the two are interchangeable; the "hat" marks a model prediction). Full derivation is in the DDPM reverse-process post.
Formulas 7–8 — the loss (the "driver")
Training the driver = the loss function. Start from maximum likelihood — we want the model to assign the highest probability to generating the images we want (the running "generate basketball-playing Kunkun" gag: maximize ). Take a , flip max to min with a minus sign (it's a loss, lower is better), and after the full DDPM derivation:
Here is a network (parameters ) that predicts the noise injected by Formula 2, and is a -dependent coefficient with in DDPM.
Two fine points (both already covered in the DDPM loss post):
- The sum runs over , not DDPM's , and the separate "" term has vanished. That's not an error — the term folds into the sum via the Kunkun rule : "Given Kunkun practiced two and a half years, what's the probability Kunkun practiced two and a half years? Obviously 1."
- The network input takes the timestep and (written out as ). The predicted target is the noise in this expression — don't confuse it with the adjacent-step noise.
The key observation (and the cliffhanger)
Stare at the loss in Formula 8 for three seconds. Notice:
The loss depends only on the distribution (Formula 2).
This is the crux. If DDIM wants to free-load DDPM's loss — i.e. reuse a pretrained DDPM model — then DDIM's loss must match DDPM's up to at most a constant coefficient (, which is just in DDPM anyway). Concretely:
DDIM may change the sampling procedure (to skip steps), but it must not change the marginal . Touch that distribution and the loss changes — and the free-loading breaks.
Hold that thought.
From this three-factor analysis (route / car / driver), the diagnosis is clear: DDPM's reverse process is shackled by the Markov chain. In car terms, DDPM's car is a clunky SDE-car — it can only crawl one step at a time, making generation hugely inefficient. That is exactly the problem DDIM sets out to fix: upgrade the car.
How does DDIM remove the Markov shackle and turn the SDE-car into an ODE-car — while keeping untouched so it can still free-load the DDPM model? That's the reveal, coming up in Part 2.
Notes taken from a video tutorial on DDIM (Part 1 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