Skip to content

Quantum machine learning

qiskit-machine-learning

Maintained by Qiskit

An open-source library built on Qiskit for quantum machine learning tasks at scale on quantum hardware and classical simulators

PythonApache-2.0
qiskit-machine-learning illustration

Resource snapshot

Category

Quantum machine learning

Stars

1.1K

Last pushed

May 7, 2026Updated 4mo ago

Open issues

27

Quickstart

Get running in a few lines.

Quickstart
from qiskit.circuit.library import n_local, zz_feature_map
from qiskit_machine_learning.optimizers import COBYLA
from qiskit_machine_learning.utils import algorithm_globals

from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.datasets import ad_hoc_data

seed = 1376
algorithm_globals.random_seed = seed

# Use ad hoc data set for training and test data
feature_dim = 2  # dimension of each data point
training_size = 20
test_size = 10

# training features, training labels, test features, test labels as np.ndarray,
# one hot encoding for labels
training_features, training_labels, test_features, test_labels = ad_hoc_data(
    training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3
)

feature_map = zz_feature_map(feature_dimension=feature_dim, reps=2, entanglement="linear")
ansatz = n_local(feature_map.num_qubits, ["ry", "rz"], "cz", reps=3)
vqc = VQC(
    feature_map=feature_map,
    ansatz=ansatz,
    optimizer=COBYLA(maxiter=100),
)
vqc.fit(training_features, training_labels)

score = vqc.score(test_features, test_labels)
print(f"Testing accuracy: {score:0.2f}")

What it is

qiskit-machine-learning is maintained by Qiskit and sits in the Quantum machine learning lane of the open-source quantum map.

An open-source library built on Qiskit for quantum machine learning tasks at scale on quantum hardware and classical simulators It commonly appears alongside qiskit-qiskit in example workflows.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Researchers and practitioners experimenting with quantum machine learning, variational models, and differentiable circuit stacks.

What you can build or learn

  • Learn how the project connects model training ideas to quantum primitives.
  • Inspect the assumptions behind differentiable or ML-oriented workflows.
  • Compare how serious or experimental the ML story really is.

Plays well with

License

Apache-2.0

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~1,126 words · about 5 min readOpen on GitHub

Qiskit Machine Learning

Build Status Coverage Status Total downloads

What is Qiskit Machine Learning?

Qiskit Machine Learning introduces fundamental computational building blocks, such as Quantum Kernels and Quantum Neural Networks, used in various applications including classification and regression.

This library is part of the Qiskit Community ecosystem, a collection of high-level libraries that are based on the Qiskit software development kit. As of version 0.7, Qiskit Machine Learning is co-maintained by IBM and the Hartree Centre, part of the UK Science and Technologies Facilities Council (STFC).

[!NOTE] A description of the library structure, features, and domain-specific applications, can be found

The Qiskit Machine Learning framework aims to be:

  • User-friendly, allowing users to quickly and easily prototype quantum machine learning models without the need of extensive quantum computing knowledge.
  • Flexible, providing tools and functionalities to conduct proofs-of-concept and innovative research in quantum machine learning for both beginners and experts.
  • Extensible, facilitating the integration of new cutting-edge features leveraging Qiskit's architectures, patterns and related services.

What are the main features of Qiskit Machine Learning?

Kernel-based methods

The FidelityQuantumKernel class uses the Fidelity algorithm. It computes kernel matrices for datasets and can be combined with a Quantum Support Vector Classifier (QSVC) or a Quantum Support Vector Regressor (QSVR) to solve classification or regression problems respectively. It is also compatible with classical kernel-based machine learning algorithms.

Quantum Neural Networks (QNNs)

Qiskit Machine Learning defines a generic interface for neural networks, implemented by two core (derived) primitives:

  • EstimatorQNN: Leverages the Estimator primitive, combining parametrized quantum circuits with quantum mechanical observables. The output is the expected value of the observable.

  • SamplerQNN: Leverages the Sampler primitive, translating bit-string counts into the desired outputs.

To train and use neural networks, Qiskit Machine Learning provides learning algorithms such as the NeuralNetworkClassifier and NeuralNetworkRegressor. Finally, built on these, the Variational Quantum Classifier (VQC) and the Variational Quantum Regressor (VQR) take a feature map and an ansatz to construct the underlying QNN automatically using high-level syntax.

Integration with PyTorch

The TorchConnector integrates QNNs with PyTorch. Thanks to the gradient algorithms in Qiskit Machine Learning, this includes automatic differentiation. The overall gradients computed by PyTorch during the backpropagation take into account quantum neural networks, too. The flexible design also allows the building of connectors to other packages or accelerated libraries.

Installation and documentation

We encourage installing Qiskit Machine Learning via the pip tool, a Python package manager.

pip install qiskit-machine-learning

pip will install all dependencies automatically, so that you will always have the most recent stable version.

