apple / apple/coremltools

Poor error trace - Error converting op

Open
#2,349 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## 🐞Describing the bug
- Make sure to only create an issue here for bugs in the coremltools Python package. If this is a bug with the Core ML Framework or Xcode, please submit your bug here: https://developer.apple.com/bug-reporting/
- Provide a clear and consise description of 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
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
- Please add a minimal code example that can reproduce the error when running it.
```
# model code:
x = nn.Linear()
x()
```
Seems to happen any time we call a function. My real issue is that I cannot tell from the error message which line of Python code corresponds to the error. I think it goes away in this case if i replace x with x.forward(..)

- If the model conversion succeeds, but there is a numerical mismatch in predictions, please include the code used for comparisons.

## System environment (please complete the following information):
- coremltools version:
- OS (e.g. MacOS version or Linux type):
- Any other relevant version information (e.g. PyTorch or TensorFlow version):

## Additional context
- Add anything else about the problem here that you want to share.

Contributor guide

Open the contributing guide

Research direction

Start with the traceback in coremltools/converters/mil/frontend/torch/ops.py, especially convert_single_node and convert_nodes, then follow the PyTorch conversion path through converter.py and load.py. Determine how the unsupported callmethod operation can identify its originating Python line. Done means conversion errors point to the relevant source location for this case and similar PyTorch operations.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.