Skip to content

Commit 38d55dc

Browse files
authored
Fix fbcode loading cpp extensions (#3372)
**Summary:** Follow-up to #3338, which always skips loading cpp extensions for fbcode. However, we actually need them for internal tests: D87008228. We should always load them for fbcode instead, which is safe because pytorch will always be nightly there. **Test Plan:** CI
1 parent 316ef03 commit 38d55dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

torchao/__init__.py

Lines changed: 6 additions & 0 deletions
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
@@ -53,6 +57,8 @@ def _parse_version(version_string):
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
5559
skip_loading_so_files = True
60+
elif is_fbcode():
61+
skip_loading_so_files = False
5662
# if torchao version has "+git", assume it's locally built and we don't know
5763
# anything about the PyTorch version used to build it unless user provides override flag
5864
# otherwise, assume it's prebuilt by torchao's build scripts and we can make

0 commit comments

Comments
 (0)