hotfix for AutoGGUF

This commit is contained in:
leafspark 2024-08-02 21:27:05 -07:00 committed by GitHub
parent ebd8f2a59d
commit b8fccb2559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 22 deletions

View File

@ -1,29 +1,24 @@
# AutoGGUF - automated GGUF model quantizer AutoGGUF - Automated GGUF Model Quantizer
This application provides a graphical user interface for quantizing GGUF models This application provides a graphical user interface for quantizing GGUF models
using the llama.cpp library. It allows users to download different versions of using the llama.cpp library. It allows users to download different versions of
llama.cpp, manage multiple backends, and perform quantization tasks with various llama.cpp, manage multiple backends, and perform quantization tasks with various
options. options.
**Main features**: Main features:
1. Download and manage llama.cpp backends 1. Download and manage llama.cpp backends
2. Select and quantize GGUF models 2. Select and quantize GGUF models
3. Configure quantization parameters 3. Configure quantization parameters
4. Monitor system resources during quantization 4. Monitor system resources during quantization
**Usage**: Usage:
1. Install dependencies, either using the `requirements.txt` file or `pip install PyQt6 requests psutil`. Run the main.py script to start the application.
2. Run the `run.bat` script to start the application, or run the command `python src/main.py`.
**Dependencies**: Dependencies:
- PyQt6 - PyQt6
- requests - requests
- psutil - psutil
**To be implemented:** Author: leafspark
- Actual progress bar tracking Version: 1.0.0
- Download safetensors from HF and convert to unquanted GGUF License: apache-2.0
- Specify multiple KV overrides
**User interface:**
![image](https://github.com/user-attachments/assets/b1b58cba-4314-479d-a1d8-21ca0b5a8935)

View File

@ -13,6 +13,10 @@
import zipfile import zipfile
from datetime import datetime from datetime import datetime
from imports_and_globals import ensure_directory from imports_and_globals import ensure_directory
from DownloadThread import *
from ModelInfoDialog import *
from TaskListItem import *
from QuantizationThread import *
class AutoGGUF(QMainWindow): class AutoGGUF(QMainWindow):
def __init__(self): def __init__(self):
@ -387,12 +391,7 @@ def load_models(self):
if file.endswith(".gguf"): if file.endswith(".gguf"):
self.model_list.addItem(file) self.model_list.addItem(file)
def browse_backend(self):
backend_path = QFileDialog.getExistingDirectory(self, "Select Llama.cpp Backend Directory")
if backend_path:
self.backend_input.setText(os.path.abspath(backend_path))
ensure_directory(backend_path)
def browse_models(self): def browse_models(self):
models_path = QFileDialog.getExistingDirectory(self, "Select Models Directory") models_path = QFileDialog.getExistingDirectory(self, "Select Models Directory")
if models_path: if models_path:
@ -431,8 +430,8 @@ def toggle_token_embedding_type(self, state):
self.token_embedding_type.setEnabled(state == Qt.CheckState.Checked) self.token_embedding_type.setEnabled(state == Qt.CheckState.Checked)
def validate_quantization_inputs(self): def validate_quantization_inputs(self):
if not self.backend_input.text(): if not self.backend_combo.currentData():
raise ValueError("Backend path is required") raise ValueError("No backend selected")
if not self.models_input.text(): if not self.models_input.text():
raise ValueError("Models path is required") raise ValueError("Models path is required")
if not self.output_input.text(): if not self.output_input.text():
@ -571,7 +570,7 @@ def toggle_gpu_offload_auto(self, state):
def generate_imatrix(self): def generate_imatrix(self):
try: try:
backend_path = self.backend_input.text() backend_path = self.backend_combo.currentData()
if not os.path.exists(backend_path): if not os.path.exists(backend_path):
raise FileNotFoundError(f"Backend path does not exist: {backend_path}") raise FileNotFoundError(f"Backend path does not exist: {backend_path}")

35
src/modify.py Normal file
View File

@ -0,0 +1,35 @@
import re
def modify_file(filename):
with open(filename, 'r') as file:
content = file.read()
# Replace validate_quantization_inputs method
content = re.sub(
r'def validate_quantization_inputs\(self\):.*?if not self\.backend_input\.text\(\):.*?raise ValueError\("Backend path is required"\)',
'def validate_quantization_inputs(self):\n if not self.backend_combo.currentData():\n raise ValueError("No backend selected")',
content, flags=re.DOTALL
)
# Replace in generate_imatrix method
content = re.sub(
r'backend_path = self\.backend_input\.text\(\)',
'backend_path = self.backend_combo.currentData()',
content
)
# Remove browse_backend method
content = re.sub(
r'def browse_backend\(self\):.*?ensure_directory\(backend_path\)\n',
'',
content, flags=re.DOTALL
)
# Write the modified content back to the file
with open(filename, 'w') as file:
file.write(content)
print(f"File {filename} has been modified.")
# Use the function
modify_file('AutoGGUF.py')