That’s a bit strange indeed!
Could you load all your target values and check for the value range?
torch.unique might be helpful or just a comparison.
If you don’t find any out of bounds values, would it be possible to provide the target tensor, i.e. upload it somewhere? I would like to have a look at it, as I would like to exclude a possible silent bug on the CPU side.