pytorch/torch/_export
Yidi Wu 92f125e622 [export] improve error message for deserializing custom triton op (#152029)
In https://github.com/pytorch/pytorch/issues/151746, users ran into an error where a custom triton op cannot be resolved into an operator from string target. We improve the error message by reminding users to register the same custom operator at de-serialization time.

Now the error looks like this:
```python
torch._export.serde.serialize.SerializeError: We failed to resolve torch.ops.triton_kernel.add.default to an operator. If it's a custom op/custom triton op, this is usally because the custom op is not registered when deserializing. Please import the custom op to register it before deserializing. Otherwise, please file an issue on github. Unsupported target type for node Node(target='torch.ops.triton_kernel.add.default', inputs=[NamedArgument(name='x', arg=Argument(as_tensor=TensorArgument(name='linear')), kind=1), NamedArgument(name='y', arg=Argument(as_tensor=TensorArgument(name='mul')), kind=1)], outputs=[Argument(as_tensor=TensorArgument(name='add'))], metadata={'stack_trace': 'File "/data/users/yidi/pytorch/test.py", line 50, in forward\n    output = triton_add(dense_output, bias)', 'nn_module_stack': 'L__self__,,__main__.SimpleModel', 'torch_fn': 'add.default_1;OpOverload.add.default'}, is_hop_single_tensor_return=None): <class 'str'>.```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/152029
Approved by: https://github.com/jingsh
2025-04-24 20:22:05 +00:00
..
db PEP585 update - torch/_export (#145138) 2025-01-19 18:48:35 +00:00
pass_infra PEP585 update - torch/_export (#145138) 2025-01-19 18:48:35 +00:00
passes [export] Integrate meta kernel generation with draft-export (#150809) 2025-04-17 20:52:31 +00:00
serde [export] improve error message for deserializing custom triton op (#152029) 2025-04-24 20:22:05 +00:00
__init__.py PEP585: More UP006 fixes (#146392) 2025-02-20 06:18:13 +00:00
converter.py [export] refactor DimHints for type errors (#149424) 2025-03-19 18:51:07 +00:00
error.py Fix global flake8 issues (#124771) 2024-04-26 15:35:53 +00:00
non_strict_utils.py [export] Enable symint inputs for AdditionalInputs and ShapesCollection (#151842) 2025-04-22 22:29:18 +00:00
pass_base.py PEP585 update - torch/_export (#145138) 2025-01-19 18:48:35 +00:00
tools.py PEP585 update - torch/_export (#145138) 2025-01-19 18:48:35 +00:00
utils.py [export] suggest dynamic re-export in input constraints hook (#151624) 2025-04-21 22:29:46 +00:00
verifier.py Expand allowed_getattr_types_for_subgm to torch.Tensor (#150867) 2025-04-09 11:01:45 +00:00
wrappers.py Support subclass constructor capturing in export (#147014) 2025-03-16 18:19:19 +00:00