(self, global_step=False, report_speed=True)
| 268 | return self.global_step_count % self.steps_per_output == 0 |
| 269 | |
| 270 | def stop(self, global_step=False, report_speed=True): |
| 271 | if not self.config.enabled or not self.started: |
| 272 | return |
| 273 | self.started = False |
| 274 | self.micro_step_count += 1 |
| 275 | if global_step: |
| 276 | self.global_step_count += 1 |
| 277 | |
| 278 | if self.start_time > 0: |
| 279 | if self.config.synchronized: |
| 280 | self._synchronize() |
| 281 | self.end_time = time.time() |
| 282 | duration = self.end_time - self.start_time |
| 283 | self.total_elapsed_time += duration |
| 284 | self.step_elapsed_time += duration |
| 285 | |
| 286 | if global_step: |
| 287 | if report_speed and self._is_report_boundary(): |
| 288 | self.logging( |
| 289 | "epoch={}/micro_step={}/global_step={}, RunningAvgSamplesPerSec={}, CurrSamplesPerSec={}, " |
| 290 | "MemAllocated={}GB, MaxMemAllocated={}GB".format( |
| 291 | self.epoch_count, |
| 292 | self.micro_step_count, |
| 293 | self.global_step_count, |
| 294 | self.avg_samples_per_sec(), |
| 295 | self.batch_size / (self.step_elapsed_time + TIME_EPSILON), |
| 296 | round(get_accelerator().memory_allocated() / 1024**3, 2), |
| 297 | round(get_accelerator().max_memory_allocated() / 1024**3, 2), |
| 298 | )) |
| 299 | if self.monitor_memory: |
| 300 | import psutil |
| 301 | virt_mem = psutil.virtual_memory() |
| 302 | swap = psutil.swap_memory() |
| 303 | self.logging("epoch={}/micro_step={}/global_step={}, vm %: {}, swap %: {}".format( |
| 304 | self.epoch_count, |
| 305 | self.micro_step_count, |
| 306 | self.global_step_count, |
| 307 | virt_mem.percent, |
| 308 | swap.percent, |
| 309 | )) |
| 310 | self.step_elapsed_time = 0 |
| 311 | |
| 312 | def avg_samples_per_sec(self): |
| 313 | if self.global_step_count > 0: |
nothing calls this directly
no test coverage detected