Try to overfit a small dataset (e.g. just 10 samples) by playing around with some hyperparameters and make sure the model is able to do so. Once this is done you could try to scale up the use case again.
Also, remove:
y_pred.require_grad=True

since y_pred should already require gradients (unless it’s detached) and also .require_grad is a new attribute as you might have wanted to manipulate the .requires_grad attribute.