I’m unsure how these indices are created, but based on the previous stack trace it seems that your are trying to index some “neighboring samples”? In case you cannot isolate and fix the issue properly (by making sure that these invalid indices are not used or by increasing the size of the tensor, which should be indexed), you could torch.clamp the indices to a max. value of 2511.