Commit 7ea5410
authored
torchao init: do not load .so files for known incompatible torch version (#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) [[email protected] ~/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:1 parent 08b1591 commit 7ea5410
1 file changed
+37
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
42 | 62 | | |
43 | 63 | | |
44 | 64 | | |
| |||
0 commit comments