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

Support low cpu mem usage in SPMD-FSDP #11

Merged
merged 2 commits into from
Sep 3, 2024
Merged
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
7 changes: 7 additions & 0 deletions torch_xla/experimental/spmd_fully_sharded_data_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import torch_xla.core.xla_model as xm
import torch_xla.distributed.spmd as spmd
from torch_xla.distributed.fsdp.wrap import recursive_wrap
from torch_xla.distributed.fsdp._init_utils import _materialize_module


def _prepare_spmd_partition_spec(param):
Expand Down Expand Up @@ -95,6 +96,12 @@ def __init__(
)
self._auto_wrap(auto_wrap_kwargs, fsdp_kwargs)

_materialize_module(
module,
None, [],
deferred_init_check_fn=lambda k: not isinstance(
k, SpmdFullyShardedDataParallel))

# Let's move the module to xla device in case it's not moved
# by the caller already.
self._orig_module = module.to(xm.xla_device())
Expand Down
Loading