Skip to content

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Bug: CogVideoXDDIMScheduler.step() and CogVideoXDPMScheduler.step() compute prev_timestep using timestep - num_train_timesteps // num_inference_steps, which only works correctly when timestep_spacing="leading". For "linspace" or "trailing" spacing, timesteps are not uniformly spaced by that stride, so the formula produces incorrect previous timestep values and wrong alpha_prod_t_prev lookups, leading to degraded or incorrect denoising.

  • Fix: Replace the hardcoded arithmetic with a previous_timestep() method that looks up the actual next entry in self.timesteps, matching the approach already used by DDPMScheduler.previous_timestep().

Files Changed

  • src/diffusers/schedulers/scheduling_ddim_cogvideox.py — use previous_timestep() in step(), add method
  • src/diffusers/schedulers/scheduling_dpm_cogvideox.py — use previous_timestep() in step(), add method

Test plan

  • Verify existing CogVideoX scheduler tests pass with no regressions
  • Run CogVideoXDDIMScheduler with timestep_spacing="trailing" and confirm prev_timestep values now match the actual timestep schedule
  • Run CogVideoXDPMScheduler with timestep_spacing="linspace" and confirm correct behavior

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 because timesteps are not uniformly spaced
by that stride. This causes wrong alpha_prod_t_prev lookups and produces
incorrect denoising results.

Replace the hardcoded arithmetic with a `previous_timestep()` method that
looks up the actual next entry in `self.timesteps`, matching the approach
already used in DDPMScheduler.
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.

1 participant