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

Function _create_zero_param_parallel_group

deepspeed/utils/groups.py:972–999  ·  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

970
971
972def _create_zero_param_parallel_group(group_size):
973 """
974 Create parameter partitioning group within ZeRO data parallel groups.
975
976 Example - ZP + D parallel
977 world_size = 16
978 zero_hpz_partition_size = 2 # number of ranks with replicated params (dual partitioning)
979 zero_param_intra_parallel_group = [0, 1], [2,3], [4,5], [6,7], [8,9] - segmented (subgroup) with rep partition
980 data_parallel_group = [0,1,...,15] - all reduce is on ZeRO model
981 """
982 assert dist.is_initialized()
983 global _ZERO_PARAM_INTRA_PARALLEL_GROUP
984 # Only create group if it does not already exist
985 assert _ZERO_PARAM_INTRA_PARALLEL_GROUP is None, \
986 'ZeRO parameter intra parallel group is already initialized'
987
988 world_size = dist.get_world_size()
989 rank = dist.get_rank()
990
991 zero_param_parallel_size_ = min(group_size, world_size)
992 _ensure_divisibility(world_size, zero_param_parallel_size_)
993
994 # Build the ZeRO param intra parallel groups.
995 for i in range(world_size // zero_param_parallel_size_):
996 ranks = range(i * zero_param_parallel_size_, (i + 1) * zero_param_parallel_size_)
997 group = dist.new_group(ranks)
998 if i == (rank // zero_param_parallel_size_):
999 _ZERO_PARAM_INTRA_PARALLEL_GROUP = group
1000
1001
1002def _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