DDIM: Same Marginals, Fewer Steps, and a Latent Space Worth Having
Published:
The assumption nobody needed
Look back at what training actually consumes. A batch is built as \(\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}\), the network predicts \(\boldsymbol{\epsilon}\), and that is all. The intermediate variables \(\mathbf{x}_1,\dots,\mathbf{x}_{t-1}\) never appear. The Markov chain was scaffolding used to derive the marginals; the objective only ever sees the marginals themselves.
So: is there another forward process with the same \(q(\mathbf{x}_t\mid\mathbf{x}_0)\) but a different joint? There is a continuum of them. Song et al. define, for any non-negative \(\sigma_t\),
Conditioning on \(\mathbf{x}_0\) throughout is what breaks the Markov property: \(\mathbf{x}_{t-1}\) depends on both its successor and the original image. The construction is arranged so the marginals survive. Substituting \(\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0+\sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}\), the fraction collapses to \(\boldsymbol{\epsilon}\) and
The two independent noise terms have variances summing to \((1-\bar{\alpha}_{t-1}-\sigma_t^2) + \sigma_t^2 = 1-\bar{\alpha}_{t-1}\), exactly as required, for every \(\sigma_t\). The mean is \(\sqrt{\bar{\alpha}_{t-1}}\mathbf{x}_0\) regardless. The whole family is consistent with one trained network.
The dial
Replace \(\mathbf{x}_0\) with the model’s estimate \(\hat{\mathbf{x}}_0 = (\mathbf{x}_t - \sqrt{1-\bar{\alpha}_t}\,\boldsymbol{\epsilon}_\theta)/\sqrt{\bar{\alpha}_t}\) and you have a sampler:
At \(\eta=1\) the coefficient is \(\sqrt{\tilde{\beta}_t}\), the DDPM posterior standard deviation, and the update reduces to ancestral sampling. At \(\eta=0\) the noise term vanishes and the step is a deterministic function of \(\mathbf{x}_t\).
Nothing here is retrained. The same weights, the same \(\bar{\alpha}\) table, a different read-out.
Why determinism buys short schedules
The subsequence \(\tau_1<\dots<\tau_S\) need not be all of \(1..T\); take every twentieth index and you have a 50-step sampler. The formula above works for any pair of adjacent indices. But the two settings of \(\eta\) degrade very differently when you stride, because \(\sigma_t\) grows with the gap. On the linear schedule with a stride of 20:
| step \(t\to t_{\text{prev}}\) | \(\sigma_t\) at \(\eta=1\) | \(\sigma_t\) at \(\eta=0\) |
|---|---|---|
| \(1000\to980\) | 0.574 | 0 |
| \(600\to580\) | 0.459 | 0 |
| \(300\to280\) | 0.319 | 0 |
| \(100\to80\) | 0.157 | 0 |
Read the top row. At \(t=1000\to980\) the total noise amplitude is \(\sqrt{1-\bar{\alpha}_{980}}\approx 1\), and \(\eta=1\) makes \(0.574\) of that freshly injected — about a third of the variance in \(\mathbf{x}_{t-1}\) is randomness added after the network had just worked to remove it. Over a 1000-step schedule that is fine, because a thousand subsequent steps remove it again. Over 50 there are not enough, and samples come out visibly noisy. At \(\eta=0\) there is nothing to remove: every step is pure progress. Song et al. report sample quality comparable to full DDPM using 10× to 50× fewer steps.
There is a deeper reason. With \(\eta=0\), dividing through by \(\sqrt{\bar{\alpha}_{t-1}}\) and writing \(\bar{\mathbf{x}} = \mathbf{x}/\sqrt{\bar{\alpha}}\), \(\varsigma = \sqrt{1-\bar{\alpha}}/\sqrt{\bar{\alpha}}\) turns the update into \(\bar{\mathbf{x}}_{t-1} - \bar{\mathbf{x}}_t = (\varsigma_{t-1}-\varsigma_t)\,\boldsymbol{\epsilon}_\theta\) — a plain Euler step on the ODE \(d\bar{\mathbf{x}} = \boldsymbol{\epsilon}_\theta\,d\varsigma\). DDIM is a first-order solver for the probability-flow ODE, and step count is a discretisation error, not a source of accumulated noise. Stochastic samplers have no such reserve to draw on.
A latent space you can navigate
Once sampling is a deterministic map \(\Phi:\mathbf{x}_T\mapsto\mathbf{x}_0\), the noise vector stops being a scratch variable and becomes an encoding. Running the same Euler steps forwards in \(\varsigma\) inverts it, mapping a real image to the latent that reproduces it — DDIM inversion, the basis of most training-free editing methods. The inversion is approximate: each step linearises \(\boldsymbol{\epsilon}_\theta\) locally, and the error grows as the step count falls, which is why editing pipelines invert with more steps than they sample with.
What it does not fix
Determinism costs diversity: with \(\eta=0\) all stochasticity lives in \(\mathbf{x}_T\), and the reverse pass cannot correct an error once made. Stochastic samplers self-correct, because injected noise gives the score field further chances to pull a drifting trajectory back — which is why Karras et al. find a non-zero optimal noise level for the best FID rather than pure ODE sampling. And 20 steps is still 20 forward passes of a large network; getting to one or two requires distillation, or rebuilding the paths to be straighter, as in flow matching.
References
- Song, J., Meng, C., & Ermon, S. Denoising Diffusion Implicit Models. ICLR 2021.
- Ho, J., Jain, A., & Abbeel, P. Denoising Diffusion Probabilistic Models. NeurIPS 2020.
- Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., & Poole, B. Score-Based Generative Modeling through Stochastic Differential Equations. ICLR 2021.
- Karras, T., Aittala, M., Aila, T., & Laine, S. Elucidating the Design Space of Diffusion-Based Generative Models. NeurIPS 2022.
- Mokady, R., Hertz, A., Aberman, K., Pritch, Y., & Cohen-Or, D. Null-text Inversion for Editing Real Images using Guided Diffusion Models. CVPR 2023.
