Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

~11 min read2021

Skip the
steps.

The first diffusion models made gorgeous images and took forever — a thousand tiny denoising steps, each nudging the noise a little, each rolling a fresh die. DDIM asked: what if we didn't roll the die, and didn't take every step? By predicting the finished image at each stage and re-projecting it forward, it turns the reverse process into something you can leap across — ten or twenty jumps instead of a thousand — and, by zeroing out the added noise, makes the whole path deterministic. Same seed, same picture, every time. No retraining, same network. Here's the update rule, the σ that vanishes, and the η knob that turns DDPM back on.

The delta

What changes against DDPM: the sampler becomes deterministic, so steps can be skipped

Rung 4 needs many steps because its reverse process is a Markov chain that injects fresh noise at every step — each step is a small stochastic move, and you cannot take a large one without leaving the distribution the model was trained on.

The change is to notice that the training objective does not actually require that particular sampler. A family of reverse processes is consistent with the same trained noise-prediction network, and one member of that family injects no noise at all. Set the added variance to zero and sampling becomes deterministic: from a given starting noise, one image, every time. The step is then a clean two-part operation — use the predicted noise to estimate the fully denoised image, then move back toward the noise level of the next step you care about.

Because that move is a deterministic jump to an arbitrary noise level, you can skip most of the schedule. Stated in rung 4's units, sampling goes from around a thousand steps to something in the region of twenty to fifty for good results — a speed-up of one to two orders of magnitude from reinterpreting the sampler, with the same weights and no retraining. A single parameter interpolates between this sampler and rung 4's, so the two are endpoints of one family rather than rivals.

Determinism buys a second thing that mattered as much: the map from noise to image is now invertible. You can run it backwards to find the noise that produces a given image, and that is what makes real-image editing possible — encode the photo, change the condition, decode.

01

The thousand-step problem

