Deep LearningAdvanced Generative Neural Networks

How does DDIM sampling differ from DDPM sampling?

DDPM and DDIM are two ways to generate images by repeatedly using a trained diffusion noise-prediction network to move from noisy data toward a clean sample. A conventional DDPM sampler takes *stochastic* reverse steps; DDIM permits *deterministic* reverse steps and can visit a shorter subsequence of timesteps. Crucially, DDIM can reuse the same model trained with the standard DDPM noise-prediction objective, so accelerated sampling does not inherently require retraining.

1. The difference in practical terms

Imagine beginning with the same random-noise image x_T.

  • DDPM: At each reverse timestep, the trained network estimates how much noise is present. The sampler computes a cleaner mean and typically adds fresh random Gaussian noise before the next step.
  • Deterministic DDIM: It uses the network's noise estimate to predict the clean image and a corresponding earlier noisy state, but adds no fresh random noise when η = 0.
  • Stochastic DDIM: A parameter η > 0 adds controlled randomness to the DDIM update. DDIM is therefore not always deterministic.
  • Fewer model calls: DDIM can move through, for example, a selected 50-timestep sequence instead of all 1,000 trained timesteps. This often accelerates sampling substantially, although quality may change.
  • Same denoiser: The difference is primarily the reverse sampling rule and step selection, not a requirement to change the model trained in Question 288.

Avoid a common oversimplification: A DDPM sampler does not *have* to use precisely one fixed number of steps in every modern implementation, and a DDIM sampler does not *have* to be deterministic. The definitions describe important algorithmic choices, not an absolute speed ranking for all schedulers.

2. How a conventional DDPM reverse step works

The original DDPM model approximates a Gaussian Markovian reverse transition from x_t to x_(t−1).

Given the noise predictor ε_θ(x_t,t), its common reverse-mean parameterization is:

μ_θ(x_t,t) = (x_t − (β_t / sqrt(1−ᾱ_t)) × ε_θ(x_t,t)) / sqrt(α_t).

A conventional posterior-variance choice is:

β̃_t = β_t × (1−ᾱ_(t−1))/(1−ᾱ_t).

Sampling then uses:

x_(t−1) = μ_θ(x_t,t) + sqrt(β̃_t) × z, with z ~ N(0,I).

  • The mean follows the predicted denoising direction.
  • The random term introduces fresh stochastic variation if the selected reverse variance is positive.
  • Variance convention matters: Some DDPMs use different fixed or learned reverse variances; the example below deliberately uses the *posterior variance* β̃_t.
  • Last transition: With ᾱ₀ = 1, β̃₁ = 0; the final step is deterministic for this posterior-variance convention.

This is the reverse sampler. For the forward noising process and how ᾱ is constructed, see Questions 286–287 rather than re-deriving them here.

3. The DDIM update and the η parameter

DDIM first estimates what the clean sample x₀ might be:

x̂₀ = (x_t − sqrt(1−ᾱ_t) × ε_θ(x_t,t)) / sqrt(ᾱ_t).

For a selected earlier timestep s < t, it constructs:

x_s = sqrt(ᾱ_s) × x̂₀ + sqrt(1−ᾱ_s−σ²) × ε_θ(x_t,t) + σ × z.

The three components are:

  • Predicted clean content: sqrt(ᾱ_s) × x̂₀.
  • Predicted noise direction: sqrt(1−ᾱ_s−σ²) × ε_θ.
  • Optional fresh randomness: σ × z, where z ~ N(0,I).

One common parameterization is:

σ(η) = η × sqrt((1−ᾱ_s)/(1−ᾱ_t)) × sqrt(1−ᾱ_t/ᾱ_s).

  • `η = 0`: σ=0. The update is deterministic given `x_t`, the predictor and the other model conditions.
  • `0 < η < 1`: Intermediate levels of fresh stochastic noise.
  • `η = 1`: For adjacent timesteps on the full original schedule and the matching posterior-variance convention, this recovers the ordinary DDPM reverse variance and corresponding update.
  • With skipped timesteps: η=1 produces a *stochastic DDIM step*, not literally the full series of omitted DDPM transitions.

The square-root expression must be nonnegative for the chosen coefficients and admissible η. Setting η=0 does not remove randomness from the initial noise `x_T`; it only removes *new randomness inside the reverse steps*.

4. Beginner-friendly numerical example: Two reverse timesteps

We will use an illustrative two-feature noisy vector rather than images. Every noise prediction and random draw below is hypothetical; the example is designed to check the mathematics, not to report a trained model's performance.

Starting values

  • Current timestep: t=2, next timestep: s=1, then final clean step s=0.
  • Noisy current sample: x₂ = [1, −1].
  • Cumulative coefficients: ᾱ₂ = 0.60, ᾱ₁ = 0.80, ᾱ₀ = 1.
  • One-step coefficient: α₂ = ᾱ₂/ᾱ₁ = 0.75, so β₂ = 0.25.
  • Hypothetical network prediction at t=2: ε̂₂ = [0.2, −0.4].

