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

Method forward

deepspeed/inference/engine.py:592–618  ·  view source on GitHub ↗

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

590 return sub_module_cuda_graph
591
592 def forward(self, *inputs, **kwargs):
593 """Execute forward propagation
594
595 Arguments:
596 *inputs: Variable length input list
597 **kwargs: variable length keyword arguments
598 """
599 start = None
600 if self.model_profile_enabled and get_accelerator().device_name() == 'cuda' and self._config.enable_cuda_graph:
601 get_accelerator().synchronize()
602 start = time.time()
603
604 if get_accelerator().device_name() == 'cuda' and self._config.enable_cuda_graph and not self.local_cuda_graph:
605 if self.cuda_graph_created:
606 outputs = self._graph_replay(*inputs, **kwargs)
607 else:
608 self._create_cuda_graph(*inputs, **kwargs)
609 outputs = self._graph_replay(*inputs, **kwargs)
610 else:
611 outputs = self.module(*inputs, **kwargs)
612
613 if self.model_profile_enabled and self._config.enable_cuda_graph:
614 get_accelerator().synchronize()
615 duration = (time.time() - start) * 1e3 # convert seconds to ms
616 self._model_times.append(duration)
617
618 return outputs
619
620 def _generate(self, *inputs, **kwargs):
621 # Reset KV-cache at the beginning of generate

Callers

nothing calls this directly

Calls 6

_graph_replayMethod · 0.95
_create_cuda_graphMethod · 0.95
get_acceleratorFunction · 0.90
device_nameMethod · 0.45
synchronizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected