[2/2] Switch ao to use py_limited_api #1277
Merged
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1277
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1322f88 with merge base 2e032c6 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
7001015 to
1afe0e3
Compare
1afe0e3 to
1322f88
Compare
msaroufim
approved these changes
Dec 18, 2024
jerryzh168
reviewed
Dec 19, 2024
| @@ -139,4 +140,7 @@ def get_extensions(): | |||
| long_description_content_type="text/markdown", | |||
| url="https://github.com/pytorch-labs/ao", | |||
Contributor
There was a problem hiding this comment.
can you remove -labs as well
Contributor
Author
There was a problem hiding this comment.
Will do as a separate PR, as that isn't related to this change
malfet
approved these changes
Dec 19, 2024
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.
This PR enables torchao to build 1 python wheel across multiple python versions. How? Our previous PR #1276 replaced reliance on the torch_python/PYBIND11 API in favor of using torch.library to register custom ops. This means that ao's custom extensions are Python free now!
As a result, we can now safely make use of Python/setuptools
py_limited_apiflags to build a Python agnostic wheel by passing the right arguments into Extension and bdist_wheel. Though the core PR has landed: pytorch/pytorch#138088, torchao wheels are built on the stable release (2.5.1 for now) so torch_python.so will still be linked. I have tested locally that linking torch_python.so does not affect the wheel's python agnosticism, because torchao cuda extensions are python free and do not use anything from torch_python.This will have repercussions on built + released wheels and will change their names to, for example,
torchao-0.8.0-cp39-abi3-linux_x86_64.whland should be installable on linux_x86_64 across multiple Python versions.Why was this a draft?
I needed to figure out a plan to safely land this (aka test well) and now I'm confident we should land this. How did I test?
The above shows that the torchao wheel built with this change is python agnostic.