huggingface / huggingface/diffusers
DDIMInverseScheduler.step: Incorrect Previous Timestep Calculation
- Dominant language
- Python
- Stars
- 34.5k
- Forks
- 7.3k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 91
Description
### Describe the bug
There is a bug in DDIMInverseScheduler.step related to how the previous timestep is computed.
The inverse scheduler should move from timestep $t+1$ to $t$, but currently, the code is mistakenly computing $t-1$ instead of $t+1$.
https://github.com/huggingface/diffusers/blob/89e4d6219805975bd7d253a267e1951badc9f1c0/src/diffusers/schedulers/scheduling_ddim_inverse.py#L327C1-L331C10
This should be corrected to ensure the inverse process aligns properly with the intended scheduling.
```
# 1. get previous step value (=t+1)
prev_timestep = min(
timestep + self.config.num_train_timesteps // self.num_inference_steps,
self.config.num_train_timesteps - 1
)
```
For comparison, DDIMScheduler correctly calculates $t-1$, as expected in a forward process:
https://github.com/huggingface/diffusers/blob/89e4d6219805975bd7d253a267e1951badc9f1c0/src/diffusers/schedulers/scheduling_ddim.py#L401C1-L402C95
### Reproduction
This issue is straightforward to verify, so a reproduction snippet is omitted.
### Logs
```shell
```
### System Info
diffusers==0.32.2
### Who can help?
@yiyixuxu
Contributor guide
Assessment
This issue has not been assessed yet.