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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve discoverability of meta function registration in documentation #126337

Closed
david20571015 opened this issue May 15, 2024 · 4 comments
Closed
Labels
module: docs Related to our documentation, both in docs/ and docblocks module: dynamic shapes module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@david20571015
Copy link
Contributor

david20571015 commented May 15, 2024

馃摎 The doc issue

While working with torch._foreach_pow_ in #125440, I encountered an error in the CI:

NotImplementedError: aten::_foreach_pow_.Scalar: attempted to run this operator with Meta tensors, but there was no fake impl or Meta kernel registered.
You may have run into this message while using an operator with PT2 compilation APIs (torch.compile/torch.export); in order to use this operator with those APIs you'll need to add a fake impl.
Please see the following doc for next steps: https://docs.google.com/document/d/1_W62p8WJOQQUzPsJYa7s701JXt0qf2OfLub2sbkHOaU/edit

After reading the Google doc, I still don't know how to fix it because I'm not familiar with the PyTorch C++ backend. Finally, the reviewer told me that I need to add an overload in torch/_meta_registrations.py. I think it is a little difficult for python contributors to find this solely. (I searched for _meta_registrations in vscode and found pytorch/docs/source/torch.compiler_dynamic_shapes.rst, which led me to The dynamic shapes manual. The document instructed me to register a meta function, but there is no example provided, I had to figure out what other functions in torch/_meta_registrations.py do before registering the one I need.)

Suggest a potential alternative/fix

Include a clear reference or FQA about using the python functions in pt2.

cc @svekars @brycebortree @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang @zou3519

@xmfan
Copy link
Member

xmfan commented May 16, 2024

cc @zou3519

@xmfan xmfan added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module topic: docs topic category module: docs Related to our documentation, both in docs/ and docblocks and removed topic: docs topic category labels May 17, 2024
@ezyang
Copy link
Contributor

ezyang commented May 21, 2024

I guess the problem is we don't have a dedicated doc for adding meta functions to PyTorch core

@ezyang
Copy link
Contributor

ezyang commented May 21, 2024

I edited the custom op doc to have a little more information, not sure if this is enough in your opinion.

@zou3519 zou3519 added the module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, label May 21, 2024
@david20571015
Copy link
Contributor Author

I edited the custom op doc to have a little more information, not sure if this is enough in your opinion.

Do you mean this?
image

Thanks for this, it provides better information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: docs Related to our documentation, both in docs/ and docblocks module: dynamic shapes module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

5 participants