I don’t think the backpropagation is wrong, but your loss is just extremely high, which would also create large gradients and could thus break the training.
If you use a mean() as the error, you’ll see that (some) training is happening:
tensor(5.0114, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(4.5654, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(4.2215, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.9387, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.7002, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.4965, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.3204, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.1662, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(3.0293, device='cuda:0', grad_fn=<MeanBackward0>)
tensor(2.9056, device='cuda:0', grad_fn=<MeanBackward0>)