Often one has an input quantum circuit and wants to calculate the expectation value of an observable, for example the Pauli ZZ. This can be done using the qiskit Estimator class. But for some applications it is useful to see the circuits used to measure the observable (so the input circuit + some gates + measurement in the Z basis). This can be done with the deprecated BackendEstimator:
from qiskit_aer import AerSimulator
from qiskit.circuit import QuantumCircuit
from qiskit.primitives import BackendEstimatorV2, BackendEstimator
from qiskit.circuit import QuantumCircuit
from qiskit_aer.primitives import EstimatorV2
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc.barrier()
backend=AerSimulator()
estimator = BackendEstimator(backend=backend)
r = estimator.run( [qc]*3, ['ZZ', 'ZX', 'ZY'] )
r.result()
for idx in range(3):
print(estimator.transpiled_circuits[idx].draw())
Can we make the functionality to generate circuits to measure the expectation values of observables available in qiskit? (either in the new BackendEstimatorV2, or some other class?
What should we add?
Often one has an input quantum circuit and wants to calculate the expectation value of an observable, for example the Pauli
ZZ
. This can be done using the qiskitEstimator
class. But for some applications it is useful to see the circuits used to measure the observable (so the input circuit + some gates + measurement in the Z basis). This can be done with the deprecatedBackendEstimator
:The corresponding functionality in the new
BackendEstimatorV2
is only available using private methods. See https://qiskit.slack.com/archives/C7SS31917/p1725017108211119?thread_ts=1725012640.985669&cid=C7SS31917Can we make the functionality to generate circuits to measure the expectation values of observables available in qiskit? (either in the new
BackendEstimatorV2
, or some other class?