Skip to content

Commit

Permalink
Move import to when needed to avoid circular dependency error (#19579)
Browse files Browse the repository at this point in the history
### Description
Move import to when needed to avoid circular dependency error


### Motivation and Context
Fixes dependency error described here:
microsoft/DeepSpeed#5140

---------

Co-authored-by: Thiago Crepaldi <[email protected]>
  • Loading branch information
jingyanwangms and Thiago Crepaldi authored Feb 22, 2024
1 parent 6b73ab3 commit 3bdb10d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from onnxruntime.capi import _pybind_state as C
from onnxruntime.tools.symbolic_shape_infer import SymbolicShapeInference
from onnxruntime.training.utils import ORTModelInputOutputSchemaType, PTable, onnx_dtype_to_pytorch_dtype
from onnxruntime.training.utils.hooks import configure_ort_compatible_zero_stage3

from . import _are_deterministic_algorithms_enabled, _io, _logger, _onnx_models, _utils
from ._fallback import (
Expand Down Expand Up @@ -143,6 +142,9 @@ def __init__(

self._zero_stage3_param_map = {}
if self._runtime_options.enable_zero_stage3_support:
# Move import to here to avoid circular dependency error
from onnxruntime.training.utils.hooks import configure_ort_compatible_zero_stage3 # type: ignore[import]

# Cannot toggle feature enabling/disabling after the first time enabled.

configure_ort_compatible_zero_stage3(debug=False, stats_output_dir="ort_output", stats_overwrite=True)
Expand Down

0 comments on commit 3bdb10d

Please sign in to comment.