Skip to content

fix: Fix RecursionError in CosineDPMSolver Brownian tree noise sampler - #14506

Open
Ricardo-M-L wants to merge 1 commit into
huggingface:mainfrom
Ricardo-M-L:fix/cosine-dpm-brownian-bounds-clean
Open

fix: Fix RecursionError in CosineDPMSolver Brownian tree noise sampler#14506
Ricardo-M-L wants to merge 1 commit into
huggingface:mainfrom
Ricardo-M-L:fix/cosine-dpm-brownian-bounds-clean

Conversation

@Ricardo-M-L

Copy link
Copy Markdown
Contributor

Clean rebase of fix/cosine-dpm-brownian-bounds

`CosineDPMSolverMultistepScheduler.step` constructs `BrownianTreeNoiseSampler`
with `sigma_min=self.config.sigma_min` / `sigma_max=self.config.sigma_max`
and then queries it with `(self.sigmas[i], self.sigmas[i+1])`. Two drifts
leave those queries outside the Brownian tree's valid interval:

  * The Karras reconstruction of `sigma_max` in fp32 can land a few ULPs
    above the config value (e.g. 500 -> 500.00006103515625), so the first
    query violates `tb <= t1`.
  * With the default `final_sigmas_type="zero"` the last query is
    `sigma_next == 0`, which is strictly below `config.sigma_min`, so it
    violates `ta >= t0`.

torchsde responds to both by recursively splitting the backing interval
until Python's recursion limit blows up, which surfaces as the
`RecursionError: maximum recursion depth exceeded` reported by stable-audio
users in huggingface#13274.

Use the actual extrema of `self.sigmas` — the same pattern already used by
`scheduling_dpmsolver_sde.py:690` — so the Brownian bounds always enclose
every query issued during sampling.

Fixes huggingface#13274
@github-actions github-actions Bot added schedulers size/S PR with diff < 50 LOC labels Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @Ricardo-M-L, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

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

Labels

schedulers size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant