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

Method stop

deepspeed/utils/timer.py:253–293  ·  view source on GitHub ↗
(self, global_step=False, report_speed=True)

Source from the content-addressed store, hash-verified

251 return self.global_step_count % self.steps_per_output == 0
252
253 def stop(self, global_step=False, report_speed=True):
254 if not self.config.enabled or not self.started:
255 return
256 self.started = False
257 self.micro_step_count += 1
258 if global_step:
259 self.global_step_count += 1
260
261 if self.start_time > 0:
262 if self.config.synchronized:
263 get_accelerator().synchronize()
264 self.end_time = time.time()
265 duration = self.end_time - self.start_time
266 self.total_elapsed_time += duration
267 self.step_elapsed_time += duration
268
269 if global_step:
270 if report_speed and self._is_report_boundary():
271 self.logging(
272 "epoch={}/micro_step={}/global_step={}, RunningAvgSamplesPerSec={}, CurrSamplesPerSec={}, "
273 "MemAllocated={}GB, MaxMemAllocated={}GB".format(
274 self.epoch_count,
275 self.micro_step_count,
276 self.global_step_count,
277 self.avg_samples_per_sec(),
278 self.batch_size / (self.step_elapsed_time + TIME_EPSILON),
279 round(get_accelerator().memory_allocated() / 1024**3, 2),
280 round(get_accelerator().max_memory_allocated() / 1024**3, 2),
281 ))
282 if self.monitor_memory:
283 import psutil
284 virt_mem = psutil.virtual_memory()
285 swap = psutil.swap_memory()
286 self.logging("epoch={}/micro_step={}/global_step={}, vm %: {}, swap %: {}".format(
287 self.epoch_count,
288 self.micro_step_count,
289 self.global_step_count,
290 virt_mem.percent,
291 swap.percent,
292 ))
293 self.step_elapsed_time = 0
294
295 def avg_samples_per_sec(self):
296 if self.global_step_count > 0:

Callers

nothing calls this directly

Calls 6

_is_report_boundaryMethod · 0.95
avg_samples_per_secMethod · 0.95
get_acceleratorFunction · 0.90
synchronizeMethod · 0.45
memory_allocatedMethod · 0.45
max_memory_allocatedMethod · 0.45

Tested by

no test coverage detected