-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Adjusting spawn_multi_process to work properly on gloo Differential Revision: D52546790
- Loading branch information
1 parent
28e657d
commit 892ce89
Showing
2 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import unittest | ||
|
||
from torchtnt.utils.distributed import get_global_rank | ||
|
||
from torchtnt.utils.test_utils import skip_if_not_distributed, spawn_multi_process | ||
|
||
|
||
class TestUtilsTest(unittest.TestCase): | ||
@staticmethod | ||
def _test_method(offset_arg: int, offset_kwarg: int) -> int: | ||
return get_global_rank() + offset_arg - offset_kwarg | ||
|
||
@skip_if_not_distributed | ||
def test_spawn_multi_process(self) -> None: | ||
ret_dict = spawn_multi_process(2, "gloo", self._test_method, 3, offset_kwarg=2) | ||
self.assertEqual(ret_dict[0], 1) | ||
self.assertEqual(ret_dict[1], 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters