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

Method __init__

deepspeed/runtime/utils.py:1371–1385  ·  view source on GitHub ↗

Args: preprocess_once_fn: A callable that takes no arguments and performs one-time preprocessing before backward (e.g., start timers). Will only be called once per backward pass. preprocess_per_tensor_fn:

(self, preprocess_once_fn, preprocess_per_tensor_fn=None)

Source from the content-addressed store, hash-verified

1369 """
1370
1371 def __init__(self, preprocess_once_fn, preprocess_per_tensor_fn=None):
1372 """
1373 Args:
1374 preprocess_once_fn: A callable that takes no arguments and performs
1375 one-time preprocessing before backward (e.g., start timers).
1376 Will only be called once per backward pass.
1377 preprocess_per_tensor_fn: Optional callable that takes a tensor and returns
1378 a potentially modified tensor. Called for each output
1379 tensor during backward (e.g., gradient scaling).
1380 If None, no per-tensor processing is done.
1381 """
1382 self.preprocess_once_fn = preprocess_once_fn
1383 self.preprocess_per_tensor_fn = preprocess_per_tensor_fn
1384 self.preprocess_done = False
1385 self.hook_handles = []
1386
1387 def _make_backward_hook(self, tensor):
1388 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected