Skip to content

Commit fe03666

Browse files
JKSenthilfacebook-github-bot
authored andcommitted
make model_is_exported oss compatible (#807)
Summary: Pull Request resolved: #807 `model_is_exported` is only available in nightlies, so let's handle this one as well bypass-github-export-checks Reviewed By: diego-urgell Differential Revision: D56539207 fbshipit-source-id: cc1979bb11d8cec4729cec60ffb68915c378e364
1 parent f0718fc commit fe03666

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

torchtnt/framework/_loop_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
import torch.nn as nn
1414
from torch.nn.parallel.distributed import DistributedDataParallel
1515

16+
_EXPORT_UTILS_AVAIL = True
17+
try:
18+
from torch.ao.quantization.pt2e.export_utils import model_is_exported
19+
except Exception:
20+
_EXPORT_UTILS_AVAIL = False
21+
1622
from torchtnt.utils.progress import Progress
1723

1824
_logger: logging.Logger = logging.getLogger(__name__)
@@ -66,7 +72,7 @@ def _set_module_training_mode(
6672
prior_module_train_states[name] = module.training
6773
is_ddp = isinstance(module, DistributedDataParallel)
6874

69-
if torch.ao.quantization.pt2e.export_utils.model_is_exported(
75+
if _EXPORT_UTILS_AVAIL and model_is_exported(
7076
module.module if is_ddp else module
7177
):
7278
if mode:

0 commit comments

Comments
 (0)