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 bugs (#1706)
Daniel Han3136fd961188
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex f5d00eab222..8d0eadb968f 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -12,7 +12,7 @@# See the License for the specific language governing permissions and# limitations under the License.-__version__ = "2025.2.8"+__version__ = "2025.2.9"__all__ = ["SUPPORTS_BFLOAT16",diff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex ec6706e5157..1eae97ff1cd 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -708,7 +708,7 @@ def LlamaModel_fast_forward(if attention_mask is None:padding_mask = Noneelif self.training:- # elif attention_mask is not None and self.training:+ # elif attention_mask is None:attention_mask = Nonepadding_mask = Noneelse:@@ -724,7 +724,8 @@ def LlamaModel_fast_forward(past_key_values_length,sliding_window = getattr(self.config, "sliding_window", None),)- attention_mask = attention_mask.to(torch.bool)+ if attention_mask is not None:+ attention_mask = attention_mask.to(torch.bool)passhidden_states = inputs_embedsdiff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex fc094b08391..3d601b0af11 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -565,8 +565,8 @@ passdef PatchFastRL(algorithm = None, FastLanguageModel = None):- return- # if FastLanguageModel is not None: PatchRL(FastLanguageModel)- # patch_trl_rl_trainers()- # if algorithm is not None: PatchRLStatistics(algorithm)+ if FastLanguageModel is not None: PatchRL(FastLanguageModel)+ patch_trl_rl_trainers()+ if type(algorithm) is str and algorithm.islower():+ PatchRLStatistics(algorithm)passdiff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.pyindex 4d7a4dbe09a..82fd3f8d3cc 100644--- a/unsloth/models/rl_replacements.py+++ b/unsloth/models/rl_replacements.py@@ -101,23 +101,20 @@ RL_FUNCTIONS["sft_trainer"].append(sft_trainer_prepare_dataset)# Ignore mean_token_accuracy since it needs logits# We override it directly with our version-def _sft_trainer_compute_loss(self, model, inputs, return_outputs = False, num_items_in_batch = None):- (loss, outputs) = super().compute_loss(- model,- inputs,- return_outputs = return_outputs,- num_items_in_batch = num_items_in_batch,- )- return (loss, outputs) if return_outputs else loss-pass-def sft_trainer_compute_loss(function_name, function):if function_name != "compute_loss": return function- function = inspect.getsource(_sft_trainer_compute_loss)- function = function.replace("def _sft_trainer_compute_loss", "def compute_loss")- function = function.split("\n")- function = "\n".join(" "*4+x for x in function)+ def compute_loss(self, model, inputs, return_outputs = False, num_items_in_batch = None):+ outputs = super().compute_loss(+ model,+ inputs,+ return_outputs = return_outputs,+ num_items_in_batch = num_items_in_batch,+ )+ return outputs+ pass++ function = inspect.getsource(compute_loss)return functionpassRL_FUNCTIONS["sft_trainer"].append(sft_trainer_compute_loss)