Revert "[distributed] Replace assert statements with AssertionError exceptions (#165216)"

This reverts commit 74db92b21868b7e9e77cc966e5d57a8246723cbd.

Reverted https://github.com/pytorch/pytorch/pull/165216 on behalf of https://github.com/clee2000 due to I think this broke distributed/test_pg_wrapper.py::ProcessGroupNCCLWrapperTest::test_debug_level_detail_no_gloo [GH job link](https://github.com/pytorch/pytorch/actions/runs/18492765290/job/52693842750) [HUD commit link](74db92b218), note to self: bad TD ([comment](https://github.com/pytorch/pytorch/pull/165216#issuecomment-3402838765))
This commit is contained in:
PyTorch MergeBot
2025-10-14 17:05:16 +00:00
parent 5eddbb5e47
commit d2494cbb2b
11 changed files with 136 additions and 222 deletions

View File

@ -83,10 +83,9 @@ def _rendezvous_helper(url: str, rank: int, world_size_opt: Optional[int], **kwa
world_size = world_size_opt
if rank != -1 or world_size != -1 or world_size_opt is None:
query_dict = _query_to_dict(result.query)
if "rank" in query_dict or "world_size" in query_dict:
raise AssertionError(
f"The url: {url} has node-specific arguments(rank, world_size) already."
)
assert "rank" not in query_dict and "world_size" not in query_dict, (
f"The url: {url} has node-specific arguments(rank, world_size) already."
)
if rank != -1:
query_dict["rank"] = str(rank)
if world_size != -1 or world_size_opt is None:
@ -228,8 +227,7 @@ def _tcp_rendezvous_handler(
world_size = int(query_dict["world_size"])
use_libuv = _get_use_libuv_from_query_dict(query_dict)
if result.hostname is None:
raise AssertionError("hostname cannot be None")
assert result.hostname is not None
store = _create_c10d_store(
result.hostname, result.port, rank, world_size, timeout, use_libuv