Table of Contents
Fetching ...

sQUlearn -- A Python Library for Quantum Machine Learning

David A. Kreplin, Moritz Willmann, Jan Schnabel, Frederic Rapp, Manuel Hagelüken, Marco Roth

Abstract

sQUlearn introduces a user-friendly, NISQ-ready Python library for quantum machine learning (QML), designed for seamless integration with classical machine learning tools like scikit-learn. The library's dual-layer architecture serves both QML researchers and practitioners, enabling efficient prototyping, experimentation, and pipelining. sQUlearn provides a comprehensive toolset that includes both quantum kernel methods and quantum neural networks, along with features like customizable data encoding strategies, automated execution handling, and specialized kernel regularization techniques. By focusing on NISQ-compatibility and end-to-end automation, sQUlearn aims to bridge the gap between current quantum computing capabilities and practical machine learning applications. The library provides substantial flexibility, enabling quick transitions between the underlying quantum frameworks Qiskit and PennyLane, as well as between simulation and running on actual hardware.

sQUlearn -- A Python Library for Quantum Machine Learning

Abstract

sQUlearn introduces a user-friendly, NISQ-ready Python library for quantum machine learning (QML), designed for seamless integration with classical machine learning tools like scikit-learn. The library's dual-layer architecture serves both QML researchers and practitioners, enabling efficient prototyping, experimentation, and pipelining. sQUlearn provides a comprehensive toolset that includes both quantum kernel methods and quantum neural networks, along with features like customizable data encoding strategies, automated execution handling, and specialized kernel regularization techniques. By focusing on NISQ-compatibility and end-to-end automation, sQUlearn aims to bridge the gap between current quantum computing capabilities and practical machine learning applications. The library provides substantial flexibility, enabling quick transitions between the underlying quantum frameworks Qiskit and PennyLane, as well as between simulation and running on actual hardware.
Paper Structure (20 sections, 10 equations, 8 figures)

This paper contains 20 sections, 10 equations, 8 figures.

Figures (8)

  • Figure 1: Schematic overview of sQUlearn. sQUlearn offers scikit-learn compatible high-level interfaces for various kernel methods and QNNs. They build on top of the low-level interfaces of the QNN engine (Sec. \ref{['sec:qnn_engine']}) and the quantum kernel engine (Sec. \ref{['sec:kernel_engine']}). The executor is used to run experiments on simulated and real backends in the Qiskit or PennyLane environment.
  • Figure 2: Prototypical architecture of a QNN. Classical data is embedded into quantum states using encoding operations $S_l(\mathbf{x})$. Parameterized quantum operations $W_l(\theta)$ are then applied to process the data. Often, this structure is repeated for several layers. After the final layer, a measurement is performed and an expectation value $f$ is calculated, see Eq. \ref{['eq:quantum-model-general']}. The parameters $\pmb{\theta}$ are then optimized using a classical optimizer to minimize a suitable empirical loss function $\mathcal{L}$, Eq. \ref{['eq:empirical_loss']}. The figure is adapted freely from Ref. Mangini2021.
  • Figure 3: Schematic overview of the QNN engine in sQUlearn: The central box in the diagram represents the high-level implementation that features the training and evaluation of QNNs with the scikit-learn interface. The elements surrounding the box are essential for initializing the high-level methods, and include the encoding circuit, output observables, the Executor, the loss function, and the optimizer. Within the high-level implementation, the encoding circuit, observables, and the Executor are utilized to set-up the low-level QNN implementation which leverages either PennyLane or Qiskit depending on the chosen backend of the Executor. This low-level implementation is also available as a standalone object in sQUlearn, and it is responsible for the evaluation of the QNN and its derivatives. Utilizing the scikit-learn RegressorMixin or ClassifierMixin creates the sQUlearn high-level QNN implementations, namely QNNRegressor and QNNClassifier, designed for regression and classification tasks.
  • Figure 4: Schematic illustration of the function principle of quantum kernel methods, which can be formally embedded into the rich mathematical framework of conventional kernel theory. Data points $\mathbf{x}$ are mapped to the quantum Hilbert space by encoding them into a quantum state $\ket{\psi(\mathbf{x})}$. Access to the quantum Hilbert space is granted by measurements. Left: In quantum mechanics, the straightforward way to express measurements is given by the Hilbert-Schmidt inner product. Quantum kernels which are defined using this fidelity-type metric are thus referred to as fidelity quantum kernels (FQKs). For pure states this reduces to Eq. \ref{['eq:fidelity_quantum_kernel']}. Right: When projecting the quantum states to an approximate classical representation using, e.g., reduced physical observables this gives rise to a family of projected quantum kernels (PQKs). One of the simplest forms of defining PQKs is to measure $k$-particle reduced density matrices, cf. Eq. \ref{['eq:kRDM']}, and process the result with a classical kernel function $h$. The resulting quantum kernel matrices (either FQK or PQK) are subsequently passed to a classical kernel algorithm such as a SVM or a GP.
  • Figure 5: Schematic overview of sQUlearn's quantum kernel engine implementation including all dependencies on other program parts. To define a quantum kernel, the user first needs to provide an encoding circuit object which is used for embedding data into the quantum Hilbert space (cf. Info Box \ref{['box:encoding_circuits']}). After defining a corresponding circuit, one can either define a FidelityKernel, or a ProjectedQuantumKernel. The latter makes use of the QNN Engine, cf. Fig. \ref{['fig:qnn_design']} and the Observables class. With the Executor the Gram matrix can be evaluated on real quantum computers or a simulator backend with automatic session handling. If the encoding circuit also contains trainable parameters, sQUlearn provides optimization routines to optionally optimize these parameters. With the kernel object created, or stored in from a previous calculation the high level methods (blue) can be initialized and executed (cf. Info Box \ref{['box:kernels']}).
  • ...and 3 more figures