Skip to content

Conversation

@Aznix07
Copy link

@Aznix07 Aznix07 commented Dec 4, 2025

What does this PR do?

Fixes duplicate timesteps issue in DPMSolverMultistepScheduler when using various sigma conversion methods (Karras, Lu, exponential, beta) combined with beta_schedule="squaredcos_cap_v2".

Before this PR

  • Timesteps were not being rounded for squaredcos_cap_v2 schedule
  • This caused multiple sigma values to map to the same timestep
  • Example: timestep 998 appeared 9 times instead of once
  • Resulted in "index out of bounds" errors during sampling

After this PR

  • All sigma conversion methods now properly round timesteps
  • Duplicate timesteps are detected and removed
  • Users are warned when fewer unique timesteps are generated
  • Sampling completes without errors

Changes Made

  1. Added _ensure_unique_timesteps() helper method to handle duplicate timesteps consistently
  2. Updated all sigma conversion methods to unconditionally round timesteps
  3. Applied duplicate detection and removal to:
    • use_karras_sigmas
    • use_lu_lambdas
    • use_exponential_sigmas
    • use_beta_sigmas
  4. Added comprehensive test test_no_duplicate_timesteps_with_sigma_methods

Testing

✅ All 42 existing tests pass
✅ New test passes
✅ No regression detected
✅ Tested with multiple sigma methods and beta schedules

Fixes #12771

Before submitting

Who can review?

@yiyixuxu

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.

DPMSolverMultistepScheduler out-of-bounds error when using beta_schedule="squaredcos_cap_v2" + use_karras_sigmas=True

1 participant