If you want to use the max error to stop your training, you could use
loss = orig_loss.max().detach().numpy()

Currently orig_loss is not a scalar, as you use reduce=False in your loss function.
Therefore float cannot cast it to a scalar float.