MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / backward

Method backward

SwissArmyTransformer/sat/quantization/kernels.py:61–67  ·  view source on GitHub ↗
(ctx, grad_output: torch.Tensor)

Source from the content-addressed store, hash-verified

59
60 @staticmethod
61 def backward(ctx, grad_output: torch.Tensor):
62 inp, quant_w, scale_w = ctx.saved_tensors
63 weight = extract_weight_to_half(quant_w, scale_w, ctx.weight_bit_width)
64 grad_output = grad_output.contiguous().view(-1, weight.size(0))
65 grad_input = grad_output.mm(weight)
66 grad_weight = grad_output.t().mm(inp)
67 return grad_input.view(ctx.inp_shape), grad_weight.view(ctx.weight_shape), None, None
68
69
70def compress_int4_weight(weight: torch.Tensor): # (n, m)

Callers 6

test_meaFunction · 0.45
test_standard_attentionFunction · 0.45
__call__Method · 0.45
test_t5.pyFile · 0.45
backward_stepFunction · 0.45

Calls 1

extract_weight_to_halfFunction · 0.85

Tested by 2

test_meaFunction · 0.36
test_standard_attentionFunction · 0.36