Skip to content

[Bug][AMD] stabilityai/stable-audio-open-1.0 encounter RecursionError: maximum recursion depth exceeded #13274

@tjtanaa

Description

@tjtanaa

Describe the bug

Running the diffuser example from the model card https://huggingface.co/stabilityai/stable-audio-open-1.0

import torch
import soundfile as sf
from diffusers import StableAudioPipeline

pipe = StableAudioPipeline.from_pretrained("stabilityai/stable-audio-open-1.0", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

# define the prompts
prompt = "The sound of a hammer hitting a wooden surface."
negative_prompt = "Low quality."

# set the seed for generator
generator = torch.Generator("cuda").manual_seed(0)

# run the generation
audio = pipe(
    prompt,
    negative_prompt=negative_prompt,
    num_inference_steps=200,
    audio_end_in_s=10.0,
    num_waveforms_per_prompt=3,
    generator=generator,
).audios

output = audio[0].T.float().cpu().numpy()
sf.write("hammer.wav", output, pipe.vae.sampling_rate)

on MI300X

throws the following error:

Loading pipeline components...:  33%|___________________________                                                    | 2/6 [00:00<00:01,  2.05it/s]/usr/
local/lib/python3.12/dist-packages/torch/nn/utils/weight_norm.py:144: FutureWarning: `torch.nn.utils.weight_norm` is deprecated in favor of `torch.nn.u
tils.parametrizations.weight_norm`.                                                                                                                    
  WeightNorm.apply(module, name, dim)                 
Loading pipeline components...: 100%|_______________________________________________________________________________| 6/6 [00:01<00:00,  5.02it/s]     
  0%|                                                                                                                     | 0/200 [00:00<?, ?it/s]/usr/
local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py:608: UserWarning: Should have tb<=t1 but got tb=500.00006103515625 and t1=50
0.0.                                                                                                                                                   
  warnings.warn(f"Should have {tb_name}<=t1 but got {tb_name}={tb} and t1={self._end}.")                                                               
100%|___________________________________________________________________________________________________________| 199/200 [00:11<00:00, 18.59it/s]/usr/
local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py:599: UserWarning: Should have ta>=t0 but got ta=0.0 and t0=0.3.             
  warnings.warn(f"Should have ta>=t0 but got ta={ta} and t0={self._start}.")                                                                           
100%|___________________________________________________________________________________________________________| 199/200 [00:11<00:00, 17.14it/s]     
Traceback (most recent call last):                                                                                                                     
  File "/usr/local/lib/python3.12/dist-packages/torch/utils/_contextlib.py", line 120, in decorate_context                                             
    return func(*args, **kwargs)                                                                                                                       
           ^^^^^^^^^^^^^^^^^^^^^                                                                                                                       
  File "/usr/local/lib/python3.12/dist-packages/diffusers/pipelines/stable_audio/pipeline_stable_audio.py", line 736, in __call__                      
    latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs).prev_sample                                                             
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                         
  File "/usr/local/lib/python3.12/dist-packages/diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py", line 662, in step                      
    noise = self.noise_sampler(self.sigmas[self.step_index], self.sigmas[self.step_index + 1]).to(                                                     
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                         
  File "/usr/local/lib/python3.12/dist-packages/diffusers/schedulers/scheduling_dpmsolver_sde.py", line 139, in __call__                               
    return self.tree(t0, t1) / (t1 - t0).abs().sqrt()                                                                                                  
           ^^^^^^^^^^^^^^^^^                                                                                                                           
  File "/usr/local/lib/python3.12/dist-packages/diffusers/schedulers/scheduling_dpmsolver_sde.py", line 107, in __call__ 
    w = torch.stack([tree(t0, t1) for tree in self.trees]) * (self.sign * sign)
                     ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 638, in __call__
    intervals = self._last_interval._loc(ta, tb)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 275, in _loc
    trampoline.trampoline(self._loc_inner(ta, tb, out))
  File "/usr/local/lib/python3.12/dist-packages/trampoline/__init__.py", line 40, in trampoline
    raise exception
  File "/usr/local/lib/python3.12/dist-packages/trampoline/__init__.py", line 26, in trampoline
    res = next(stack[-1])
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 296, in _loc_inner
    self._split(tb)
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 328, in _split
    self._left_child._split(midway)
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 328, in _split
    self._left_child._split(midway)
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 328, in _split
    self._left_child._split(midway)
  [Previous line repeated 984 more times]
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 323, in _split
    self._split_exact(0.5 * (self._end + self._start))
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 341, in _split_exact
    self._left_child = _Interval(start=self._start,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torchsde/_brownian/brownian_interval.py", line 153, in __init__
    self._start = top._round(start)  # the left hand edge of the interval
                  ^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

Reproduction

Running the diffuser example from the model card https://huggingface.co/stabilityai/stable-audio-open-1.0

import torch
import soundfile as sf
from diffusers import StableAudioPipeline

pipe = StableAudioPipeline.from_pretrained("stabilityai/stable-audio-open-1.0", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

# define the prompts
prompt = "The sound of a hammer hitting a wooden surface."
negative_prompt = "Low quality."

# set the seed for generator
generator = torch.Generator("cuda").manual_seed(0)

# run the generation
audio = pipe(
    prompt,
    negative_prompt=negative_prompt,
    num_inference_steps=200,
    audio_end_in_s=10.0,
    num_waveforms_per_prompt=3,
    generator=generator,
).audios

output = audio[0].T.float().cpu().numpy()
sf.write("hammer.wav", output, pipe.vae.sampling_rate)

Logs

System Info

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

  • 🤗 Diffusers version: 0.37.0
  • Platform: Linux-5.15.0-116-generic-x86_64-with-glibc2.35
  • Running on Google Colab?: No
  • Python version: 3.12.12
  • PyTorch version (GPU?): 2.9.1+git8907517 (True)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Huggingface_hub version: 0.36.2
  • Transformers version: 4.57.6
  • Accelerate version: 1.12.0
  • PEFT version: 0.18.1
  • Bitsandbytes version: not installed
  • Safetensors version: 0.7.0
  • xFormers version: not installed
  • Accelerator: NA
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions