Skip to content

Commit a820df6

Browse files
Kai Lifacebook-github-bot
authored andcommitted
Add is_fbcode() check to unblock unrecognized torchao version (#3338)
Summary: As title. Differential Revision: D87008228
1 parent 4f5bc7a commit a820df6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchao/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
logger = logging.getLogger(__name__)
2727

2828

29+
def is_fbcode():
30+
return not hasattr(torch.version, "git_version")
31+
32+
2933
def _parse_version(version_string):
3034
"""
3135
Parse version string representing pre-release with -1
@@ -48,7 +52,7 @@ def _parse_version(version_string):
4852
force_skip_loading_so_files = (
4953
os.getenv("TORCHAO_FORCE_SKIP_LOADING_SO_FILES", "0") == "1"
5054
)
51-
if force_skip_loading_so_files:
55+
if force_skip_loading_so_files or is_fbcode():
5256
# user override
5357
# users can set env var TORCHAO_FORCE_SKIP_LOADING_SO_FILES=1 to skip loading .so files
5458
# this way, if they are using an incompatbile torch version, they can still use the API by setting the env var

0 commit comments

Comments
 (0)