Skip to content

Warn when add_noise is called before set_timesteps - #15097

Open
TejasS1233 wants to merge 1 commit into
huggingface:mainfrom
TejasS1233:15043-feature-warn-add-noise-before-set-timesteps
Open

TejasS1233 wants to merge 1 commit into
huggingface:mainfrom
TejasS1233:15043-feature-warn-add-noise-before-set-timesteps

Conversation

@TejasS1233

Copy link
Copy Markdown

What does this PR do?

add_noise reads self.sigmas, which is only built by set_timesteps. If it is called before set_timesteps, the noise level is computed from the default sigmas and silently comes out wrong. This adds a warning to the shared implementation used by DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler and DEISMultistepScheduler, plus a test that checks the warning is raised and that add_noise stays quiet once set_timesteps has run. No behavior is changed apart from the warning.

Fixes #15043.

Testing

Ran the scheduler tests for the four affected schedulers:

pytest tests/schedulers/test_scheduler_dpm_multi.py tests/schedulers/test_scheduler_dpm_single.py tests/schedulers/test_scheduler_unipc.py tests/schedulers/test_scheduler_deis.py

176 passed, 3 skipped. DPMSolverSinglestepSchedulerTest::test_beta_sigmas fails in my local environment, but it fails on unmodified main as well, so it is unrelated to this change.

ruff check and ruff format --check pass on the modified files.

The schedulers build `self.sigmas` in `set_timesteps`, and `add_noise`
reads them directly. Calling `add_noise` before `set_timesteps` therefore
uses the default sigmas and silently produces a wrong noise level.

Emit a warning from the shared implementation in DPMSolverMultistep,
DPMSolverSinglestep, UniPC and DEIS, and add a test covering both the
warning and the absence of it after `set_timesteps`.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 15:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Warn when add_noise runs before set_timesteps

2 participants