Skip to content

Commit

Permalink
Handle special case of libuv for Windows (deepspeedai#7064)
Browse files Browse the repository at this point in the history
More information on libuv in pytorch:
https://pytorch.org/tutorials/intermediate/TCPStore_libuv_backend.html
Issue tracking the prevalence of the error on Windows (unresolved at the
time of this PR): pytorch/pytorch#139990
LibUV github: https://github.com/libuv/libuv

Windows error:
```
  File "C:\hostedtoolcache\windows\Python\3.12.7\x64\Lib\site-packages\torch\distributed\rendezvous.py", line 189, in _create_c10d_store
    return TCPStore(
           ^^^^^^^^^
RuntimeError: use_libuv was requested but PyTorch was build without libuv support
```

use_libuv isn't well supported on Windows in pytorch <2.4, so we need to
guard around this case.

---------

Signed-off-by: Logan Adams <[email protected]>
  • Loading branch information
loadams authored Feb 20, 2025
1 parent cb20d44 commit 8577bd2
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions deepspeed/comm/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,22 @@ def has_reduce_scatter_tensor(self):

def init_process_group(self, backend, timeout, init_method, rank, world_size):
if not torch.distributed.is_initialized():
torch.distributed.init_process_group(backend,
timeout=timeout,
init_method=init_method,
rank=rank,
world_size=world_size)
if not required_torch_version(min_version=2.4):
# Windows torch builds do not come with lib_uv by default.
# More information here: https://pytorch.org/tutorials/intermediate/TCPStore_libuv_backend.html
use_libuv = False if os.name == "nt" else True
torch.distributed.init_process_group(backend,
timeout=timeout,
init_method=init_method,
rank=rank,
world_size=world_size,
use_libuv=use_libuv)
else:
torch.distributed.init_process_group(backend,
timeout=timeout,
init_method=init_method,
rank=rank,
world_size=world_size)
self.using_mpi = torch.distributed.get_backend() == 'mpi'

@disable_compiler_collective
Expand Down

0 comments on commit 8577bd2

Please sign in to comment.