Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whisper compile #35413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jiqing-feng
Copy link
Contributor

@jiqing-feng jiqing-feng commented Dec 25, 2024

This change could fix the whisper compile error.
Besides, we don't need cache here, this change also avoids the log warning [here].

To reproduce the error:

import torch
from transformers import pipeline
from datasets import load_dataset

pipe = pipeline("automatic-speech-recognition", model="openai/whisper-small")
pipe.model.forward = torch.compile(pipe.model.forward)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
sample = ds[0]["audio"]
prediction = pipe(sample.copy(), batch_size=8)["text"]
print(prediction)

Traceback:

...
    if truth_fn(mod):
  File "/home/jiqing/transformers/src/transformers/cache_utils.py", line 405, in __len__
    return len(self.key_cache)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1931, in __getattr__
    raise AttributeError(
torch._dynamo.exc.InternalTorchDynamoError: AttributeError: 'DynamicCache' object has no attribute 'key_cache'

Signed-off-by: jiqing-feng <[email protected]>
@jiqing-feng jiqing-feng changed the title Fix whisper compile error Fix whisper warning Dec 25, 2024
@jiqing-feng jiqing-feng changed the title Fix whisper warning Fix whisper compile Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant