huggingface / huggingface/diffusers

DDIM previous timestep issue

Open
#11,347 1 comment 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

### Describe the bug

When using `diffusers.schedulers.scheduling_ddim.DDIMScheduler` with timestep_spacing='linspace' the value of the previous timestep that is calculated is not the right one, leading to a drop in model performance.

If you run the attached code with `print(timestep,prev_timestep,prev_timestep_)` added just after calculating the previous timestep in the step fn, you can see that the timestep and prev_timestep do not match from one iteration to the next.

### Reproduction

from diffusers.schedulers.scheduling_ddim import DDIMScheduler
import torch

ddim_scheduler = DDIMScheduler(
num_train_timesteps=100,
beta_schedule='squaredcos_cap_v2',
clip_sample=True,
prediction_type='epsilon',
timestep_spacing='linspace',
)

ddim_scheduler.set_timesteps(5)

for i in ddim_scheduler.timesteps:
noise = torch.randn(1, 3, 64, 64)
a = ddim_scheduler.step(noise,i,noise)

### Logs

```shell

```

### System Info

Name: diffusers
Version: 0.32.2
Summary: State-of-the-art diffusion in PyTorch and JAX.
Home-page: https://github.com/huggingface/diffusers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/diffusers/graphs/contributors)
Author-email: diffusers@huggingface.co
License: Apache 2.0 License
Location: /home/m84396953/miniconda3/envs/eaib/lib/python3.12/site-packages
Requires: filelock, huggingface-hub, importlib-metadata, numpy, Pillow, regex, requests, safetensors
Required-by:

Python 3.12.8

### Who can help?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.