This line of code:
p = p - self.alpha * (x_normal - x_tilde)

would create a non-leaf tensor, so that the following p.grad call would raise this warning.
Based on your code I think you should new a new variable name for this assignment and keep p pointing to the parameters in the optimizer.
Also, don’t use the .data attribute, as it might have unwanted side effects and wrap the code in a torch.no_grad() block, if necessary.