Skip to content

Fix DDIMScheduler.step() prev_timestep for non-leading spacing#13108

Open
Mr-Neutr0n wants to merge 1 commit intohuggingface:mainfrom
Mr-Neutr0n:fix-torchao-logger
Open

Fix DDIMScheduler.step() prev_timestep for non-leading spacing#13108
Mr-Neutr0n wants to merge 1 commit intohuggingface:mainfrom
Mr-Neutr0n:fix-torchao-logger

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Fix DDIMScheduler.step() to correctly compute prev_timestep when timestep_spacing is set to linspace or trailing
  • The previous implementation used a hard-coded formula (timestep - num_train_timesteps // num_inference_steps) that only produces correct values for timestep_spacing="leading"
  • Replace with a previous_timestep() method that looks up the next timestep from self.timesteps, consistent with the approach already used in DDPMScheduler

Fixes #12633

Test plan

  • Verify DDIM sampling produces correct results with timestep_spacing="linspace"
  • Verify DDIM sampling produces correct results with timestep_spacing="trailing"
  • Verify no regression with default timestep_spacing="leading"

When timestep_spacing is set to 'linspace' or 'trailing', the formula
timestep - num_train_timesteps // num_inference_steps does not produce
the correct previous timestep. Use a lookup into self.timesteps instead,
matching the approach used in DDPMScheduler.previous_timestep().
@Mr-Neutr0n
Copy link
Author

Friendly bump! Let me know if there's anything I should update or improve to help move this forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DDIMScheduler.step() logic mismatches set_timesteps() list when using timestep_spacing='linspace'

1 participant