Anthonyg5005
commited on
Commit
•
92886bd
1
Parent(s):
dc20c83
add vs 2019
Browse filesalso remove old windows quantizing and add --upgrade just in case it tries to falsely install from cache
- auto-exl2-upload/INSTRUCTIONS.txt +3 -2
- auto-exl2-upload/auto-exl2-upload.zip +2 -2
- auto-exl2-upload/linux-setup.sh +2 -2
- auto-exl2-upload/windows-setup.bat +2 -2
- exl2-multi-quant-local/INSTRUCTIONS.txt +3 -2
- exl2-multi-quant-local/exl2-multi-quant-local.zip +2 -2
- exl2-multi-quant-local/linux-setup.sh +2 -2
- exl2-multi-quant-local/windows-setup.bat +2 -2
- exl2-windows-local/convert-model-auto.bat +0 -9
- exl2-windows-local/download-model.bat +0 -5
- exl2-windows-local/download-model.py +0 -323
- exl2-windows-local/exl2-windows-local.zip +0 -3
- exl2-windows-local/instructions.txt +0 -21
- exl2-windows-local/windows-setup.bat +0 -58
auto-exl2-upload/INSTRUCTIONS.txt
CHANGED
@@ -8,8 +8,9 @@ https://developer.nvidia.com/cuda-11-8-0-download-archive
|
|
8 |
|
9 |
Restart your computer after installing the CUDA toolkit to make sure the PATH is set correctly.
|
10 |
|
11 |
-
Haven't done much testing but for Windows, Visual Studio with desktop development for C++ might be required.
|
12 |
-
|
|
|
13 |
|
14 |
This may work with AMD cards but only on linux and possibly WSL2. I can't guarantee that it will work on AMD cards, I personally don't have one to test with. You may need to install stuff before starting. https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html
|
15 |
|
|
|
8 |
|
9 |
Restart your computer after installing the CUDA toolkit to make sure the PATH is set correctly.
|
10 |
|
11 |
+
Haven't done much testing but for Windows, Visual Studio 2019 with desktop development for C++ might be required.
|
12 |
+
https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=community&rel=16&utm_medium=microsoft&utm_campaign=download+from+relnotes&utm_content=vs2019ga+button
|
13 |
+
install the desktop development for C++ workload
|
14 |
|
15 |
This may work with AMD cards but only on linux and possibly WSL2. I can't guarantee that it will work on AMD cards, I personally don't have one to test with. You may need to install stuff before starting. https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html
|
16 |
|
auto-exl2-upload/auto-exl2-upload.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2c2720bae3c941245912a72e95c2a4ad708e9118b1629a94ea473354705f045c
|
3 |
+
size 7085
|
auto-exl2-upload/linux-setup.sh
CHANGED
@@ -27,13 +27,13 @@ read -p "Please enter your GPU compute version, CUDA 11/12 or AMD ROCm (11, 12,
|
|
27 |
|
28 |
if [ "$pytorch_version" = "11" ]; then
|
29 |
echo "Installing PyTorch for CUDA 11.8"
|
30 |
-
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/cu118
|
31 |
elif [ "$pytorch_version" = "12" ]; then
|
32 |
echo "Installing PyTorch for CUDA 12.1"
|
33 |
venv/bin/python -m pip install torch
|
34 |
elif [ "$pytorch_version" = "rocm" ]; then
|
35 |
echo "Installing PyTorch for AMD ROCm 5.7"
|
36 |
-
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/rocm5.7
|
37 |
else
|
38 |
echo "Invalid compute version. Please enter 11, 12, or rocm."
|
39 |
read -p "Press enter to continue"
|
|
|
27 |
|
28 |
if [ "$pytorch_version" = "11" ]; then
|
29 |
echo "Installing PyTorch for CUDA 11.8"
|
30 |
+
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/cu118 --upgrade
|
31 |
elif [ "$pytorch_version" = "12" ]; then
|
32 |
echo "Installing PyTorch for CUDA 12.1"
|
33 |
venv/bin/python -m pip install torch
|
34 |
elif [ "$pytorch_version" = "rocm" ]; then
|
35 |
echo "Installing PyTorch for AMD ROCm 5.7"
|
36 |
+
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/rocm5.7 --upgrade
|
37 |
else
|
38 |
echo "Invalid compute version. Please enter 11, 12, or rocm."
|
39 |
read -p "Press enter to continue"
|
auto-exl2-upload/windows-setup.bat
CHANGED
@@ -30,10 +30,10 @@ set /p cuda_version="Please enter your CUDA version (11 or 12): "
|
|
30 |
|
31 |
if "%cuda_version%"=="11" (
|
32 |
echo Installing PyTorch for CUDA 11.8...
|
33 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu118
|
34 |
) else if "%cuda_version%"=="12" (
|
35 |
echo Installing PyTorch for CUDA 12.1...
|
36 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu121
|
37 |
) else (
|
38 |
echo Invalid CUDA version. Please enter 11 or 12.
|
39 |
pause
|
|
|
30 |
|
31 |
if "%cuda_version%"=="11" (
|
32 |
echo Installing PyTorch for CUDA 11.8...
|
33 |
+
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu118 --upgrade
|
34 |
) else if "%cuda_version%"=="12" (
|
35 |
echo Installing PyTorch for CUDA 12.1...
|
36 |
+
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu121 --upgrade
|
37 |
) else (
|
38 |
echo Invalid CUDA version. Please enter 11 or 12.
|
39 |
pause
|
exl2-multi-quant-local/INSTRUCTIONS.txt
CHANGED
@@ -8,8 +8,9 @@ https://developer.nvidia.com/cuda-11-8-0-download-archive
|
|
8 |
|
9 |
Restart your computer after installing the CUDA toolkit to make sure the PATH is set correctly.
|
10 |
|
11 |
-
Haven't done much testing but for Windows, Visual Studio with desktop development for C++ might be required.
|
12 |
-
|
|
|
13 |
|
14 |
This may work with AMD cards but only on linux and possibly WSL2. I can't guarantee that it will work on AMD cards, I personally don't have one to test with. You may need to install stuff before starting. https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html
|
15 |
|
|
|
8 |
|
9 |
Restart your computer after installing the CUDA toolkit to make sure the PATH is set correctly.
|
10 |
|
11 |
+
Haven't done much testing but for Windows, Visual Studio 2019 with desktop development for C++ might be required.
|
12 |
+
https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=community&rel=16&utm_medium=microsoft&utm_campaign=download+from+relnotes&utm_content=vs2019ga+button
|
13 |
+
install the desktop development for C++ workload
|
14 |
|
15 |
This may work with AMD cards but only on linux and possibly WSL2. I can't guarantee that it will work on AMD cards, I personally don't have one to test with. You may need to install stuff before starting. https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html
|
16 |
|
exl2-multi-quant-local/exl2-multi-quant-local.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9a6b8c97cdc430994bb2c5ee50104e4a6852b56b87d5cf1984aa6309a53cac17
|
3 |
+
size 6103
|
exl2-multi-quant-local/linux-setup.sh
CHANGED
@@ -27,13 +27,13 @@ read -p "Please enter your GPU compute version, CUDA 11/12 or AMD ROCm (11, 12,
|
|
27 |
|
28 |
if [ "$pytorch_version" = "11" ]; then
|
29 |
echo "Installing PyTorch for CUDA 11.8"
|
30 |
-
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/cu118
|
31 |
elif [ "$pytorch_version" = "12" ]; then
|
32 |
echo "Installing PyTorch for CUDA 12.1"
|
33 |
venv/bin/python -m pip install torch
|
34 |
elif [ "$pytorch_version" = "rocm" ]; then
|
35 |
echo "Installing PyTorch for AMD ROCm 5.7"
|
36 |
-
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/rocm5.7
|
37 |
else
|
38 |
echo "Invalid compute version. Please enter 11, 12, or rocm."
|
39 |
read -p "Press enter to continue"
|
|
|
27 |
|
28 |
if [ "$pytorch_version" = "11" ]; then
|
29 |
echo "Installing PyTorch for CUDA 11.8"
|
30 |
+
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/cu118 --upgrade
|
31 |
elif [ "$pytorch_version" = "12" ]; then
|
32 |
echo "Installing PyTorch for CUDA 12.1"
|
33 |
venv/bin/python -m pip install torch
|
34 |
elif [ "$pytorch_version" = "rocm" ]; then
|
35 |
echo "Installing PyTorch for AMD ROCm 5.7"
|
36 |
+
venv/bin/python -m pip install torch --index-url https://download.pytorch.org/whl/rocm5.7 --upgrade
|
37 |
else
|
38 |
echo "Invalid compute version. Please enter 11, 12, or rocm."
|
39 |
read -p "Press enter to continue"
|
exl2-multi-quant-local/windows-setup.bat
CHANGED
@@ -30,10 +30,10 @@ set /p cuda_version="Please enter your CUDA version (11 or 12): "
|
|
30 |
|
31 |
if "%cuda_version%"=="11" (
|
32 |
echo Installing PyTorch for CUDA 11.8...
|
33 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu118
|
34 |
) else if "%cuda_version%"=="12" (
|
35 |
echo Installing PyTorch for CUDA 12.1...
|
36 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu121
|
37 |
) else (
|
38 |
echo Invalid CUDA version. Please enter 11 or 12.
|
39 |
pause
|
|
|
30 |
|
31 |
if "%cuda_version%"=="11" (
|
32 |
echo Installing PyTorch for CUDA 11.8...
|
33 |
+
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu118 --upgrade
|
34 |
) else if "%cuda_version%"=="12" (
|
35 |
echo Installing PyTorch for CUDA 12.1...
|
36 |
+
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu121 --upgrade
|
37 |
) else (
|
38 |
echo Invalid CUDA version. Please enter 11 or 12.
|
39 |
pause
|
exl2-windows-local/convert-model-auto.bat
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
@echo off
|
2 |
-
|
3 |
-
set /p "model=Folder name: "
|
4 |
-
set /p "bpw=Target BPW: "
|
5 |
-
mkdir %model%-exl2-%bpw%bpw
|
6 |
-
mkdir %model%-exl2-%bpw%bpw-WD
|
7 |
-
copy %model%\config.json %model%-exl2-%bpw%bpw-WD
|
8 |
-
venv\scripts\python.exe convert.py -i %model% -o %model%-exl2-%bpw%bpw-WD -cf %model%-exl2-%bpw%bpw -b %bpw%
|
9 |
-
rmdir /s /q %model%-exl2-%bpw%-WD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exl2-windows-local/download-model.bat
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
@echo off
|
2 |
-
|
3 |
-
echo Enter the model repo. User/Repo:Branch (Branch optional)
|
4 |
-
set /p "repo=Model repo: "
|
5 |
-
venv\scripts\python.exe download-model.py %repo%
|
|
|
|
|
|
|
|
|
|
|
|
exl2-windows-local/download-model.py
DELETED
@@ -1,323 +0,0 @@
|
|
1 |
-
'''
|
2 |
-
Downloads models from Hugging Face to models/username_modelname.
|
3 |
-
|
4 |
-
Example:
|
5 |
-
python download-model.py facebook/opt-1.3b
|
6 |
-
|
7 |
-
'''
|
8 |
-
|
9 |
-
import argparse
|
10 |
-
import base64
|
11 |
-
import datetime
|
12 |
-
import hashlib
|
13 |
-
import json
|
14 |
-
import os
|
15 |
-
import re
|
16 |
-
import sys
|
17 |
-
from pathlib import Path
|
18 |
-
|
19 |
-
import requests
|
20 |
-
import tqdm
|
21 |
-
from requests.adapters import HTTPAdapter
|
22 |
-
from tqdm.contrib.concurrent import thread_map
|
23 |
-
from huggingface_hub import get_token
|
24 |
-
|
25 |
-
base = "https://huggingface.co"
|
26 |
-
|
27 |
-
|
28 |
-
class ModelDownloader:
|
29 |
-
def __init__(self, max_retries=5):
|
30 |
-
self.max_retries = max_retries
|
31 |
-
|
32 |
-
def get_session(self):
|
33 |
-
session = requests.Session()
|
34 |
-
if self.max_retries:
|
35 |
-
session.mount('https://cdn-lfs.huggingface.co', HTTPAdapter(max_retries=self.max_retries))
|
36 |
-
session.mount('https://huggingface.co', HTTPAdapter(max_retries=self.max_retries))
|
37 |
-
|
38 |
-
if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
|
39 |
-
session.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
|
40 |
-
|
41 |
-
try:
|
42 |
-
from huggingface_hub import get_token
|
43 |
-
token = get_token()
|
44 |
-
except ImportError:
|
45 |
-
token = os.getenv("HF_TOKEN")
|
46 |
-
|
47 |
-
if token is not None:
|
48 |
-
session.headers = {'authorization': f'Bearer {token}'}
|
49 |
-
|
50 |
-
return session
|
51 |
-
|
52 |
-
def sanitize_model_and_branch_names(self, model, branch):
|
53 |
-
if model[-1] == '/':
|
54 |
-
model = model[:-1]
|
55 |
-
|
56 |
-
if model.startswith(base + '/'):
|
57 |
-
model = model[len(base) + 1:]
|
58 |
-
|
59 |
-
model_parts = model.split(":")
|
60 |
-
model = model_parts[0] if len(model_parts) > 0 else model
|
61 |
-
branch = model_parts[1] if len(model_parts) > 1 else branch
|
62 |
-
|
63 |
-
if branch is None:
|
64 |
-
branch = "main"
|
65 |
-
else:
|
66 |
-
pattern = re.compile(r"^[a-zA-Z0-9._-]+$")
|
67 |
-
if not pattern.match(branch):
|
68 |
-
raise ValueError(
|
69 |
-
"Invalid branch name. Only alphanumeric characters, period, underscore and dash are allowed.")
|
70 |
-
|
71 |
-
return model, branch
|
72 |
-
|
73 |
-
def get_download_links_from_huggingface(self, model, branch, text_only=False, specific_file=None):
|
74 |
-
session = self.get_session()
|
75 |
-
page = f"/api/models/{model}/tree/{branch}"
|
76 |
-
cursor = b""
|
77 |
-
|
78 |
-
links = []
|
79 |
-
sha256 = []
|
80 |
-
classifications = []
|
81 |
-
has_pytorch = False
|
82 |
-
has_pt = False
|
83 |
-
has_gguf = False
|
84 |
-
has_safetensors = False
|
85 |
-
is_lora = False
|
86 |
-
while True:
|
87 |
-
url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
|
88 |
-
r = session.get(url, timeout=10)
|
89 |
-
r.raise_for_status()
|
90 |
-
content = r.content
|
91 |
-
|
92 |
-
dict = json.loads(content)
|
93 |
-
if len(dict) == 0:
|
94 |
-
break
|
95 |
-
|
96 |
-
for i in range(len(dict)):
|
97 |
-
fname = dict[i]['path']
|
98 |
-
if specific_file not in [None, ''] and fname != specific_file:
|
99 |
-
continue
|
100 |
-
|
101 |
-
if not is_lora and fname.endswith(('adapter_config.json', 'adapter_model.bin')):
|
102 |
-
is_lora = True
|
103 |
-
|
104 |
-
is_pytorch = re.match(r"(pytorch|adapter|gptq)_model.*\.bin", fname)
|
105 |
-
is_safetensors = re.match(r".*\.safetensors", fname)
|
106 |
-
is_pt = re.match(r".*\.pt", fname)
|
107 |
-
is_gguf = re.match(r'.*\.gguf', fname)
|
108 |
-
is_tiktoken = re.match(r".*\.tiktoken", fname)
|
109 |
-
is_tokenizer = re.match(r"(tokenizer|ice|spiece).*\.model", fname) or is_tiktoken
|
110 |
-
is_text = re.match(r".*\.(txt|json|py|md)", fname) or is_tokenizer
|
111 |
-
if any((is_pytorch, is_safetensors, is_pt, is_gguf, is_tokenizer, is_text)):
|
112 |
-
if 'lfs' in dict[i]:
|
113 |
-
sha256.append([fname, dict[i]['lfs']['oid']])
|
114 |
-
|
115 |
-
if is_text:
|
116 |
-
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
|
117 |
-
classifications.append('text')
|
118 |
-
continue
|
119 |
-
|
120 |
-
if not text_only:
|
121 |
-
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
|
122 |
-
if is_safetensors:
|
123 |
-
has_safetensors = True
|
124 |
-
classifications.append('safetensors')
|
125 |
-
elif is_pytorch:
|
126 |
-
has_pytorch = True
|
127 |
-
classifications.append('pytorch')
|
128 |
-
elif is_pt:
|
129 |
-
has_pt = True
|
130 |
-
classifications.append('pt')
|
131 |
-
elif is_gguf:
|
132 |
-
has_gguf = True
|
133 |
-
classifications.append('gguf')
|
134 |
-
|
135 |
-
cursor = base64.b64encode(f'{{"file_name":"{dict[-1]["path"]}"}}'.encode()) + b':50'
|
136 |
-
cursor = base64.b64encode(cursor)
|
137 |
-
cursor = cursor.replace(b'=', b'%3D')
|
138 |
-
|
139 |
-
# If both pytorch and safetensors are available, download safetensors only
|
140 |
-
if (has_pytorch or has_pt) and has_safetensors:
|
141 |
-
for i in range(len(classifications) - 1, -1, -1):
|
142 |
-
if classifications[i] in ['pytorch', 'pt']:
|
143 |
-
links.pop(i)
|
144 |
-
|
145 |
-
# For GGUF, try to download only the Q4_K_M if no specific file is specified.
|
146 |
-
# If not present, exclude all GGUFs, as that's likely a repository with both
|
147 |
-
# GGUF and fp16 files.
|
148 |
-
if has_gguf and specific_file is None:
|
149 |
-
has_q4km = False
|
150 |
-
for i in range(len(classifications) - 1, -1, -1):
|
151 |
-
if 'q4_k_m' in links[i].lower():
|
152 |
-
has_q4km = True
|
153 |
-
|
154 |
-
if has_q4km:
|
155 |
-
for i in range(len(classifications) - 1, -1, -1):
|
156 |
-
if 'q4_k_m' not in links[i].lower():
|
157 |
-
links.pop(i)
|
158 |
-
else:
|
159 |
-
for i in range(len(classifications) - 1, -1, -1):
|
160 |
-
if links[i].lower().endswith('.gguf'):
|
161 |
-
links.pop(i)
|
162 |
-
|
163 |
-
is_llamacpp = has_gguf and specific_file is not None
|
164 |
-
return links, sha256, is_lora, is_llamacpp
|
165 |
-
|
166 |
-
def get_output_folder(self, model, branch, is_lora, is_llamacpp=False):
|
167 |
-
base_folder = '.' if not is_lora else 'loras'
|
168 |
-
|
169 |
-
# If the model is of type GGUF, save directly in the base_folder
|
170 |
-
if is_llamacpp:
|
171 |
-
return Path(base_folder)
|
172 |
-
|
173 |
-
output_folder = f"{'_'.join(model.split('/')[-2:])}"
|
174 |
-
if branch != 'main':
|
175 |
-
output_folder += f'_{branch}'
|
176 |
-
|
177 |
-
output_folder = Path(base_folder) / output_folder
|
178 |
-
return output_folder
|
179 |
-
|
180 |
-
def get_single_file(self, url, output_folder, start_from_scratch=False):
|
181 |
-
session = self.get_session()
|
182 |
-
filename = Path(url.rsplit('/', 1)[1])
|
183 |
-
output_path = output_folder / filename
|
184 |
-
headers = {}
|
185 |
-
mode = 'wb'
|
186 |
-
if output_path.exists() and not start_from_scratch:
|
187 |
-
|
188 |
-
# Check if the file has already been downloaded completely
|
189 |
-
r = session.get(url, stream=True, timeout=10)
|
190 |
-
total_size = int(r.headers.get('content-length', 0))
|
191 |
-
if output_path.stat().st_size >= total_size:
|
192 |
-
return
|
193 |
-
|
194 |
-
# Otherwise, resume the download from where it left off
|
195 |
-
headers = {'Range': f'bytes={output_path.stat().st_size}-'}
|
196 |
-
mode = 'ab'
|
197 |
-
|
198 |
-
with session.get(url, stream=True, headers=headers, timeout=10) as r:
|
199 |
-
r.raise_for_status() # Do not continue the download if the request was unsuccessful
|
200 |
-
total_size = int(r.headers.get('content-length', 0))
|
201 |
-
block_size = 1024 * 1024 # 1MB
|
202 |
-
|
203 |
-
tqdm_kwargs = {
|
204 |
-
'total': total_size,
|
205 |
-
'unit': 'iB',
|
206 |
-
'unit_scale': True,
|
207 |
-
'bar_format': '{l_bar}{bar}| {n_fmt:6}/{total_fmt:6} {rate_fmt:6}'
|
208 |
-
}
|
209 |
-
|
210 |
-
if 'COLAB_GPU' in os.environ:
|
211 |
-
tqdm_kwargs.update({
|
212 |
-
'position': 0,
|
213 |
-
'leave': True
|
214 |
-
})
|
215 |
-
|
216 |
-
with open(output_path, mode) as f:
|
217 |
-
with tqdm.tqdm(**tqdm_kwargs) as t:
|
218 |
-
count = 0
|
219 |
-
for data in r.iter_content(block_size):
|
220 |
-
t.update(len(data))
|
221 |
-
f.write(data)
|
222 |
-
if total_size != 0 and self.progress_bar is not None:
|
223 |
-
count += len(data)
|
224 |
-
self.progress_bar(float(count) / float(total_size), f"{filename}")
|
225 |
-
|
226 |
-
def start_download_threads(self, file_list, output_folder, start_from_scratch=False, threads=4):
|
227 |
-
thread_map(lambda url: self.get_single_file(url, output_folder, start_from_scratch=start_from_scratch), file_list, max_workers=threads, disable=True)
|
228 |
-
|
229 |
-
def download_model_files(self, model, branch, links, sha256, output_folder, progress_bar=None, start_from_scratch=False, threads=4, specific_file=None, is_llamacpp=False):
|
230 |
-
self.progress_bar = progress_bar
|
231 |
-
|
232 |
-
# Create the folder and writing the metadata
|
233 |
-
output_folder.mkdir(parents=True, exist_ok=True)
|
234 |
-
|
235 |
-
if not is_llamacpp:
|
236 |
-
metadata = f'url: https://huggingface.co/{model}\n' \
|
237 |
-
f'branch: {branch}\n' \
|
238 |
-
f'download date: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\n'
|
239 |
-
|
240 |
-
sha256_str = '\n'.join([f' {item[1]} {item[0]}' for item in sha256])
|
241 |
-
if sha256_str:
|
242 |
-
metadata += f'sha256sum:\n{sha256_str}'
|
243 |
-
|
244 |
-
metadata += '\n'
|
245 |
-
(output_folder / 'huggingface-metadata.txt').write_text(metadata)
|
246 |
-
|
247 |
-
if specific_file:
|
248 |
-
print(f"Downloading {specific_file} to {output_folder}")
|
249 |
-
else:
|
250 |
-
print(f"Downloading the model to {output_folder}")
|
251 |
-
|
252 |
-
self.start_download_threads(links, output_folder, start_from_scratch=start_from_scratch, threads=threads)
|
253 |
-
|
254 |
-
def check_model_files(self, model, branch, links, sha256, output_folder):
|
255 |
-
# Validate the checksums
|
256 |
-
validated = True
|
257 |
-
for i in range(len(sha256)):
|
258 |
-
fpath = (output_folder / sha256[i][0])
|
259 |
-
|
260 |
-
if not fpath.exists():
|
261 |
-
print(f"The following file is missing: {fpath}")
|
262 |
-
validated = False
|
263 |
-
continue
|
264 |
-
|
265 |
-
with open(output_folder / sha256[i][0], "rb") as f:
|
266 |
-
file_hash = hashlib.file_digest(f, "sha256").hexdigest()
|
267 |
-
if file_hash != sha256[i][1]:
|
268 |
-
print(f'Checksum failed: {sha256[i][0]} {sha256[i][1]}')
|
269 |
-
validated = False
|
270 |
-
else:
|
271 |
-
print(f'Checksum validated: {sha256[i][0]} {sha256[i][1]}')
|
272 |
-
|
273 |
-
if validated:
|
274 |
-
print('[+] Validated checksums of all model files!')
|
275 |
-
else:
|
276 |
-
print('[-] Invalid checksums. Rerun download-model.py with the --clean flag.')
|
277 |
-
|
278 |
-
|
279 |
-
if __name__ == '__main__':
|
280 |
-
|
281 |
-
parser = argparse.ArgumentParser()
|
282 |
-
parser.add_argument('MODEL', type=str, default=None, nargs='?')
|
283 |
-
parser.add_argument('--branch', type=str, default='main', help='Name of the Git branch to download from.')
|
284 |
-
parser.add_argument('--threads', type=int, default=4, help='Number of files to download simultaneously.')
|
285 |
-
parser.add_argument('--text-only', action='store_true', help='Only download text files (txt/json).')
|
286 |
-
parser.add_argument('--specific-file', type=str, default=None, help='Name of the specific file to download (if not provided, downloads all).')
|
287 |
-
parser.add_argument('--output', type=str, default=None, help='The folder where the model should be saved.')
|
288 |
-
parser.add_argument('--clean', action='store_true', help='Does not resume the previous download.')
|
289 |
-
parser.add_argument('--check', action='store_true', help='Validates the checksums of model files.')
|
290 |
-
parser.add_argument('--max-retries', type=int, default=5, help='Max retries count when get error in download time.')
|
291 |
-
args = parser.parse_args()
|
292 |
-
|
293 |
-
branch = args.branch
|
294 |
-
model = args.MODEL
|
295 |
-
specific_file = args.specific_file
|
296 |
-
|
297 |
-
if model is None:
|
298 |
-
print("Error: Please specify the model you'd like to download (e.g. 'python download-model.py facebook/opt-1.3b').")
|
299 |
-
sys.exit()
|
300 |
-
|
301 |
-
downloader = ModelDownloader(max_retries=args.max_retries)
|
302 |
-
# Clean up the model/branch names
|
303 |
-
try:
|
304 |
-
model, branch = downloader.sanitize_model_and_branch_names(model, branch)
|
305 |
-
except ValueError as err_branch:
|
306 |
-
print(f"Error: {err_branch}")
|
307 |
-
sys.exit()
|
308 |
-
|
309 |
-
# Get the download links from Hugging Face
|
310 |
-
links, sha256, is_lora, is_llamacpp = downloader.get_download_links_from_huggingface(model, branch, text_only=args.text_only, specific_file=specific_file)
|
311 |
-
|
312 |
-
# Get the output folder
|
313 |
-
if args.output:
|
314 |
-
output_folder = Path(args.output)
|
315 |
-
else:
|
316 |
-
output_folder = downloader.get_output_folder(model, branch, is_lora, is_llamacpp=is_llamacpp)
|
317 |
-
|
318 |
-
if args.check:
|
319 |
-
# Check previously downloaded files
|
320 |
-
downloader.check_model_files(model, branch, links, sha256, output_folder)
|
321 |
-
else:
|
322 |
-
# Download files
|
323 |
-
downloader.download_model_files(model, branch, links, sha256, output_folder, specific_file=specific_file, threads=args.threads, is_llamacpp=is_llamacpp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exl2-windows-local/exl2-windows-local.zip
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:d1d305f32329e1c812ff858f6ca564c008ce02c0f1837c5f3560c62c7293d945
|
3 |
-
size 5918
|
|
|
|
|
|
|
|
exl2-windows-local/instructions.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
install the CUDA toolkit
|
2 |
-
|
3 |
-
Nvidia Maxwell or higher
|
4 |
-
https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64
|
5 |
-
|
6 |
-
Nvidia Kepler or higher
|
7 |
-
https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Windows&target_arch=x86_64
|
8 |
-
|
9 |
-
Haven't done much testing but Visual Studio with desktop development for C++ might be required. I've gotten cl.exe errors on a previous install
|
10 |
-
|
11 |
-
make sure you setup the environment by using windows-setup.bat
|
12 |
-
after everything is done just download a model using download-model.bat
|
13 |
-
to quant, use convert-model-auto.bat. Enter the model's folder name, then the BPW for the model
|
14 |
-
|
15 |
-
You can always pause the quantization process by pressing Ctrl + C and typing exit. All progress will be stored in the WD (working directory) folder. You can resume where you left off by running the convert-model-auto.bat script with the same arguments you used before.
|
16 |
-
|
17 |
-
Credit to turboderp for creating exllamav2 and the exl2 quantization method.
|
18 |
-
https://github.com/turboderp
|
19 |
-
|
20 |
-
Credit to oobabooga the original download script.
|
21 |
-
https://github.com/oobabooga
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exl2-windows-local/windows-setup.bat
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
@echo off
|
2 |
-
|
3 |
-
setlocal
|
4 |
-
|
5 |
-
REM check if "venv" subdirectory exists, if not, create one
|
6 |
-
if not exist "venv\" (
|
7 |
-
python -m venv venv
|
8 |
-
) else (
|
9 |
-
echo venv directory already exists. If something is broken, delete everything but exl2-quant.py and run this script again.
|
10 |
-
pause
|
11 |
-
exit
|
12 |
-
)
|
13 |
-
|
14 |
-
REM ask if the user has git installed
|
15 |
-
set /p gitinst="Do you have git installed? (y/n) "
|
16 |
-
|
17 |
-
if "%gitinst%"=="y" (
|
18 |
-
echo Setting up environment
|
19 |
-
) else (
|
20 |
-
echo Please install git before running this script.
|
21 |
-
pause
|
22 |
-
exit
|
23 |
-
)
|
24 |
-
|
25 |
-
REM if CUDA version 12 install pytorch for 12.1, else if CUDA 11 install pytorch for 11.8
|
26 |
-
echo CUDA path: %CUDA_HOME%
|
27 |
-
set /p cuda_version="Please enter your CUDA version (11 or 12): "
|
28 |
-
|
29 |
-
if "%cuda_version%"=="11" (
|
30 |
-
echo Installing PyTorch for CUDA 11.8...
|
31 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu118 --upgrade
|
32 |
-
) else if "%cuda_version%"=="12" (
|
33 |
-
echo Installing PyTorch for CUDA 12.1...
|
34 |
-
venv\scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu121 --upgrade
|
35 |
-
) else (
|
36 |
-
echo Invalid CUDA version. Please enter 11 or 12.
|
37 |
-
pause
|
38 |
-
exit
|
39 |
-
)
|
40 |
-
|
41 |
-
REM download stuff
|
42 |
-
echo Downloading files...
|
43 |
-
git clone https://github.com/turboderp/exllamav2
|
44 |
-
|
45 |
-
echo Installing pip packages...
|
46 |
-
|
47 |
-
venv\scripts\python.exe -m pip install -r exllamav2/requirements.txt
|
48 |
-
venv\scripts\python.exe -m pip install huggingface-hub
|
49 |
-
venv\scripts\python.exe -m pip install .\exllamav2
|
50 |
-
|
51 |
-
move download-model.bat exllamav2
|
52 |
-
move convert-model-auto.bat exllamav2
|
53 |
-
move download-model.py exllamav2
|
54 |
-
move venv exllamav2
|
55 |
-
|
56 |
-
powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\tada.wav").PlaySync();
|
57 |
-
echo Environment setup complete. Read instructions.txt for further instructions.
|
58 |
-
pause
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|