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

Method backward

deepspeed/module_inject/layers.py:278–286  ·  view source on GitHub ↗
(ctx: Any, grad_output: torch.Tensor)

Source from the content-addressed store, hash-verified

276
277 @staticmethod
278 def backward(ctx: Any, grad_output: torch.Tensor) -> Tuple[None, torch.Tensor]:
279
280 input, weight = ctx.saved_tensors
281 grad_input = grad_output.matmul(weight)
282 handle = dist.all_reduce(grad_input.contiguous(), group=ctx.group, async_op=True)
283 grad_weight = grad_output.view(-1, grad_output.shape[-1]).t().matmul(input.view(-1, input.shape[-1]))
284 grad_bias = grad_output.sum(0) if ctx.use_bias else None
285 handle.wait()
286 return None, grad_input, grad_weight, grad_bias, None
287
288
289class ColumnParallel(torch.autograd.Function):

Callers

nothing calls this directly

Calls 4

contiguousMethod · 0.80
sumMethod · 0.80
all_reduceMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected