DDPM schedulers add fresh noise on terminal transitions when the final timestep is nonzero
Describe the bug
With variance_type="fixed_large" and timestep_spacing="trailing", DDPMScheduler.step() adds noise to the final clean-data prediction. For 1000 training timesteps and 50 inference steps, the last selected timestep is 19 and previous_timestep(19) returns -1, but step() still enters its noise branch because it checks t > 0.
The mean at this boundary is already pred_original_sample (alpha_prod_t_prev=1). Adding a fresh random term changes the returned clean prediction. The default fixed_small variance and leading spacing are controls; this report does not claim they have the same visible output error.
The same guard appears in DDPMParallelScheduler.step(). I also reproduced the issue with a custom schedule ending at a positive timestep and with learned/learned_range variance. This report concerns these step() methods; video/image-quality impact has not been measured.
Current main source:
- https://github.com/huggingface/diffusers/blob/06a9cfb86ae8aa69c6a220ba0da0f37b819dde6a/src/diffusers/schedulers/scheduling_ddpm.py#L543
- https://github.com/huggingface/diffusers/blob/06a9cfb86ae8aa69c6a220ba0da0f37b819dde6a/src/diffusers/schedulers/scheduling_ddpm_parallel.py#L558
Reproduction
This directly calls the public scheduler API on CPU; no model weights are required. prediction_type="sample" supplies the predicted clean sample explicitly.
import torch
from diffusers import DDPMScheduler
x = torch.zeros(1, 1, 2, 2)
x0 = torch.full_like(x, 0.25)
for variance in ("fixed_small", "fixed_large"):
scheduler = DDPMScheduler(
variance_type=variance,
timestep_spacing="trailing",
prediction_type="sample",
clip_sample=False,
)
scheduler.set_timesteps(50)
t = scheduler.timesteps[-1]
out = scheduler.step(x0, t, x, generator=torch.Generator().manual_seed(0))
print(variance, int(t), int(scheduler.previous_timestep(t)),
(out.prev_sample - out.pred_original_sample).abs().max().item())
Logs
fixed_small 19 -1 0.0
fixed_large 19 -1 0.1654895395040512
Expected: at this terminal transition, prev_sample equals pred_original_sample, as it does when the final selected timestep is zero. For fixed_large, changing only the random generator seed changes the returned clean endpoint.
A candidate fix is to gate noise addition on whether the predecessor exists (prev_t >= 0) rather than on t > 0. In local checks, this resolves 24 terminal cases across both classes, three schedule layouts, and four variance modes, while intermediate steps still sample noise. This needs maintainer review before proposing a PR.
System Info
- Diffusers: reproduced on 0.42.1 and current main 06a9cfb86ae8aa69c6a220ba0da0f37b819dde6a (0.42.0.dev0)
- Platform: macOS 27.0, arm64
- Python: 3.12.10
- PyTorch: 2.14.1
- huggingface_hub: 2.3.0
- Safetensors: 0.8.0
- CPU, float32; no distributed setup or model downloads
Pretrained google/ddpm-cifar10-32, CPU float32, 50 steps, trailing, and the model’s fixed_large variance. Identical settings and seeds 0–3; only the terminal-noise guard changes. Difference amplified 4×; 32×32 outputs enlarged without smoothing. This illustrates the added noise, not an overall quality benchmark.

I benchmarked 32 seeds with the pretrained CIFAR-10 model, using 50 steps and the affected trailing setting.
Extra error relative to the model’s final clean prediction, on a 0–255 intensity scale:
| Measurement | Before | Fixed |
|---|---|---|
| Mean absolute error | 7.59 | 0 |
| Root mean squared error | 9.56 | 0 |
| RGB channels with error ≥10 | 29.3% | 0% |
The default leading setting produced identical images before and after for all 32 seeds.
These numbers quantify the unwanted noise removed. They don’t establish an overall quality improvement such as a better FID score.
Hi, I'd like to pick this up. Plan: gate the noise branch in DDPMScheduler.step() and DDPMParallelScheduler.step() on whether a predecessor timestep exists (prev_t >= 0) instead of on t > 0, and add regression tests asserting the terminal transition returns pred_original_sample exactly for both schedulers.
Claiming this issue; fix is in PR #15203 (davrens101 fork). Change tested locally; AI-assisted, disclosed in PR body.