MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / forward

Method forward

deepspeed/runtime/engine.py:1681–1761  ·  view source on GitHub ↗

r"""Execute forward propagation Arguments: *inputs: Variable length input list **kwargs: variable length keyword arguments

(self, *inputs, **kwargs)

Source from the content-addressed store, hash-verified

1679
1680 @instrument_w_nvtx
1681 def forward(self, *inputs, **kwargs):
1682 r"""Execute forward propagation
1683 Arguments:
1684 *inputs: Variable length input list
1685 **kwargs: variable length keyword arguments
1686 """
1687
1688 if self.autotuning_profile_model_info():
1689 ma = get_ma_status()
1690 else:
1691 see_memory_usage("Engine before forward", force=self.memory_breakdown())
1692
1693 flops_profiler_active = (self.flops_profiler_enabled()
1694 and self.global_steps == self.flops_profiler_profile_step() and self.global_rank == 0)
1695
1696 # used to check quantization happens at step 0!
1697 if self.global_steps == 0 and hasattr(self, "compression_scheduler"):
1698 self.compression_scheduler.step(step_zero_check=True)
1699 if self.quantizer:
1700 tensor_to_quantize = self.optimizer.bit16_groups if self.zero_optimization_stage(
1701 ) == 2 else self.optimizer.fp16_groups
1702 if self.compression_scheduler.weight_quantization_enabled:
1703 self.quantizer.quantize(
1704 tensor_to_quantize,
1705 (self.optimizer.overflow if self.fp16_enabled() else False),
1706 self.eigenvalue_enabled(),
1707 None,
1708 )
1709
1710 if flops_profiler_active:
1711 self.flops_profiler.start_profile(ignore_list=None)
1712
1713 if self.module.training:
1714 if self.progressive_layer_drop:
1715 kwargs.update(self.progressive_layer_drop.get_state())
1716
1717 if self.__class__.__name__ != "PipelineEngine":
1718 # TODO: The above if condition is a HACK since for PipelineEngine
1719 # it's difficult to inject argument in forward pass.
1720 if self.module.training and self.curriculum_enabled_legacy():
1721 self.curriculum_scheduler_legacy.update_difficulty(self.global_steps + 1)
1722 if self.curriculum_params_legacy()["curriculum_type"] == "seqlen":
1723 kwargs.update({"curriculum_seqlen": self.curriculum_scheduler_legacy.get_current_difficulty()})
1724
1725 if self.module.training and self.random_ltd_enabled():
1726 self.random_ltd_scheduler.update_seq(self.global_steps)
1727
1728 if self.zero_optimization_partition_weights():
1729 # Enable automated discovery of external parameters by indicating that
1730 # we are in a forward pass.
1731 for module in self.module.modules():
1732 module._parameters._in_forward = True
1733
1734 self._start_timers(self.engine_timers.forward_timers)
1735
1736 if self.training_dataloader is None:
1737 self.tput_timer.start()
1738

Callers

nothing calls this directly

Calls 15

memory_breakdownMethod · 0.95
fp16_enabledMethod · 0.95
eigenvalue_enabledMethod · 0.95
random_ltd_enabledMethod · 0.95
_start_timersMethod · 0.95

Tested by

no test coverage detected