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.
Do you use near-term quantum hardware? Have you tried Mitiq? Either way, take our survey and help make Mitiq better! bit.ly/mitiq-survey
pip install mitiq
Define a function which inputs a circuit 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: cirq.Circuit, noise_level: float = 0.001) -> float: """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: cirq.Circuit = benchmarks.generate_rb_circuits(n_qubits=1, num_cliffords=50) 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): %0.4f" %abs((true_value - noisy_value) / true_value)) print(f"Error (with Mitiq): %0.4f" %abs((true_value - zne_value) / true_value))
Error (w/o Mitiq): 0.0688 Error (with Mitiq): 0.0002
Error mitigation techniques#
Probabilistic error cancellation
(Variable-noise) Clifford data regression
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.
Note: Cirq is a core requirement of Mitiq and is installed when you
pip install mitiq.
You can use Mitiq with any backend you have access to that can interface with supported frontends.
We welcome contributions to Mitiq including bug fixes, feature requests, etc. To get started, check out our contribution guidelines and/or documentation guidelines. An up-to-date list of contributors can be found here and below.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!