Move from/to to torch::stable::detail#164956
Move from/to to torch::stable::detail#164956janeyx99 wants to merge 2 commits intogh/janeyx99/312/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/164956
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ⏳ No Failures, 5 PendingAs of commit 59ca068 with merge base ab82456 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| AtenTensorHandle ath = torch::aot_inductor::new_tensor_handle( | ||
| std::move(const_cast<at::Tensor&>(ivalue.toTensor()))); | ||
| return from(ath); | ||
| return torch::stable::detail::from(ath); |
There was a problem hiding this comment.
Just add using namespace torch::stable::detail on line 1411 and don't make any changes later on
There was a problem hiding this comment.
If we want to keep the global from/to for BC, this leads to ambiguity. I wrote it in my PR desc:
Note that this means that within libtorch, we do not get the luxury of tacking on a using torch::stable::detail::from because then it leads to build time ambiguous calls --> both the global and namespace APIs are exposed, which one do I want? So that is why you see every local site is updated.
| from(std::nullopt), | ||
| from(std::nullopt), | ||
| from(std::nullopt)}; | ||
| torch::stable::detail::from(self), |
There was a problem hiding this comment.
Same as above, add using namespace torch::stable::detail
|
Rebased |
|
Starting merge as part of PR stack under #164959 |
Pull Request resolved: #164959 Approved by: https://github.com/Skylion007, https://github.com/mikaylagawarecki ghstack dependencies: #164882, #164956
To not pollute the global namespace, we should move the `from`/`to` APIs into torch::stable::detail. We are also following our normal deprecation cycle and choosing to continue exposing the global `from`/`to` for the time being as people who onboard their extensions onto 2.9 would not be able to build with 2.10 otherwise. Note that this means that within libtorch, we do not get the luxury of tacking on a `using torch::stable::detail::from` because then it leads to build time ambiguous calls --> both the global and namespace APIs are exposed, which one do I want? So that is why you see every local site is updated. Note that the update is _not_ necessary from a custom op writer point of view. FA3 can continue to build on torch nightlies without changing any code. (Since this is a header change, this PR has no implication on runtime, a previously built FA3 ABI stable wheel will continue to work fine with newer torch versions after this PR.) Once TORCH_BOX lands, we would be free to remove these global APIs when the deprecation cycle is up (April 2026) and encourage people to use TORCH_BOX and avoid from/to entirely. Pull Request resolved: pytorch#164956 Approved by: https://github.com/malfet ghstack dependencies: pytorch#164882
Pull Request resolved: pytorch#164959 Approved by: https://github.com/Skylion007, https://github.com/mikaylagawarecki ghstack dependencies: pytorch#164882, pytorch#164956
To not pollute the global namespace, we should move the `from`/`to` APIs into torch::stable::detail. We are also following our normal deprecation cycle and choosing to continue exposing the global `from`/`to` for the time being as people who onboard their extensions onto 2.9 would not be able to build with 2.10 otherwise. Note that this means that within libtorch, we do not get the luxury of tacking on a `using torch::stable::detail::from` because then it leads to build time ambiguous calls --> both the global and namespace APIs are exposed, which one do I want? So that is why you see every local site is updated. Note that the update is _not_ necessary from a custom op writer point of view. FA3 can continue to build on torch nightlies without changing any code. (Since this is a header change, this PR has no implication on runtime, a previously built FA3 ABI stable wheel will continue to work fine with newer torch versions after this PR.) Once TORCH_BOX lands, we would be free to remove these global APIs when the deprecation cycle is up (April 2026) and encourage people to use TORCH_BOX and avoid from/to entirely. Pull Request resolved: pytorch#164956 Approved by: https://github.com/malfet ghstack dependencies: pytorch#164882
Pull Request resolved: pytorch#164959 Approved by: https://github.com/Skylion007, https://github.com/mikaylagawarecki ghstack dependencies: pytorch#164882, pytorch#164956
ghstack-source-id: 3389bff Pull Request resolved: pytorch/pytorch#164956
To not pollute the global namespace, we should move the
from/toAPIs into torch::stable::detail. We are also following our normal deprecation cycle and choosing to continue exposing the globalfrom/tofor the time being as people who onboard their extensions onto 2.9 would not be able to build with 2.10 otherwise.Note that this means that within libtorch, we do not get the luxury of tacking on a
using torch::stable::detail::frombecause then it leads to build time ambiguous calls --> both the global and namespace APIs are exposed, which one do I want? So that is why you see every local site is updated.Note that the update is not necessary from a custom op writer point of view. FA3 can continue to build on torch nightlies without changing any code. (Since this is a header change, this PR has no implication on runtime, a previously built FA3 ABI stable wheel will continue to work fine with newer torch versions after this PR.)
Once TORCH_BOX lands, we would be free to remove these global APIs when the deprecation cycle is up (April 2026) and encourage people to use TORCH_BOX and avoid from/to entirely.
Stack from ghstack (oldest at bottom):