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

torch._dynamo.exc.Unsupported: call_method UserDefinedObjectVariable(Logger) #32922

Closed
2 of 4 tasks
jsoto-gladia opened this issue Aug 21, 2024 · 11 comments
Closed
2 of 4 tasks
Labels

Comments

@jsoto-gladia
Copy link

System Info

  • transformers version: 4.43.0
  • Platform: Linux-5.15.0-118-generic-x86_64-with-glibc2.35
  • Python version: 3.10.14
  • Huggingface_hub version: 0.23.3
  • Safetensors version: 0.4.3
  • Accelerate version: 0.24.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.1+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?:
  • Using GPU in script?:
  • GPU type: Tesla V100S-PCIE-32GB

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

from datasets import load_dataset
from transformers import WhisperProcessor, WhisperForConditionalGeneration
import torch

ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_sample = ds[0]["audio"]

processor = WhisperProcessor.from_pretrained("openai/whisper-tiny")
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny")
model = model.to('cuda')

model.generation_config.cache_implementation = "static"
model.forward = torch.compile(model.forward, mode="reduce-overhead", fullgraph=True)

input_features = processor(
audio_sample["array"], sampling_rate=audio_sample["sampling_rate"], return_tensors="pt"
).input_features

input_features = input_features.to("cuda")
_ = model.generate(input_features)

Expected behavior

it does not raise an error
as of now it raises
File "/home/jsoto/.pyenv/versions/3.10.14/envs/triton-server/lib/python3.10/site-packages/torch/_dynamo/exc.py", line 172, in unimplemented
raise Unsupported(msg)
torch._dynamo.exc.Unsupported: call_method UserDefinedObjectVariable(Logger) warning_once [ConstantVariable(str)] {}

@jsoto-gladia
Copy link
Author

related to #31987

@jsoto-gladia
Copy link
Author

if I put fullgraph=False, it works fine

@jsoto-gladia
Copy link
Author

the same problem arises with torch 2.2.1

@jsoto-gladia
Copy link
Author

the same problem arises with torch 2.3.1

@jsoto-gladia
Copy link
Author

a similar problem arises with torch 2.4.0
File "/home/jsoto/.pyenv/versions/3.10.14/envs/triton-server/lib/python3.10/site-packages/torch/_dynamo/exc.py", line 221, in unimplemented
raise Unsupported(msg)
torch._dynamo.exc.Unsupported: Logger not supported for non-export cases

@jsoto-gladia
Copy link
Author

it seems the problem is related to multilingual model...
If I use tiny, it gives the error above
I I use tiny.en, everything works fine

@jsoto-gladia
Copy link
Author

@sanchit-gandhi

@jsoto-gladia
Copy link
Author

when putting a mulitlingual model I get the following error
File "/home/jsoto/.pyenv/versions/3.10.14/envs/triton-server/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 464, in inner
raise exc.UserError(
torch._dynamo.exc.UserError: Dynamic control flow is not supported at the moment. Please use functorch.experimental.control_flow.cond to explicitly capture the control flow. For more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#cond-operands

@jsoto-gladia
Copy link
Author

I found the problem. It lies in the fact that if you do not specify the language
torch compile will try to run detect language (that contains an if condition here) and thus fails
the solution is to provide the language

@jsoto-gladia
Copy link
Author

for the record the versions are:
torch==2.3.0
torchaudio==2.3.0
transformers==4.44.1

@ArthurZucker
Copy link
Collaborator

Well, we can keep this open as language detection would be nice to have in compile as well no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants