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")