If you want to work instead on the very latest work-in-progress versions of Qiskit Machine Learning, either to try features ahead of their official release or if you want to contribute to the library, then you can install from source. For more details on how to do so and much more, follow the instructions in the documentation.

Optional Installs

  • PyTorch may be installed either using command pip install 'qiskit-machine-learning[torch]' to install the package or refer to PyTorch getting started guide. When PyTorch is installed, the TorchConnector facilitates the combination of hybrid quantum-classical neural networks.

  • Sparse may be installed using command pip install 'qiskit-machine-learning[sparse]' to install the package. Sparse is built on top of NumPy and scipy.sparse, and enables efficient operations of sparse arrays and tensors. Refer to the Sparse installation guide for further details.

  • NLopt is required for the global optimizers. NLopt can be installed manually with pip install nlopt on Windows and Linux platforms, or with brew install nlopt on MacOS using the Homebrew package manager. For more information, refer to the installation guide.


Creating your first Qiskit Machine Learning program

Now that Qiskit Machine Learning is installed, it's time to begin working with the machine learning modules. Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to train and test samples from a data set to see how accurately the test set can be classified.

from qiskit.circuit.library import n_local, zz_feature_map
from qiskit_machine_learning.optimizers import COBYLA
from qiskit_machine_learning.utils import algorithm_globals

from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.datasets import ad_hoc_data

seed = 1376
algorithm_globals.random_seed = seed

# Use ad hoc data set for training and test data
feature_dim = 2  # dimension of each data point
training_size = 20
test_size = 10

# training features, training labels, test features, test labels as np.ndarray,
# one hot encoding for labels
training_features, training_labels, test_features, test_labels = ad_hoc_data(
    training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3
)

feature_map = zz_feature_map(feature_dimension=feature_dim, reps=2, entanglement="linear")
ansatz = n_local(feature_map.num_qubits, ["ry", "rz"], "cz", reps=3)
vqc = VQC(
    feature_map=feature_map,
    ansatz=ansatz,
    optimizer=COBYLA(maxiter=100),
)
vqc.fit(training_features, training_labels)

score = vqc.score(test_features, test_labels)
print(f"Testing accuracy: {score:0.2f}")

More examples

Learning materials can be found in the Tutorials section of the documentation. These notebooks will walk you step by step through different tasks and are designed to be hackable, making them a great place to start.

Another good place to learn the fundamentals of quantum machine learning is the Quantum Machine Learning notebooks from the original Qiskit Textbook (now archived). The notebooks are convenient for beginners who are eager to learn quantum machine learning from scratch, as well as understand the background and theory behind algorithms in Qiskit Machine Learning. The notebooks cover a variety of topics to build an understanding of parameterized circuits, data encoding, variational algorithms and more, with the ultimate goal of building and training quantum ML models for supervised and unsupervised learning. The Textbook notebooks are complementary to the tutorials of this library. These tutorials focus emphasize the algorithms, while the Textbook notebooks explain in more detail the underlying fundamental quantum information principles of quantum machine learning.


How can I contribute?

If you'd like to contribute to Qiskit, please take a look at our contribution guidelines. This project adheres to the Qiskit code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please join the Qiskit Slack community and use the #qiskit-machine-learning channel for discussions and short questions. For questions that are more suited for a forum, you can use the Qiskit tag in Stack Overflow.

How can I cite Qiskit Machine Learning?

If you use Qiskit Machine Learning in your work, please cite the "overview" ArXiv paper to support the continued development and visibility of the library. The BibTeX citation handle can be found in the CITATION.bib file.

Humans behind Qiskit Machine Learning

Qiskit Machine Learning was inspired, authored and brought about by the collective work of a team of researchers and software engineers. This library continues to grow with the help and work of many people, who contribute to the project at different levels.

License

This project uses the Apache License 2.0.

Read on GitHub

Activity

Latest release

—

Watchers

19

Python support

—

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

quantumlib

Cirq

Python framework for creating, editing, and running Noisy Intermediate-Scale Quantum (NISQ) circuits.

PythonApache-2.0Flagship

4,971 stars · Updated 3mo ago

XanaduAI

pennylane

PennyLane is an open-source quantum software platform for quantum computing, quantum machine learning, and quantum chemistry.

PythonApache-2.0FlagshipQtangl relevant

3,229 stars · Updated 3mo ago

jpzwolak

QFlow-lite

Machine learning code for quantum dots

Jupyter Notebook

40 stars · Updated 4y ago

QISKit

qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

PythonApache-2.0FlagshipQtangl relevant

7,412 stars · Updated 3mo ago

artiste-qb-net

Quantum_Edward

Python tools for supervised learning by Quantum Neural Networks

PythonMIT

51 stars · Updated 7y ago

Microsoft

QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing

Jupyter NotebookMITFlagshipArchive

4,862 stars · Updated 2y ago