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

Method backward

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

Source from the content-addressed store, hash-verified

280
281 @staticmethod
282 def backward(ctx: Any, grad_output: torch.Tensor) -> Tuple[None, torch.Tensor]:
283
284 input, weight = ctx.saved_tensors
285 grad_input = grad_output.matmul(weight)
286 handle = dist.all_reduce(grad_input.contiguous(), group=ctx.group, async_op=True)
287 grad_weight = grad_output.view(-1, grad_output.shape[-1]).t().matmul(input.view(-1, input.shape[-1]))
288 grad_bias = grad_output.sum(0) if ctx.use_bias else None
289 handle.wait()
290 return None, grad_input, grad_weight, grad_bias, None
291
292
293class 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