[schedulers] fix RecursionError in CosineDPMSolverMultistepScheduler#13754
Open
zxuhan wants to merge 1 commit into
Open
[schedulers] fix RecursionError in CosineDPMSolverMultistepScheduler#13754zxuhan wants to merge 1 commit into
zxuhan wants to merge 1 commit into
Conversation
`CosineDPMSolverMultistepScheduler.step` initialised `BrownianTreeNoiseSampler` with `sigma_min`/`sigma_max` from the config, but the sampler is queried with `self.sigmas[step_index]` values that drift outside those bounds: the Karras/exponential reconstruction of the endpoints in fp32 lands a few ULPs off, and `final_sigmas_type="zero"` makes the last `sigmas` entry strictly below `config.sigma_min`. Out-of-range queries push torchsde into unbounded recursive interval splitting and trip Python's recursion limit (huggingface#13274). Initialise the sampler with the actual `self.sigmas` extrema instead, matching the pattern in `scheduling_dpmsolver_sde.py`. Adds a regression test covering both Karras and exponential schedules with `final_sigmas_type="zero"`.
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?
Fixes #13274.
CosineDPMSolverMultistepScheduler.stepconstructsBrownianTreeNoiseSamplerwith the config bounds (sigma_min,sigma_max), but the sampler is then queried with the discretized schedule inself.sigmas, which drifts outside those bounds at both ends:sigma_max=500on the exponential schedule,self.sigmas[0]is500.00006103515625. The first query violates torchsde'stb <= t1check.final_sigmas_type="zero"the last query hassigma_next == 0, which is strictly belowconfig.sigma_min. That violatesta >= t0.torchsde reacts to either by recursively splitting its backing interval until Python's recursion limit is hit, producing the
RecursionError: maximum recursion depth exceededreported forstabilityai/stable-audio-open-1.0in #13274.This PR switches the Brownian bounds to the actual extrema of
self.sigmas, matching the pattern already used inscheduling_dpmsolver_sde.py. After the change the sampler is always constructed over an interval that encloses every query issued during sampling.A new regression test in
tests/schedulers/test_scheduler_cosine_dpmsolver_multistep.pyexercises both Karras and exponential schedules withfinal_sigmas_type="zero". Without the fix the exponential subtest reproduces theRecursionError; with the fix both subtests pass.Before submitting
stabilityai/stable-audio-open-1.0encounterRecursionError: maximum recursion depth exceeded#13274.Who can review?
@yiyixuxu @sayakpaul