Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mbridge/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ def unwrap_model(model, module_instances=ALL_MODULE_WRAPPER_CLASSNAMES):
def broadcast_from_megatron_pp(tensor: torch.Tensor):
# tensor is not None only in one of the pp ranks
if tensor is not None:
# FSDP DTensor: gather full tensor before PP broadcast.
try:
from torch.distributed.tensor import DTensor

if isinstance(tensor, DTensor):
tensor = tensor.full_tensor()
except ImportError:
pass
shape = tensor.shape
dtype = tensor.dtype
tensor_parallel = getattr(tensor, "tensor_model_parallel", None)
Expand Down