MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / __init__

Method __init__

deepspeed/runtime/zero/partition_parameters.py:955–1188  ·  view source on GitHub ↗

A context to enable massive model construction for training with ZeRO-3. Models are automatically partitioned (or, sharded) across the system and converted to half precision. Args: module (``torch.nn.Module``, optional): If provided, partition the model as

(self,
                 module=None,
                 data_parallel_group=None,
                 mem_efficient_linear=True,
                 remote_device=None,
                 pin_memory=False,
                 config_dict_or_path=None,
                 config=None,
                 enabled=True,
                 dtype=None,
                 mpu=None,
                 zero_param_parallel_group=None,
                 zero_quantized_weights=False,
                 zero_quantized_nontrainable_weights=False,
                 sequence_data_parallel_group=None,
                 param_swapper=None,
                 tensor_overrides=DEFAULT_TENSOR_OVERRIDES)

Source from the content-addressed store, hash-verified

953 override_module_apply = get_config_default(DeepSpeedZeroConfig, "override_module_apply")
954
955 def __init__(self,
956 module=None,
957 data_parallel_group=None,
958 mem_efficient_linear=True,
959 remote_device=None,
960 pin_memory=False,
961 config_dict_or_path=None,
962 config=None,
963 enabled=True,
964 dtype=None,
965 mpu=None,
966 zero_param_parallel_group=None,
967 zero_quantized_weights=False,
968 zero_quantized_nontrainable_weights=False,
969 sequence_data_parallel_group=None,
970 param_swapper=None,
971 tensor_overrides=DEFAULT_TENSOR_OVERRIDES):
972 """A context to enable massive model construction for training with
973 ZeRO-3. Models are automatically partitioned (or, sharded) across the
974 system and converted to half precision.
975
976 Args:
977 module (``torch.nn.Module``, optional): If provided, partition the model as
978 if it was constructed in the context.
979 data_parallel_group (``deepspeed.comm`` process group, optional):
980 The group of processes to partition among. Defaults to all processes.
981 Synonymous with sequence data parallel group for param partitioning
982 across both sequence and data parallel groups.
983 mem_efficient_linear (bool, optional): Replace
984 torch.nn.functional.linear with an implementation that allows
985 DeepSpeed to partition parameters. Defaults to ``True``.
986 remote_device (string, optional): The initial device to store model
987 weights e.g., ``cpu``, ``nvme``. Passing ``"cpu"`` will create the model in CPU
988 memory. The model may still be moved to GPU based on the
989 offload settings for training. Defaults to param offload device if a config is
990 defined, otherwise GPU.
991 pin_memory (bool, optional): Potentially increase performance by
992 using pinned memory for model weights. ``remote_device`` must be
993 ``"cpu"``. Defaults to pin_memory value in config, otherwise ``False``.
994 config_dict_or_path (dict or ``json file``, optional): If provided, provides configuration
995 for swapping fp16 params to NVMe and other things like ``dtype``.
996 config (dict or ``json file``, optional): Deprecated, use config_dict_or_path instead.
997 enabled (bool, optional): If ``False``, this context has no
998 effect. Defaults to ``True``.
999 dtype (``dtype``, optional): Can be used to change the data type of the parameters.
1000 Supported options are ``torch.half`` and ``torch.float``. Defaults to ``None``
1001 mpu (``object``, optional): A model parallelism unit object that implements get_{model,data}_parallel_{rank,group,world_size}.
1002 zero_param_parallel_group(``object``, optional): Parallel (comm) group for dual partitioning of ZeRO params.
1003 zero_quantized_weights (bool, optional): If ``True``, turn on quantized weights in all gather weights. Default is ``False``
1004 zero_quantized_nontrainable_weights (bool, optional): If ``True``, nontrainable weights will be stored in quantized format. Default is ``False``
1005 param_swapper (``deepspeed.runtime.swap_tensor.partitioned_param_swapper.AsyncPartitionedParameterSwapper``, optional): [Experimental] Use existing parameter swapper. Defaults to ``None``.
1006 This argument will be removed in the near future.
1007 tensor_overrides ([`deepspeed.runtime.zero.DeepSpeedTensorOverride`], optional): Tensor attributes to override. Defaults to overriding dtype and device.
1008
1009 This context accelerates model initialization and enables models that
1010 are too large to allocate in their entirety in CPU memory. It has the
1011 following effects:
1012

Callers

nothing calls this directly

Calls 15

_keep_in_fp32Method · 0.95
init_distributedFunction · 0.90
get_acceleratorFunction · 0.90
get_config_defaultFunction · 0.90
CUDAQuantizerClass · 0.85
warningMethod · 0.80
get_world_groupMethod · 0.80

Tested by

no test coverage detected