Skip to content

Move from/to to torch::stable::detail#164956

Closed
janeyx99 wants to merge 2 commits intogh/janeyx99/312/basefrom
gh/janeyx99/312/head
Closed

Move from/to to torch::stable::detail#164956
janeyx99 wants to merge 2 commits intogh/janeyx99/312/basefrom
gh/janeyx99/312/head

Conversation

@janeyx99
Copy link
Contributor

@janeyx99 janeyx99 commented Oct 8, 2025

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.

Stack from ghstack (oldest at bottom):

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 8, 2025

🔗 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 SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

⏳ No Failures, 5 Pending

As of commit 59ca068 with merge base ab82456 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

janeyx99 added a commit that referenced this pull request Oct 8, 2025
ghstack-source-id: 1852145
Pull Request resolved: #164956
@janeyx99 janeyx99 requested review from albanD, lw and malfet October 8, 2025 18:04
@janeyx99 janeyx99 added release notes: cpp release notes category topic: deprecation topic category labels Oct 8, 2025
Copy link
Contributor

@lw lw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer waiting until we make a call on #164882 before reviewing

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add using namespace torch::stable::detail on line 1411 and don't make any changes later on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, add using namespace torch::stable::detail

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Rebased gh/janeyx99/313/orig onto refs/remotes/origin/viable/strict because #164959 was rebased, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/164956)

@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #164959

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
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
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
zhudada0120 pushed a commit to zhudada0120/pytorch that referenced this pull request Oct 22, 2025
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
zhudada0120 pushed a commit to zhudada0120/pytorch that referenced this pull request Oct 22, 2025
Khanaksahu pushed a commit to Khanaksahu/pytorch that referenced this pull request Nov 17, 2025
ghstack-source-id: 3389bff
Pull Request resolved: pytorch/pytorch#164956
@github-actions github-actions bot deleted the gh/janeyx99/312/head branch November 21, 2025 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants