diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index bfa94d86d7..6148b1783e 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -289,6 +289,8 @@ class FastLanguageModel(FastLlamaModel): trust_remote_code = trust_remote_code, ) is_model = True + except ImportError: + raise except Exception as error: autoconfig_error = str(error) if "architecture" in autoconfig_error: @@ -305,6 +307,8 @@ class FastLanguageModel(FastLlamaModel): trust_remote_code = trust_remote_code, ) is_peft = True + except ImportError: + raise except Exception as error: peft_error = str(error) if "architecture" in peft_error: @@ -326,7 +330,8 @@ class FastLanguageModel(FastLlamaModel): "Please separate the LoRA and base models to 2 repos." ) model_types = get_transformers_model_type( - peft_config if peft_config is not None else model_config + peft_config if peft_config is not None else model_config, + trust_remote_code = trust_remote_code, ) if len(model_types) == 1: model_type = model_types[0] @@ -826,6 +831,8 @@ class FastModel(FastBaseModel): trust_remote_code = trust_remote_code, ) is_model = True + except ImportError: + raise except Exception as error: autoconfig_error = str(error) if "architecture" in autoconfig_error: @@ -842,6 +849,8 @@ class FastModel(FastBaseModel): trust_remote_code = trust_remote_code, ) is_peft = True + except ImportError: + raise except Exception as error: peft_error = str(error) if "architecture" in peft_error: @@ -861,7 +870,8 @@ class FastModel(FastBaseModel): "Please separate the LoRA and base models to 2 repos." ) model_types = get_transformers_model_type( - peft_config if peft_config is not None else model_config + peft_config if peft_config is not None else model_config, + trust_remote_code = trust_remote_code, ) model_types_all = ",".join(model_types) + ","