Repository navigation
Warn when add_noise is called before set_timesteps - #15097
Open
TejasS1233 wants to merge 1 commit into
Open
TejasS1233 wants to merge 1 commit into
TejasS1233 wants to merge 1 commit into
Conversation
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`.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
add_noisereadsself.sigmas, which is only built byset_timesteps. If it is called beforeset_timesteps, the noise level is computed from the default sigmas and silently comes out wrong. This adds a warning to the shared implementation used byDPMSolverMultistepScheduler,DPMSolverSinglestepScheduler,UniPCMultistepSchedulerandDEISMultistepScheduler, plus a test that checks the warning is raised and thatadd_noisestays quiet onceset_timestepshas 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.py176 passed, 3 skipped.
DPMSolverSinglestepSchedulerTest::test_beta_sigmasfails in my local environment, but it fails on unmodified main as well, so it is unrelated to this change.ruff checkandruff format --checkpass on the modified files.