constants.py 1.2 KB

12345678910111213141516171819202122232425
  1. from datetime import timedelta
  2. from torch._C._distributed_c10d import _DEFAULT_PG_TIMEOUT
  3. __all__ = ["default_pg_timeout", "default_pg_nccl_timeout"]
  4. # Default process group wide timeout, if applicable.
  5. # This only applies to the non-nccl backends
  6. # To make an attempt at backwards compatibility with THD, we use an
  7. # extraordinarily high default timeout, given that THD did not have timeouts.
  8. default_pg_timeout: timedelta = _DEFAULT_PG_TIMEOUT
  9. # Separate timeout for PGNCCL mainly because it's always been that way in the C++ layer, but until recently
  10. # there was one default that applied across all backends in the python layer.
  11. # Later, we could consider merging them back together at the c++ layer if we can align on a same value.
  12. # (only if TORCH_NCCL_BLOCKING_WAIT or TORCH_NCCL_ASYNC_ERROR_HANDLING is set to 1).
  13. try:
  14. from torch._C._distributed_c10d import _DEFAULT_PG_NCCL_TIMEOUT
  15. default_pg_nccl_timeout: timedelta | None = _DEFAULT_PG_NCCL_TIMEOUT
  16. except ImportError:
  17. # if C++ NCCL support is not compiled, we don't have access to the default nccl value.
  18. # if anyone is actually trying to use nccl in this state, it should error.
  19. default_pg_nccl_timeout = None