-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Miscellaneous CI, dependency, and version fixes (#1151)
- Loading branch information
1 parent
069b12b
commit 37636a8
Showing
12 changed files
with
104 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
from importlib.metadata import PackageNotFoundError, version | ||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
import torchao | ||
|
||
|
||
def _is_fbcode(): | ||
return not hasattr(torch.version, "git_version") | ||
|
||
|
||
def _get_torchao_version() -> Tuple[Optional[str], Optional[bool]]: | ||
""" | ||
Get torchao version. Returns a tuple of two elements, the first element | ||
is the version string, the second element is whether it's a nightly version. | ||
For fbcode usage, return None, None. | ||
Checks: | ||
1) is_fbcode, then | ||
2) importlib's version(torchao-nightly) for nightlies, then | ||
3) torchao.__version__ (only defined for torchao >= 0.3.0), then | ||
4) importlib's version(torchao) for non-nightly | ||
If none of these work, raise an error. | ||
""" | ||
if _is_fbcode(): | ||
return None, None | ||
# Check for nightly install first | ||
try: | ||
ao_version = version("torchao-nightly") | ||
is_nightly = True | ||
except PackageNotFoundError: | ||
try: | ||
ao_version = torchao.__version__ | ||
is_nightly = False | ||
except AttributeError: | ||
ao_version = "unknown" | ||
if ao_version == "unknown": | ||
try: | ||
ao_version = version("torchao") | ||
is_nightly = False | ||
except Exception as e: | ||
raise PackageNotFoundError("Could not find torchao version") from e | ||
return ao_version, is_nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters