ZeroShotMind

Paper

Denoising Diffusion Implicit Models

DDIM keeps DDPM's training objective untouched but replaces the Markovian reverse chain with a non-Markovian one, yielding a deterministic sampler that reaches DDPM-quality images in 20–50 steps instead of 1000 — and a stable, invertible map between noise and image.

Jiaming Song, Chenlin Meng, Stefano Ermon — Stanford University2020arXiv ↗Views:

diffusionsamplinggenerative-models

The problem

DDPM generates beautifully and samples miserably. Drawing one image means running the reverse Markov chain all the way down — one full U-Net forward pass for each of T=1000T = 1000 steps — which for a high-resolution image is minutes per sample. The cost looked like a property of the trained model, but DDIM's insight is that it is not: it is a property of how the model is used at inference, and it can be changed without retraining a single weight.

The opening in the objective

The DDPM training loss only ever saw pairs (x0,xt)(x_0, x_t) built from the closed-form marginal q(xtx0)q(x_t \mid x_0).

Lsimple=Et,x0,ϵ ⁣[ϵϵθ(xt,t)2]L_\text{simple} = \mathbb{E}_{t,\, x_0,\, \epsilon}\!\left[\, \big\| \epsilon - \epsilon_\theta(x_t, t) \big\|^2 \,\right]

Nowhere in that expectation does the forward Markov chain q(xtxt1)q(x_t \mid x_{t-1}) appear — only the marginals do. The network learns to denoise xtx_t at every noise level, but the reverse process that chains those denoisings together is a separate choice, made at inference. DDPM's Markovian reverse chain is just one option among many.

The non-Markovian construction

DDIM defines a family of non-Markovian forward processes qσ(x1:Tx0)q_\sigma(x_{1:T} \mid x_0), indexed by a vector σ1,,σT\sigma_1, \dots, \sigma_T, every member engineered to share the same marginals q(xtx0)=N(αˉtx0,(1αˉt)I)q(x_t \mid x_0) = \mathcal{N}(\sqrt{\bar\alpha_t}\, x_0, (1 - \bar\alpha_t) I) as DDPM. Identical marginals is the whole point: since the network was trained only against those marginals, the same weights are optimal for the entire family, and σ\sigma becomes a free dial controlling how much stochasticity the reverse process injects. The corresponding reverse step is

xt1=αˉt1(xt1αˉtϵθ(xt,t)αˉt)predicted x0+1αˉt1σt2  ϵθ(xt,t)+σtz,x_{t-1} = \sqrt{\bar\alpha_{t-1}}\, \underbrace{\left(\frac{x_t - \sqrt{1 - \bar\alpha_t}\, \epsilon_\theta(x_t, t)}{\sqrt{\bar\alpha_t}}\right)}_{\text{predicted } x_0} + \sqrt{1 - \bar\alpha_{t-1} - \sigma_t^2}\; \epsilon_\theta(x_t, t) + \sigma_t z,

read left to right as a recipe: estimate where the clean image is, point back toward xt1x_{t-1} along the predicted noise direction, and add σtz\sigma_t z of fresh randomness. Choosing σt\sigma_t to match DDPM's posterior variance recovers the original stochastic sampler exactly — so DDIM is a strict generalization, not a different model.

Deterministic sampling

Set σt=0\sigma_t = 0 at every step and the last term vanishes: xt1x_{t-1} becomes a deterministic function of xtx_t and the network's output. This is the DDIM sampler proper. There is no longer a stochastic walk that explores; there is a fixed trajectory, computed by a function, from a noise sample to an image. As the step size shrinks, this deterministic update is the Euler discretization of an ordinary differential equation — the probability-flow ODE whose solutions carry the same time-evolving marginals as the stochastic diffusion but along smooth, non-random paths. (The ODE/SDE view of diffusion is developed in full by Song et al.'s concurrent score-based generative modeling through SDEs.)

Reading sampling as ODE integration is what unlocks the speed. A smooth ODE does not need a thousand tiny steps; it needs enough steps to track the curvature of its trajectory. Because the probability-flow trajectories are smooth, you can take a coarse subset of timesteps — 50 or 20 out of the original 1000 — and treat each retained step as a larger integration stride. At 50 steps the samples are close to indistinguishable from full 1000-step DDPM; at 20 there is visible degradation but often an acceptable trade. This single change — same weights, integrated more coarsely — is the entire saving, and a 10–50× speedup at matched quality is the headline result.

Determinism as a feature

Determinism buys a second thing stochastic sampling cannot give: a stable correspondence between noise and image. With σ=0\sigma = 0 the map from the initial xTx_T to the final x0x_0 is a fixed function, so the same seed always yields the same picture and nearby seeds yield related pictures. Linearly interpolating between two noise vectors and decoding each produces a smooth semantic morph between the two images — interpolation done entirely in noise space, which the stochastic DDPM sampler cannot support because its randomness severs the link between latent and output. And because the ODE runs both directions, you can integrate forward from a real image to recover the noise that generates it (DDIM inversion), the entry point for editing a given image by manipulating its latent code.

Why it matters

DDIM is the reason diffusion became practical for deployment. Nearly every production diffusion system — Stable Diffusion and its descendants — samples with DDIM or one of the higher-order ODE solvers (DPM-Solver and relatives) that build directly on its ODE framing. It also draws the boundary that the rest of the field pushed past: it cuts the number of steps but leaves each step a full U-Net pass over the full-resolution image, which is exactly the cost latent diffusion attacks by moving the whole process into a compressed space. The deterministic noise-to-image map, meanwhile, underpins a large literature on diffusion-based image editing and inversion. Two ideas — same objective, different sampler; and sampling as ODE integration — turned a thousand-step curiosity into the backbone of modern image generation.