Skip to content

Commit 2dedd73

Browse files
committed
Update compatibility matrix (#3178)
Previous compatibility checks seemed incorrect. For example, torchao 0.14.0 was released before pytorch 2.9.0 was released, so it should be compatible with 2.9.0.dev instead. In general, each torchao version should be compatible with the latest stable pytorch version and the nightlies that follow.
1 parent 0294124 commit 2dedd73

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

torchao/__init__.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,26 @@ def _parse_version(version_string):
5757
elif not ("+git" in __version__) and not ("unknown" in __version__):
5858
# We know that torchao .so files built using PyTorch 2.8.0 are not ABI compatible with PyTorch 2.9+. (see #2919)
5959
# The following code skips importing the .so files if incompatible torch version is detected,
60-
# to avoid crashing the Python process with "Aborted (core
61-
# dumped)".
62-
torch_version = _parse_version(torch.__version__)
63-
torchao_version = _parse_version(__version__)
64-
65-
v2_8_0 = _parse_version("2.8.0")
66-
v0_13_0 = _parse_version("0.13.0")
67-
v2_9_0_dev = _parse_version("2.9.0.dev")
68-
v0_14_0_dev = _parse_version("0.14.0.dev")
69-
70-
if torch_version == v2_8_0 and torchao_version == v0_13_0:
71-
# current torchao version and torch version, check here for clarity
72-
skip_loading_so_files = False
73-
elif torch_version == v2_9_0_dev and torchao_version == v0_14_0_dev:
74-
# .dev for nightlies since 2.9.0 and 0.14.0 has not been released
75-
skip_loading_so_files = False
76-
else:
77-
skip_loading_so_files = True
60+
# to avoid crashing the Python process with "Aborted (core dumped)".
61+
torchao_pytorch_compatible_versions = [
62+
# Built against torch 2.8.0
63+
(_parse_version("0.13.0"), _parse_version("2.8.0")),
64+
(_parse_version("0.13.0"), _parse_version("2.9.0.dev")),
65+
(_parse_version("0.14.0"), _parse_version("2.8.0")),
66+
(_parse_version("0.14.0"), _parse_version("2.9.0.dev")),
67+
# Built against torch 2.9.0
68+
(_parse_version("0.14.1"), _parse_version("2.9.0")),
69+
(_parse_version("0.14.1"), _parse_version("2.10.0.dev")),
70+
]
71+
72+
current_torch_version = _parse_version(torch.__version__)
73+
current_torchao_version = _parse_version(__version__)
74+
75+
skip_loading_so_files = True
76+
for torchao_v, torch_v in torchao_pytorch_compatible_versions:
77+
if current_torchao_version == torchao_v and current_torch_version == torch_v:
78+
skip_loading_so_files = False
79+
break
7880

7981

8082
if skip_loading_so_files:

0 commit comments

Comments
 (0)