mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Revert "Make distributed modules importable even when backend not built (#159889)"
This reverts commit ef3be6726f7ff4b77c22db10cec5b686f9107ea9. Reverted https://github.com/pytorch/pytorch/pull/159889 on behalf of https://github.com/jeanschmidt due to Breaking internal build rules, see D81756619 ([comment](https://github.com/pytorch/pytorch/pull/160449#issuecomment-3259430011))
This commit is contained in:
@ -1,11 +1,7 @@
|
||||
from datetime import timedelta
|
||||
from typing import Optional
|
||||
|
||||
# Import from centralized fallback module - no ImportError handling needed
|
||||
from torch.distributed._distributed_c10d import (
|
||||
_DEFAULT_PG_NCCL_TIMEOUT,
|
||||
_DEFAULT_PG_TIMEOUT,
|
||||
)
|
||||
from torch._C._distributed_c10d import _DEFAULT_PG_TIMEOUT
|
||||
|
||||
|
||||
__all__ = ["default_pg_timeout", "default_pg_nccl_timeout"]
|
||||
@ -20,4 +16,11 @@ default_pg_timeout: timedelta = _DEFAULT_PG_TIMEOUT
|
||||
# Later, we could consider merging them back together at the c++ layer if we can align on a same value.
|
||||
# (only if TORCH_NCCL_BLOCKING_WAIT or TORCH_NCCL_ASYNC_ERROR_HANDLING is set to 1).
|
||||
|
||||
default_pg_nccl_timeout: Optional[timedelta] = _DEFAULT_PG_NCCL_TIMEOUT
|
||||
try:
|
||||
from torch._C._distributed_c10d import _DEFAULT_PG_NCCL_TIMEOUT
|
||||
|
||||
default_pg_nccl_timeout: Optional[timedelta] = _DEFAULT_PG_NCCL_TIMEOUT
|
||||
except ImportError:
|
||||
# if C++ NCCL support is not compiled, we don't have access to the default nccl value.
|
||||
# if anyone is actually trying to use nccl in this state, it should error.
|
||||
default_pg_nccl_timeout = None
|
||||
|
Reference in New Issue
Block a user