@@ -57,29 +57,29 @@ def _parse_version(version_string):
5757elif 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 = _parse_version ("0.14.0" )
69- v2_10_0_dev = _parse_version ("2.10.0.dev" )
70- v0_15_0_dev = _parse_version ( "0.15.0.dev" )
71-
72- if torch_version == v2_8_0 and torchao_version == v0_13_0 :
73- # current torchao version and torch version, check here for clarity
74- skip_loading_so_files = False
75- elif torch_version == v2_9_0_dev and torchao_version == v0_14_0 :
76- # .dev for nightlies since 2.9.0 and 0.14.0 has not been released
77- skip_loading_so_files = False
78- elif torch_version == v2_10_0_dev and torchao_version == v0_15_0_dev :
79- # .dev for nightlies since 2.10.0 and 0.15.0 has not been released
80- skip_loading_so_files = False
81- else :
82- 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+ # Current torchao version
71+ ( _parse_version ( "0.15.0.dev" ), _parse_version ( "2.9.0" )),
72+ ( _parse_version ( "0.15.0.dev" ), _parse_version ( "2.10.0.dev" )),
73+ ]
74+
75+ current_torch_version = _parse_version ( torch . __version__ )
76+ current_torchao_version = _parse_version ( __version__ )
77+
78+ skip_loading_so_files = True
79+ for torchao_v , torch_v in torchao_pytorch_compatible_versions :
80+ if current_torchao_version == torchao_v and current_torch_version == torch_v :
81+ skip_loading_so_files = False
82+ break
8383
8484
8585if skip_loading_so_files :
0 commit comments