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.

Fix

Daniel Han3b908c36e8cb
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 279064b5eb9..ff2c8726e41 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -799,9 +799,7 @@ def patch_linear_scaling(
f"from typing import Union, Optional, List, Any, Callable, Tuple\n"\
f"from {model_filepath} import logger, "\
f"{model_name.title()}Attention, {model_name.title()}Config"
-
- print(exec_code)
- print(inspect.getsource(attention_module.__init__))
+
try:
function = inspect.getsource(attention_module.__init__)
except:
@@ -845,12 +843,12 @@ def patch_linear_scaling(
"self.rotary_emb = .+?\)", function,
flags = re.DOTALL | re.MULTILINE,
)
- if len(rotary_emb) == 0: return None, function
+ if len(rotary_emb) == 0:
+ return None, exec_code + "\n\n" + function
+
rotary_emb = rotary_emb[0]
function = function.replace(rotary_emb, fix_rope_function, 1)
function = exec_code + "\n\n" + function
- print("###########")
- print(exec_code)
return init_name, function
pass
diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py
index 4edc3b7990b..9a97015f9b9 100644
--- a/unsloth/models/mistral.py
+++ b/unsloth/models/mistral.py
@@ -305,9 +305,7 @@ class FastMistralModel(FastLlamaModel):
)
# Just for Mistral Nemo models!
if function is not None:
- print(function)
function = patch_mistral_nemo_attention(function)
- print(function)
# if True:#init_name is not None:
exec(function, globals())
MistralAttention.__init__ = eval(init_name)