Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Update cross_entropy_loss.py

Daniel Han7fa3179e882d
diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py
index 35df2573294..4895d273103 100644
--- a/unsloth/kernels/cross_entropy_loss.py
+++ b/unsloth/kernels/cross_entropy_loss.py
@@ -373,9 +373,9 @@ def fast_cross_entropy_loss(
logit_softcapping,
logit_scaling,
)
- print(n_items)
if n_items is None:
n_items = torch.count_nonzero(labels != -100)
+ print(n_items)
return loss.sum() / n_items
pass