Skip to content

Quantum machine learning

qadence

Maintained by pasqal-io

Digital-analog quantum programming interface

PythonPASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived)v1.11.5
qadence illustration

Resource snapshot

Category

Quantum machine learning

Stars

88

Last pushed

Dec 8, 2025Updated 9mo ago

Open issues

21

What it is

qadence is maintained by pasqal-io and sits in the Quantum machine learning lane of the open-source quantum map.

Digital-analog quantum programming interface It commonly appears alongside quantumlib-openfermion 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.

Code samples

Examples from the repository.

Differentiable Backend (examples/backends/differentiable_backend.py)
#!/bin/python
from __future__ import annotations
from pathlib import Path
import numpy as np
import sympy
import torch
DEVICE = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
torch.set_default_device(DEVICE)
torch.manual_seed(42)
from qadence import CNOT, RX, RY, Parameter, QuantumCircuit, chain, total_magnetization
from qadence.backends.pyqtorch.backend import Backend as PyQTorchBackend
from qadence.engines.torch.differentiable_backend import DifferentiableBackend
from qadence.logger import get_script_logger
logger = get_script_logger("diff_backend")
def circuit(n_qubits):
    """Helper function to make an example circuit."""
    x = Parameter("x", trainable=False)
    theta = Parameter("theta")
    fm = chain(RX(0, 3 * x), RY(1, sympy.exp(x)), RX(0, theta), RY(1, np.pi / 2))
    ansatz = CNOT(0, 1)
    block = chain(fm, ansatz)
    circ = QuantumCircuit(n_qubits, block)
    return circ
if __name__ == "__main__":
    torch.manual_seed(42)
    n_qubits = 2
    batch_size = 5
    logger.info(f"Running example {Path(__file__).name} with n_qubits = {n_qubits}")
    # Making circuit with AD
    circ = circuit(n_qubits)
    observable = total_magnetization(n_qubits=n_qubits)
    quantum_backend = PyQTorchBackend()
    diff_backend = DifferentiableBackend(quantum_backend, diff_mode="ad")
    diff_circ, diff_obs, embed, params = diff_backend.convert(circ, observable)
    # Running for some inputs
    values = {"x": torch.rand(batch_size, requires_grad=True)}
    wf = diff_backend.run(diff_circ, embed(params, values))
    expval = diff_backend.expectation(diff_circ, diff_obs, embed(params, values))
    dexpval_x = torch.autograd.grad(
        expval, values["x"], torch.ones_like(expval), create_graph=True
Horqrux Analog (examples/backends/low_level/horqrux_analog.py)
from __future__ import annotations
from pathlib import Path
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import optax
from jax import Array, jit, value_and_grad
from numpy.typing import ArrayLike
from qadence import (
    AnalogInteraction,
    AnalogRX,
    AnalogRY,
    AnalogRZ,
    FeatureParameter,
    Register,
    VariationalParameter,
    Z,
    chain,
    hamiltonian_factory,
)
from qadence.backends import backend_factory
from qadence.circuit import QuantumCircuit
from qadence.logger import get_script_logger
from qadence.types import BackendName, DiffMode
logger = get_script_logger("horqrux_analog")
N_QUBITS = 4
N_EPOCHS = 200
BACKEND_NAME = BackendName.HORQRUX
DIFF_MODE = DiffMode.AD
logger.info(f"Running example {Path(__file__).name} with n_qubits = {N_QUBITS}")
bknd = backend_factory(BACKEND_NAME, DIFF_MODE)
register = Register.line(N_QUBITS, spacing=8.0)
# The input feature phi for the circuit to learn f(x)
phi = FeatureParameter("phi")
# Feature map with a few global analog rotations
fm = chain(
    AnalogRX(phi),
    AnalogRY(2 * phi),
    AnalogRZ(3 * phi),
)
Horqrux Dqc (examples/backends/low_level/horqrux_dqc.py)
from __future__ import annotations
from pathlib import Path
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import optax
from jax import Array, grad, jit, value_and_grad, vmap
from numpy.random import uniform
from numpy.typing import ArrayLike
from qadence.backends import backend_factory
from qadence.blocks.utils import chain
from qadence.circuit import QuantumCircuit
from qadence.constructors import feature_map, hea, ising_hamiltonian
from qadence.logger import get_script_logger
from qadence.types import BackendName, BasisSet, DiffMode
logger = get_script_logger("Horqrux DQC")
N_QUBITS, DEPTH, LEARNING_RATE, N_POINTS = 4, 3, 0.01, 20
logger.info(f"Running example {Path(__file__).name} with n_qubits = {N_QUBITS}")
# building the DQC model
ansatz = hea(n_qubits=N_QUBITS, depth=DEPTH)
# the input data is encoded via a feature map
fm = feature_map(n_qubits=N_QUBITS, param="x", fm_type=BasisSet.CHEBYSHEV)
# choosing a cost function
obs = ising_hamiltonian(n_qubits=N_QUBITS)
# building the circuit and the quantum model
circ = QuantumCircuit(N_QUBITS, chain(fm, ansatz))
bknd = backend_factory(BackendName.HORQRUX, DiffMode.AD)
conv_circ, conv_obs, embedding_fn, params = bknd.convert(circ, obs)
optimizer = optax.adam(learning_rate=LEARNING_RATE)
opt_state = optimizer.init(params)
def exp_fn(params: dict[str, Array], inputs: dict[str, Array]) -> ArrayLike:
    return bknd.expectation(conv_circ, conv_obs, embedding_fn(params, inputs))
# define a problem-specific MSE loss function
# for the ODE df/dx=4x^3+x^2-2x-1/2
def loss_fn(params: dict[str, Array], x: Array) -> Array:
    def loss(x: float) -> Array:
        dfdx = grad(lambda x: exp_fn(params, {"x": x}))(x)
        ode_loss = dfdx - (4 * x**3 + x**2 - 2 * x - 0.5)
        boundary_loss = exp_fn(params, {"x": jnp.zeros_like(x)}) - jnp.ones_like(x)
        return jnp.power(ode_loss, 2) + jnp.power(boundary_loss, 2)

Plays well with

License

PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived)

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.

