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
5 changes: 3 additions & 2 deletions composer/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,15 @@ def is_model_ddp(model: torch.nn.Module) -> bool:
def is_model_fsdp(model: torch.nn.Module) -> bool:
"""Whether ``model`` is an instance of a :class:`.FullyShardedDataParallel`."""
try:
from torch.distributed.fsdp import FSDPModule
from torch.distributed.fsdp import FullyShardedDataParallel as FSDP

if isinstance(model, FSDP):
if isinstance(model, (FSDP, FSDPModule)):
return True

# Check if model is wrapped with FSDP
for _, obj in model.named_children():
if isinstance(obj, FSDP):
if isinstance(obj, (FSDP, FSDPModule)):
return True
return False
except ImportError:
Expand Down
Loading