apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.44k stars 643 forks source link

Poor error trace - Error converting op #2349

Open darylsew opened 1 month ago

darylsew commented 1 month ago

🐞Describing the bug

Stack Trace

ERROR - converting 'callmethod' op (located at: '0'):

Converting PyTorch Frontend ==> MIL Ops:   2%|█▌                                                                                           | 857/50346 [00:00<00:15, 3185.51 ops/s]
Traceback (most recent call last):
  File "/Users/daryl/tangia/E2TTS/lucidrain-fork/export_model.py", line 217, in <module>
    model = coremltools.convert(
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/_converters_entry.py", line 635, in convert
    mlmodel = mil_convert(
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/converter.py", line 188, in mil_convert
    return _mil_convert(model, convert_from, convert_to, ConverterRegistry, MLModel, compute_units, **kwargs)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/converter.py", line 212, in _mil_convert
    proto, mil_program = mil_convert_to_proto(
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/converter.py", line 288, in mil_convert_to_proto
    prog = frontend_converter(model, **kwargs)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/converter.py", line 108, in __call__
    return load(*args, **kwargs)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 87, in load
    return _perform_torch_convert(converter, debug)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 131, in _perform_torch_convert
    raise e
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 123, in _perform_torch_convert
    prog = converter.convert()
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/converter.py", line 1293, in convert
    convert_nodes(self.context, self.graph, early_exit=not has_states)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 92, in convert_nodes
    raise e     # re-raise exception
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 87, in convert_nodes
    convert_single_node(context, node)
  File "/Users/daryl/opt/anaconda3/envs/tangia/lib/python3.10/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 117, in convert_single_node
    raise RuntimeError(
RuntimeError: PyTorch convert function for op 'callmethod' not implemented.
(tangia) Daryl-MBP:lucidrain-fork daryl$ 

To Reproduce

System environment (please complete the following information):

Additional context

darylsew commented 1 month ago

by cloning the repo and putting in a pdb, i was able to get the info i needed.

-> scope_names = node.get_scope_info()[0]
(Pdb) node
  %3934 = callmethod[name=forward](%proj.1, %input.19)
Converting PyTorch Frontend ==> MIL Ops:   1%|▍                               | 707/50058 [00:20<00:19, 2507.84 ops/s]
  %3934 = callmethod[name=forward](%proj.1, %input.19)

2 questions: 1) why wouldn't forward calls be supported? am i expected to have my entire graph be flat without any classes? 2) would there be any issue with having this exception in ops.py print str(node)? might make a PR, as node.get_scope_info() is kinda useless - (Pdb) node.get_scope_info()[0] ['0', '3934']

TobyRoseman commented 1 month ago

I'm not understanding the issue here. Please add a complete example to reproduce the issue. Please include all nesscessary import statements and the call to coremltools.convert.