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

Daniel Handaa4d1356405
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index c7c779a2315..27eb226f279 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -826,13 +826,19 @@ def patch_llama_rope_scaling(
)
fix_rope_function = """
if getattr(self.config, "rope_scaling", None) is None:
- # Hack
- if self.config.max_position_embeddings == 131072
- self.rotary_emb = {rope_function}(
- self.head_dim,
- max_position_embeddings=self.max_position_embeddings,
- base=self.rope_theta,
- )
+ # Hack to check for Llama-3.1
+ if 'llama-3.1' in str(self.config.config._name_or_path).lower():
+ self.rotary_emb = {extended_rope_function}(
+ self.head_dim,
+ max_position_embeddings=self.max_position_embeddings,
+ base=self.rope_theta,
+ )
+ else:
+ self.rotary_emb = {rope_function}(
+ self.head_dim,
+ max_position_embeddings=self.max_position_embeddings,
+ base=self.rope_theta,
+ )
else:
scaling_type = self.config.rope_scaling["type"]
scaling_factor = self.config.rope_scaling.get("factor")