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
hack for rotary
Daniel Hand587ce218da6
diff --git a/unsloth/models/gemma.py b/unsloth/models/gemma.pyindex ce89ad3be69..6c9a57abf71 100644--- a/unsloth/models/gemma.py+++ b/unsloth/models/gemma.py@@ -205,7 +205,9 @@ class GemmaFixedRotaryEmbedding(torch.nn.Module):# Fixes https://github.com/huggingface/transformers/pull/28837# https://github.com/microsoft/DeepSpeed/issues/4932# The precision of RoPE buffers is not correct, so we cast to int64.- def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None,+ config = None, # [TODO] Hack to pass in config - need to remove later+ ):super().__init__()self.dim = dimself.max_position_embeddings = max_position_embeddings@@ -264,7 +266,9 @@ class GemmaFixedLinearScalingRotaryEmbedding(GemmaFixedRotaryEmbedding):# Fixes https://github.com/huggingface/transformers/pull/28837# https://github.com/microsoft/DeepSpeed/issues/4932# The precision of RoPE buffers is not correct, so we cast to int64.- def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0,+ config = None, # [TODO] Hack to pass in config - need to remove later+ ):self.scaling_factor = scaling_factorsuper().__init__(dim, max_position_embeddings, base, device)passdiff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex 830b345d794..929c324966c 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -977,7 +977,9 @@ class LlamaRotaryEmbedding(torch.nn.Module):# Fixes https://github.com/huggingface/transformers/pull/28837# https://github.com/microsoft/DeepSpeed/issues/4932# The precision of RoPE buffers is not correct, so we cast to int64.- def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None,+ config = None, # [TODO] Hack to pass in config - need to remove later+ ):super().__init__()self.dim = dimself.max_position_embeddings = max_position_embeddings@@ -1030,7 +1032,9 @@ class LlamaLinearScalingRotaryEmbedding(LlamaRotaryEmbedding):# Fixes https://github.com/huggingface/transformers/pull/28837# https://github.com/microsoft/DeepSpeed/issues/4932# The precision of RoPE buffers is not correct, so we cast to int64.- def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0,+ config = None, # [TODO] Hack to pass in config - need to remove later+ ):self.scaling_factor = scaling_factorsuper().__init__(dim, max_position_embeddings, base, device)pass@@ -1055,7 +1059,9 @@ pass# See https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/rotary_embedding.py#L736# For Llama 3.1class LlamaExtendedRotaryEmbedding(torch.nn.Module):- def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None,+ config = None, # [TODO] Hack to pass in config - need to remove later+ ):super().__init__()self.dim = dimself.max_position_embeddings = max_position_embeddings