Hybrid stabilizers tensor-networks quantum circuit simulator
Clifford speed where the circuit is Clifford, tensor-network accuracy where it isn't.
Docs · Quick start · Paper · Issues
mpstab simulates quantum circuits with the hybrid stabilizer–Matrix Product Operator (HSMPO) formalism (Mello, Santini & Collura, PRL 2024): Clifford gates are absorbed by a stabilizer tableau, and only the non-stabilizer part is carried by an MPO. Circuits that are both highly entangled and moderately non-Clifford become tractable.
✨ Features
| 🧬 Hybrid evolution | Stabilizer and tensor-network engines combined: in-house, Stim or Quimb |
| ⚙️ Qibo native | Use Qibo circuits and observables, or mpstab as a Qibo backend |
| 🌫️ Fast noise | Pauli, coherent, non-unital, crosstalk, idle, prep and readout noise, no density matrix |
| 🛡️ Error mitigation | Clifford data regression (CDR, vnCDR) trained with HSMPO |
| 📈 Analytic gradients | Every parameter in one forward and one backward pass |
| 📊 Metrics | Fidelity lower bounds, truncation tracking, entanglement entropies |
| 🧩 Ansätze | Ready-made circuits: hardware-efficient, kicked Ising, QFT, QPE, Grover, … |
📦 Installation
pip install mpstab
Optional backends: pip install "mpstab[pytorch]" or pip install "mpstab[jax]".
From source, with optional backends and dependency groups
git clone https://github.com/MatteoRobbiati/mpstab.git && cd mpstab
uv sync # or: pip install .
| What | uv | pip |
|---|---|---|
| PyTorch backend | uv sync --extra pytorch |
pip install ".[pytorch]" |
| JAX backend | uv sync --extra jax |
pip install ".[jax]" |
| rustiq resynthesis | uv sync --group rustiq |
pip install git+https://github.com/smartiel/rustiq.git |
| Tests | uv sync --group test |
|
| Docs | uv sync --group docs |
|
| Dev tools | uv sync --group dev |
|
| Everything | uv sync --all-extras --all-groups |
Don't have uv? curl -LsSf https://astral.sh/uv/install.sh | sh
🚀 Quick start
Energy and gradient of a 40-qubit J1-J2 Heisenberg chain, built with Qibo symbols. A statevector would need 2⁴⁰ amplitudes; the HSMPO keeps the Clifford part in a tableau and only the rest in a bond-dimension-64 MPO:
from qibo.hamiltonians import SymbolicHamiltonian
from qibo.symbols import X, Y, Z
from mpstab import HSMPO
from mpstab.models.ansatze import HammingWeightPreserving
n, j1, j2 = 40, 1.0, 0.5
# H = J1 Σ σ_i·σ_{i+1} + J2 Σ σ_i·σ_{i+2}, periodic boundaries
form = sum(
j * sum(P(i) * P((i + d) % n) for P in (X, Y, Z))
for d, j in ((1, j1), (2, j2))
for i in range(n)
)
hamiltonian = SymbolicHamiltonian(form, nqubits=n)
# 2-layer Hamming-weight-preserving ansatz, simulated with MPO bond dimension ≤ 64
ansatz = HammingWeightPreserving(nqubits=n, nlayers=2)
surrogate = HSMPO(ansatz, max_bond_dimension=64)
# fidelity: lower bound on the fidelity of the truncated MPO state
energy, fidelity = surrogate.expectation(hamiltonian, return_fidelity=True)
gradient = surrogate.gradient(hamiltonian) # all 320 derivatives, one backward pass
Noisy expectation values
from qibo import gates
from mpstab import HSMPO, DepolarizingError, NoiseModel, PauliError, ReadoutError
from mpstab.models.ansatze import KickedIsing
surrogate = HSMPO(KickedIsing(nqubits=4, n_steps=1, theta_h=0.7, theta_z=0.3))
noise = NoiseModel()
noise.add(PauliError({"X": 1e-3, "Y": 1e-3, "Z": 1e-3}))
noise.add(DepolarizingError(0.01), gates.CNOT)
noise.add(ReadoutError(0.01, 0.03))
result = surrogate.noisy_expectation("ZIIZ", noise, n_samples=500, seed=0)
print(f"{result.mean:+.4f} ± {result.stderr:.4f}")
mpstab as a Qibo backend
from qibo import Circuit, construct_backend, gates
from qibo.hamiltonians import TFIM
circuit = Circuit(8)
circuit.add(gates.H(q) for q in range(8))
circuit.add(gates.RY(q, theta=0.3) for q in range(8))
circuit.add(gates.CNOT(0, 1))
hamiltonian = TFIM(nqubits=8, h=0.5, backend=construct_backend("mpstab"), dense=False)
print(hamiltonian.expectation(circuit))
More in the tutorials: noise, error mitigation, ground states, VQE gradients, state metrics, …
🛠️ Development
uv sync --all-extras --all-groups
pre-commit install # formatting on every commit
uv run pytest --cov=mpstab --cov-report=html # tests + coverage
uv run sphinx-build -b html docs docs/_build/html # docs
Contributing — PRs welcome! Fork, branch, and open a pull request with:
- ✅ tests for every new feature, all passing locally
- 📝 Google-style docstrings for public functions and classes, docs updated with the API
- ▶️ executable docs examples: every
::block indocs/**/*.rstruns as a test (pytest tests/test_rst_code_blocks.py), so each needs its own imports and variables
📖 Citation
If you use mpstab, please cite:
@misc{crognaletti2026mpstab,
title = {MPStab: an hybrid stabilizers tensor-network quantum circuit simulator},
author = {Giulio Crognaletti and Mattia Robbiano and Michele Grossi and Matteo Robbiati},
year = {2026},
eprint = {2607.24258},
archivePrefix = {arXiv},
primaryClass = {quant-ph},
url = {https://arxiv.org/abs/2607.24258},
}
👥 Authors
Matteo Robbiati · Giulio Crognaletti · Mattia Robbiano · Roberto Di Lauro · Michele Grossi
Questions or ideas? Open an issue or a discussion. Released under the Apache 2.0 License.
Metadata
Release files for mpstab 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mpstab-0.1.0.tar.gz | 3.5 MB | Without provenance | Details for mpstab-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mpstab-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mpstab-0.1.0-py3-none-any.whl |
Total release size: 3.7 MB
Release files / mpstab-0.1.0.tar.gz
| Download URL | mpstab-0.1.0.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
027058a710f2c68b29ee8e9c63db1a14d2affa69340225a2043720da19369ea1
|
|
BLAKE2b-256 checksum How to use checksums |
2a50ff0f90abbca37570c1d145266e13b6cdb1568ff37385efdea7c95c9da6d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mpstab-0.1.0-py3-none-any.whl
| Download URL | mpstab-0.1.0-py3-none-any.whl |
|---|---|
| Size | 194.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9263dfbf25610acba094b742f2521f8173d63f58c7429f05286536bcf53cecb2
|
|
BLAKE2b-256 checksum How to use checksums |
08ac2461789b3c2695b3f8868e15d1550d023296454c91c37bb80e1386cca636
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for mpstab 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.