Hi,
Does diff contain some pathological values?
Does the gradient flowing back does? You can print it by doing:
y_2 = torch.pow(diff, 2) 
y_2.register_hook(print)  # This will print the gradient when it's computed.