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 mistral.py

Daniel Han0b20946bcf55
diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py
index 15e9efc4268..00dcc5cd1d5 100644
--- a/unsloth/models/mistral.py
+++ b/unsloth/models/mistral.py
@@ -254,8 +254,9 @@ def MistralForCausalLM_fast_forward(
shift_labels = torch.hstack((labels[..., 1:], self.extra_ignored_labels[:labels.shape[0]]))
loss = fast_cross_entropy_loss(
- logits = shift_logits,
- labels = shift_labels,
+ logits = shift_logits,
+ labels = shift_labels,
+ n_items = kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None),
)
pass