mirror of https://github.com/leafspark/AutoGGUF
146 lines
5.6 KiB
Python
146 lines
5.6 KiB
Python
class AutoGGUF(QMainWindow):
|
|
"""
|
|
AutoGGUF is a PySide6-based graphical user interface for managing and quantizing large language models.
|
|
|
|
This class provides functionality for:
|
|
- Loading and displaying models (including sharded models)
|
|
- Quantizing models with various options
|
|
- Downloading llama.cpp releases
|
|
- Generating importance matrices
|
|
- Converting and exporting LoRA models
|
|
- Managing quantization tasks
|
|
- Converting Hugging Face models to GGUF format
|
|
|
|
The GUI allows users to interact with these features in an intuitive way, providing
|
|
options for model selection, quantization parameters, and task management.
|
|
|
|
Attributes:
|
|
logger (Logger): Instance of the Logger class for logging operations.
|
|
ram_bar (QProgressBar): Progress bar for displaying RAM usage.
|
|
cpu_label (QLabel): Label for displaying CPU usage.
|
|
gpu_monitor (GPUMonitor): Widget for monitoring GPU usage.
|
|
backend_combo (QComboBox): Dropdown for selecting the backend.
|
|
model_tree (QTreeWidget): Tree widget for displaying available models.
|
|
task_list (QListWidget): List widget for displaying ongoing tasks.
|
|
quant_threads (list): List to store active quantization threads.
|
|
|
|
The class also contains numerous UI elements for user input and interaction,
|
|
including text inputs, checkboxes, and buttons for various operations.
|
|
"""
|
|
|
|
def __init__(self):
|
|
"""
|
|
Initialize the AutoGGUF application window.
|
|
|
|
This method sets up the main window, initializes the UI components,
|
|
sets up layouts, and connects various signals to their respective slots.
|
|
It also initializes the logger, sets up the system info update timer,
|
|
and prepares the application for model management and quantization tasks.
|
|
|
|
The initialization process includes:
|
|
- Setting up the main window properties (title, icon, size)
|
|
- Creating and arranging UI components for different functionalities
|
|
- Initializing backend and release information
|
|
- Setting up file browsers for various inputs
|
|
- Preparing quantization options and task management interface
|
|
- Initializing iMatrix generation interface
|
|
- Setting up LoRA conversion and export interfaces
|
|
- Preparing Hugging Face to GGUF conversion interface
|
|
"""
|
|
|
|
def refresh_backends(self):
|
|
"""
|
|
Refresh the list of available backends.
|
|
|
|
This method scans the 'llama_bin' directory for valid backends,
|
|
updates the backend selection combo box, and enables/disables
|
|
it based on the availability of backends.
|
|
|
|
The method logs the refresh operation and the number of valid
|
|
backends found.
|
|
"""
|
|
|
|
def update_assets(self):
|
|
"""
|
|
Update the list of assets for the selected llama.cpp release.
|
|
|
|
This method clears the current asset list and populates it with
|
|
the assets of the selected release. It also updates the CUDA
|
|
option visibility based on the selected asset.
|
|
"""
|
|
|
|
def download_llama_cpp(self):
|
|
"""
|
|
Initiate the download of the selected llama.cpp release asset.
|
|
|
|
This method starts a download thread for the selected asset,
|
|
updates the UI to show download progress, and sets up signal
|
|
connections for download completion and error handling.
|
|
"""
|
|
|
|
def load_models(self):
|
|
"""
|
|
Load and display the list of available models.
|
|
|
|
This method scans the specified models directory for .gguf files,
|
|
organizes them into sharded and single models, and populates
|
|
the model tree widget with this information.
|
|
"""
|
|
|
|
def quantize_model(self):
|
|
"""
|
|
Start the quantization process for the selected model.
|
|
|
|
This method prepares the quantization command based on user-selected
|
|
options, creates a new quantization thread, and sets up a task item
|
|
in the task list to track the quantization progress.
|
|
"""
|
|
|
|
def generate_imatrix(self):
|
|
"""
|
|
Start the importance matrix generation process.
|
|
|
|
This method prepares the iMatrix generation command based on user inputs,
|
|
creates a new thread for the operation, and sets up a task item
|
|
in the task list to track the generation progress.
|
|
"""
|
|
|
|
def convert_lora(self):
|
|
"""
|
|
Start the LoRA conversion process.
|
|
|
|
This method prepares the LoRA conversion command based on user inputs,
|
|
creates a new thread for the conversion, and sets up a task item
|
|
in the task list to track the conversion progress.
|
|
"""
|
|
|
|
def export_lora(self):
|
|
"""
|
|
Start the LoRA export process.
|
|
|
|
This method prepares the LoRA export command based on user inputs,
|
|
creates a new thread for the export operation, and sets up a task item
|
|
in the task list to track the export progress.
|
|
"""
|
|
|
|
def convert_hf_to_gguf(self):
|
|
"""
|
|
Start the process of converting a Hugging Face model to GGUF format.
|
|
|
|
This method prepares the conversion command based on user inputs,
|
|
creates a new thread for the conversion, and sets up a task item
|
|
in the task list to track the conversion progress.
|
|
"""
|
|
|
|
def closeEvent(self, event: QCloseEvent):
|
|
"""
|
|
Handle the window close event.
|
|
|
|
This method is called when the user attempts to close the application.
|
|
It checks for any running tasks and prompts the user for confirmation
|
|
before closing if tasks are still in progress.
|
|
|
|
Args:
|
|
event (QCloseEvent): The close event object.
|
|
"""
|