Skip to content

Commit

Permalink
fif gptq install
Browse files Browse the repository at this point in the history
  • Loading branch information
winglian committed Apr 17, 2023
1 parent d553bf3 commit d5cf34a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 527 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ einops
colorama
peft @ git+https://github.com/huggingface/peft.git@70af02a2bca5a63921790036b2c9430edf4037e2
transformers @ git+https://github.com/huggingface/transformers.git
gptq_llama @ git+https://github.com/sterlind/GPTQ-for-LLaMa.git@lora_4bit
19 changes: 4 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

install_requires = []
with open("./requirements.txt", "r") as requirements_file:
# don't include gptq_llama by default
reqs = [r.strip() for r in requirements_file.readlines() if "gptq_llama" not in r]
reqs = [r.strip() for r in requirements_file.readlines()]
for r in reqs:
install_requires.append(r)

Expand All @@ -16,26 +15,16 @@
'src/alpaca_lora_4bit/quant_cuda/quant_cuda_kernel.cu'
])

# conditionally only install the cuda extension explicitly
ext_modules = []
cmdclass = {}
if '--cuda' in sys.argv or any(["cuda" in arg for arg in sys.argv]):
ext_modules.append(quant_cuda_module)
cmdclass = {'build_ext': BuildExtension}
sys.argv.remove('--cuda')


setup(
name='alpaca_lora_4bit',
version='0.1',
description='Alpaca LoRA 4-bit',
package_dir={'alpaca_lora_4bit': 'src/alpaca_lora_4bit'},
packages=['alpaca_lora_4bit', 'alpaca_lora_4bit.monkeypatch'],
packages=['alpaca_lora_4bit', 'alpaca_lora_4bit.monkeypatch', 'alpaca_lora_4bit.quant_cuda'],
install_requires=install_requires,
extras_require={
'cuda': 'gptq_llama @ git+https://github.com/sterlind/GPTQ-for-LLaMa.git@lora_4bit',
'triton': 'triton',
},
ext_modules=ext_modules,
cmdclass=cmdclass,
ext_modules=[quant_cuda_module],
cmdclass={'build_ext': BuildExtension},
)
2 changes: 1 addition & 1 deletion src/alpaca_lora_4bit/autograd_4bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def switch_backend_to(to_backend):
global backend
if to_backend == 'cuda':
if not is_gptq_backend_available():
raise ValueError('gptq_llama not found. Please install gptq_llama')
raise ValueError('quant_cuda not found. Please reinstall with pip install .')
AutogradMatmul4bit = AutogradMatmul4bitCuda
backend = 'cuda'
print(Style.BRIGHT + Fore.GREEN + 'Using CUDA implementation.')
Expand Down
2 changes: 1 addition & 1 deletion src/alpaca_lora_4bit/matmul_utils_4bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch
import numpy as np
try:
from gptq_llama import quant_cuda
from alpaca_lora_4bit import quant_cuda
except (ImportError, ModuleNotFoundError) as e:
logging.exception("Please run: `pip install alpaca_lora_4bit[cuda]`")
raise e
Expand Down
Loading

0 comments on commit d5cf34a

Please sign in to comment.