Deterministic sampling
In the DDPM example you trained a noise predictor and generated samples with the stochastic reverse chain. That chain has two practical drawbacks. It is slow, because it visits every timestep, and with that means 500 network calls per sample. It is also random. Even from a fixed starting noise the chain adds fresh noise at each step, so you cannot reproduce a sample or interpolate between two of them. DDIM (Song et al., 2020) addresses both. It defines a non-Markovian forward process with the same marginals as DDPM (Ho et al., 2020), so the same trained works with a different sampler. The sampler can skip timesteps, for example 50 steps instead of 500. A noise level moves it between a chain close to DDPM at and a deterministic update at . The deterministic case turns the model into a map from Gaussian noise to data. With a finite number of steps this map is only approximately invertible, and it becomes exactly invertible as the step size shrinks. That near-invertibility is what makes latent-space arithmetic and image editing possible. The schedule is the one from the DDPM example: 500 steps with linear from to . In the clock of the Fokker-Planck section, the forward chain is the Ornstein-Uhlenbeck process observed at discrete times, with and . The last step sits at . The sampler starts from , which is close to the last forward marginal but not equal to it. The stochastic DDPM chain is Gaussian by construction, while the true finite-step reverse transitions of a mixture are not, so that chain only approximates them. DDIM with integrates the probability flow ODE, which the score-based section also uses. Each update is an Euler step, but not in the time . After the change of variables and , the right side of the ODE is the noise prediction alone, and one Euler step in is exactly the DDIM update. The section before the update rule derives this. Each sample moves along a velocity field, as in flow matching, so the same starting noise always gives the same sample.Same target distribution as the DDPM tutorial
The 3-cluster MoG, seed 42, 300 points. We then train the same MLP noise predictor with the same DDPM objective.Code
Code
Forward (noising) process
Same fixed Markov noising chain as DDPM: . We visualize a few specific timesteps so the noise schedule is concrete before training.Code
Code
Train the noise predictor (same architecture and objective as DDPM)
DDIM and DDPM share the training step, only the sampler differs.Code
Code
The deterministic update as an Euler step
Write and for the coefficients in , with the OU time. Step sits at , where and . So for every , and the prediction table gives the score . The probability flow ODE from the Fokker-Planck section then reads The right side has a linear part and a part that depends on the network. Change variables to the rescaled position and the noise-to-signal ratio, With and , the time derivatives of the new variables are Dividing the first by the second removes the factor and the linear part with it: One Euler step in from to an earlier gives . Multiplying by returns to : With the same step reads , the case of the update rule below. DDIM is therefore an Euler integrator in , not in OU time. Its error comes from how much changes over the step. If the noise prediction were constant along the path, a single step would be exact.The DDIM update rule
Given the trained , define a strictly increasing sub-sequence . The DDIM reverse step from to is with the predicted clean sample and the per-step noise scale Two regimes:- , full noise. The sampler becomes equivalent to DDPM (after accounting for sub-sequence corrections).
- , deterministic. The noise term disappears and the step reduces to the Euler step in from the previous section, so the same always produces the same .
Code
Code
Code
Code
DDIM in 50 steps versus DDPM-equivalent in 500 steps
Three samplers, same model, 1000 generated points each:- DDIM η=0, 50 steps, fast, deterministic.
- DDIM η=1, 500 steps, equivalent to DDPM, sanity check.
- DDIM η=0, 500 steps, deterministic with the full timestep grid.
Code
Code
Determinism: same noise, same sample
With the sampler is a deterministic function of the initial noise . Run it twice with the same and you get bit-identical outputs, regardless of how many steps you take.Code
Code
Latent interpolation: slerp on
Because DDIM is a deterministic map that is approximately invertible (exactly so only as the step size shrinks), you can pick two endpoints in noise space and walk a path between them; each intermediate noise decodes to a coherent point in data space. The right path on the unit sphere is spherical linear interpolation (slerp), which preserves the Gaussian magnitude.Code
Code
Connections to other concepts
- Sampler decoupling. Training trains; sampling samples. DDIM proves you can swap samplers freely as long as marginals are preserved. Modern stacks ship many samplers (DDIM, DPM-Solver, Euler, Heun, …) on top of the same DDPM-trained network.
- Step count is a knob, not a constant. Image-generation pipelines routinely use 20-50 DDIM steps in production where DDPM would take 1000.
- Deterministic, approximately invertible. DDIM gives you a noise-to-data map you can run forwards and backwards. The round trip is exact only as the step size shrinks, and it is accurate enough for editing and interpolation.
- Bridge to flows and ODEs. Deterministic DDIM is the discretization of a probability-flow ODE. That connection underlies most of the recent diffusion-model speedup work (consistency models, rectified flow, …).
- Score-based unification. The score mixture example trains a score network on the same mixture under the same Ornstein-Uhlenbeck process, then samples with the reverse SDE and the probability flow ODE (Song et al., 2020). Deterministic DDIM is an Euler discretization of that ODE in rescaled coordinates.
PyTorch reference
References
- Ho, J., Jain, A., Abbeel, P. (2020). Denoising Diffusion Probabilistic Models. arXiv [cs.LG]. DOI
- Song, J., Meng, C., Ermon, S. (2020). Denoising Diffusion Implicit Models. arXiv [cs.LG]. DOI
- Song, Y., Sohl-Dickstein, J., Kingma, D., Kumar, A., Ermon, S., et al. (2020). Score-based generative modeling through stochastic differential equations. arXiv [cs.LG]. DOI
Found an error on this page? Report an issue.

