pybind->TORCH_LIBRARY; get ABI stable with CPython#193
Open
janeyx99 wants to merge 3 commits into
Open
Conversation
fa9c1ed to
3726f95
Compare
3726f95 to
3911d00
Compare
janeyx99
commented
Jul 2, 2026
| static inline PtrT* get_tensor_ptr(const at::Tensor& tensor) { | ||
| if (tensor.has_storage()) { | ||
| static inline PtrT* get_tensor_ptr(const torch::stable::Tensor& tensor) { | ||
| if (tensor.defined()) { |
Author
There was a problem hiding this comment.
This is a weaker check, but as these kernels are registered to the CUDA backend key, the inputs will either be CUDA storage-backed tensors or null tensors so this check is sufficient.
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.
Fixes #180
The first commit migrates the library from pybind -> TORCH_LIBRARY. This allows the library to be CPython agnostic, meaning you can build one wheel for multiple python versions (3.10+ here). Then, the second commit does the mechanical work of migrating APIs to the stable APIs.
After the first commit, there are 70 unstable APIs used by the .so:
After the second, there are none!!
Test Plan
After commit 1:
After commit 2 (showing that perf diff is insignificant):
After both commits (ran twice):
test_fmha_sm100.py also had no failures:
Details