_config.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import os
  2. import sys
  3. from typing import Optional
  4. # [@compile_ignored: debug] Fails hard instead of graph breaking on guard on data dependent errors.
  5. no_data_dependent_graph_break = (
  6. os.environ.get("TORCHDYNAMO_NO_DATA_DEPENDENT_GRAPH_BREAK", "0") == "1"
  7. )
  8. # [@compile_ignored: debug] Uses z3 for validating the guard optimizations transformations.
  9. translation_validation = (
  10. os.environ.get("TORCHDYNAMO_TRANSLATION_VALIDATION", "0") == "1"
  11. )
  12. # Timeout (in milliseconds) for z3 finding a solution.
  13. # [@compile_ignored: debug]
  14. translation_validation_timeout = int(
  15. os.environ.get("TORCHDYNAMO_TRANSLATION_VALIDATION_TIMEOUT", "600000")
  16. )
  17. # Disables bisection for translation validation.
  18. #
  19. # Translation validation bisection is enabled by default, if translation validation
  20. # is also enabled. This should help finding guard simplification issues. However,
  21. # since validation uses Z3 for bisecting, it might take a lot of time.
  22. #
  23. # Set this configuration option so as to avoid bisecting.
  24. # [@compile_ignored: debug]
  25. translation_validation_no_bisect = (
  26. os.environ.get("TORCHDYNAMO_TRANSLATION_NO_BISECT", "0") == "1"
  27. )
  28. # Checks whether replaying ShapeEnv events on a freshly constructed one yields
  29. # the a ShapeEnv with the same state. This should be used only in testing.
  30. check_shape_env_recorded_events = False
  31. # TODO: Perhaps consider allowing unions for the configs below (so you can hit
  32. # multiple reps at the same time)
  33. # Give extended debug information if the string representation of a guard
  34. # matches this. For example, set this to "Ne(s0, 10)" and whenever we issue
  35. # this guard, we will generate full Python and C++ backtrace
  36. # [@compile_ignored: debug]
  37. extended_debug_guard_added = os.environ.get(
  38. "TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED", None
  39. )
  40. # Give extended debug information when a particular symbol is allocated. For
  41. # example, set this to "u2" and whenever we create this symbol, we will
  42. # generate full Python and C++ backtrace
  43. # [@compile_ignored: debug]
  44. extended_debug_create_symbol = os.environ.get(
  45. "TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL", None
  46. )
  47. # Give extended debug information (C++ backtrace) for all extended debug
  48. # settings as well as errors. The C++ backtrace is slow and very spammy so we
  49. # don't include it by default even when you're requesting extended debug.
  50. # [@compile_ignored: debug]
  51. extended_debug_cpp = os.environ.get("TORCHDYNAMO_EXTENDED_DEBUG_CPP", "") != ""
  52. # Give extended debug information (line of code) when a torch function
  53. # is called during export. This is useful for showing progress and detecting
  54. # where export might be stuck. Currently only works for strict=False.
  55. # [@compile_ignored: debug]
  56. extended_debug_current_loc = (
  57. os.environ.get("TORCHEXPORT_EXTENDED_DEBUG_CURRENT_LOC", "0") == "1"
  58. )
  59. # [@compile_ignored: debug] Show a warning for every specialization
  60. print_specializations = False
  61. # wraps (un)equalities with 'Not' class after recording the correct expression
  62. # in the FX graph. This should incorrectly construct the divisible and replacement
  63. # lists, and incorrectly issue guards.
  64. inject_EVALUATE_EXPR_flip_equality_TESTING_ONLY = False
  65. # [@compile_ignored: debug] Validate that ShapeEnv's version key is updated correctly
  66. validate_shape_env_version_key = False
  67. # If we produce more than this many guards on a symbol, force the symbol to
  68. # get specialized and bail out if this many guards mention this particular
  69. # symbol. This may be slightly more aggressive than the true number of guards
  70. # issued (as we test if we've hit the limit on-the-fly, whereas we may
  71. # do further simplifications at final guard issuance time that make guards
  72. # irrelevant.)
  73. symbol_guard_limit_before_specialize: Optional[int] = None
  74. # This flag changes whether we should use the same symbolic variable to represent input sizes that are the same.
  75. use_duck_shape = True
  76. # Controls the registration of torch.nonzero() on the meta device.
  77. # When True, nonzero returns a tensor with shape (self.numel(), self.dim())
  78. # assuming all elements are none-zero.
  79. # Default is False to prevent unintended registration. Set to True to enable.
  80. meta_nonzero_assume_all_nonzero = False
  81. # Applies size-oblivious reasoning to backed symbols. This allocates a [0, inf] range for backed size symbols,
  82. # and relies on size-oblivious semantics to avoid 0/1 specialization guards by marking them size-like.
  83. # Currently an experimental option for export.
  84. backed_size_oblivious = False
  85. # Skip dtype check in meta registrations. Only used for systems that does its own dtype checking.
  86. skip_dtype_check_in_meta_registrations = False
  87. from torch.utils._config_module import install_config_module
  88. install_config_module(sys.modules[__name__])