I want to compare the fidelity of a circuit implemented on IBMQ Santiago with the ideal circuit simulated using the statevector backend. Is there a way to do this? So far I have only seen examples where both circuits involve the statevector backend.


It is not possible to compare the statevector of a circuit run on the statevector_simulator and on a real device, like IBMQ Santiago, because the result of a job run on hardware is in the form of counts. You can see this by running the following command in qiskit:


for a specific circuit and job run on a real IBMQ device. The output you will get will be in the form of

{'counts': {...}}

where {...} is a dictionary mapping states to counts for those states.

If you run the same command on a job run on the statevector simulator, you will get

{'counts':{...}, 'statevector': array([...])}

where array([...]) is an array form of the resulting statevector, and the dictionary for counts maps that same statevector to a count of 1.

However, you can compute the hellinger fidelity, which compares counts instead of state vectors. You can read more about it here: https://qiskit.org/documentation/stubs/qiskit.quantum_info.hellinger_fidelity.html

  • $\begingroup$ Perfect, this is exactly what I was looking for! Thank you so much! $\endgroup$ – sycramore Sep 9 '20 at 21:17
  • $\begingroup$ No problem, glad to be of help :) $\endgroup$ – Winona Sep 10 '20 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.