Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDIMInverseScheduler.step: Incorrect Previous Timestep Calculation #10695

Open
stop1one opened this issue Jan 31, 2025 · 0 comments
Open

DDIMInverseScheduler.step: Incorrect Previous Timestep Calculation #10695

stop1one opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@stop1one
Copy link

stop1one commented Jan 31, 2025

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

System Info

diffusers==0.32.2

Who can help?

@yiyixuxu

@stop1one stop1one added the bug Something isn't working label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant