Anthonyg5005
commited on
Commit
·
fa3019e
1
Parent(s):
daf0108
better token handling
Browse filesalso fixed windows setup bug requiring to open twice to actually setup venv
- HF Login Snippet Kaggle.py +4 -2
- HF Login Snippet.py +9 -5
- auto-exl2-upload/INSTRUCTIONS.txt +2 -2
- auto-exl2-upload/auto-exl2-upload.zip +2 -2
- auto-exl2-upload/exl2-quant.py +14 -4
- auto-exl2-upload/windows-setup.bat +3 -1
- exl2-multi-quant-local/INSTRUCTIONS.txt +2 -2
- exl2-multi-quant-local/exl2-multi-quant-local.zip +2 -2
- exl2-multi-quant-local/exl2-quant.py +19 -14
- exl2-multi-quant-local/windows-setup.bat +3 -1
HF Login Snippet Kaggle.py
CHANGED
@@ -16,8 +16,10 @@ if os.environ.get('KAGGLE_KERNEL_RUN_TYPE', None) is not None: #check if user in
|
|
16 |
Set your secrets with the secrets add-on on the top of the screen.
|
17 |
''')
|
18 |
if get_token() is not None:
|
19 |
-
|
20 |
-
|
|
|
|
|
21 |
else:
|
22 |
#if the token is not found then prompt user to provide it:
|
23 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: "))
|
|
|
16 |
Set your secrets with the secrets add-on on the top of the screen.
|
17 |
''')
|
18 |
if get_token() is not None:
|
19 |
+
try:
|
20 |
+
login(get_token()) #attempt to login with token found
|
21 |
+
except ValueError:
|
22 |
+
login(input("API token is no longer valid. Enter your new HuggingFace (WRITE) token: ")) #if token is invalid then prompt user to provide new token
|
23 |
else:
|
24 |
#if the token is not found then prompt user to provide it:
|
25 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: "))
|
HF Login Snippet.py
CHANGED
@@ -16,13 +16,17 @@ def clear_screen():
|
|
16 |
|
17 |
#get token
|
18 |
if get_token() is not None:
|
19 |
-
#if the token is found in either HF_TOKEN or cli login then log in:
|
20 |
-
login(get_token())
|
21 |
tfound = 'true' #remove if lines 27-34 removed
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
else:
|
23 |
#if the token is not found then prompt user to provide it:
|
24 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: ")) # can remove "(WRITE)" if not required
|
25 |
-
tfound = 'false' #remove if lines
|
26 |
|
27 |
#if the token is read only then prompt user to provide a write token (Only required if user needs a WRITE token, remove if READ is enough):
|
28 |
while True:
|
@@ -30,8 +34,8 @@ while True:
|
|
30 |
clear_screen()
|
31 |
if os.environ.get('HF_TOKEN', None) is not None: #if environ finds HF_TOKEN as write then display following text and exit:
|
32 |
print(f'''
|
33 |
-
|
34 |
-
|
35 |
Either set the environment variable to a (WRITE) token or remove it.
|
36 |
''')
|
37 |
input("Press enter to continue.")
|
|
|
16 |
|
17 |
#get token
|
18 |
if get_token() is not None:
|
|
|
|
|
19 |
tfound = 'true' #remove if lines 27-34 removed
|
20 |
+
#if the token is found in either HF_TOKEN or cli login then log in:
|
21 |
+
try:
|
22 |
+
login(get_token()) #attempt to login with token found
|
23 |
+
except ValueError:
|
24 |
+
login(input("API token is no longer valid. Enter your new HuggingFace (WRITE) token: ")) #if token is invalid then prompt user to provide new token
|
25 |
+
tfound = 'false' #remove if lines 47-55 removed
|
26 |
else:
|
27 |
#if the token is not found then prompt user to provide it:
|
28 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: ")) # can remove "(WRITE)" if not required
|
29 |
+
tfound = 'false' #remove if lines 47-55 removed
|
30 |
|
31 |
#if the token is read only then prompt user to provide a write token (Only required if user needs a WRITE token, remove if READ is enough):
|
32 |
while True:
|
|
|
34 |
clear_screen()
|
35 |
if os.environ.get('HF_TOKEN', None) is not None: #if environ finds HF_TOKEN as write then display following text and exit:
|
36 |
print(f'''
|
37 |
+
You have the environment variable HF_TOKEN set.
|
38 |
+
You cannot log in.
|
39 |
Either set the environment variable to a (WRITE) token or remove it.
|
40 |
''')
|
41 |
input("Press enter to continue.")
|
auto-exl2-upload/INSTRUCTIONS.txt
CHANGED
@@ -23,7 +23,7 @@ Only python 3.8 - 3.12 is known to work. If you have a higher/lower version of p
|
|
23 |
|
24 |
|
25 |
|
26 |
-
First setup your environment by using either windows.bat or linux.sh.
|
27 |
|
28 |
After setup is complete then you'll have a file called start-quant. Use this to run the quant script.
|
29 |
|
@@ -32,7 +32,7 @@ Make sure to also have a lot of RAM depending on the model. Have noticed gemma t
|
|
32 |
|
33 |
If you close the terminal or the terminal crashes, check the last BPW it was on and enter the remaining quants you wanted. It should be able to pick up where it left off. Don't type the BPW of completed quants as it will start from the beginning. You may also use ctrl + c to pause at any time during the quant process.
|
34 |
|
35 |
-
To add more options to the quantization process, you can add them to line
|
36 |
|
37 |
Things may break in the future as it downloads the latest version of all the dependencies which may either change names or how they work. If something breaks, please open a discussion at https://huggingface.co/Anthonyg5005/hf-scripts/discussions
|
38 |
|
|
|
23 |
|
24 |
|
25 |
|
26 |
+
First setup your environment by using either windows.bat or linux.sh. If you want to upgrade your exllama version, you can run the setup script again.
|
27 |
|
28 |
After setup is complete then you'll have a file called start-quant. Use this to run the quant script.
|
29 |
|
|
|
32 |
|
33 |
If you close the terminal or the terminal crashes, check the last BPW it was on and enter the remaining quants you wanted. It should be able to pick up where it left off. Don't type the BPW of completed quants as it will start from the beginning. You may also use ctrl + c to pause at any time during the quant process.
|
34 |
|
35 |
+
To add more options to the quantization process, you can add them to line 199. All options: https://github.com/turboderp/exllamav2/blob/master/doc/convert.md
|
36 |
|
37 |
Things may break in the future as it downloads the latest version of all the dependencies which may either change names or how they work. If something breaks, please open a discussion at https://huggingface.co/Anthonyg5005/hf-scripts/discussions
|
38 |
|
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:592f8d6daa3245f7d76fd0c73c197580a3c51eb68690541a1c4e7ddedafb8a6b
|
3 |
+
size 8402
|
auto-exl2-upload/exl2-quant.py
CHANGED
@@ -28,6 +28,12 @@ def clear_screen():
|
|
28 |
os.system(osclear)
|
29 |
|
30 |
#get token
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if os.environ.get('KAGGLE_KERNEL_RUN_TYPE', None) is not None: #check if user in kaggle
|
32 |
from kaggle_secrets import UserSecretsClient # type: ignore
|
33 |
from kaggle_web_client import BackendError # type: ignore
|
@@ -40,9 +46,13 @@ if os.environ.get('KAGGLE_KERNEL_RUN_TYPE', None) is not None: #check if user in
|
|
40 |
Set your secrets with the secrets add-on on the top of the screen.
|
41 |
''')
|
42 |
if get_token() is not None:
|
43 |
-
|
44 |
-
login
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
else:
|
47 |
#if the token is not found then prompt user to provide it:
|
48 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: "))
|
@@ -54,7 +64,7 @@ while True:
|
|
54 |
clear_screen()
|
55 |
if os.environ.get('HF_TOKEN', None) is not None: #if environ finds HF_TOKEN as read-only then display following text and exit:
|
56 |
print('''
|
57 |
-
|
58 |
You cannot log in.
|
59 |
Either set the environment variable to a 'WRITE' token or remove it.
|
60 |
''')
|
|
|
28 |
os.system(osclear)
|
29 |
|
30 |
#get token
|
31 |
+
if os.environ.get('HF_TOKEN', None) is not None:
|
32 |
+
try:
|
33 |
+
login(get_token())
|
34 |
+
except ValueError:
|
35 |
+
print("You have an invalid token set in your environment variable HF_TOKEN. This will cause issues with this script\nRemove the variable or set it to a valid WRITE token.")
|
36 |
+
sys.exit("Exiting...")
|
37 |
if os.environ.get('KAGGLE_KERNEL_RUN_TYPE', None) is not None: #check if user in kaggle
|
38 |
from kaggle_secrets import UserSecretsClient # type: ignore
|
39 |
from kaggle_web_client import BackendError # type: ignore
|
|
|
46 |
Set your secrets with the secrets add-on on the top of the screen.
|
47 |
''')
|
48 |
if get_token() is not None:
|
49 |
+
tfound = 'true'
|
50 |
+
#if the token is found in either HF_TOKEN or cli login then log in:
|
51 |
+
try:
|
52 |
+
login(get_token())
|
53 |
+
except ValueError:
|
54 |
+
login(input("API token is no longer valid. Enter your new HuggingFace (WRITE) token: "))
|
55 |
+
tfound = 'false'
|
56 |
else:
|
57 |
#if the token is not found then prompt user to provide it:
|
58 |
login(input("API token not detected. Enter your HuggingFace (WRITE) token: "))
|
|
|
64 |
clear_screen()
|
65 |
if os.environ.get('HF_TOKEN', None) is not None: #if environ finds HF_TOKEN as read-only then display following text and exit:
|
66 |
print('''
|
67 |
+
You have the environment variable HF_TOKEN set to a 'READ' token.
|
68 |
You cannot log in.
|
69 |
Either set the environment variable to a 'WRITE' token or remove it.
|
70 |
''')
|
auto-exl2-upload/windows-setup.bat
CHANGED
@@ -3,15 +3,17 @@
|
|
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 |
set /p reinst="venv directory already exists. Looking to upgrade/reinstall exllama? (will reinstall python venv) (y/n) "
|
10 |
)
|
11 |
if "%reinst%"=="y" (
|
12 |
rmdir /s /q venv
|
13 |
python -m venv venv
|
14 |
-
) else (
|
15 |
exit
|
16 |
)
|
17 |
|
|
|
3 |
setlocal
|
4 |
|
5 |
REM check if "venv" subdirectory exists, if not, create one
|
6 |
+
set reinst=n
|
7 |
if not exist "venv\" (
|
8 |
python -m venv venv
|
9 |
+
set newvenv=y
|
10 |
) else (
|
11 |
set /p reinst="venv directory already exists. Looking to upgrade/reinstall exllama? (will reinstall python venv) (y/n) "
|
12 |
)
|
13 |
if "%reinst%"=="y" (
|
14 |
rmdir /s /q venv
|
15 |
python -m venv venv
|
16 |
+
) else if not "%newvenv%"=="y" (
|
17 |
exit
|
18 |
)
|
19 |
|
exl2-multi-quant-local/INSTRUCTIONS.txt
CHANGED
@@ -23,7 +23,7 @@ Only python 3.8 - 3.12 is known to work. If you have a higher/lower version of p
|
|
23 |
|
24 |
|
25 |
|
26 |
-
First setup your environment by using either windows.bat or linux.sh.
|
27 |
|
28 |
After setup is complete then you'll have a file called start-quant. Use this to run the quant script.
|
29 |
|
@@ -32,7 +32,7 @@ Make sure to also have a lot of RAM depending on the model. Have noticed gemma t
|
|
32 |
|
33 |
If you close the terminal or the terminal crashes, check the last BPW it was on and enter the remaining quants you wanted. It should be able to pick up where it left off. Don't type the BPW of completed quants as it will start from the beginning. You may also use ctrl + c to pause at any time during the quant process.
|
34 |
|
35 |
-
To add more options to the quantization process, you can add them to line
|
36 |
|
37 |
Things may break in the future as it downloads the latest version of all the dependencies which may either change names or how they work. If something breaks, please open a discussion at https://huggingface.co/Anthonyg5005/hf-scripts/discussions
|
38 |
|
|
|
23 |
|
24 |
|
25 |
|
26 |
+
First setup your environment by using either windows.bat or linux.sh. If you want to upgrade your exllama version, you can run the setup script again.
|
27 |
|
28 |
After setup is complete then you'll have a file called start-quant. Use this to run the quant script.
|
29 |
|
|
|
32 |
|
33 |
If you close the terminal or the terminal crashes, check the last BPW it was on and enter the remaining quants you wanted. It should be able to pick up where it left off. Don't type the BPW of completed quants as it will start from the beginning. You may also use ctrl + c to pause at any time during the quant process.
|
34 |
|
35 |
+
To add more options to the quantization process, you can add them to line 145. All options: https://github.com/turboderp/exllamav2/blob/master/doc/convert.md
|
36 |
|
37 |
Things may break in the future as it downloads the latest version of all the dependencies which may either change names or how they work. If something breaks, please open a discussion at https://huggingface.co/Anthonyg5005/hf-scripts/discussions
|
38 |
|
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:5b939c9a6f47484cf54048980107e8a086f4b6fa4fb1c94f36226d726baff766
|
3 |
+
size 7227
|
exl2-multi-quant-local/exl2-quant.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
#usually it's what is on the inside that counts, not this time. This script is a mess, but at least it works.
|
2 |
#import required modules
|
3 |
-
from huggingface_hub import login, get_token, whoami, repo_exists
|
4 |
import os
|
5 |
import sys
|
6 |
import subprocess
|
@@ -29,21 +29,26 @@ def clear_screen():
|
|
29 |
os.system(osclear)
|
30 |
|
31 |
#get token
|
32 |
-
if os.environ.get('
|
33 |
-
from kaggle_secrets import UserSecretsClient # type: ignore
|
34 |
-
from kaggle_web_client import BackendError # type: ignore
|
35 |
try:
|
36 |
-
login(
|
37 |
-
except
|
38 |
-
print(
|
39 |
-
|
40 |
-
This will prevent the need to login every time you run the script.
|
41 |
-
Set your secrets with the secrets add-on on the top of the screen.
|
42 |
-
''')
|
43 |
if get_token() is not None:
|
44 |
-
|
45 |
-
login
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
else:
|
48 |
#if the token is not found then prompt user to provide it:
|
49 |
tfound = "false"
|
|
|
1 |
#usually it's what is on the inside that counts, not this time. This script is a mess, but at least it works.
|
2 |
#import required modules
|
3 |
+
from huggingface_hub import login, logout, get_token, whoami, repo_exists
|
4 |
import os
|
5 |
import sys
|
6 |
import subprocess
|
|
|
29 |
os.system(osclear)
|
30 |
|
31 |
#get token
|
32 |
+
if os.environ.get('HF_TOKEN', None) is not None:
|
|
|
|
|
33 |
try:
|
34 |
+
login(get_token())
|
35 |
+
except ValueError:
|
36 |
+
print("You have an invalid token set in your environment variable HF_TOKEN. This will cause issues with this script\nRemove the variable or set it to a valid token.")
|
37 |
+
sys.exit("Exiting...")
|
|
|
|
|
|
|
38 |
if get_token() is not None:
|
39 |
+
tfound = 'true'
|
40 |
+
#if the token is found in either HF_TOKEN or cli login then log in:
|
41 |
+
try:
|
42 |
+
login(get_token())
|
43 |
+
except ValueError:
|
44 |
+
try:
|
45 |
+
login(input("API token is no longer valid. Enter your new HuggingFace token (empty to logout): "))
|
46 |
+
except:
|
47 |
+
logout()
|
48 |
+
print("Logging out... (Unable to access private or gated models)")
|
49 |
+
tfound = 'false but logged out'
|
50 |
+
time.sleep(3)
|
51 |
+
tfound = 'false'
|
52 |
else:
|
53 |
#if the token is not found then prompt user to provide it:
|
54 |
tfound = "false"
|
exl2-multi-quant-local/windows-setup.bat
CHANGED
@@ -3,15 +3,17 @@
|
|
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 |
set /p reinst="venv directory already exists. Looking to upgrade/reinstall exllama? (will reinstall python venv) (y/n) "
|
10 |
)
|
11 |
if "%reinst%"=="y" (
|
12 |
rmdir /s /q venv
|
13 |
python -m venv venv
|
14 |
-
) else (
|
15 |
exit
|
16 |
)
|
17 |
|
|
|
3 |
setlocal
|
4 |
|
5 |
REM check if "venv" subdirectory exists, if not, create one
|
6 |
+
set reinst=n
|
7 |
if not exist "venv\" (
|
8 |
python -m venv venv
|
9 |
+
set newvenv=y
|
10 |
) else (
|
11 |
set /p reinst="venv directory already exists. Looking to upgrade/reinstall exllama? (will reinstall python venv) (y/n) "
|
12 |
)
|
13 |
if "%reinst%"=="y" (
|
14 |
rmdir /s /q venv
|
15 |
python -m venv venv
|
16 |
+
) else if not "%newvenv%"=="y" (
|
17 |
exit
|
18 |
)
|
19 |
|