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

Function _hook

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

Source from the content-addressed store, hash-verified

504 monkeypatch.setattr(torch.autograd.graph, "_get_grad_fn_or_grad_acc", _require_grad_enabled)
505
506 def _hook(grad):
507 seen["count"] = ds_utils.count_used_parameters_in_backward([param])
508 return grad
509
510 param.register_hook(_hook)
511 loss = (param * 2.0).sum()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected