Home

Awesome

<a href="https://github.com/unitaryfund/mitiq"><img src="https://raw.githubusercontent.com/unitaryfund/mitiq/main/docs/source/img/mitiq-logo.png" alt="Mitiq logo" width="350"/></a>

build Documentation Status codecov PyPI version arXiv Downloads Repository Unitary Fund Discord Chat

Mitiq is a Python toolkit for implementing error mitigation techniques on quantum computers.

Current quantum computers are noisy due to interactions with the environment, imperfect gate applications, state preparation and measurement errors, etc. Error mitigation seeks to reduce these effects at the software level by compiling quantum programs in clever ways.

Want to know more?

Quickstart

Installation

pip install mitiq

Example

Define a function which takes a circuit as input and returns an expectation value you want to compute, then use Mitiq to mitigate errors.

import cirq
from mitiq import zne, benchmarks


def execute(circuit, noise_level=0.005):
    """Returns Tr[ρ |0⟩⟨0|] where ρ is the state prepared by the circuit
    with depolarizing noise."""
    noisy_circuit = circuit.with_noise(cirq.depolarize(p=noise_level))
    return (
        cirq.DensityMatrixSimulator()
        .simulate(noisy_circuit)
        .final_density_matrix[0, 0]
        .real
    )


circuit = benchmarks.generate_rb_circuits(n_qubits=1, num_cliffords=50)[0]

true_value = execute(circuit, noise_level=0.0)      # Ideal quantum computer
noisy_value = execute(circuit)                      # Noisy quantum computer
zne_value = zne.execute_with_zne(circuit, execute)  # Noisy quantum computer + Mitiq

print(f"Error w/o  Mitiq: {abs((true_value - noisy_value) / true_value):.3f}")
print(f"Error w Mitiq:    {abs((true_value - zne_value) / true_value):.3f}")

Sample output:

Error w/o  Mitiq: 0.264
Error w Mitiq:    0.073

Calibration

Unsure which error mitigation technique or parameters to use? Try out the calibration module demonstrated below to help find the best parameters for your particular backend!

See our guides and examples for more explanation, techniques, and benchmarks.

Quick Tour

Error mitigation techniques

You can check out currently available quantum error mitigation techniques by calling

mitiq.qem_methods()
TechniqueDocumentationMitiq modulePaper Reference(s)
Zero-noise extrapolationZNEmitiq.zne1611.09301<br>1612.02058<br>1805.04492
Probabilistic error cancellationPECmitiq.pec1612.02058<br>1712.09271<br>1905.10135
(Variable-noise) Clifford data regressionCDRmitiq.cdr2005.10189<br>2011.01157
Digital dynamical decouplingDDDmitiq.ddd9803057<br>1807.08768
Readout-error mitigationREMmitiq.rem1907.08518 <br>2006.14044
Quantum Subspace ExpansionQSEmitiq.qse1903.05786
Robust Shadow Estimation 🚧RSEmitiq.qse2011.09636 <br> 2002.08953
Layerwise Richardson ExtrapolationLREmitiq.lre2402.04000

In addition, we also have a noise tailoring technique currently available with limited functionality:

Noise-tailoring TechniqueDocumentationMitiq modulePaper Reference(s)
Pauli Twirling 🚧PTmitiq.pt1512.01098

🚧: Technique is currently a work in progress or is untested and may have some rough edges. If you try any of these techniques and have suggestions, please open an issue!

See our roadmap for additional candidate techniques to implement. If there is a technique you are looking for, please file a feature request.

Interface

We refer to any programming language you can write quantum circuits in as a frontend, and any quantum computer / simulator you can simulate circuits in as a backend.

Supported frontends

CirqQiskitpyQuilBraketPennyLaneQibo
<a href="https://quantumai.google/cirq"><img src="https://raw.githubusercontent.com/quantumlib/Cirq/main/docs/images/Cirq_logo_color.png" alt="Cirq logo" width="65"/></a><a href="https://qiskit.org/"><img src="https://raw.githubusercontent.com/unitaryfund/mitiq/main/docs/source/img/frontend-logos/qiskit-logo.png" alt="Qiskit logo" width="85"/></a><a href="https://github.com/rigetti/pyquil"><img src="https://www.rigetti.com/uploads/Logos/logo-rigetti-gray.jpg" alt="Rigetti logo" width="75"/></a><a href="https://github.com/aws/amazon-braket-sdk-python"><img src="https://a0.awsstatic.com/libra-css/images/logos/aws_logo_smile_1200x630.png" alt="AWS logo" width="75"/></a><a href="https://pennylane.ai/"><img src="https://raw.githubusercontent.com/PennyLaneAI/pennylane/c2f96705efd4570e8755e829b11cc869b4c2287d/doc/_static/logo.png" alt="PennyLane logo" width="30"/></a><a href="https://qibo.science/"><img src="https://raw.githubusercontent.com/qiboteam/qibo/master/doc/source/_static/qibo_logo_dark.svg" alt="Qibo logo" width="60"/></a>

You can install Mitiq support for these frontends by specifying them during installation, as optional extras, along with the main package. To install Mitiq with one or more frontends, you can specify each frontend in square brackets as part of the installation command.

For example, to install Mitiq with support for Qiskit and Qibo:

pip install mitiq[qiskit,qibo]

Here is an up-to-date list of supported frontends.

Note: Currently, Cirq is a core requirement of Mitiq and is installed when you pip install mitiq (even without the optional [cirq])

Supported backends

You can use Mitiq with any backend you have access to that can interface with supported frontends.

Citing Mitiq

If you use Mitiq in your research, please reference the Mitiq whitepaper using the bibtex entry found in CITATION.bib.

A list of papers citing Mitiq can be found on Google Scholar / Semantic Scholar.

License

GNU GPL v.3.0.

Contributing

We welcome contributions to Mitiq including bug fixes, feature requests, etc. To get started, check out our contribution guidelines and/or documentation guidelines.

Contributors ✨

Thank you to all of the wonderful people that have made this project possible. Non-code contributors are also much appreciated, and are listed here. Thank you to

Contributions of any kind are welcome!