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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix Boolean value of Tensor ambiguity error in mistral.py (#3790)
ゆり5f1361aea38b
diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.pyindex 0eed45c5cd7..5e893d2b6fc 100644--- a/unsloth/models/mistral.py+++ b/unsloth/models/mistral.py@@ -307,9 +307,9 @@ def MistralForCausalLM_fast_forward(RETURN_LOGITS = Falseif not RETURN_LOGITS and labels is not None:- n_items = kwargs.get("num_items_in_batch", None) or kwargs.get(- "n_items", None- )+ n_items = kwargs.get("num_items_in_batch", None)+ if n_items is None:+ n_items = kwargs.get("n_items", None)logit_softcapping = getattr(self.config, "final_logit_softcapping", 0)# loss = fused_linear_cross_entropy(@@ -363,11 +363,13 @@ def MistralForCausalLM_fast_forward(shift_labels,kwargs.get("packed_seq_lengths"),)+ n_items = kwargs.get("num_items_in_batch", None)+ if n_items is None:+ n_items = kwargs.get("n_items", None)loss = fast_cross_entropy_loss(logits = shift_logits,labels = shift_labels,- n_items = kwargs.get("num_items_in_batch", None)- or kwargs.get("n_items", None),+ n_items = n_items,)if not return_dict:diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex 003a0e7f1b6..03f2c447014 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -22,7 +22,6 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Unionimport inspectimport osimport re-import torchfrom unsloth_zoo.compiler import create_new_functionfrom unsloth_zoo.log import loggerfrom unsloth_zoo.logging_utils import PatchRLStatisticsdiff --git a/unsloth/models/vision.py b/unsloth/models/vision.pyindex e1cf8f6f82d..36cfbf0b17d 100644--- a/unsloth/models/vision.py+++ b/unsloth/models/vision.py@@ -68,11 +68,9 @@ import functoolsimport osimport gcimport math-import functoolsfrom typing import Optional, Tuple, List, Unionimport re, inspect, sysimport contextlib-import typestry:from huggingface_hub.utils import get_token