Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to extend nccl collective timeout #858

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions tests/utils/test_checkpoint_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class TestCheckpointUtilsGPU(unittest.TestCase):
@skip_if_not_gpu
def test_get_checkpoint_dirpaths_distributed(self) -> None:
spawn_multi_process(
2,
"nccl",
self._test_get_checkpoint_dirpaths,
2, "nccl", self._test_get_checkpoint_dirpaths, timeout_s=180
)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions tests/utils/test_distributed_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_pg_wrapper_scatter_object_list_nccl(self) -> None:
2,
"nccl",
self._test_pg_wrapper_scatter_object_list,
timeout_s=180,
)

@classmethod
Expand Down
17 changes: 15 additions & 2 deletions torchtnt/utils/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class ProcessGroupSetupParams:
backend: str
port: str
world_size: int
timeout_s: int


def spawn_multi_process(
Expand All @@ -538,6 +539,11 @@ def spawn_multi_process(
method_args: args for the method
method_kwargs: kwargs for the method

Note:
The default timeout used for distributed collectives in the process group is 60 seconds.
This can be overridden by passing a `timeout_s` key in the `method_kwargs`. It will be
extracted before passing to the method call.

Returns:
A list, l, where l[i] is the return value of method(*method_args, **methods_kwargs) on rank i
"""
Expand All @@ -550,7 +556,12 @@ def spawn_multi_process(
# https://pytorch.org/docs/stable/multiprocessing.html#torch.multiprocessing.spawn
_init_pg_and_rank_and_launch_method,
args=(
ProcessGroupSetupParams(backend=backend, port=port, world_size=world_size),
ProcessGroupSetupParams(
backend=backend,
port=port,
world_size=world_size,
timeout_s=method_kwargs.pop("timeout_s", 60),
),
mp_output_dict,
method,
method_args,
Expand Down Expand Up @@ -582,7 +593,9 @@ def _init_pg_and_rank_and_launch_method(
rank=rank,
world_size=pg_setup_params.world_size,
backend=pg_setup_params.backend,
timeout=timedelta(seconds=60), # setting up timeout for distributed collectives
timeout=timedelta( # setting up timeout for distributed collectives
seconds=pg_setup_params.timeout_s
),
)
try:
# pyre-ignore: spawn_multi_process uses unsafe types to begin with
Expand Down
Loading