Hi,
Because you are not using any gradient value from any operation after you custom autograd function.



 kingstar101:

return target * 2.


If you check your backward method, you have a argument u which contains all grads from operations after Square. Because you are not using it, no matter what you do, it just breaks the all backwards edges right there.
What you are computing:

What you should compute:

So overally:
To fix this, just incorporate u into your computation of backward:
return u * (target * 2.)

Bests