Step A — Predict clean x₀ from x₂

x̂₀ = ([1,−1] − sqrt(0.40)×[0.2,−0.4]) / sqrt(0.60).

  • sqrt(0.40) ≈ 0.632456; sqrt(0.60) ≈ 0.774597.
  • sqrt(0.40)×ε̂₂ ≈ [0.126491,−0.252982].
  • x̂₀ ≈ [1.127695, −0.964396].

Step B — Deterministic DDIM (η=0), t=2 → s=1

With σ=0, the next state is:

x₁(DDIM,η=0) = sqrt(0.80)×x̂₀ + sqrt(0.20)×ε̂₂.

  • Clean-component term: sqrt(0.80)×x̂₀ ≈ [1.008643,−0.862582].
  • Noise-direction term: sqrt(0.20)×ε̂₂ ≈ [0.089443,−0.178885].
  • Result: `x₁(DDIM,η=0) ≈ [1.098084, −1.041467]`.

There is no new Gaussian-noise draw for this step.

Step C — Stochastic DDPM, t=2 → s=1

Choose the original DDPM posterior-variance convention:

β̃₂ = 0.25 × (1−0.80)/(1−0.60) = 0.125.

  • Reverse standard deviation: sqrt(β̃₂) = sqrt(0.125) ≈ 0.353553.
  • DDPM reverse mean:

μ₂ = ([1,−1] − (0.25/sqrt(0.40))×[0.2,−0.4]) / sqrt(0.75)

  • μ₂ ≈ [1.063413, −0.972126].
  • Choose a hypothetical fresh noise draw: z₂ = [0.5, −1].
  • Gaussian-noise contribution: sqrt(0.125)×z₂ ≈ [0.176777,−0.353553].
  • Result: `x₁(DDPM) ≈ [1.240190, −1.325680]`.

The new z₂ makes the stochastic DDPM state differ from the deterministic DDIM state, even though they began with the same `x₂` and the same predicted `ε̂₂`.

Step D — What happens for stochastic DDIM with η=1?

For these adjacent timesteps, the DDIM formula gives:

σ(1) = sqrt((1−0.80)/(1−0.60)) × sqrt(1−0.60/0.80) = sqrt(0.125) ≈ 0.353553.

Then:

x₁(DDIM,η=1) = sqrt(0.80)×x̂₀ + sqrt(0.20−0.125)×ε̂₂ + sqrt(0.125)×z₂.

With the same chosen z₂=[0.5,−1], this evaluates to:

  • `x₁(DDIM,η=1) ≈ [1.240190, −1.325680]`.
  • This matches the illustrated posterior-variance DDPM step, as it should for this particular adjacent-step setup.
  • For η=0.5, the stochastic standard deviation is half of 0.353553, or approximately 0.176777; the predicted-noise coefficient also changes, so simply halving the last DDPM noise vector is not the complete update.

Step E — Move from t=1 to the clean output at t=0

At the final transition ᾱ₀=1, so the posterior variance is zero in this toy convention. Each branch must use the denoiser's new prediction at its own x₁ state.

  • For the deterministic-DDIM branch, *suppose* ε̂₁=[0.1,−0.2].
  • Clean output estimate: x₀(DDIM) = (x₁(DDIM) − sqrt(0.20)×ε̂₁)/sqrt(0.80).
  • `x₀(DDIM) ≈ [1.177695, −1.064396]`.

For the different stochastic-DDPM state:

  • *Suppose* its next hypothetical noise prediction is ε̂₁=[0.15,−0.25].
  • x₀(DDPM) = (x₁(DDPM) − sqrt(0.20)×ε̂₁)/sqrt(0.80).
  • `x₀(DDPM) ≈ [1.311575, −1.357155]`.

These new t=1 predictions are illustrative assumed outputs of the same time-conditioned denoiser evaluated at different inputs. The numerical example does not imply one method is more accurate, and output values cannot be judged without a true data distribution.

5. Why can DDIM skip timesteps?

The DDIM update depends on the cumulative coefficients of the current and target timesteps, not just two adjacent indices. Instead of visiting T,T−1,...,1,0, a sampler can choose a descending subset such as T, ..., 500, 250, 100, 0 if those timestep indices are valid for its schedule.

Toy skipped-step example:

  • Start with the same x₂=[1,−1] and ε̂₂=[0.2,−0.4].
  • With deterministic DDIM, jump directly from t=2 to s=0.
  • Because ᾱ₀=1, its update simply returns the current clean estimate:

`x₀(DDIM, 2→0) ≈ [1.127695, −0.964396]`.

  • Compare this with the two-step DDIM result [1.177695,−1.064396] above. They differ because a two-step run can make a new noise prediction at t=1, while the skipped run never does.

