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

Method __init__

deepspeed/runtime/pipe/engine.py:72–253  ·  view source on GitHub ↗
(self, has_bool_tensors=False, *super_args, **super_kwargs)

Source from the content-addressed store, hash-verified

70 DTYPE_TO_ID = {dtype: id_ for id_, dtype in enumerate(ID_TO_DTYPE)}
71
72 def __init__(self, has_bool_tensors=False, *super_args, **super_kwargs):
73 super().__init__(*super_args, **super_kwargs)
74 assert isinstance(self.module, PipelineModule), "model must base PipelineModule"
75
76 assert self.zero_optimization_stage(
77 ) < ZeroStageEnum.gradients, "ZeRO-2 and ZeRO-3 are incompatible with pipeline parallelism"
78
79 # We schedule the all-reduces, so disable it in super().backward()
80 self.enable_backward_allreduce = False
81 self.has_bool_tensors = has_bool_tensors
82 self.eval_return_logits = False
83 self.outputs = None
84 # BF16 Optimizer is hardcoded for fp32 gradient accumulation
85 self.using_bf16_optimizer = type(self.optimizer) == BF16_Optimizer
86
87 self.pipeline_enable_backward_allreduce = True
88
89 # pipeline step for logging
90 self.log_batch_step_id = -1
91
92 self.micro_batch_size = self.train_micro_batch_size_per_gpu()
93 self.micro_batches = self.gradient_accumulation_steps()
94
95 # Set Grid and Communication Groups
96 self.grid = self.module._grid
97 if self.grid.get_global_rank() == 0:
98 logger.info(f'CONFIG: micro_batches={self.micro_batches} '
99 f'micro_batch_size={self.micro_batch_size}')
100
101 self.global_rank = self.grid.get_global_rank()
102
103 assert self.dp_world_size == self.grid.data_parallel_size
104 assert self.train_batch_size() == \
105 self.micro_batch_size * self.micro_batches * self.grid.data_parallel_size
106
107 # Set Stage Inf
108 self.num_stages = self.grid.pipe_parallel_size
109 self.stage_id = self.grid.get_stage_id()
110 self.prev_stage = self.stage_id - 1
111 self.next_stage = self.stage_id + 1
112
113 self.data_iterator = None
114 self.batch_fn = None
115
116 self._force_grad_boundary = False
117
118 self.batch_timer = ThroughputTimer(self._config.timers_config,
119 batch_size=self.train_batch_size(),
120 logging_fn=self.tput_log,
121 monitor_memory=False,
122 steps_per_output=self.steps_per_print())
123
124 # PipelineEngine needs to handle data loading specially due to only the first
125 # and last stages loading inputs/labels. We construct a sampler that uses
126 if self.training_data:
127 self._build_data_iter(self.training_data)
128
129 self.is_pipe_parallel = self.grid.pipe_parallel_size > 1

Callers

nothing calls this directly

Calls 15

_build_data_iterMethod · 0.95
is_last_stageMethod · 0.95
is_first_stageMethod · 0.95
ThroughputTimerClass · 0.90
is_evenFunction · 0.85
train_batch_sizeMethod · 0.80
get_stage_idMethod · 0.80
steps_per_printMethod · 0.80
wall_clock_breakdownMethod · 0.80

Tested by

no test coverage detected