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.

Resize rope embeddings for long sequence training (#3586)

DoubleMathewccebde2cb374
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 3af9cba6695..306f95b41b9 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -1051,6 +1051,10 @@ def LlamaModel_fast_forward(
# Also, transformers 4.45.0 supports granite but with the attention refactor (it always had the refactor)
# unsloth's check for granite too has "version >= 4.45.0 (rightly so)".
# so let granite always use the attention refactor implementation.
+
+ self.rotary_emb.extend_rope_embedding(
+ hidden_states, self.config.max_position_embeddings
+ )
position_embeddings = self.rotary_emb.get_cached(
self.config.max_position_embeddings, hidden_states.device.index
)