Skip to content

Commit a4447f3

Browse files
author
Andrew Gu
committed
Update on "[TCPStore] Threw value error if passing world_size=0 to TCPStore"
cc XilunWu H-Huang kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o [ghstack-poisoned]
1 parent 9fc436f commit a4447f3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/distributed/test_store.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ def test_store_timeout_on_missing_clients(self):
516516
use_libuv=self._use_libuv,
517517
)
518518

519+
@skip_if_win32()
520+
def test_world_size_0_raises(self):
521+
with self.assertRaisesRegex(ValueError, "TCPStore world size cannot be 0"):
522+
dist.TCPStore("localhost", 0, world_size=0, is_master=False)
523+
519524

520525
class LibUvTCPStoreTest(TCPStoreTest):
521526
_use_libuv = True

torch/csrc/distributed/c10d/init.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,9 +1534,9 @@ Example::
15341534
bool useLibUV) {
15351535
std::optional<std::size_t> numWorkers = std::nullopt;
15361536
if (worldSize.has_value() && worldSize.value() > -1) {
1537-
if (worldSize.value() == 0) {
1538-
throw py::value_error("TCPStore world size cannot be 0");
1539-
}
1537+
if (worldSize.value() == 0) {
1538+
throw py::value_error("TCPStore world size cannot be 0");
1539+
}
15401540
numWorkers = static_cast<std::size_t>(worldSize.value());
15411541
}
15421542

0 commit comments

Comments
 (0)