mlx.nn.FullyShardedModule#
- class FullyShardedModule(module: Module, group: Group | None = None, compute_dtype: Dtype | None = None)#
Wrap a module so each member of the group holds only a shard of its parameters.
The full parameters are gathered for the forward pass and the gradients are reduce-scattered in the backward pass, so during training each member of the group stores and updates only its own shard.
Every parameter is sharded along axis 0, so each parameter’s size along that axis must be divisible by the size of
group.Use
fully_shard()to wrap a module.- Parameters:
Methods
as_linear(*args, **kwargs)