huggingface / huggingface/diffusers

AttributeError: 'GPT2Model' object has no attribute '_get_initial_cache_position' in AudioLDM2Pipeline

Open
#12,630 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

### Describe the bug

```python3
! python3 -m pip install -U phonemizer
! sudo apt install -y --no-install-recommends espeak-ng
import scipy, transformers
import torch
from diffusers import AudioLDM2Pipeline

repo_id = "anhnct/audioldm2_gigaspeech"
pipe = AudioLDM2Pipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

# define the prompts
prompt = "An female actor say with angry voice"
transcript = "wish you have a good day, i hope you never forget me"
negative_prompt = "low quality"

# run the generation
audio = pipe(
prompt,
negative_prompt=negative_prompt,
transcription=transcript,
num_inference_steps=200,
audio_length_in_s=8.0,
num_waveforms_per_prompt=1,
max_new_tokens=512
).audios

# save the best audio sample (index 0) as a .wav file
scipy.io.wavfile.write("techno_2.wav", rate=16000, data=audio[0])
from IPython.display import Audio
Audio("techno_2.wav")
```
keep showing 'GPT2Model' object has no attribute '_get_initial_cache_position's

the problem seems to happen in transformers, I downgrade to transformers==4.47.0 to make it works

### Reproduction

see above

### Logs

```shell

```

### System Info

diffusers 0.34.0, transformers 4.53.3. I test it in kaggle p100

### Who can help?

@yiyixuxu @DN6

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the AudioLDM2Pipeline example with diffusers 0.34.0 and transformers 4.53.3, then compare the behavior with transformers 4.47.0. Trace the GPT2Model cache-position call in the AudioLDM2 pipeline and its Transformers integration; done means the provided generation completes without the AttributeError while preserving the supported dependency behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.