mitiq
mitiq copied to clipboard
Expectation values of Mitiq observables are buggy if circuits have measurements
Issue Description
Expectation values of Mitiq observables are buggy if circuits have measurements It seems that change of basis rotations are applied after measurement gates instead of before.
How to Reproduce
Code Snippet
from mitiq import Observable, PauliString
from qiskit import QuantumCircuit
obs = Observable(PauliString("X"))
qiskit_circuit = QuantumCircuit(1)
qiskit_circuit.h(0)
qiskit_circuit.measure_all()
print("Input circuit")
print(qiskit_circuit)
print(f"Circuit to measure {obs}")
print(obs.measure_in(qiskit_circuit)[0])
Output
Input circuit
┌───┐ ░ ┌─┐
q: ┤ H ├─░─┤M├
└───┘ ░ └╥┘
meas: 1/═════════╩═
0
Circuit to measure X(q(0))
┌───┐┌─┐┌──────────┐┌─┐
q: ┤ H ├┤M├┤ Ry(-π/2) ├┤M├
└───┘└╥┘└──────────┘└╥┘
m_meas_0: 1/══════╩══════════════╬═
0 ║
║
m0: 1/═════════════════════╩═```
Expected Output
The Circuit to measure X(q(0)) should have a single measurement gate applied after the Ry rotation (instead of two measurement gates).
Environment Context
Use the about()
function to summarize information on operating system, python version and dependencies.
Mitiq: A Python toolkit for implementing error mitigation on quantum computers
==============================================================================
Authored by: Mitiq team, 2020 & later (https://github.com/unitaryfund/mitiq)
Mitiq Version: 0.18.0dev
Core Dependencies
-----------------
Cirq Version: 0.15.0
NumPy Version: 1.20.3
SciPy Version: 1.7.3
Optional Dependencies
---------------------
PyQuil Version: 3.0.1
Qiskit Version: 0.36.2
Braket Version: 1.26.2
Python Version: 3.7.7
Platform Info: Linux (x86_64)