Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSDP][Easy] Allow ModuleWrapPolicy to take Iterable #104999

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions torch/distributed/fsdp/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,14 @@ def _module_wrap_policy(
class ModuleWrapPolicy(_FSDPPolicy):
"""This is a wrapper around :func:`_module_wrap_policy`."""

def __init__(self, module_classes: Set[Type[nn.Module]]):
def __init__(self, module_classes: Iterable[Type[nn.Module]]):
module_classes_set = set(module_classes)
self._policy: Callable = functools.partial(
_module_wrap_policy,
module_classes=module_classes,
module_classes=module_classes_set,
)
self._module_classes = module_classes
self._module_classes_str = str(module_classes)
self._module_classes = module_classes_set
self._module_classes_str = str(module_classes_set)

@property
def policy(self):
Expand Down