y.grad is the gradient of a non-leaf variable. To access it’s gradient, you have to use a backward hook: