Skip to content

DDIMInverseScheduler.step: Incorrect Previous Timestep Calculation #10695

Open
@stop1one

Description

@stop1one

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions