Nikronic:

torch.autograd.grad(y, [x], grad_outputs=grad_outputs, create_graph=True)[0]


Thanks! I updated my code accordingly.
Unfortunately results stay the same.
I get better results with numerical gradients (f’(x) = f(x + d) - f(x - d) / 2d)), but still want to use the analytical if possible, so I’ll keep investigating it.
BTW: ω=1 in my code.