In Qiskit we can't use noise models in the 'state vector_simulator' or the 'unitary simulator', hence making it impossible to compute fidelity of the output of the noisy circuit and the noiseless circuit. We can, of course, do a noisy simulation using the qasm simulator but it gives us the probability distribution instead of a state vector/density matrix. How do we compare the fidelity in this case? Or is there any other way to do it?
1 Answer
I think you can use noise in the statevector simulator.
If nevertheless you want to use the qasm simulator, you can use snapshots: https://qiskit.org/documentation/apidoc/aer_extensions.html. Although in the lack of notebooks it's a little tricky to understand how to use. You can see examples here for how to insert a snapshot in a circuit: https://github.com/Qiskit/qiskit-aer/blob/master/test/terra/reference/ref_snapshot_state.py. Then another example here for how to read the snapshot result: https://github.com/Qiskit/qiskit-aer/blob/master/test/terra/backends/qasm_simulator/qasm_snapshot.py
If you apply the snapshot on a subset of the qubits, be aware that the qubit ordering may be confusing.
-
$\begingroup$ Hey, Yael thanks. I have tried using snapshots in the qasm simulator, but it fails while I include the noise model like without the noise model it shows proper results(gives a proper state vector) but when I try to include any noise it gives the state vector with all zeros. And I think we cannot use noise models in SV sim because of its just one shot simulation, unlike the qasm simulator which in which we can do enough shots to implement the probability of the errors in the noise model. $\endgroup$ Aug 27, 2020 at 10:24
-
$\begingroup$ Discussion has moved to github.com/Qiskit/qiskit-aer/issues/908 $\endgroup$ Aug 30, 2020 at 16:18
-
1$\begingroup$ @YaelBen-Haim please edit the answer to add any new relevant information $\endgroup$– glS ♦Dec 26, 2022 at 13:31