-
Notifications
You must be signed in to change notification settings - Fork 349
torchao init: do not load .so files for known incompatible torch version #2908
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
Merged
Conversation
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2908
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, 1 PendingAs of commit d22bbf5 with merge base 2f78cfe ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
156a99f
to
aa7f066
Compare
atalman
approved these changes
Aug 29, 2025
Summary: Short term fix for #2901 to unblock the 0.13.0 release. Long version: 1. torchao's c++ kernels are not using libtorch and therefore are not guaranteed to work across different PyTorch versions 2. looks like we got lucky with (1) as torchao kernels just happened to work across PyTorch versions <= 2.8, but PyTorch nightlies in 2.9 introduce a breaking ABI change (I don't know what specifically). Therefore, if we build torchao with torch 2.8, and then import it in an environment with torch 2.9+, the Python process will crash with `Aborted (core dumped)`. For now, I just gate out the "known broken" case where we detect that the torch version used to build torchao is < 2.9, and the torch version in the environment when torchao is imported is >= 2.9. If this is detected, this PR skips importing the `.so` files and logs a warning, to at least have most of the torchao Python API still work and give the user some information about how to get the custom kernels working. For future releases, we'll need to make this more robust - leaving that for future PRs. Test Plan: ```bash // install the 0.13.0 RC, built with PyTorch 2.8 with-proxy pip install torchao==0.13.0 --extra-index-url https://download.pytorch.org/whl/test/cu128 // copy over these changes to the local __init__.py file in the installation: // ~/.conda/envs/pytorch_nightly/lib/python3.11/site-packages/torchao/__init__.py // install PyTorch 2.9.x nightly with-proxy pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 // import torchao, verify no more crash and the warning message is emitted (pytorch_nightly) [vasiliy@devgpu007.eag6 ~/local]$ python -X faulthandler -c "import torch; print(torch.__version__); import torchao" 2.9.0.dev20250829+cu128 Skipping import of cpp extensions due to incompatible torch version 2.9.0.dev20250829+cu128 for torchao version 0.13.0+cu128 ``` Reviewers: Subscribers: Tasks: Tags:
aa7f066
to
d22bbf5
Compare
vkuzo
added a commit
that referenced
this pull request
Aug 29, 2025
…ion (#2908) Summary: Short term fix for #2901 to unblock the 0.13.0 release. Long version: 1. torchao's c++ kernels are not using libtorch and therefore are not guaranteed to work across different PyTorch versions 2. looks like we got lucky with (1) as torchao kernels just happened to work across PyTorch versions <= 2.8, but PyTorch nightlies in 2.9 introduce a breaking ABI change (I don't know what specifically). Therefore, if we build torchao with torch 2.8, and then import it in an environment with torch 2.9+, the Python process will crash with `Aborted (core dumped)`. For now, I just gate out the "known broken" case where we detect that the torch version used to build torchao is < 2.9, and the torch version in the environment when torchao is imported is >= 2.9. If this is detected, this PR skips importing the `.so` files and logs a warning, to at least have most of the torchao Python API still work and give the user some information about how to get the custom kernels working. For future releases, we'll need to make this more robust - leaving that for future PRs. Test Plan: ```bash // install the 0.13.0 RC, built with PyTorch 2.8 with-proxy pip install torchao==0.13.0 --extra-index-url https://download.pytorch.org/whl/test/cu128 // copy over these changes to the local __init__.py file in the installation: // ~/.conda/envs/pytorch_nightly/lib/python3.11/site-packages/torchao/__init__.py // install PyTorch 2.9.x nightly with-proxy pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 // import torchao, verify no more crash and the warning message is emitted (pytorch_nightly) [vasiliy@devgpu007.eag6 ~/local]$ python -X faulthandler -c "import torch; print(torch.__version__); import torchao" 2.9.0.dev20250829+cu128 Skipping import of cpp extensions due to incompatible torch version 2.9.0.dev20250829+cu128 for torchao version 0.13.0+cu128 ``` Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Fix error in #2908. The version string for PyTorch 2.8 reads "2.8.0...", so we need to compare `>= 2.9` to properly gate out PyTorch 2.9. Test Plan: 1. make this change in a locally installed __init__ file of torchao downloaded via pip 2. install PyTorch 2.8.0 3. import torchao, verify warning was not hit Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Fix error in #2908. The version string for PyTorch 2.8 reads "2.8.0...", so we need to compare `>= 2.9` to properly gate out PyTorch 2.9. Test Plan: 1. make this change in a locally installed __init__ file of torchao downloaded via pip 2. install PyTorch 2.8.0 3. import torchao, verify warning was not hit Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Fix error in #2908. The version string for PyTorch 2.8 reads "2.8.0...", so we need to compare `>= 2.9` to properly gate out PyTorch 2.9. Test Plan: 1. make this change in a locally installed __init__ file of torchao downloaded via pip 2. install PyTorch 2.8.0 3. import torchao, verify warning was not hit Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Undoes part of #2908 to make the message about missing `.so` files be a debug print instead of a warning. Reason: this always happens for builds without executorch ops. Keeps the version mismatch log as a warning. Test Plan: Make this change locally in an install of torchao on an H100, verify warning no longer prints. Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Undoes part of #2908 to make the message about missing `.so` files be a debug print instead of a warning. Reason: this always happens for builds without executorch ops. Keeps the version mismatch log as a warning. Test Plan: Make this change locally in an install of torchao on an H100, verify warning no longer prints. Reviewers: Subscribers: Tasks: Tags:
vkuzo
added a commit
that referenced
this pull request
Sep 2, 2025
Summary: Undoes part of #2908 to make the message about missing `.so` files be a debug print instead of a warning. Reason: this always happens for builds without executorch ops. Keeps the version mismatch log as a warning. Test Plan: Make this change locally in an install of torchao on an H100, verify warning no longer prints. Reviewers: Subscribers: Tasks: Tags:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
topic: bug fix
Use this tag for PRs that fix bugs
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.
Summary:
Short term fix for #2901 to unblock the 0.13.0 release.
Long version:
Aborted (core dumped)
.For now, I just gate out the "known broken" case where we detect that the torch version used to build torchao is < 2.9, and the torch version in the environment when torchao is imported is >= 2.9. If this is detected, this PR skips importing the
.so
files and logs a warning, to at least have most of the torchao Python API still work and give the user some information about how to get the custom kernels working.For future releases, we'll need to make this more robust - leaving that for future PRs.
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags: