Skip to content

fix(schedulers.lms): bound multistep order by available derivatives (#15108) - #15116

Open
Vuln3rat0r wants to merge 1 commit into
huggingface:mainfrom
Vuln3rat0r:fix/lms-multistep-order-offset
Open

Vuln3rat0r wants to merge 1 commit into
huggingface:mainfrom
Vuln3rat0r:fix/lms-multistep-order-offset

Conversation

@Vuln3rat0r

Copy link
Copy Markdown

Summary

LMSDiscreteScheduler.step sets multistep order from step_index instead of the number of stored derivatives. When sampling starts at an offset index (begin_index > 0, such as img2img or inpainting with strength < 1), step_index evaluates to a high value while self.derivatives holds only the first sample. The scheduler calculates higher-order polynomial coefficients while missing derivatives are silently truncated by zip(), corrupting early denoising steps.

Bounding order by len(self.derivatives) ensures polynomial quadrature matches available history, executing order ramp-up correctly from the initial offset step.

Fixes #15108.

Testing

  • Added test_step_order_with_begin_index in tests/schedulers/test_scheduler_lms.py verifying that step calculation at an offset index matches a 1st-order Euler update on step 1 and accumulates derivatives on step 2.
  • Updated test_full_loop_with_noise pinned values to reflect corrected Adams-Bashforth integration when running truncated schedules.
  • Verified exact reconstruction on StableDiffusionImg2ImgPipeline with an ideal predictor (relative error drops from 8.24% to 0.00%).
  • Ran full test suite in tests/schedulers/test_scheduler_lms.py (33 passed).

Reviewers

@yiyixuxu @dg845

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LMSDiscreteScheduler uses the wrong multistep order when sampling starts part-way through the schedule (img2img, inpainting)

1 participant