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

Method _capture

deepspeed/runtime/hybrid_engine_graph.py:107–124  ·  view source on GitHub ↗

Record a graph for ``position`` and keep its static input buffers.

(self, position, args, kwargs)

Source from the content-addressed store, hash-verified

105 self._use_graphs = True
106
107 def _capture(self, position, args, kwargs):
108 """Record a graph for ``position`` and keep its static input buffers."""
109 static = {name: kwargs[name].clone() for name in _tensor_kwargs(kwargs)}
110 capture_kwargs = dict(kwargs)
111 capture_kwargs.update(static)
112
113 graph = get_accelerator().create_graph()
114 if self._pool is None:
115 with get_accelerator().capture_to_graph(graph):
116 output = self._forward(*args, **capture_kwargs)
117 self._pool = graph.pool()
118 else:
119 with get_accelerator().capture_to_graph(graph, pool=self._pool):
120 output = self._forward(*args, **capture_kwargs)
121
122 self._graphs[position] = graph
123 self._static_kwargs[position] = static
124 self._static_outputs[position] = output
125
126 def _replay(self, position, kwargs):
127 for name, buffer in self._static_kwargs[position].items():

Callers 1

__call__Method · 0.95

Calls 6

get_acceleratorFunction · 0.90
_tensor_kwargsFunction · 0.85
updateMethod · 0.45
create_graphMethod · 0.45
capture_to_graphMethod · 0.45
_forwardMethod · 0.45

Tested by

no test coverage detected