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

Function _create_zero_param_parallel_group

deepspeed/utils/groups.py:944–971  ·  view source on GitHub ↗

Create parameter partitioning group within ZeRO data parallel groups. Example - ZP + D parallel world_size = 16 zero_hpz_partition_size = 2 # number of ranks with replicated params (dual partitioning) zero_param_intra_parallel_group = [0, 1], [2,3], [4,5], [

(group_size)

Source from the content-addressed store, hash-verified

942
943
944def _create_zero_param_parallel_group(group_size):
945 """
946 Create parameter partitioning group within ZeRO data parallel groups.
947
948 Example - ZP + D parallel
949 world_size = 16
950 zero_hpz_partition_size = 2 # number of ranks with replicated params (dual partitioning)
951 zero_param_intra_parallel_group = [0, 1], [2,3], [4,5], [6,7], [8,9] - segmented (subgroup) with rep partition
952 data_parallel_group = [0,1,...,15] - all reduce is on ZeRO model
953 """
954 assert dist.is_initialized()
955 global _ZERO_PARAM_INTRA_PARALLEL_GROUP
956 # Only create group if it does not already exist
957 assert _ZERO_PARAM_INTRA_PARALLEL_GROUP is None, \
958 'ZeRO parameter intra parallel group is already initialized'
959
960 world_size = dist.get_world_size()
961 rank = dist.get_rank()
962
963 zero_param_parallel_size_ = min(group_size, world_size)
964 _ensure_divisibility(world_size, zero_param_parallel_size_)
965
966 # Build the ZeRO param intra parallel groups.
967 for i in range(world_size // zero_param_parallel_size_):
968 ranks = range(i * zero_param_parallel_size_, (i + 1) * zero_param_parallel_size_)
969 group = dist.new_group(ranks)
970 if i == (rank // zero_param_parallel_size_):
971 _ZERO_PARAM_INTRA_PARALLEL_GROUP = group
972
973
974def _get_zero_param_intra_parallel_group():

Callers

nothing calls this directly

Calls 5

_ensure_divisibilityFunction · 0.85
get_world_sizeMethod · 0.80
is_initializedMethod · 0.45
get_rankMethod · 0.45
new_groupMethod · 0.45

Tested by

no test coverage detected