How dan-lb/quantum_kernel_discovery_ad_hep works
Project Type & Purpose
• This project is a specialized scientific/quantum computing pipeline for anomaly detection using quantum kernel discovery techniques.
• Its purpose is to provide a means for comparing quantum-based kernels against classical methods (e.g., OC-SVM), and includes capabilities for kernel evaluation, optimization, and visualization.
• The repository indicates multiple operational modes (“CUSTOM”, “FIXED”, “CLASSICAL”) to test and compare different kernel configurations.
High-Level Components
• Entry/Execution Controller:
• Main entry point: The main.py file in the project’s root orchestrates the pipeline.
• Additional scripts (create_plot.py, prepare_plot_scores.py, plot.py) are responsible for post-run visualization and reporting.
• Core Quantum Kernel Module (darqk/core):
• Contains abstractions for quantum kernels: ansatz definitions, kernel creation logic (kernel_factory.py), kernel type, and operations.
• Kernel Core Implementation:
• Found in darqk/core_implementation (e.g., pennylane_kernel.py) – this module provides the actual implementation using specific quantum frameworks (PennyLane).
• Evaluator Module (darqk/evaluator):
• Multiple evaluators exist to measure kernel performance such as centered_kernel_alignment, covering number, Haar evaluation, spectral bias and others.
• A significant portion is dedicated to latent_ad_qml which includes custom algorithms like kernel machines (qsvm, one_class_svm) and autoencoder scripts.
• Optimizer Module (darqk/optimizer):
• Provides different strategies for enhancing the kernel’s performance. These include Bayesian optimization, greedy methods, metaheuristic, and reinforcement learning optimizers.
• Contains environment setups for “tight” and “wide” kernel environments.
• Tests:
• darqk/tests helps ensure that the kernel implementations and evaluations function as expected.
• Environment & Dependency Management:
• Files like environment.yml and requirements.txt indicate how external libraries (e.g., quantum computing libraries, PennyLane, etc.) should be integrated.
Detailed Architectural Relationships & Data Flow
• The main.py script serves as the central orchestrator. It parses command line modes and parameters (e.g., latent_dim, n_op, final_train/test) and directs the workflow.
• Starting from main.py, data acquired either from the provided external dataset or prepared locally is fed into the pipeline.
• Kernel Discovery and Construction:
• darqk/core modules abstract how kernels are built.
• The kernel_factory and operational components decide the kernel configuration and instantiate either a quantum or classical kernel.
• The core_implementation (pennylane_kernel) ties these abstractions to a concrete quantum framework.
• Evaluation Phase:
• The evaluator modules (grouped under darqk/evaluator) analyze kernel performance using numerous metrics.
• Specific latent_ad_qml evaluators incorporate both classical algorithms and quantum algorithms (like kmeans, kmedians, qsvm) enabling rigorous performance benchmarks.
• Optimization Phase:
• Optimizer modules (darqk/optimizer) interact with the kernel module to refine parameters based on different optimization strategies.
• These components may exchange data (performance metrics, error signals) back to the kernel updater.
• Visualization & Reporting:
• After evaluation/optimization, scripts for preparing plots (prepare_plot_scores.py) and for final visualizations (create_plot.py) are invoked to generate result graphs.
• Dependencies include external plotting libraries, and the visual output serves as both model comparison and debugging information.