google-ai-edge / ai-edge-torch

Supporting PyTorch models with the Google AI Edge TFLite runtime.
Apache License 2.0
199 stars 23 forks source link

Bug: redefinition of symbol named 'gelu_decomp_0' #38

Closed Misaka17032 closed 3 weeks ago

Misaka17032 commented 1 month ago

Description of the bug:

When trying to convert a huggingface-based whisper pytorch model, the error msg error: redefinition of symbol named 'gelu_decomp_0' comes out.

Environment:

linux x86 with 2080ti
cuda 12.1
python 3.11.9
torch==2.4.0.dev20240429+cpu
torchvision==0.19.0.dev20240429+cpu
torchaudio==2.2.0.dev20240429+cpu
torch_xla-nightly+20240429
tf-nightly-cpu==2.17.0.dev20240605

Actual vs expected behavior:

No response

Any other information you'd like to share?

Full Log:

Traceback (most recent call last):
  File "/root/convert/convert.py", line 29, in <module>
    edge_model = ai_edge_torch.convert(model.eval(), (input_features, decoder_input_ids))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/ai_edge_torch/convert/converter.py", line 165, in convert
    return Converter().convert(
           ^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/ai_edge_torch/convert/converter.py", line 110, in convert
    return conversion.convert_signatures(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/ai_edge_torch/convert/conversion.py", line 110, in convert_signatures
    tflite_model = cutils.convert_stablehlo_to_tflite(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/ai_edge_torch/convert/conversion_utils.py", line 328, in convert_stablehlo_to_tflite
    tflite_model = converter.convert()
                   ^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/lite.py", line 1231, in wrapper
    return self._convert_and_export_metrics(convert_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/lite.py", line 1183, in _convert_and_export_metrics
    result = convert_func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/lite.py", line 1562, in convert
    return self._convert_from_saved_model(graph_def)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/lite.py", line 1423, in _convert_from_saved_model
    result = _convert_saved_model(**converter_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/convert_phase.py", line 212, in wrapper
    raise converter_error from None  # Re-throws the exception.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/convert_phase.py", line 205, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/convert.py", line 1031, in convert_saved_model
    data = convert(
           ^^^^^^^^
  File "/root/miniconda3/envs/to_torch/lib/python3.11/site-packages/tensorflow/lite/python/convert.py", line 376, in convert
    raise converter_error
tensorflow.lite.python.convert_phase.ConverterError: <unknown>:0: error: redefinition of symbol named 'gelu_decomp_0'
<unknown>:0: note: see existing symbol definition here
chunnienc commented 3 weeks ago

Hi @Misaka17032, thanks for filing the issue. We have fixed this issue in the latest tf-nightly, please reinstall the requirements.txt and make sure tf-nightly>=2.18.0.dev20240607 in your environment, thanks!