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

Function _hook

tests/unit/runtime/test_runtime_utils.py:379–381  ·  view source on GitHub ↗
(grad)

Source from the content-addressed store, hash-verified

377 monkeypatch.setattr(torch.autograd.graph, "_get_grad_fn_or_grad_acc", _require_grad_enabled)
378
379 def _hook(grad):
380 seen["count"] = ds_utils.count_used_parameters_in_backward([param])
381 return grad
382
383 param.register_hook(_hook)
384 loss = (param * 2.0).sum()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected