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

Method _create_cuda_graph

deepspeed/inference/engine.py:532–549  ·  view source on GitHub ↗
(self, *inputs, **kwargs)

Source from the content-addressed store, hash-verified

530 self.module.float()
531
532 def _create_cuda_graph(self, *inputs, **kwargs):
533 # warmup to create the workspace and cublas handle
534 cuda_stream = get_accelerator().Stream()
535 cuda_stream.wait_stream(get_accelerator().current_stream())
536 with get_accelerator().stream(cuda_stream):
537 for i in range(3):
538 ret = self.module(*inputs, **kwargs)
539 get_accelerator().current_stream().wait_stream(cuda_stream)
540
541 # create cuda_graph and assign static_inputs and static_outputs
542 self._cuda_graphs = torch.cuda.CUDAGraph()
543 self.static_inputs = inputs
544 self.static_kwargs = kwargs
545
546 with torch.cuda.graph(self._cuda_graphs):
547 self.static_output = self.module(*self.static_inputs, **self.static_kwargs)
548
549 self.cuda_graph_created = True
550
551 def _graph_replay(self, *inputs, **kwargs):
552 for i in range(len(inputs)):

Callers 1

forwardMethod · 0.95

Calls 4

get_acceleratorFunction · 0.90
StreamMethod · 0.45
current_streamMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected