mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-10-08 12:52:26 +00:00
[model checkpoint] add gloo groups for cpu tensor communication (#589)
This commit is contained in:
@@ -20,6 +20,7 @@ class Initializer_Pipeline(ProcessGroupInitializer):
|
||||
pipeline_parallel_size (int): Size of pipeline parallel
|
||||
tensor_parallel_size (int): Size of tensor parallel
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.data_group_size = self.world_size // self.data_parallel_size
|
||||
@@ -36,20 +37,19 @@ class Initializer_Pipeline(ProcessGroupInitializer):
|
||||
for i in range(self.data_parallel_size):
|
||||
for j in range(self.pipeline_stage_size):
|
||||
pipe_ranks = list(
|
||||
range(i * self.data_group_size + j,
|
||||
(i + 1) * self.data_group_size,
|
||||
self.pipeline_stage_size))
|
||||
range(i * self.data_group_size + j, (i + 1) * self.data_group_size, self.pipeline_stage_size))
|
||||
pipe_group_size = len(pipe_ranks)
|
||||
pipe_group = dist.new_group(pipe_ranks)
|
||||
group_cpu = dist.new_group(pipe_ranks, backend='gloo') if dist.get_backend() != 'gloo' else pipe_group
|
||||
|
||||
if self.rank in pipe_ranks:
|
||||
local_rank = pipe_ranks.index(self.rank)
|
||||
group_world_size = pipe_group_size
|
||||
process_group = pipe_group
|
||||
cpu_group = group_cpu
|
||||
ranks_in_group = pipe_ranks
|
||||
dist_settings.append(
|
||||
tuple((local_rank, group_world_size,
|
||||
process_group, ranks_in_group,
|
||||
tuple((local_rank, group_world_size, process_group, cpu_group, ranks_in_group,
|
||||
ParallelMode.PIPELINE)))
|
||||
|
||||
return dist_settings
|
||||
|
Reference in New Issue
Block a user