From 4d508cbe586823d360e2bcaec4cde16f134331e1 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:44:43 -0300 Subject: [PATCH] Add some checks to AutoGPTQ loader --- modules/AutoGPTQ_loader.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/AutoGPTQ_loader.py b/modules/AutoGPTQ_loader.py index 5f2fd71b..8cb078af 100644 --- a/modules/AutoGPTQ_loader.py +++ b/modules/AutoGPTQ_loader.py @@ -53,13 +53,16 @@ def load_quantized(model_name): model = AutoGPTQForCausalLM.from_quantized(path_to_model, **params) # These lines fix the multimodal extension when used with AutoGPTQ - if not hasattr(model, 'dtype'): - model.dtype = model.model.dtype + if hasattr(model, 'model'): + if not hasattr(model, 'dtype'): + if hasattr(model.model, 'dtype'): + model.dtype = model.model.dtype - if not hasattr(model, 'embed_tokens'): - model.embed_tokens = model.model.model.embed_tokens + if hasattr(model.model, 'model') and hasattr(model.model.model, 'embed_tokens'): + if not hasattr(model, 'embed_tokens'): + model.embed_tokens = model.model.model.embed_tokens - if not hasattr(model.model, 'embed_tokens'): - model.model.embed_tokens = model.model.model.embed_tokens + if not hasattr(model.model, 'embed_tokens'): + model.model.embed_tokens = model.model.model.embed_tokens return model