MCPcopy Create free account
hub / github.com/modelscope/modelscope / get_dist_info

Function get_dist_info

modelscope/utils/torch_utils.py:124–143  ·  view source on GitHub ↗

Get dist info of a specified group Args: group: The parallel group, default None, for the global group Returns: A tuple of the current rank and world_size of the group

(group=None)

Source from the content-addressed store, hash-verified

122
123
124def get_dist_info(group=None) -> Tuple[int, int]:
125 """Get dist info of a specified group
126
127 Args:
128 group: The parallel group, default None, for the global group
129
130 Returns:
131 A tuple of the current rank and world_size of the group
132 """
133 if is_dist():
134 from modelscope.utils.megatron_utils import is_megatron_initialized
135 if group is None and is_megatron_initialized():
136 from megatron_util import mpu
137 group = mpu.get_data_parallel_group()
138 rank = dist.get_rank(group)
139 world_size = dist.get_world_size(group)
140 else:
141 rank = 0
142 world_size = 1
143 return rank, world_size
144
145
146def get_local_rank():

Callers 13

init_distMethod · 0.90
multi_gpu_testFunction · 0.90
collect_results_cpuFunction · 0.90
collect_results_gpuFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
get_deepspeed_configMethod · 0.90
test_funcFunction · 0.90
test_normalMethod · 0.90
__init__Method · 0.50
evaluateMethod · 0.50

Calls 2

is_megatron_initializedFunction · 0.90
is_distFunction · 0.85

Tested by 2

test_funcFunction · 0.72
test_normalMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…