From 18900721c2a3ac7f95d228d8fb41b2c3bfb6f869 Mon Sep 17 00:00:00 2001 From: XiaoYang Date: Wed, 31 Jul 2024 01:15:09 +0800 Subject: [PATCH] fix UnboundLocalError (#834) * When an exception has been assigned using as target, it is cleared at the end of the except clause.(https://docs.python.org/3/reference/compound_stmts.html#the-try-statement) * Update loader.py --------- Co-authored-by: xiaoyang Co-authored-by: Daniel Han --- unsloth/models/loader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index e2bfe1d639..34deb8f9bd 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -155,14 +155,14 @@ class FastLanguageModel(FastLlamaModel): try: model_config = AutoConfig.from_pretrained(model_name, token = token, revision = revision) is_model = True - except Exception as autoconfig_error: - autoconfig_error = str(autoconfig_error) + except Exception as error: + autoconfig_error = str(error) is_model = False try: peft_config = PeftConfig .from_pretrained(model_name, token = token, revision = revision) is_peft = True - except Exception as peft_error: - peft_error = str(peft_error) + except Exception as error: + peft_error = str(error) is_peft = False pass