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

Method _create_cuda_graph

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

Source from the content-addressed store, hash-verified

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

Callers 1

forwardMethod · 0.95

Calls 7

get_acceleratorFunction · 0.90
StreamMethod · 0.45
wait_streamMethod · 0.45
current_streamMethod · 0.45
streamMethod · 0.45
create_graphMethod · 0.45
capture_to_graphMethod · 0.45

Tested by

no test coverage detected