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

Method _exec_optimizer_step

deepspeed/runtime/pipe/engine.py:1212–1247  ·  view source on GitHub ↗
(self, lr_kwargs=None)

Source from the content-addressed store, hash-verified

1210 self.timers(PIPE_RECV_GRAD_TIMER).stop()
1211
1212 def _exec_optimizer_step(self, lr_kwargs=None):
1213 if self.wall_clock_breakdown():
1214 self.timers(STEP_MICRO_TIMER).start()
1215 self.timers(STEP_GLOBAL_TIMER).start()
1216
1217 self._force_grad_boundary = True
1218 self._take_model_step(lr_kwargs)
1219 self._force_grad_boundary = False
1220
1221 if self.global_rank == 0 and self.monitor.enabled:
1222 self.summary_events = [('Train/Samples/lr', self.get_lr()[0], self.global_samples)]
1223 loss_scale = self._get_optimizer_loss_scale() if self.fp16_enabled() else None
1224 if loss_scale is not None:
1225 self.summary_events.append(('Train/Samples/loss_scale', loss_scale, self.global_samples))
1226 self.monitor.write_events(self.summary_events)
1227
1228 if self.wall_clock_breakdown():
1229 self.timers(STEP_MICRO_TIMER).stop()
1230 self.timers(STEP_GLOBAL_TIMER).stop()
1231 if self.global_steps % self.steps_per_print() == 0:
1232 self.timers.log([
1233 BATCH_INPUT_TIMER,
1234 FORWARD_MICRO_TIMER,
1235 BACKWARD_MICRO_TIMER,
1236 BACKWARD_INNER_MICRO_TIMER,
1237 BACKWARD_REDUCE_MICRO_TIMER,
1238 STEP_MICRO_TIMER,
1239 ])
1240 if self.global_steps % self.steps_per_print() == 0:
1241 self.timers.log([
1242 FORWARD_GLOBAL_TIMER,
1243 BACKWARD_GLOBAL_TIMER,
1244 BACKWARD_INNER_GLOBAL_TIMER,
1245 BACKWARD_REDUCE_GLOBAL_TIMER,
1246 STEP_GLOBAL_TIMER,
1247 ])
1248
1249 def _allocate_zeros(self, shape, **kwargs):
1250 """ Allocate a tensor of zeros on the engine's device.

Callers

nothing calls this directly

Calls 11

wall_clock_breakdownMethod · 0.80
_take_model_stepMethod · 0.80
appendMethod · 0.80
steps_per_printMethod · 0.80
startMethod · 0.45
get_lrMethod · 0.45
fp16_enabledMethod · 0.45
write_eventsMethod · 0.45
stopMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected