Skip to content

Commit 8968543

Browse files
committed
feat: support low cpu mem usage in spmd-fsdp
1 parent 63e20fb commit 8968543

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

torch_xla/experimental/spmd_fully_sharded_data_parallel.py

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import torch_xla.core.xla_model as xm
1212
import torch_xla.distributed.spmd as spmd
1313
from torch_xla.distributed.fsdp.wrap import recursive_wrap
14+
from torch_xla.distributed.fsdp._init_utils import _materialize_module
1415

1516

1617
def _prepare_spmd_partition_spec(param):
@@ -95,6 +96,13 @@ def __init__(
9596
)
9697
self._auto_wrap(auto_wrap_kwargs, fsdp_kwargs)
9798

99+
_materialize_module(
100+
module,
101+
None,
102+
[],
103+
deferred_init_check_fn=lambda k: not isinstance(
104+
k, SpmdFullyShardedDataParallel))
105+
98106
# Let's move the module to xla device in case it's not moved
99107
# by the caller already.
100108
self._orig_module = module.to(xm.xla_device())

0 commit comments

Comments
 (0)