-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Add shim.h C API to call dispatcher on our own aten ops #148832
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/148832
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 9 Pending, 2 Unrelated FailuresAs of commit 9f133f4 with merge base c983e11 ( BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Attention! PyTorch one of the C-stable API file was changedYou MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function. Caused by: |
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
test/test_cpp_extensions_aot.py
Outdated
self.assertEqual(cpu_t, torch.ones_like(t, device="cpu")) | ||
|
||
def _make_cuda_tensors(prior_mem): | ||
cuda_t = libtorch_agnostic.ops.my_ones_like(t, "cuda") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, passing in the device obj here does not work
cuda_t = libtorch_agnostic.ops.my_ones_like(t, "cuda") | |
cuda_t = libtorch_agnostic.ops.my_ones_like(t, device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? Device is not a supported type for the stable dispatcher registration?
test/cpp_extensions/libtorch_agnostic_extension/test/test_libtorch_agnostic.py
Outdated
Show resolved
Hide resolved
...p_extensions/libtorch_agnostic_extension/libtorch_agnostic/csrc/libtorch_agnostic_kernel.cpp
Outdated
Show resolved
Hide resolved
This PR still needs testing through some cpp extension [ghstack-poisoned]
test/test_cpp_extensions_aot.py
Outdated
self.assertEqual(cpu_t, torch.ones_like(t, device="cpu")) | ||
|
||
def _make_cuda_tensors(prior_mem): | ||
cuda_t = libtorch_agnostic.ops.my_ones_like(t, "cuda") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? Device is not a supported type for the stable dispatcher registration?
auto inner_type = arg_type->castRaw<at::OptionalType>()->getElementType(); | ||
|
||
// our contract is that IValue None = StableIValue nullptr | ||
if (to<std::nullptr_t>(stable_ivalue) == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's ok, you are definitely going to confuse a value 0 with empty optional here.
I think the simplest would be to do some tagging here: have a special value that means "nullopt" and forbid the content of the optional being that value (with a runtime check).
My guess here is that you want something that is unlikely to be a used int64 or pointer or etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to respect the branch cut, i got rid of supporting optional for now
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
This PR still needs testing through some cpp extension [ghstack-poisoned]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
// calls the op overload defined by a given opName, overloadName, and a | ||
// stack of StableIValues. This call will populate any return values of the | ||
// op into the stack in their StableIValue form, with ret0 at index 0, ret1 | ||
// at index 1, and so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo after this: we should document our StableIValue stack definition and expose to/from helpers for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually did that, just in library.h https://github.com/pytorch/pytorch/blob/main/torch/csrc/stable/library.h#L69
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: inductor / cuda12.6-py3.10-gcc9-sm86 / test (inductor_timm, 1, 2, linux.g5.4xlarge.nvidia.gpu) Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge -f "Failures are preexisting on trunk" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
This PR still needs testing through some cpp extension
Stack from ghstack (oldest at bottom):