|
@@ -42,7 +42,7 @@ def load_model(model_name):
|
|
|
shared.is_RWKV = model_name.lower().startswith('rwkv-')
|
|
shared.is_RWKV = model_name.lower().startswith('rwkv-')
|
|
|
|
|
|
|
|
# Default settings
|
|
# Default settings
|
|
|
- if not (shared.args.cpu or shared.args.load_in_8bit or shared.args.load_in_4bit or shared.args.auto_devices or shared.args.disk or shared.args.gpu_memory is not None or shared.args.cpu_memory is not None or shared.args.deepspeed or shared.args.flexgen or shared.is_RWKV):
|
|
|
|
|
|
|
+ if not (shared.args.cpu or shared.args.load_in_8bit or shared.args.llama_bits>0 or shared.args.auto_devices or shared.args.disk or shared.args.gpu_memory is not None or shared.args.cpu_memory is not None or shared.args.deepspeed or shared.args.flexgen or shared.is_RWKV):
|
|
|
if any(size in shared.model_name.lower() for size in ('13b', '20b', '30b')):
|
|
if any(size in shared.model_name.lower() for size in ('13b', '20b', '30b')):
|
|
|
model = AutoModelForCausalLM.from_pretrained(Path(f"models/{shared.model_name}"), device_map='auto', load_in_8bit=True)
|
|
model = AutoModelForCausalLM.from_pretrained(Path(f"models/{shared.model_name}"), device_map='auto', load_in_8bit=True)
|
|
|
else:
|
|
else:
|
|
@@ -88,23 +88,24 @@ def load_model(model_name):
|
|
|
return model, tokenizer
|
|
return model, tokenizer
|
|
|
|
|
|
|
|
# 4-bit LLaMA
|
|
# 4-bit LLaMA
|
|
|
- elif shared.args.load_in_4bit:
|
|
|
|
|
|
|
+ elif shared.args.llama_bits>0:
|
|
|
sys.path.insert(0, os.path.abspath(Path("repositories/GPTQ-for-LLaMa")))
|
|
sys.path.insert(0, os.path.abspath(Path("repositories/GPTQ-for-LLaMa")))
|
|
|
|
|
+ bits = shared.args.llama_bits
|
|
|
|
|
|
|
|
from llama import load_quant
|
|
from llama import load_quant
|
|
|
|
|
|
|
|
path_to_model = Path(f'models/{model_name}')
|
|
path_to_model = Path(f'models/{model_name}')
|
|
|
pt_model = ''
|
|
pt_model = ''
|
|
|
if path_to_model.name.lower().startswith('llama-7b'):
|
|
if path_to_model.name.lower().startswith('llama-7b'):
|
|
|
- pt_model = 'llama-7b-4bit.pt'
|
|
|
|
|
|
|
+ pt_model = f'llama-7b-{bits}bit.pt'
|
|
|
elif path_to_model.name.lower().startswith('llama-13b'):
|
|
elif path_to_model.name.lower().startswith('llama-13b'):
|
|
|
- pt_model = 'llama-13b-4bit.pt'
|
|
|
|
|
|
|
+ pt_model = f'llama-13b-{bits}bit.pt'
|
|
|
elif path_to_model.name.lower().startswith('llama-30b'):
|
|
elif path_to_model.name.lower().startswith('llama-30b'):
|
|
|
- pt_model = 'llama-30b-4bit.pt'
|
|
|
|
|
|
|
+ pt_model = f'llama-30b-{bits}bit.pt'
|
|
|
elif path_to_model.name.lower().startswith('llama-65b'):
|
|
elif path_to_model.name.lower().startswith('llama-65b'):
|
|
|
- pt_model = 'llama-65b-4bit.pt'
|
|
|
|
|
|
|
+ pt_model = f'llama-65b-{bits}bit.pt'
|
|
|
else:
|
|
else:
|
|
|
- pt_model = f'{model_name}-4bit.pt'
|
|
|
|
|
|
|
+ pt_model = f'{model_name}-{bits}bit.pt'
|
|
|
|
|
|
|
|
# Try to find the .pt both in models/ and in the subfolder
|
|
# Try to find the .pt both in models/ and in the subfolder
|
|
|
pt_path = None
|
|
pt_path = None
|
|
@@ -116,7 +117,7 @@ def load_model(model_name):
|
|
|
print(f"Could not find {pt_model}, exiting...")
|
|
print(f"Could not find {pt_model}, exiting...")
|
|
|
exit()
|
|
exit()
|
|
|
|
|
|
|
|
- model = load_quant(path_to_model, Path(f"models/{pt_model}"), 4)
|
|
|
|
|
|
|
+ model = load_quant(path_to_model, Path(f"{pt_path}"), bits)
|
|
|
|
|
|
|
|
# Multi-GPU setup
|
|
# Multi-GPU setup
|
|
|
if shared.args.gpu_memory:
|
|
if shared.args.gpu_memory:
|