From 8a42668028a3e9c4a8b6c1c88393743aef422a78 Mon Sep 17 00:00:00 2001 From: Christian Azinn Date: Sun, 14 Apr 2024 20:47:37 -0400 Subject: [PATCH] further refactors + custom scheduler --- .gitignore | 3 +- Homepage.py | 6 +- install_windows.ps1 | 133 ----------------- .../__pycache__/docs_inline.cpython-310.pyc | Bin 25833 -> 0 bytes modules/__pycache__/shared.cpython-310.pyc | Bin 711 -> 0 bytes ...Quantization.py => Convert_Safetensors.py} | 18 +-- pages/Create_IMatrix.py | 18 +++ pages/Docs.py | 9 +- pages/HF_Token_Encrypter.py | 44 +----- pages/Hugging_Face_Downloader.py | 8 +- ...ision_Quantization.py => Quantize_GGUF.py} | 29 +--- pages/Queue_GUI.py | 0 pages/Upload_Converted_To_HF.py | 58 ++------ .../HF_Token_Encrypter.cpython-310.pyc | Bin 0 -> 2810 bytes tools/key_generation.py | 17 --- util/__pycache__/find.cpython-310.pyc | Bin 0 -> 1172 bytes .../__pycache__/find_models.cpython-310.pyc | Bin modules/shared.py => util/constants.py | 11 +- {modules => util}/docs_inline.py | 0 {tools => util}/find.py | 24 ++- util/key.py | 49 +++++++ util/scheduler.py | 138 ++++++++++++++++++ 22 files changed, 274 insertions(+), 291 deletions(-) delete mode 100755 install_windows.ps1 delete mode 100644 modules/__pycache__/docs_inline.cpython-310.pyc delete mode 100644 modules/__pycache__/shared.cpython-310.pyc rename pages/{High_Precision_Quantization.py => Convert_Safetensors.py} (90%) mode change 100755 => 100644 create mode 100644 pages/Create_IMatrix.py rename pages/{Medium_Precision_Quantization.py => Quantize_GGUF.py} (89%) mode change 100755 => 100644 create mode 100644 pages/Queue_GUI.py create mode 100644 pages/__pycache__/HF_Token_Encrypter.cpython-310.pyc delete mode 100644 tools/key_generation.py create mode 100644 util/__pycache__/find.cpython-310.pyc rename {tools => util}/__pycache__/find_models.cpython-310.pyc (100%) rename modules/shared.py => util/constants.py (67%) mode change 100755 => 100644 rename {modules => util}/docs_inline.py (100%) rename {tools => util}/find.py (58%) create mode 100644 util/key.py create mode 100644 util/scheduler.py diff --git a/.gitignore b/.gitignore index e3eb99a..fa7f0c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ llama.cpp/* logs/* .vscode/* -TODO.md \ No newline at end of file +TODO.md +testing/* \ No newline at end of file diff --git a/Homepage.py b/Homepage.py index 3c02c03..0e823d6 100755 --- a/Homepage.py +++ b/Homepage.py @@ -10,9 +10,11 @@ Page("pages/Docs.py", "Docs", ":books:"), Section("Manually convert models", icon=":arrows_counterclockwise:"), Page("pages/Hugging_Face_Downloader.py", "Download model", ":inbox_tray:"), - Page("pages/High_Precision_Quantization.py", "High Precision Quantization", ":gem:"), - Page("pages/Medium_Precision_Quantization.py", "Medium Precision Quantization", ":heavy_plus_sign:" ), + Page("pages/Convert_Safetensors.py", "Convert Safetensors to High Precision", ":gem:"), + Page("pages/Create_IMatrix.py", "Create Importance Matrix", ":chart_with_upwards_trend:"), + Page("pages/Quantize_GGUF.py", "Quantize GGUF", ":heavy_plus_sign:" ), Page("pages/Upload_Converted_To_HF.py", "Upload model to HuggingFace", ":outbox_tray:"), + Page("pages/Queue_GUI.py", "Queue GUI", ":inbox_tray:"), Section("Extra Tools", icon=":toolbox:"), Page("pages/HF_Token_Encrypter.py", "Security", ":lock:"), ] diff --git a/install_windows.ps1 b/install_windows.ps1 deleted file mode 100755 index e81815d..0000000 --- a/install_windows.ps1 +++ /dev/null @@ -1,133 +0,0 @@ -# Install Python 3.10 -$pythonInstalled = Get-Command python | ForEach-Object { $_.Version.Major } - -if ($pythonInstalled -notcontains 3.10 -and $pythonInstalled -notcontains 3.11) { - winget install -e --id Python.Python.3.10 -} else { - Write-Host "Python 3.10 or 3.11 is already installed." -} - - -# Attempt to install Python requirements -# List of required libraries -$requiredLibs = @('streamlit', 'requests', 'flask', 'flask-cloudflared', 'httpx', 'litellm', 'huggingface_hub', 'asyncio', 'Pyyaml', 'APScheduler', 'cryptography', 'gradio','numpy','sentencepiece','gguf','torch','transformers' ) - -# Array to hold libraries that are not installed -$libsToInstall = @() - -foreach ($lib in $requiredLibs) { - try { - pip show $lib | Out-Null - } catch { - $libsToInstall += $lib - } -} - -if ($libsToInstall.Length -gt 0) { - Write-Host "The following libraries are not installed and will be installed:" - Write-Host ($libsToInstall -join ", ") - - # Confirmation prompt - $confirmation = Read-Host "Do you want to proceed with the installation? (Y/N)" - if ($confirmation -eq 'Y') { - try { - pip install $libsToInstall -ErrorAction Stop - } catch { - Write-Host "An error occurred during pip install. Please relog your account and try running the script again." - Exit - } - } else { - Write-Host "Installation canceled." - } -} else { - Write-Host "All required libraries are already installed." -} - - -# Function to check if CMake is installed -function Check-CMakeInstalled { - try { - $cmakeVersion = cmake --version | Select-Object -First 1 - if ($cmakeVersion -like "cmake version*") { - return $true - } - } catch { - return $false - } -} - -# Check if CMake is installed -$cmakeInstalled = Check-CMakeInstalled - -if (-not $cmakeInstalled) { - Write-Host "CMake is not installed." - - # Ask for confirmation to install CMake - $confirmation = Read-Host "Do you want to install CMake? (Y/N)" - if ($confirmation -eq 'Y') { - # Download and install CMake - $cmakeInstaller = "https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-windows-x86_64.msi" - $installerPath = "$env:TEMP\cmake_installer.msi" - Invoke-WebRequest -Uri $cmakeInstaller -OutFile $installerPath - Start-Process msiexec.exe -Wait -ArgumentList "/i $installerPath /quiet /norestart" - Write-Host "CMake has been installed." - } else { - Write-Host "Installation of CMake canceled." - } -} else { - Write-Host "CMake is already installed." -} - - -# Build llama.cpp with CMake -if (Test-Path -Path ".\llama.cpp") { - New-Item -Path ".\llama.cpp\build" -ItemType "directory" -Force - Set-Location -Path ".\llama.cpp\build" - cmake .. -DLLAMA_CUBLAS=ON - cmake --build . --config Release - Set-Location -Path "..\.." -} - -# Function to check if aria2 is installed -function Check-Aria2Installed { - try { - $aria2Version = aria2c --version | Select-Object -First 1 - if ($aria2Version -like "aria2 version*") { - return $true - } - } catch { - return $false - } -} - -# Check if aria2 is installed -$aria2Installed = Check-Aria2Installed - -if (-not $aria2Installed) { - Write-Host "aria2 is not installed." - - # Ask for confirmation to install aria2 - $confirmation = Read-Host "Do you want to install aria2? (Y/N)" - if ($confirmation -eq 'Y') { - # Install aria2 using winget - winget install --id=aria2.aria2 -e - Write-Host "aria2 has been installed." - } else { - Write-Host "Installation of aria2 canceled." - } -} else { - Write-Host "aria2 is already installed." -} - -#make non .exe copies of the .exe's -Get-ChildItem -Path ".\llama.cpp" -Recurse -Filter *.exe | ForEach-Object { - $linkName = $_.FullName -replace '\.exe$', '' - New-Item -ItemType HardLink -Path $linkName -Target $_.FullName -} - -# fix up the installs the be in the places we expect. -Get-ChildItem -Path .\llama.cpp\build\bin\Release -Filter *.exe | Where-Object { $_.Name -notin @('benchmark.exe', 'test-c.exe', 'test-grad0.exe', 'test-grammar-parser.exe', 'test-llama-grammar.exe', 'test-quantize-fns.exe', 'test-quantize-perf.exe', 'test-rope.exe', 'test-sampling.exe', 'test-tokenizer-0-falcon.exe', 'test-tokenizer-0-llama.exe', 'test-tokenizer-1-bpe.exe', 'test-tokenizer-1-llama.exe') } | ForEach-Object { Copy-Item -Path $_.FullName -Destination .\llama.cpp -Verbose; if (Test-Path ($_.FullName -replace '\.exe$','')) { New-Item -ItemType HardLink -Path (Join-Path .\llama.cpp $_.BaseName) -Target $_.FullName } } - - -# Final message -Write-Host "Thanks for installing the windows version. This OS is not fully supported with Ollama but you can still use this program to interface with an Ollama endpoint or use the quantizing features." diff --git a/modules/__pycache__/docs_inline.cpython-310.pyc b/modules/__pycache__/docs_inline.cpython-310.pyc deleted file mode 100644 index 5d772b190ba039fc56cd0d5f606fc0cf9b7e1fd9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25833 zcmd^{U5^~udEdEQt}V5_mSxF?VZ?D|76{3~bPvhpaw)=zJREYkj7jZqITYmx23gZx zJyT+JRjaC-)iU%cfQVzfL!HUI6#o!|9Q@-s_q%m>mZHR`QkV)lf`j%YS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N<8ggY&yuTp+#)45|{&41{-@Qom*tQhun%=ly-L;ugT)U`WC=O!>!BmVYh+L&U(_(o1P*z zG+~3#mX1OUG_Y-~;`HXzcSh$UNWBTE6|MufsV^Dd0k)~Nrq-GxO?jnl;dW+0M;Y{t zvLb+6ko6#l;tMLjMj2~MH!|n$nH`j zxFuQpU7wt5sm4yes_K5LN-lIvEq}<W{T=dD2)LeH0eKxOsE)5kDGM?`)`iJXFw z4Ej{yoZ~o2d6qw+Y*9^H!Rv~bu-p?~0Bw2QeV(K~gVA`STb{|Xn%>E=9mDOa|0QYw Qj_p{^yFFoB=BvDY0J}Zzga7~l diff --git a/pages/High_Precision_Quantization.py b/pages/Convert_Safetensors.py old mode 100755 new mode 100644 similarity index 90% rename from pages/High_Precision_Quantization.py rename to pages/Convert_Safetensors.py index 3dbc4b0..4f639f7 --- a/pages/High_Precision_Quantization.py +++ b/pages/Convert_Safetensors.py @@ -1,21 +1,15 @@ # IMPORTS --------------------------------------------------------------------------------- +import subprocess, threading, queue, streamlit as st from apscheduler.schedulers.background import BackgroundScheduler -import subprocess -import threading -from pathlib import Path -import streamlit as st -from modules.shared import shared -import sys -import queue -from tools.find import find_llama_models_dir +from st_pages import add_indentation +from util.constants import config +from util.find import find_llama_models_dir # FUNCTIONS --------------------------------------------------------------------------------- # Initialize queue command_queue = queue.Queue() -# Existing function definitions (find_llama_models_dir, run_command, trigger_command) - def process_queue(): if not command_queue.empty(): model_folder, out_type = command_queue.get() @@ -65,13 +59,15 @@ def trigger_command(model_folder, options): # UI CODE --------------------------------------------------------------------------------- +add_indentation() + st.title("High Precision Quantization") models_dir = Path("llama.cpp/models/") model_folders = [f.name for f in models_dir.iterdir() if f.is_dir()] if models_dir.exists() else ["Directory not found"] model_folder = st.selectbox("Select a Model Folder", model_folders) -options = {option: st.checkbox(label=option) for option in shared['checkbox_high_options']} +options = {option: st.checkbox(label=option) for option in config['checkbox_high_options']} if st.button("Run Commands"): if not any(options.values()): diff --git a/pages/Create_IMatrix.py b/pages/Create_IMatrix.py new file mode 100644 index 0000000..317be62 --- /dev/null +++ b/pages/Create_IMatrix.py @@ -0,0 +1,18 @@ +# IMPORTS --------------------------------------------------------------------------------- +import streamlit as st +from st_pages import add_indentation + +# FUNCTIONS --------------------------------------------------------------------------------- + +# UI CODE --------------------------------------------------------------------------------- + +add_indentation() + +st.title("Create Importance Matrix") + +# TODO make the entire damn page lmao +with st.expander("What is an Importance Matrix?"): + st.markdown(""" + An Importance Matrix is a tool used to determine the importance of each feature in a dataset. + It is a matrix that shows how much each feature contributes to the prediction of the target variable. + """) \ No newline at end of file diff --git a/pages/Docs.py b/pages/Docs.py index 3bfb97c..4d2c785 100644 --- a/pages/Docs.py +++ b/pages/Docs.py @@ -1,11 +1,12 @@ +# IMPORTS --------------------------------------------------------------------------------- import streamlit as st -from modules.docs_inline import docs -from st_pages import Page, add_indentation - -add_indentation() +from util.docs_inline import docs +from st_pages import add_indentation # UI CODE --------------------------------------------------------------------------------- +add_indentation() + # Create Tabs for Main Subjects tab_main = st.tabs(list(docs.keys())) diff --git a/pages/HF_Token_Encrypter.py b/pages/HF_Token_Encrypter.py index 3b874aa..1d42745 100755 --- a/pages/HF_Token_Encrypter.py +++ b/pages/HF_Token_Encrypter.py @@ -1,48 +1,12 @@ # IMPORTS --------------------------------------------------------------------------------- import streamlit as st -from cryptography.fernet import Fernet -from pathlib import Path -import subprocess - -# FUNCTIONS --------------------------------------------------------------------------------- - -# Function to load the existing key -def load_key(): - key_dir = Path('.') / '.key' - key_file_path = key_dir / 'encryption.key' - return key_file_path.read_bytes() - -# Encrypt the token -def encrypt_token(token): - key = load_key() - f = Fernet(key) - encrypted_token = f.encrypt(token.encode()) - return encrypted_token.decode() - -def generate_new_key(): - key_dir = Path('.') / '.key' - key_file_path = key_dir / 'encryption.key' - - # Check if the key file exists and delete it - if key_file_path.exists(): - try: - key_file_path.unlink() # Deletes the file - print("Existing key file deleted.") - except Exception as e: - return f"Error deleting existing key: {e}" - - # Generate new key - root_dir = Path(__file__).parent.parent - script_path = root_dir / 'tools/key_generation.py' - try: - subprocess.run(['python3', str(script_path)], check=True) - return "New private key generated successfully." - except subprocess.CalledProcessError as e: - return f"Error generating new key: {e}" - +from st_pages import add_indentation +from util.key import encrypt_token, generate_new_key # UI CODE --------------------------------------------------------------------------------- +add_indentation() + # def show_token_encrypt_page(): st.title("Token Encryption") diff --git a/pages/Hugging_Face_Downloader.py b/pages/Hugging_Face_Downloader.py index dae0fc6..7cb5b21 100755 --- a/pages/Hugging_Face_Downloader.py +++ b/pages/Hugging_Face_Downloader.py @@ -1,10 +1,8 @@ # IMPORTS --------------------------------------------------------------------------------- -import os -import subprocess -import streamlit as st -import requests +import os, subprocess, requests, streamlit as st from apscheduler.schedulers.background import BackgroundScheduler from pathlib import Path +from st_pages import add_indentation # FUNCTIONS --------------------------------------------------------------------------------- @@ -87,6 +85,8 @@ def get_files_from_repo(url, repo_name): # UI CODE --------------------------------------------------------------------------------- +add_indentation() + st.title("Model Downloader") model_name = st.text_input("Download PyTorch models from Huggingface", "Use the HuggingfaceUsername/Modelname") diff --git a/pages/Medium_Precision_Quantization.py b/pages/Quantize_GGUF.py old mode 100755 new mode 100644 similarity index 89% rename from pages/Medium_Precision_Quantization.py rename to pages/Quantize_GGUF.py index 36c5ee8..3c17964 --- a/pages/Medium_Precision_Quantization.py +++ b/pages/Quantize_GGUF.py @@ -1,11 +1,10 @@ # IMPORTS --------------------------------------------------------------------------------- -import os -import subprocess -import streamlit as st -from modules.shared import shared +import os, subprocess, sys, streamlit as st from apscheduler.schedulers.background import BackgroundScheduler from pathlib import Path -import sys +from st_pages import add_indentation +from util.constants import config +from util.find import find_llama_cpp_dir # FUNCTIONS --------------------------------------------------------------------------------- @@ -13,24 +12,6 @@ scheduler = BackgroundScheduler() scheduler.start() -def find_llama_cpp_dir(): - # Search for llama.cpp directory two levels up - current_dir = Path(__file__).resolve().parent - for _ in range(2): - current_dir = current_dir.parent - llama_cpp_dir = current_dir / 'llama.cpp' - if llama_cpp_dir.is_dir(): - return llama_cpp_dir - - # If not found, search two levels down - current_dir = Path(__file__).resolve().parent - for _ in range(2): - current_dir = current_dir / 'llama.cpp' - if current_dir.is_dir(): - return current_dir - - return None - def list_gguf_files(models_dir): gguf_files = [] if os.path.exists(models_dir): @@ -109,6 +90,8 @@ def trigger_command(modelpath, options, use_docker): # UI CODE --------------------------------------------------------------------------------- +add_indentation() + st.title("Medium Precision Quantization") models_dir = os.path.join("llama.cpp", "models") diff --git a/pages/Queue_GUI.py b/pages/Queue_GUI.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/Upload_Converted_To_HF.py b/pages/Upload_Converted_To_HF.py index 1a5027c..139e881 100755 --- a/pages/Upload_Converted_To_HF.py +++ b/pages/Upload_Converted_To_HF.py @@ -1,58 +1,25 @@ -import os -import streamlit as st +# IMPORTS --------------------------------------------------------------------------------- +import os, streamlit as st +from st_pages import add_indentation from huggingface_hub import HfApi from requests.exceptions import HTTPError -from cryptography.fernet import Fernet -from pages.HF_Token_Encrypter import load_key from pathlib import Path # Import pathlib +from util.find import find_llama_cpp_dir +from util.key import decrypt_token -# Initialize session state for selected_model -if 'selected_model' not in st.session_state: - st.session_state['selected_model'] = '' -if 'selected_files' not in st.session_state: - st.session_state['selected_files'] = [] - -# Define a function to search for the llama.cpp directory -def find_llama_cpp_dir(): - # Search for llama.cpp directory three levels up - current_dir = Path(__file__).resolve().parent - for _ in range(3): - current_dir = current_dir.parent - llama_cpp_dir = current_dir / 'llama.cpp' - models_dir = llama_cpp_dir / "models" - if llama_cpp_dir.is_dir(): - return llama_cpp_dir, models_dir - - # If not found, search two levels down - current_dir = Path(__file__).resolve().parent - for _ in range(2): - current_dir = current_dir / 'llama.cpp' - models_dir = current_dir / "models" - if current_dir.is_dir(): - return current_dir, models_dir - - return None, None +# FUNCTIONS --------------------------------------------------------------------------------- # Search for the llama.cpp directory llama_cpp_dir, models_dir = find_llama_cpp_dir() if not llama_cpp_dir: st.error("llama.cpp directory not found. Please check the file structure.") - - - ## Uses username from HF Token def get_username_from_token(token): api = HfApi() user_info = api.whoami(token=token) return user_info['name'] -# Decrypt the token -def decrypt_token(encrypted_token): - key = load_key() - f = Fernet(key) - return f.decrypt(encrypted_token.encode()).decode() - # Gathers files and uploads to HuggingFace def upload_files_to_repo(token, models_dir, repo_name, files_to_upload, readme_content, high_precision_files, medium_precision_files, selected_model): @@ -117,19 +84,14 @@ def list_model_files(models_dir, subfolder): # print("High Precision Files:", high_precision_files) # print("Medium Precision Files:", medium_precision_files) -# Old UI drawing -# def show_model_management_page(): -# Search for the llama.cpp directory -# llama_cpp_dir = find_llama_cpp_dir() -# models_dir = "llama.cpp/models/" -# high_precision_files = list_model_files(models_dir, "High-Precision-Quantization") -# medium_precision_files = list_model_files(models_dir, "Medium-Precision-Quantization") - - def get_combined_files(model): # Combine files from both precision types return high_precision_files.get(model, []) + medium_precision_files.get(model, []) +# UI CODE --------------------------------------------------------------------------------- + +add_indentation() + # Main UI st.title("Upload Converted Models to HuggingFace") diff --git a/pages/__pycache__/HF_Token_Encrypter.cpython-310.pyc b/pages/__pycache__/HF_Token_Encrypter.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a6202a8079c0f00e66ee2ee18044e50d2b8f0a54 GIT binary patch literal 2810 zcmaJ@O>g7I8Rk$FMN78q{q#0Xi$T$LAtR8Rq^CuZ7Fc+*K>%Y5J6J?Ls5EC}(WXdZ zW*996Z&5(GF8TwC0`@Vt{D%CDx#pC6PJ2n8cPP2uO%oEF@Avz8-(j(})%Ec7K7Dsm zZ+hOhG`aainEVBw{vM6+1k1b;L+@w)tTk#eT5Dy&tUYSGG0VbHh_xW=%%V|*wYCVq z^hO(^BO>%&u_3zXdoo&j%#-YLQ}nJFjn1~jrq~kwSN^Dv^=+|z#nhqft50NC_Lpq5 zgEP0pj@%Kq#O+s*owsrBwz$*KgW@hI{w8}%Z*&Jccjap5?4GzM?u*@5{=fQ8=6&&i zXr9BKzze)3*};yy_dTuWS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FiN28o2`hM3Buy&huF$!6i?F5_bH$VIrG08OL literal 0 HcmV?d00001 diff --git a/tools/key_generation.py b/tools/key_generation.py deleted file mode 100644 index 302f559..0000000 --- a/tools/key_generation.py +++ /dev/null @@ -1,17 +0,0 @@ -## Key_generation.py -from cryptography.fernet import Fernet -from pathlib import Path - -def generate_key(): - key_dir = Path('.') / '.key' - key_file_path = key_dir / 'encryption.key' - - if not key_file_path.exists(): - key = Fernet.generate_key() - if not key_dir.exists(): - key_dir.mkdir(parents=True, exist_ok=True) - with open(key_file_path, 'wb') as key_file: - key_file.write(key) - -# Call the function to ensure the key is generated when the module is imported -generate_key() diff --git a/util/__pycache__/find.cpython-310.pyc b/util/__pycache__/find.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..644ba4461572e8b2f891c884c7cb2c3c5dbaf7eb GIT binary patch literal 1172 zcma)*&rjPh6vu7HNkc}vN*g~mIP9>)dRW6BfGQ+7SDGsAfP^Y5PS>zB3APaog;OgP zj{6VbxPK|vo%%0u+1_*36{JbblAoMc`}>|hUpH?y0|MjS!S1NZ3Hga1j|b$)0ZhFM zK@v$*a!g}-%A_Z`bZ2x*j~z(|q|;cy4$@!XiG>3p!mu2e#fdrHgD|IaXT&6xZ06rO zhMdwlnKQ^ZlF$4py=6B}Nu)bv*G}oEx1}>6Hw-e~lwq}g#6V>^aEVCp>xCA}eE zx$-0#5I974$Q`*Ss$H)^ik48agz{U&3OfCVcAAQb=te~mPI4KidO<;{!zwSnOtjIJ zR|pkn1~R-5W?Z>4F3cD=OvL5zyr^0_7AhLU@u82gIbEkdZPTldxM6798rCfhWum(KX&#AG_qtEZJt2ZL zT$q-~XIMN(L<0I5u)3r7BayOdKVyG+{>-?5AKr1oV2Z zQ4_TytylJytTqV5OUI{3L+7W