In that case, this is because your model is linear. And so it’s gradient is independant of it’s weights and so the gradients don’t require gradients because they never involved anything that requires gradients.
If your function is not linear like: L = linear(x).sum()**2 then it works as expected.