Code Monkey home page Code Monkey logo

prototype-quantum-kernel-training's Introduction

Platform Python Qiskit Qiskit Machine Learning License Tests


Logo

Quantum Kernel Training Toolkit

Launch Demo Watch Video

Table of Contents


About This Project

The quantum kernel training (QKT) toolkit is designed to enable users to leverage quantum kernels for machine learning tasks; in particular, researchers who are interested in investigating quantum kernel training algorithms in their own research, as well as practitioners looking to explore and apply these algorithms to their machine learning applications.

We've designed this python-based toolkit around new components in Qiskit Machine Learning that provide extensible kernel training capabilities, documentation to guide users, as well as datasets and utilities for exploring and testing concepts.

This project evolved out of research at IBM Quantum on "Covariant Quantum Kernels for Data with Group Structure" [1].

Problem Statement

Given a labeled dataset, optimize a parametrized quantum kernel, according to a given loss function, for a machine learning task. For example, use quantum kernel alignment (QKA) as a loss function to iteratively adapt a quantum kernel to a classification dataset while converging to the maximum SVM margin.

Why Does It Matter?

Kernel methods are widespread in machine learning applications. A kernel is a similarity measure between data encoded in a high-dimensional feature space and can be utilized, for instance, in classification tasks with support vector machines. It is known that quantum computers can be used to replace classical feature spaces by encoding data in a quantum-enhanced feature space. Using an algorithm called the quantum kernel estimator (QKE), one can compute quantum kernels with data provided classically [2]. A key observation of this work was that a necessary condition for a computational advantage requires quantum circuits for the kernel that are hard to estimate classically. More recently, researchers proved that a quantum kernel can offer superpolynomial speedups over any classical learner on a particular learning problem based on the hardness of the discrete logarithm problem [3]. Furthermore, this particular kernel is contained in a kernel family, called covariant quantum kernels, that can be used for data with a group structure [1]. These results indicate that quantum kernels are an increasingly promising approach in machine learning problems.

However, finding a good quantum kernel for any given dataset can be a challenging problem in practice. Sometimes, structure in the data can inform this selection, other times a kernel is chosen in an ad hoc manner. Quantum Kernel Alignment (QKA) is one approach to learning a quantum kernel on a dataset. This technique iteratively adapts a parametrized quantum kernel to have high similarity to a target kernel informed from the underlying data distribution, while converging to the maximum SVM margin [1,4-6]. Such an approach has connections to the performance of the machine learning model; that is, QKA finds a quantum kernel, from a family of kernels, that yields the smallest upper bound to the generalization error. For data with an underlying group structure, covariant quantum kernels can be designed to exploit that structure. In this case, QKA provides a way to optimize the fiducial state of the quantum feature map on such a dataset. This toolkit provides examples of datasets with group structure and corresponding covariant quantum kernels. More information can be found in the background material and in Ref. [1].

To enable future research on quantum kernel training algorithms, this toolkit is extensible to methods beyond QKA. More information about the design is provided in the next section.

Overall Architecture

The structure of the QKT Toolkit is illustrated in the diagram below. New components and features were integrated into Qiskit Machine Learning to enable training of quantum kernels. The QKT Tookit is built on top of these integrations and includes local components such as datasets, feature maps, and documentation—all maintained with style, unit, and notebook tests.


New Integrations into Qiskit Machine Learning

  • QuantumKernelTrainer: (New) Class to manage quantum kernel training for a given loss function and optimizer.
  • QuantumKernel: Option to handle quantum kernels with trainable parameters.
  • KernelLoss: (New) Base class to calculate loss of quantum kernel functions over trainable parameters and input data.
  • SVCLoss(KernelLoss): (New) Class to compute loss corresponding to QKA for classification tasks.

This framework is extensible to other loss functions and optimizers and is compatible with Qiskit's existing kernel-based model interfaces (e.g., classification with QSVC and regression with QSVR).

Datasets and Feature Maps

The QKT toolkit includes datasets useful for illustrating how to train quantum kernels. Two datasets with a particular underlying group structure are provided for 7 and 10 qubits. These datasets can be used with a covariant quantum kernel to test and explore kernel training algorithms. More information about the datasets and kernel can be found in the background material.

Documentation

The QKT Toolkit includes documentation split into


How to Give Feedback

We encourage your feedback! You can share your thoughts with us by:


Contribution Guidelines

For information on how to contribute to this project, please take a look at our contribution guidelines.


Acknowledgements

This toolkit is based on the research described in [1].

The initial codebase was written by Jennifer R. Glick and Tanvi P. Gujarati.


About prototypes

Prototypes is a collaboration between developers and researchers that will give users access to prototypes from cutting-edge research in areas like quantum simulation and machine learning. These software packages are built on top of, and may eventually be integrated into the Qiskit SDK. They are a contribution as part of the Qiskit community.

Check out our blog post for more information!


References

[1] Jennifer R. Glick, Tanvi P. Gujarati, Antonio D. Córcoles, Youngseok Kim, Abhinav Kandala, Jay M. Gambetta, and Kristan Temme. Covariant quantum kernels for data with group structure. link

[2] Havlíček et al. Supervised learning with quantum-enhanced feature spaces. Nature 567, 209 (2019) link

[3] Liu et al. A rigorous and robust quantum speed-up in supervised machine learning. Nature Physics 17, 1013 (2021) link

[4] B. E. Boser et al. Proceedings of the Fifth Annual Workshop on Computational Learning Theory. COLT ’92, 144-152 link

[5] V. Vapnik. The Nature of Statistical Learning Theory. Information Science and Statistics (Springer New York, 2013) link

[6] N. Cristianini et al. Advances in Neural Information Processing Systems 14 (2001) link

Qiskit Global Summer School on Quantum Machine Learning (in particular, lectures 6.1, 6.2, and 6.3)


License

Apache License 2.0

prototype-quantum-kernel-training's People

Contributors

caleb-johnson avatar garrison avatar jenglick avatar pedrorrivero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.