Solved by richard in post #2 
              
              
                Did you mean you were expecting the result to be tensor([ 8., 16., 24.])? 
The gradient of alpha is going to be the same size as alpha. alpha was expanded to tensor([4., 4., 4.]) for the computation, and so the values of 8, 16, 24 were summed to get the complete gradient. 
To get what you expected, …