diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py index fbb14013ff..cdd5b1cf12 100644 --- a/unsloth/kernels/cross_entropy_loss.py +++ b/unsloth/kernels/cross_entropy_loss.py @@ -301,6 +301,7 @@ class Fast_CrossEntropyLoss(torch.autograd.Function): vocab_size: int n_rows, vocab_size = logits.shape device = logits.device + labels = labels.to(device) div, mod = divmod(vocab_size, MAX_FUSED_SIZE) n_chunks: int = div + (mod != 0)