The reason is that I noticed that recomputing the loss is anyway faster than calling .item() on the loss. But actually you’re right. A cleaner version would replace the recomputation of the loss with simply .detach(), thanks.