The loss tensor seems to be detached from the model (or rather the output) and you can verify it by checking its .grad_fn which should yield None.
To fix this, check the intermediate tensors in the forward pass (starting with the output) and try to isolate where the graph is detached.
Also, make sure you didn’t globally disable the gradient calculation.