Skip to content

Commit c1388df

Browse files
tanquermeta-codesync[bot]
authored andcommitted
Fix device_mesh test to compatible with old pytorch (#87)
Summary: Pull Request resolved: #87 device_mesh test has to be run with old pytorch, which does not have GroupName. Import GroupName will break the github oss ci: https://github.com/meta-pytorch/torchcomms/commits/main/. Let's make sure it works with old pytorch Reviewed By: YulunW Differential Revision: D88823652 fbshipit-source-id: ce4b00bb00eed51c21393621557259c3211b5758
1 parent 0218801 commit c1388df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

comms/torchcomms/device_mesh.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99

1010
from torch.distributed.device_mesh import _mesh_resources
1111

12-
from torch.distributed.distributed_c10d import GroupName
13-
1412
from torchcomms._comms import _BackendWrapper, _get_store, new_comm, TorchComm
1513

14+
try:
15+
from torch.distributed.distributed_c10d import GroupName
16+
except ImportError:
17+
print("GroupName is not available.")
18+
# Fallback: GroupName is effectively just str when not available from torch
19+
# We use cast to satisfy type checkers while keeping runtime behavior simple
20+
GroupName = str # type: ignore[misc]
21+
1622

1723
def _create_torchcomm_process_group(
1824
comm: TorchComm,

0 commit comments

Comments
 (0)