Skip to content

Commit 08e212a

Browse files
authored
skip device mesh creation when deepspeed and sp_size >1 (#3914)
1 parent 38dadd9 commit 08e212a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/accelerate/parallelism_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ def build_device_mesh(self, device_type: str):
215215
Args:
216216
device_type (`str`): The type of device for which to build the mesh, e
217217
"""
218+
# Skip mesh creation for DeepSpeed SP - DeepSpeed handles its own SP groups
219+
# Only skip when SP is actually enabled (sp_size > 1), otherwise user might still want TP/CP/FSDP
220+
if self.sp_backend == "deepspeed" and self.sp_size > 1:
221+
return None
222+
218223
if is_torch_version(">=", "2.2.0"):
219224
from torch.distributed.device_mesh import init_device_mesh
220225
else:

0 commit comments

Comments
 (0)