Always build USE_DISTRIBUTED. (#160449)

Signed-off-by: Edward Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/160449
Approved by: https://github.com/wconstab, https://github.com/albanD, https://github.com/dcci
This commit is contained in:
Edward Yang
2025-09-04 12:58:51 -04:00
committed by PyTorch MergeBot
parent 6087ef41e5
commit de893e96c7
29 changed files with 124 additions and 213 deletions

View File

@ -14,16 +14,10 @@ log = logging.getLogger(__name__)
def is_available() -> bool:
"""
Return ``True`` if the distributed package is available.
Otherwise,
``torch.distributed`` does not expose any other APIs. Currently,
``torch.distributed`` is available on Linux, MacOS and Windows. Set
``USE_DISTRIBUTED=1`` to enable it when building PyTorch from source.
Currently, the default value is ``USE_DISTRIBUTED=1`` for Linux and Windows,
``USE_DISTRIBUTED=0`` for MacOS.
Always returns ``True``. Note that even if distributed is available,
there may not necessarily be any usable backends.
"""
return hasattr(torch._C, "_c10d_init")
return True
if is_available() and not torch._C._c10d_init():