From 8953a06764a00d47a2cabe3c0d90191db091d6fa Mon Sep 17 00:00:00 2001 From: DoubleMathew Date: Sat, 29 Nov 2025 08:44:26 -0600 Subject: [PATCH] fix rope_theta -> rope_parameters['rope_theta'] (#3651) --- unsloth/models/_utils.py | 6 ++++++ unsloth/models/llama.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 6ca128bd83..cd4eeefb69 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -562,6 +562,12 @@ for model_name in model_architectures: config = inspect.getsource(eval(config_filename)) except: continue + if "RopeParameters" in config: + try: + exec(f"from {config_filepath} import RopeParameters", globals()) + except: + continue + if "rope_scaling" in config: continue config = re.sub( diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index b1b8a8fb78..f6a0fff117 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1551,7 +1551,11 @@ class LlamaRotaryEmbedding(torch.nn.Module): super().__init__() if config is not None: # [TODO] Hack to pass in config - need to remove later - base = config.rope_theta + try: + base = config.rope_theta + except: + base = getattr(config, "rope_parameters", {}) + base = base["rope_theta"] partial_rotary_factor = ( config.partial_rotary_factor if hasattr(config, "partial_rotary_factor")