Conversation
yeetypete
force-pushed
the
torch-stubs-return-types
branch
from
September 12, 2026 16:56
02d0462 to
f17cc9b
Compare
Contributor
|
Thanks @yeetypete! Something seems stuck here - auto-import actually failed, and I can't seem to import manually either. Maybe a rebase would help, but another option might be to just close this and open a fresh PR. What ought to happen is that a diff number should usually appear a few minutes after a PR is submitted |
stroxler
requested review from
stroxler
and removed request for
NathanTempest
September 15, 2026 13:45
Assisted-by: AI
yeetypete
force-pushed
the
torch-stubs-return-types
branch
from
September 18, 2026 17:28
f17cc9b to
229fca0
Compare
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D119814478. (Because this pull request was imported automatically, there will not be any future comments.) |
Contributor
Author
|
Apologies for the delay. Rebased and looks like the import worked now :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a stub for
torch.return_typesand use it for the operations that return named tuples. Currentlysort,max(dim=...),topk,aminmax,slogdet, etc. return types are annotated as plaintuple[Tensor, Tensor]and.values,.indices,.sign, and the other documented fields are reported asmissing-attributeerrors.PyTorch adds these annotations by generating its own
return_types.pyifrom the output names innative_functions.yaml:https://github.com/pytorch/pytorch/blob/d6c03540dc0f040e1d8a920d19d9333de6513545/torchgen/api/python.py#L1012-L1033
For simplicity we just write the stubs manually here instead of generating them.
Note:
linalg_slogdetis included as well although its missing in the PyTorch generated stubs.Test Plan
Run
test.py.