-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathinstall_quantization_libs.py
More file actions
94 lines (73 loc) · 3.13 KB
/
install_quantization_libs.py
File metadata and controls
94 lines (73 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import argparse
import os
import subprocess
import sys
EXTERNAL_REPOS_DIR = "external_repos"
def clone_or_pull_repo(repo_url, repo_location_path):
"""Clone the repo if it doesn't exist; otherwise, pull the latest changes."""
if os.path.exists(repo_location_path):
print(f"Directory {repo_location_path} already exists. Pulling the latest changes.")
subprocess.run(f"cd {repo_location_path} && git pull", shell=True, check=True)
else:
repo_name = repo_location_path.split("/")[-1]
print(f"Cloning {repo_name} into {repo_location_path}")
subprocess.run(f"git clone {repo_url} {repo_location_path}", shell=True, check=True)
def install_autoawq_from_source():
"""Install the AutoAWQ and AutoAWQ_kernels packages from GitHub."""
print("Installing AutoAWQ and AutoAWQ_kernels packages.")
autoawq_repo_name = "AutoAWQ"
autoawq_kernels_repo_name = "AutoAWQ_kernels"
autoawq_repo_path = os.path.join(EXTERNAL_REPOS_DIR, autoawq_repo_name)
kernels_repo_path = os.path.join(EXTERNAL_REPOS_DIR, autoawq_kernels_repo_name)
clone_or_pull_repo(f"https://github.com/casper-hansen/{autoawq_kernels_repo_name}", kernels_repo_path)
subprocess.run(
f"cd {kernels_repo_path} && {sys.executable} -m pip install .",
shell=True,
check=True,
env=os.environ,
)
clone_or_pull_repo(f"https://github.com/casper-hansen/{autoawq_repo_name}", autoawq_repo_path)
subprocess.run(
f"cd {autoawq_repo_path} && {sys.executable} -m pip install .",
shell=True,
check=True,
env=os.environ,
)
print("AutoAWQ and AutoAWQ_kernels packages installed.")
def install_autogptq_from_source():
"""Install the AutoGPTQ package from GitHub."""
print("Installing AutoGPTQ package.")
autogptq_repo_path = os.path.join(EXTERNAL_REPOS_DIR, "AutoGPTQ")
clone_or_pull_repo("https://github.com/PanQiWei/AutoGPTQ.git", autogptq_repo_path)
subprocess.run("pip install numpy gekko pandas", shell=True, check=True, env=os.environ)
subprocess.run(
f"cd {autogptq_repo_path} && {sys.executable} -m pip install .",
shell=True,
check=True,
env=os.environ,
)
print("AutoGPTQ package installed.")
def main():
parser = argparse.ArgumentParser(description="Install AutoAWQ or AutoGPTQ from source.")
parser.add_argument(
"--install-autoawq-from-source",
action="store_true",
help="Install AutoAWQ and AutoAWQ_kernels packages from source.",
)
parser.add_argument(
"--install-autogptq-from-source",
action="store_true",
help="Install AutoGPTQ package from source.",
)
args = parser.parse_args()
if args.install_autoawq_from_source:
install_autoawq_from_source()
if args.install_autogptq_from_source:
install_autogptq_from_source()
if not args.install_autoawq_from_source and not args.install_autogptq_from_source:
print(
"Please specify an installation option. Use --install-autoawq-from-source or --install-autogptq-from-source."
)
sys.exit(1)
if __name__ == "__main__":
main()