Use presence of _symint in kernel name to generate symint sig or not#84579
Use presence of _symint in kernel name to generate symint sig or not#84579ezyang wants to merge 14 commits intogh/ezyang/1367/basefrom
Conversation
Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
🔗 Helpful links
✅ No Failures (24 Pending)As of commit 3d31ef2 (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> ghstack-source-id: 2e883d5 Pull Request resolved: #84579
Before this PR, was the idea that 'meta' kernels were getting c++ symint signatures but real kernels weren't, and now this becomes more explicit because for either meta or composite kernels you just have to write _symint in the name and take out the guesswork? |
Yep |
| return NativeSignature(f.func, prefix=prefix, symint=backend_index.symint) | ||
| meta = backend_index.get_kernel(f) | ||
| return NativeSignature( | ||
| f.func, prefix=prefix, symint=meta is not None and meta.supports_symint() |
There was a problem hiding this comment.
does having a python decomp count here in favor of being symint compatible, or is a 'meta' kernel always strictly necessary?
There was a problem hiding this comment.
Python decomp suffices, meta is not required
| return self.reshape(size); | ||
| } else { | ||
| auto output = at::_ops::view::call(self, size); | ||
| auto output = at::_ops::view::call(self, c10::SymIntArrayRef::fromIntArrayRef(size)); |
There was a problem hiding this comment.
ok what's going on in this kernel? the view_copy name above didn't get _symint tacked on, and some of the symint related stuff got removed, but then we are constructing symints and invoking view.
| if func.kind() == SchemaKind.out | ||
| else cpp.name(func) | ||
| ) | ||
| ) + "_symint" # TODO: hmm |
There was a problem hiding this comment.
why is _symint assumed here? shouldn't this be driven by the yaml?
There was a problem hiding this comment.
# Details are in the function, but we only generate composite kernels (in some cases) today.
Are we assuming all composite kernels are supposed to be _symint?
There was a problem hiding this comment.
Sooo I am not entirely sure here, but the idea is that these kernels are autogenerated, and they handle SymInts, so we should give them symint names so they get the right signature. It's a bit dodgy though... I got here by just tweaking until it compiled
There was a problem hiding this comment.
that sounds reasonable
clarification: these 'generated' kernels are going to call into handwritten kernels (adapting from functional to out or vice versa) right? if so, would we be potentially having a situation like this?
foo_out <-- handwritten, no symint support
foo_symint <-- generated, just trivially unwraps symints and expects ints, calls foo_out
if so, i still don't think that's a problem. other than, we should probably make it clearer what's going on
There was a problem hiding this comment.
Err, not really? The generated kernels typically call into other API as defined by the codegen; e.g., a generated out will generate a call to functional and then copy_ (but the functional call is not a direct native:: call; it'll just be to some dispatched api).
wconstab
left a comment
There was a problem hiding this comment.
This sounds like a better policy to me, and it looks correct outside of the minor questions I raised
|
|
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures. Signed-off-by: Edward Z. Yang <ezyangfb.com> Differential Revision: [D39310060](https://our.internmc.facebook.com/intern/diff/D39310060) [ghstack-poisoned]
Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> ghstack-source-id: 7a70312 Pull Request resolved: #84579
|
@ezyang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@pytorchbot merge |
Merge failedReason: This PR has internal changes and must be landed via Phabricator Details for Dev Infra teamRaised by workflow job |
|
@ezyang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…(#84579) Summary: X-link: pytorch/pytorch#84579 Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Reviewed By: wconstab Differential Revision: D39310060 Pulled By: ezyang fbshipit-source-id: ee29f3a2d7aed9f32bb6e62d8da427507733482c
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
|
@pytorchbot successfully started a merge job. Check the current status here. |
Merge failedReason: Command Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot rebase |
|
@pytorchbot successfully started a rebase job. Check the current status here |
|
Rebase failed due to Command Raised by https://github.com/pytorch/pytorch/actions/runs/3024376973 |
…sig or not" Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures. Signed-off-by: Edward Z. Yang <ezyangfb.com> Differential Revision: [D39310060](https://our.internmc.facebook.com/intern/diff/D39310060) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/84579
Note: Links to docs will display an error until the docs builds have been completed. ✅ No Failures, 1 PendingAs of commit fcb056c: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. Signed-off-by: Edward Z. Yang <ezyangfb.com> ghstack-source-id: c42301c Pull Request resolved: #84579
|
Rebased to include new xla hash from @zou3519, |
|
@pytorchbot merge -f "already passed CI, merged internally, need to get in ASAP" |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Hey @ezyang. |
…84579) Summary: Pull Request resolved: #84579 Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS **Static Docs Preview: executorch** |[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39310060/V6/executorch/)| |**Modified Pages**| Reviewed By: wconstab Differential Revision: D39310060 Pulled By: ezyang fbshipit-source-id: ee29f3a2d7aed9f32bb6e62d8da427507733482c
…ng the tests or ops explicitly (#3978) * Companion PR for pytorch/pytorch#84579 Signed-off-by: Edward Z. Yang <ezyang@fb.com> * pin Signed-off-by: Edward Z. Yang <ezyang@fb.com> * modify expect counters * undo counter fix * Delete .torch_pin Signed-off-by: Edward Z. Yang <ezyang@fb.com> Co-authored-by: Edward Z. Yang <ezyang@fb.com>
…ytorch#84579) Something people found confusing was that whether or not a native:: signature would get SymInt or not in its type was based on the dispatch key. This changes it so that SymInt or not in type is based on whether or not you have _symint in the name of the kernel or not. This means that even when we make operators support SymInt, you no longer have to go and update all the preexisting definitions; instead, you now selectively write _symint to opt individual kernels into SymInt support. I then go and update a bunch of kernels that don't have proper SymInt support to make use of this convention. There is some hacking around for view generation code. I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: [D39310060](https://our.internmc.facebook.com/intern/diff/D39310060) Pull Request resolved: pytorch#84579 Approved by: https://github.com/wconstab
Stack from ghstack (oldest at bottom):
Something people found confusing was that whether or not a native::
signature would get SymInt or not in its type was based on the dispatch
key. This changes it so that SymInt or not in type is based on whether
or not you have _symint in the name of the kernel or not. This means
that even when we make operators support SymInt, you no longer have to
go and update all the preexisting definitions; instead, you now
selectively write _symint to opt individual kernels into SymInt support.
I then go and update a bunch of kernels that don't have proper SymInt
support to make use of this convention. There is some hacking around
for view generation code.
I also add support for external backends to specify 'symint' operators, for which we generate SymInt signatures instead of regular signatures.
Signed-off-by: Edward Z. Yang ezyang@fb.com
Differential Revision: D39310060