~784 words · about 4 min readOpen on GitHub

[!CAUTION] Qadence is currently not actively maintained!

Qadence is a Python package that provides a simple interface to build digital-analog quantum programs with tunable qubit interactions and arbitrary register topologies realizable on neutral atom devices.

For a high-level overview of Qadence features, check out our white paper.

**For more detailed information, check out the documentation.

**For any questions or comments, feel free to start a discussion. **

Linting Tests Documentation Pypi

Feature highlights

Installation guide

Qadence is available on PyPI and can be installed using pip as follows:

pip install qadence

The default, pre-installed backend for Qadence is PyQTorch, a differentiable state vector simulator for digital-analog simulation based on PyTorch. It is possible to install additional, PyTorch -based backends and the circuit visualization library using the following extras:

  • visualization: A visualization library to display quantum circuit diagrams.
  • protocols: A collection of protocols for error mitigation in Qadence.
  • libs: A collection of functionalities for graph machine learning problems build on top of Qadence.
  • pulser: The Pulser backend for composing, simulating and executing pulse sequences for neutral-atom quantum devices (experimental).

Qadence also supports a JAX engine which is currently supporting the Horqrux backend. horqrux is currently only available via the low-level API.

To install individual extras, use the following syntax (IMPORTANT Make sure to use quotes):

pip install "qadence[pulser,visualization]"

To install all available extras, simply do:

pip install "qadence[all]"

IMPORTANT Before installing qadence with the visualization extra, make sure to install the graphviz package on your system:

# For Debian-based distributions (e.g. Debian, Ubuntu)
sudo apt install graphviz

# on MacOS
brew install graphviz

# via conda
conda install python-graphviz

On Windows Linux Subsystem (WSL2) it has been reported that in some cases "wslutilities" must be installed. Please follow instructions here for your flavour. For example on Ubuntu 22.04 LTS and later you must run:

sudo add-apt-repository ppa:wslutilities/wslu
sudo apt update
sudo apt install wslu

Contributing

Before making a contribution, please review our code of conduct.

  • Submitting Issues: To submit bug reports or feature requests, please use our issue tracker.
  • Developing in qadence: To learn more about how to develop within qadence, please refer to contributing guidelines.

Setting up qadence in development mode

We recommend to use the hatch environment manager to install qadence from source:

python -m pip install hatch

# get into a shell with all the dependencies
python -m hatch shell

# run a command within the virtual environment with all the dependencies
python -m hatch run python my_script.py

WARNING hatch will not combine nicely with other environment managers such as Conda. If you still want to use Conda, install it from source using pip:

# within the Conda environment
python -m pip install -e .

Users also report problems running Hatch on Windows, we suggest using WSL2.

Citation

If you use Qadence for a publication, we kindly ask you to cite our work using the following BibTex entry:

@article{qadence2025,
author = {Seitz, Dominik and Heim, Niklas and Moutinho, João and Guichard, Roland and Abramavicius, Vytautas and Wennersteen, Aleksander and Both, Gert-Jan and Quelle, Anton and Groot, Caroline and Velikova, Gergana and Elfving, Vincent and Dagrada, Mario},
year = {2025},
month = {01},
pages = {1-14},
title = {Qadence: a differentiable interface for digital and analog programs},
volume = {PP},
journal = {IEEE Software},
doi = {10.1109/MS.2025.3536607}
}

If you use the approximate Generalized parameter shift rule for your publication, we kindly ask you to cite:

@misc{2505.18090,
Author = {Vytautas Abramavicius and Evan Philip and Kaonan Micadei and Charles Moussa and Mario Dagrada and Vincent E. Elfving and Panagiotis Barkoutsos and Roland Guichard},
Title = {Evaluation of derivatives using approximate generalized parameter shift rule},
Year = {2025},
Eprint = {arXiv:2505.18090},
}

License

Qadence is a free and open source software package, released under the PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived).

Read on GitHub

Activity

Latest release

—

Watchers

11

Python support

>=3.9

Key dependencies

numpy, torch, openfermion, sympy, sympytorch, rich, tensorboard, deepdiff, jsonschema, nevergrad, scipy, pyqtorch

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

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

Qiskit

qiskit-machine-learning

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

PythonApache-2.0

1,055 stars · Updated 4mo 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