Fix broadcast use cuda device lead to memory capacity unbalanced (#5416)

This commit is contained in:
lambert0312
2025-04-15 17:47:26 +08:00
committed by GitHub
parent d06a83fb01
commit 471650dee0
3 changed files with 35 additions and 11 deletions

View File

@@ -846,9 +846,12 @@ def broadcast_pyobj(
rank: int,
dist_group: Optional[torch.distributed.ProcessGroup] = None,
src: int = 0,
force_cpu_device: bool = True,
):
"""Broadcast inputs from rank=0 to all other ranks with torch.dist backend."""
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device(
"cuda" if torch.cuda.is_available() and not force_cpu_device else "cpu"
)
if rank == 0:
if len(data) == 0: