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

View File

@ -13,6 +13,10 @@
import zipfile
from datetime import datetime
from imports_and_globals import ensure_directory
from DownloadThread import *
from ModelInfoDialog import *
from TaskListItem import *
from QuantizationThread import *
class AutoGGUF(QMainWindow):
def __init__(self):
@ -387,11 +391,6 @@ def load_models(self):
if file.endswith(".gguf"):
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):
models_path = QFileDialog.getExistingDirectory(self, "Select Models Directory")
@ -431,8 +430,8 @@ def toggle_token_embedding_type(self, state):
self.token_embedding_type.setEnabled(state == Qt.CheckState.Checked)
def validate_quantization_inputs(self):
if not self.backend_input.text():
raise ValueError("Backend path is required")
if not self.backend_combo.currentData():
raise ValueError("No backend selected")
if not self.models_input.text():
raise ValueError("Models path is required")
if not self.output_input.text():
@ -571,7 +570,7 @@ def toggle_gpu_offload_auto(self, state):
def generate_imatrix(self):
try:
backend_path = self.backend_input.text()
backend_path = self.backend_combo.currentData()
if not os.path.exists(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')