A 1,000-timestep DDPM baseline might require roughly 1,000 denoiser evaluations, while a 50-step DDIM schedule needs roughly 50. That is approximately 20× fewer denoiser calls, *not a guaranteed 20× wall-clock speedup or equal sample quality*. The original DDIM paper reported 10–50× faster generation in its particular experiments.

Crucial nuance: DDIM's ability to skip steps arises from its update construction and preserved forward marginals; simply deleting intermediate transitions from an unmodified DDPM sampler is not mathematically equivalent.

6. Speed, quality, determinism, and when to use which

  • DDPM stochasticity: Fresh randomness in reverse steps can produce different outcomes even from the same starting x_T, when reverse variances are positive.
  • DDIM η=0 repeatability: A fixed initial x_T, fixed model, conditioning and numerical execution yield the same output (up to hardware/software nondeterminism), which helps controlled comparisons and latent interpolation.
  • DDIM η>0 flexibility: Adds stochasticity while retaining the DDIM update family; a higher η does not universally imply better diversity or quality.
  • Speed trade-off: Fewer denoising steps usually save neural-network calls, but larger jumps can reduce detail, miss structure or amplify predictor error.
  • Quality trade-off: Compare sample realism, diversity/coverage, latency and, when appropriate, FID/KID on a consistent evaluation setup. Neither sampler is universally superior at every budget.
  • Practical applications: Faster text-to-image or other diffusion generation, rapid iteration on synthetic samples, deterministic editing experiments, and situations where inference cost matters.
  • Beyond this comparison: Modern solvers and variance-learning methods can accelerate DDPM-derived models too; DDPM ≠ always slow, DDIM ≠ automatically faster in every implementation.

7. Implementation checklist and pitfalls

  1. Start from the trained predictor: Reuse ε_θ(x_t,t) and the exact training-time cumulative alpha-bar schedule. DDIM does not need a separately trained generator.
  2. Select descending timesteps: Ensure every target timestep is earlier than the current one; include an appropriate clean endpoint ᾱ₀=1.
  3. Predict `ε̂` and `x̂₀`: Compute the clean estimate at the current noise level before forming the next state.
  4. Apply the correct update: DDPM uses its reverse mean and chosen variance; DDIM uses clean content, predicted noise direction and optional σ(η)z.
  5. Check indexing: Some code defines training timesteps 0,...,T−1 and represents the mathematical clean endpoint with index −1. Do not accidentally use a corrupted alpha-bar value for that endpoint.
  6. Keep square roots valid: Floating-point errors near boundaries can make 1−ᾱ_s−σ² slightly negative; clamp only justified numerical roundoff and validate admissible variance.
  7. Know the variance convention: A learned-variance DDPM or a sampler using variance β_t is not identical to the posterior-variance toy DDPM used here.
  8. Beware guidance and clipping: Changing guidance strength, clipping x̂₀, or altering timestep spacing can modify results; compare schedules under otherwise consistent settings.
  9. Evaluate end-to-end: Measure denoiser calls, actual device latency, image fidelity, diversity and seed sensitivity, not just theoretical step counts.

Curriculum boundaries: Question 286 covers forward Gaussian noising; Question 287 covers the noise schedule; Question 288 covers training ε_θ. This lesson focuses on using a trained noise predictor for DDPM versus DDIM reverse sampling. Question 290 introduces classifier-free guidance, which is a separate way to use conditioning at inference.

Key takeaway: DDPM generally samples stochastic reverse transitions, while DDIM offers an `η`-controlled family of updates that can be deterministic and can skip timesteps using the same DDPM-trained noise predictor. Fewer neural-network evaluations can improve speed, but quality, variance conventions, indexing and schedule compatibility still matter.

Research: Ho, Jain & Abbeel, *Denoising Diffusion Probabilistic Models* (NeurIPS 2020); Song, Meng & Ermon, *Denoising Diffusion Implicit Models* (ICLR 2021); Nichol & Dhariwal, *Improved Denoising Diffusion Probabilistic Models* (ICML 2021).

#DDIM sampling vs DDPM sampling explained#DDIM DDPM deterministic stochastic eta numerical example#DDIM reverse sampling formula predicted x0 epsilon theta#DDIM eta parameter timestep skipping comparison#DDPM posterior variance reverse mean example#DDIM same DDPM trained denoiser faster sampling#DDIM vs DDPM speed sample quality tradeoffs#deep-learning#diffusion-models#ddim

Learning Sequence

Deep Learning Curriculum

99% Completed
Up NextDeep Learning

What is classifier-free guidance in diffusion models?

Explore Related Questions

Deepen your understanding across related Deep Learning topics.

Machinoai Logo
Machinoai

Your edge in the AI era. Deep dives into machine learning concepts, paper explainers, verified industry jobs, and developer tools.

© 2026 Machinoai. All rights reserved.