A diffusion model learns to reverse a gradual noising process. To generate an image it starts from pure noise and denoises in many small steps — in the original DDPM, typically a thousand of them. Each step calls the neural network once, so a single image costs a thousand forward passes. Worse, each reverse step deliberately injects a little fresh random noise (it's sampling from a distribution), so the process is stochastic: the same starting seed doesn't map to a fixed output, and there's no clean way to invert it. Beautiful results, but painfully slow and hard to control.

DDIM (Denoising Diffusion Implicit Models, Song, Meng & Ermon, 2021) fixes both problems at once — and, remarkably, with the exact same trained network. It reformulates the reverse process so that (a) you can take big jumps across many timesteps, sampling in 10–50 steps instead of 1000, and (b) you can make each step deterministic by removing the random noise. It's not a new model; it's a smarter way to walk backward through the one you already trained.

The one-sentence version

Each DDIM step predicts the clean image x0 from the current noisy image, then re-projects it to an earlier timestep via x_{t−1} = √ᾱ_{t−1}·x0 + √(1−ᾱ_{t−1}−σ²)·ε + σ·noise; setting σ = 0 makes it deterministic and lets you skip timesteps — same network, no retraining.

02

Predict, then re-project

The key reframing: at every timestep, don't think about "removing a little noise." Think about guessing the whole finished image, then stepping partway back toward it. The trained network predicts the noise ε in the current noisy image x_t; from that you can algebraically solve for an estimate of the fully clean image:

ᾱ_t (alpha-bar) is the cumulative fraction of the original signal still present at step t. This just inverts the forward noising x_t = √ᾱ_t·x0 + √(1−ᾱ_t)·ε to recover x0 from x_t and the predicted ε.

Once you have a guess x̂₀ for the destination, you don't have to crawl there one timestep at a time — you can re-project it forward to any earlier noise level you like, jumping over dozens of intermediate steps. That's what breaks the thousand-step tyranny: because each step is anchored to a prediction of the final image rather than a purely local nudge, big jumps stay coherent. Pick a sub-sequence of, say, 50 timesteps out of 1000, and denoise along just those. The predict-then-re-project structure is what makes the skipping valid.

03

Zero the noise

The full DDIM step re-projects the predicted clean image with three ingredients:

The three parts of a DDIM step
→ x̂₀Point toward the predicted clean image: √ᾱ_{t−1} · x̂₀.
→ εPoint along the predicted noise direction: √(1−ᾱ_{t−1}−σ²) · ε.
→ noiseAdd fresh random noise: σ · z. This is the only stochastic part.
σ = 0Drop the random term entirely — the step becomes a deterministic function of x_t.

The random term is scaled by σ. DDIM's move is simply to set σ = 0. With no random noise injected, the next state is a fixed, deterministic function of the current one — the same starting noise always produces the same image. That determinism is not just about speed; it unlocks real capabilities. You get reproducibility (a seed maps to exactly one output), meaningful interpolation (blend two seeds and the images blend smoothly, because latents and outputs are one-to-one), and inversion — run the deterministic map backward to recover the latent of a real image, then edit it. None of that is possible when every step rolls fresh dice.

04

The update rule

The full DDIM update, with the stochasticity controlled by σ:

x̂₀ is the predicted clean image; ε is the network's noise prediction; z is fresh standard noise. The middle term keeps just enough noise to land at level ᾱ_{t−1}, minus whatever σ re-injects.

The magic is that a single parameter σ spans a whole family of samplers. The paper writes it as:

η = 1 gives σ its full value, a stochastic DDPM-style sampler with the posterior variance (not the larger σ² = β setting behind the DDPM paper's FID 3.17); η = 0 gives σ = 0 and the fully deterministic DDIM. Intermediate η blends the two.

So DDPM and DDIM aren't rival models — they're the two endpoints of one parameterized family, with η the dial between "diverse and stochastic" and "deterministic and invertible." The runnable version below implements the clean-image prediction, the σ formula, and a deterministic step — and shows the noise term vanishing when σ = 0.

How it works

How DDIM reuses a DDPM network with a faster sampler, step by step

Song, Meng and Ermon start from what DDPM's training loss actually depends on. The objective is built only from the marginals q(xt | x0), one noise level at a time, never from the joint distribution of the whole forward chain. Any forward process with the same marginals therefore has the same training objective and the same optimal network. DDIM builds a family of such processes, most of them not Markov chains, and derives a sampler from each.

DDPM sampler: 1,000 steps, noise every step x1000 x999 x998 … x2 x1 x0 one network call + fresh noise per arrow DDIM sampler, η = 0: 4 jumps, no noise x1000 x750 x500 x250 x0 via x̂0 via x̂0 via x̂0 via x̂0 every kept step keeps DDPM's marginal q(xt | x0), so the same εθ applies
DDPM’s sampler (top) must walk the whole chain. DDIM’s (bottom) jumps between a few kept timesteps through the predicted clean image, with no injected noise at η = 0. The kept steps share DDPM’s marginals, which is why no retraining is needed.

A note on notation: the DDIM paper writes αt for the cumulative product that DDPM calls ᾱt. This page uses ᾱt throughout.

  1. Keep the trained network. Start from εθ(xt, t) trained with DDPM's simple loss on a 1,000-step schedule. Every sampler compared in the paper runs on the same weights for a given dataset; nothing is retrained.
  2. Define a non-Markovian forward process. Choose a variance σt^2 for every step and define qσ(xt−1 | xt, x0) as a Gaussian whose mean mixes x0 with the noise direction implied by xt. By construction every marginal qσ(xt | x0) equals DDPM's N(√ᾱt x0, (1 − ᾱt) I). The implied forward step from xt−1 to xt depends on x0 as well, which is what makes the process non-Markovian.
  3. Turn it into a sampler. At generation time x0 is unknown, so substitute the estimate x̂0 = (xt − √(1 − ᾱt) εθ)/√ᾱt and sample from qσ(xt−1 | xt, x̂0). At the final step the output is x̂0 itself.
  4. Choose how much noise. One number, η, sets every σt. At η = 1 the process becomes Markovian again and the sampler is DDPM's with the posterior variance. At η = 0 no noise is added at all: this is the denoising diffusion implicit model, a deterministic map from xT to x0.
  5. Skip timesteps. Pick an increasing sub-sequence τ of the 1,000 training timesteps, S of them, spaced linearly or quadratically. The same construction defined only over τ still has matching marginals, so the same network applies, and each update jumps from τi to τi−1 using ᾱ at those two indices. The paper tested S from 10 up to the full 1,000.
  6. Optionally run it backward. With η = 0 the update is invertible in the limit of small steps, so applying it from t = 0 upward encodes a real image into the xT that regenerates it.

Why the same network is valid for every member

For each choice of σ, the variational objective of the new process equals a DDPM loss with some per-step weights, plus a constant. If the network's parameters were not shared across timesteps, the optimum of such a weighted loss would not depend on the weights at all, so the network trained with equal weights is the right network for every σ. The paper uses this argument to justify reusing DDPM checkpoints. DDIM is a statement about sampling, not a new model.

The ODE reading

Divide the deterministic update by √ᾱ and it becomes one Euler step of an ordinary differential equation in the rescaled variable x/√ᾱ, integrated against the noise level √((1 − ᾱ)/ᾱ). That explains why larger steps work as long as the trajectory is smooth, why a fixed xT gives consistent images across different step counts, and why later samplers such as DPM-Solver could improve on it with higher-order integration of the same equation.

The math

The non-Markovian posterior that keeps DDPM’s marginals

qσ(xt−1 | xt, x0) = N( √ᾱt−1 x0 + √(1 − ᾱt−1 − σt^2) · (xt − √ᾱt x0) / √(1 − ᾱt), σt^2 I )
⟹ qσ(xt | x0) = N( √ᾱt x0, (1 − ᾱt) I ) for every t, whatever σ is
Jσ = Lγ + C; with σ = 0: xt−Δt/√ᾱt−Δt = xt/√ᾱt + ( √((1 − ᾱt−Δt)/ᾱt−Δt) − √((1 − ᾱt)/ᾱt) ) εθ(xt, t)
  • (xt − √ᾱt x0)/√(1 − ᾱt) — the exact unit noise that produced xt from x0; the sampler replaces it with εθ.
  • √(1 − ᾱt−1 − σt^2) — how much of that same noise to keep. Kept noise variance plus fresh noise variance σt^2 always total 1 − ᾱt−1, which is how the marginal is preserved.
  • Jσ = Lγ + C — each member's variational objective equals a DDPM loss with some per-step weights γ, plus a constant.
  • the last line — the deterministic update rewritten as one Euler step of an ODE in x/√ᾱ.

Extremes: σt^2 = 1 − ᾱt−1 keeps none of the old noise, so xt−1 forgets xt except through x̂0. σt = 0 keeps all of it, so the trajectory is deterministic and fresh noise never enters. η = 1 sits between them, at the DDPM posterior variance.

The evidence

What DDIM measured: FID against the number of steps

The main experiment fixes one trained network per dataset and varies only the sampler: η ∈ {0, 0.2, 0.5, 1} and the number of steps S ∈ {10, 20, 50, 100, 1000}, on CIFAR-10 (32×32), CelebA (64×64) and LSUN Bedroom and Church (256×256). An extra baseline, written σ̂, uses the larger variance σt^2 = βt of the original DDPM CIFAR-10 sampler. Scores are FID, lower is better. CIFAR-10:

SamplerS = 1020501001000
DDIM, η = 013.366.844.674.164.04
η = 1 (DDPM, posterior variance)41.0718.368.015.784.73
σ̂ (DDPM, σ^2 = β)367.43133.3732.729.993.17

The pattern held on the other datasets: at short schedules η = 0 was best, and its lead widened as S fell. The paper summarizes the result as high-quality samples 10× to 50× faster in wall-clock time than DDPM.

The negative result is in the last column. With all 1,000 steps, the original DDPM sampler with σ̂ beats DDIM, 3.17 against 4.04, so determinism is not free when you can afford the full chain. The σ̂ row also shows how badly a high-variance stochastic sampler tolerates skipping: an FID of 367 at 10 steps means noise, not images.

Three further results follow from determinism. Samples generated from the same xT with different S share their high-level content, so xT behaves like a latent code. Spherical interpolation between two xT values gives smooth, semantically meaningful transitions. And encoding CIFAR-10 test images to xT and decoding them back gives a reconstruction error that falls steadily as S grows, something DDPM's stochastic sampler cannot offer at all.

Since then

What the authors admit, and what happened next

Quality does degrade as the step count falls, and the paper reports it rather than presenting the speed-up as free — there is a knee, and very aggressive schedules show it. The deterministic sampler also gives up some of the diversity that the injected noise supplied, which is a real trade even though it is usually a good one.

Inversion is exact in theory and approximate in practice: round-tripping a real image through the reverse and forward processes accumulates error, especially with strong conditioning, and a great deal of subsequent editing research is about controlling that drift.

How it held up: nobody runs a thousand steps. This rung made diffusion usable, and the direction it opened — treat sampling as solving a differential equation and bring better solvers to it — produced a steady march down to a handful of steps, and then to distilled samplers that need one or two. The invertibility is the quieter contribution and arguably the more important one, since it turned a generator into an editor.

SOLVE IT YOURSELF

A DDIM step, from scratch

DDIM sampling is two moves: predict the clean image x0 from the noisy x_t and the model's noise ε, then re-project to an earlier noise level. Here it is on scalars — no U-Net, just the algebra. predict_x0 inverts the forward noising; sigma(eta) is zero for deterministic DDIM and positive for stochastic DDPM; and with σ=0 the step ignores the random-noise argument entirely. Change the alpha-bar schedule and η and watch DDPM turn into DDIM.

YOUR TASK

Write the body of ddim_step. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. Predict_x0 inverts the noising -- it recovers the clean image (x0 = 2.0)
  2. DDIM is deterministic -- with sigma=0 the random-noise argument is ignored
  3. Eta=0 gives zero noise variance -- the deterministic DDIM sampler
  4. Eta=1 gives positive noise -- this is the stochastic, DDPM-style sampler
  5. The final step (abar_prev = 1) lands exactly on the clean image x0 = 2.0
CPython · WebAssembly
06

The fast-sampler era

DDIM's reframing of sampling as following a deterministic trajectory — effectively solving an ordinary differential equation — kicked off the entire fast-sampler research line. DPM-Solver and its successors treat the reverse process as an ODE and use higher-order numerical integrators to get comparable quality in even fewer steps, sometimes under ten. Nearly every modern diffusion tool ships with a menu of these samplers, and DDIM is the historical root and still a common default.

Its determinism became foundational for control. "DDIM inversion" — running the deterministic map backward to find the latent that would generate a given real image — underpins a large family of diffusion-based image-editing methods. The deterministic latent space also pairs naturally with classifier-free guidance for prompt control, and the whole approach carries over to the compressed latent space of latent diffusion that powers today's text-to-image systems. What began as a cleverer way to walk backward through a diffusion model became one of the load-bearing pieces of the generative-imaging stack.

Worth knowing

DDIM doesn't change the training objective at all — it's purely an inference-time reinterpretation of the same trained noise-prediction network. That's why you can take any existing DDPM checkpoint and immediately sample from it with DDIM, or even switch samplers between generations. The paper showed the DDPM and DDIM objectives share the same training loss, so the model never needs to know which sampler will be used.

Questions

Questions people ask about DDIM

Why can DDIM sample from a DDPM checkpoint without retraining?

DDPM's training loss is built only from the marginals q(x_t | x_0), the distribution of a noisy image at one noise level given the clean image; it never uses the joint distribution of the whole forward chain. DDIM constructs a family of forward processes, mostly non-Markovian, that share exactly those marginals, and proves that each one's variational objective equals a DDPM loss with some per-step weighting plus a constant. A network trained on the standard equal-weight loss is the right network for all of them, at least when weights are not shared across steps, which is the argument the paper relies on. So every sampler in the family, including the deterministic one, runs on the same weights; only the update rule used at generation time changes.

How is the DDIM update rule derived?

Start from two requirements: x_{t−1} given x_t and x_0 must be Gaussian, and the marginal at every step must stay N(√ᾱ_t x_0, (1 − ᾱ_t) I). Write x_t as √ᾱ_t x_0 plus √(1 − ᾱ_t) times a unit noise. Then build x_{t−1} as √ᾱ_{t−1} x_0, plus some multiple of that same noise, plus fresh noise of variance σ_t², with the two noise variances summing to 1 − ᾱ_{t−1}. That fixes the coefficient on the old noise at √(1 − ᾱ_{t−1} − σ_t²). At sampling time the clean image and the old noise are unknown, so substitute the network's estimates: predicted noise ε_θ, and x̂_0 from inverting the forward formula. Setting σ_t = 0 gives the deterministic DDIM step.

How many sampling steps does DDIM need compared with DDPM?

On CIFAR-10 the deterministic sampler reached FID 6.84 with 20 steps, 4.67 with 50 and 4.16 with 100, against 4.04 with all 1,000. The DDPM sampler with the posterior variance needed far more for the same quality, scoring 18.36 at 20 steps and 8.01 at 50, and the original DDPM variance collapsed on short schedules, 133 at 20 steps. So 50 to 100 DDIM steps match what DDPM needs most of its 1,000 steps to reach, and the paper puts the speed-up at 10 to 50 times in wall-clock time. At the full 1,000 steps, though, original DDPM sampling is still better, 3.17 against 4.04, so DDIM wins on budget rather than on peak quality.

Is DDIM an ODE solver?

Its deterministic version is. Dividing the update by √ᾱ turns it into exactly one Euler step of an ordinary differential equation for the rescaled image x/√ᾱ, integrated against the noise level √((1 − ᾱ)/ᾱ), with the trained noise predictor supplying the direction. The paper makes the connection explicitly and shows the equation corresponds to the probability-flow ODE of the variance-exploding score-based model of Song and colleagues, with the Euler step taken in a different variable. Seeing sampling as numerical integration opened the door to better integrators: DPM-Solver and similar higher-order methods reach comparable quality in fewer steps, and they still run on the same pretrained networks.

What does the eta parameter do in DDIM, and when is eta = 1 better?

Eta scales the fresh noise added at each step: σ_t = η · √((1 − ᾱ_{t−1})/(1 − ᾱ_t)) · √(1 − ᾱ_t/ᾱ_{t−1}). At eta = 0 no noise is added and sampling is deterministic and invertible. At eta = 1 the noise equals the DDPM posterior variance and the forward process becomes Markovian again, so the sampler is DDPM's. In the paper's experiments eta = 0 gave the best FID on short schedules, and larger eta got steadily worse as steps were removed, because each injected noise sample must be cleaned up by later steps and short schedules have too few of them. Stochasticity pays off mainly on long schedules: at 1,000 steps the original DDPM variance gave the best CIFAR-10 FID of all, 3.17.

How does DDIM inversion work, and why is it only approximate?

Because the deterministic update maps x_t to x_{t−1} with no randomness, you can run it in the other direction, from t = 0 upward, using the network's noise prediction at each step to move a real image to the noise level of the next kept timestep. The endpoint is an x_T that the ordinary sampler turns back into roughly the same image, so you can edit by changing the prompt or other conditioning and sampling again. It is exact only in the limit of infinitely small steps, since each backward step uses the noise predicted at the current point rather than at the point it is moving to. The paper's CIFAR-10 reconstruction error shrinks as the number of steps grows; with strong guidance the drift grows, which later inversion methods correct.

Check yourself

4 questions to test what you just read

Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.

With ᾱ_t = 0.5, ᾱ_{t−1} = 0.8, x_t = 1.0 and predicted noise ε = 0.4, what x_{t−1} does a deterministic DDIM step produce?

Show answer

First predict the clean image: x̂0 = (1.0 − √0.5 × 0.4)/√0.5 = 0.7172/0.7071 ≈ 1.014. Then re-project it to the lower noise level: xt−1 = √0.8 × 1.014 + √0.2 × 0.4 ≈ 0.907 + 0.179 ≈ 1.086, with no random term because σ = 0.

For the same ᾱ values, how large is σ at η = 1, and how does it change the coefficient on the predicted noise?

Show answer

σ = √(0.2/0.5) × √(1 − 0.5/0.8) = 0.632 × 0.612 ≈ 0.387, so σ² ≈ 0.15. The coefficient on ε drops from √0.2 ≈ 0.447 to √(0.2 − 0.15) = √0.05 ≈ 0.224: most of the old noise direction is replaced by fresh noise.

Why does the η = 1 sampler degrade far faster than η = 0 as S falls from 1,000 to 10 on CIFAR-10?

Show answer

Every stochastic step injects new noise that later steps must remove. With 10 steps there are only a few large jumps left to clean up, so leftover noise remains: FID 41.07 against 13.36 for η = 0. The deterministic sampler just follows a smooth trajectory, which Euler steps approximate tolerably even when they are large.

Why does changing the forward process not change what the network should learn?

Show answer

The loss only ever sees xt drawn from the marginal q(xt | x0), one t at a time. Every member of the DDIM family has the same marginals, so the training inputs, the target ε and the optimal predictor are identical; only the way steps are chained at sampling time differs.

Where this sits

Generating pixels

Ten papers from the first latent-variable generator to video and real-time 3D. The diffusion half is strictly cumulative — each rung removes a cost the last one paid.

  1. 1VAE2014
  2. 2GANs2014
  3. 3VQ-VAE2017
  4. 4DDPM2020
  5. 5DDIM2021
  6. 6Classifier-Free Guidance2021
  7. 7Latent Diffusion2022
  8. 8Sora2024
  9. 9NeRF2020
  10. 103D Gaussian Splatting2023

All 110 papers, in 19 ladders →

Finished this one? 0 / 110 Paper Breakdowns done
NextClassifier-Free Guidance Next on the “Generating pixels” ladder · rung 6 of 10

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns