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

Fix auto-registered torch.special operators #979

Merged
merged 7 commits into from
Aug 21, 2024
Merged

Conversation

kiya00
Copy link
Collaborator

@kiya00 kiya00 commented Aug 16, 2024

Before submitting
  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Background:
This PR addresses a bug related to the handling of torch.special operators, discovered during the development of PR #976.

torch.special operators has __name__ in the format special_opname, requiring extraction of the actual opname. Similar issues occur with torch.linalg and torch.fft operators.

In this PR:

  • Add function _get_torch_function_name to infer the python call name from the torch module and function
  • Add support for auto-registration of torch.linalg and torch.fft operators and the tests

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@kiya00
Copy link
Collaborator Author

kiya00 commented Aug 16, 2024

Hi @t-vi @IvanYashchuk , we could discuss further if #976 is necessary, this is a bug I found along the way, so I split it out and we could review this first.
Testing results:

[2024-08-16 13:59:44] thunder/tests/test_auto_register_torchops.py::test_torch_ops_trace[cuda-train-special.i0e] PASSED
[2024-08-16 13:59:45] thunder/tests/test_auto_register_torchops.py::test_torch_ops_trace[cuda-train-special.i1] PASSED
[2024-08-16 13:59:45] thunder/tests/test_auto_register_torchops.py::test_torch_ops_trace[cuda-train-special.i1e] PASSED
[2024-08-16 13:59:45] thunder/tests/test_auto_register_torchops.py::test_torch_ops_trace[cuda-train-special.ndtr] PASSED
...

thunder/torch/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kiya00! Cool stuff; I made some requests for comments to improve readability

Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvanYashchuk would you like to review, too?

@IvanYashchuk IvanYashchuk enabled auto-merge (squash) August 21, 2024 08:08
@IvanYashchuk IvanYashchuk merged commit d4d9786 into main Aug 21, 2024
37 checks passed
@IvanYashchuk IvanYashchuk deleted the fix_torchspecial branch August 21, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants