config.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """
  2. Configuration module for torch.export.export.
  3. This module contains various configuration flags and settings that control torch.export's
  4. behavior, including:
  5. - Runtime behavior flags
  6. - Debugging and development options
  7. """
  8. import sys
  9. from typing import Any, TYPE_CHECKING
  10. from torch._environment import is_fbcode
  11. from torch.utils._config_module import install_config_module
  12. # this flag controls whether we use new functional tracer. It
  13. # should be True in the long term.
  14. use_new_tracer_experimental = True
  15. # this flag is used to control whether we want to instrument
  16. # fake tensor creation to track potential leaks. It is off
  17. # by default, but user can turn it on to debug leaks.
  18. detect_non_strict_fake_tensor_leaks = False
  19. # error on potentially pre-dispatch/non-strict tracing limitation
  20. # this type of error usually happens when we encounter an op
  21. # that we don't know how to proxy, resulting in untracked fake tensors
  22. error_on_lifted_constant_tensors = True
  23. # enable auto_functionalized_v2 in export
  24. # We turn this off in fbcode due to downstream users not
  25. # being ready to handle auto_functionalized_v2.
  26. enable_auto_functionalized_v2_for_export = not is_fbcode()
  27. use_legacy_dynamo_graph_capture = True
  28. if TYPE_CHECKING:
  29. from torch.utils._config_typing import * # noqa: F401, F403
  30. def _make_closure_patcher(**changes: Any) -> Any: ...
  31. install_config_module(sys.modules[__name__])