I think the grad_loss might be the problematic Tensor as it is of size 1 and is modified inplace when you do +=.
Could you change that to be out of place with grad_loss = grad_loss + ... to see if it fixes the problem?