# Question Related to the Qiskit Statevector_simulator, which returns the probability in a mixed form each time

"""

from qiskit.providers import aer
from qiskit.circuit import QuantumCircuit,reset

def run_circuit(circuit:QuantumCircuit)
print(circuit)
simulator = aer.Aer.get_backend("statevector_simulator")
result1 = simulator.run(circuit).result()
statevector1 = result1.get_statevector(circuit)
prob_vector1 = Statevector(statevector1).probabilities()
print(prob_vector1)
result2=simulator.run(circuit).result()
statevector2 = result2.get_statevector(circuit)
prob_vector2 = Statevector(statevector2).probabilities()
print(prob_vector2)


""" The code above is what I am using to run some simple circuit. See image of the circuit below.

As you can see from the print line after the circuit, the probability vector is mixed up for the same circuit when run twice. Does anyone know why this is happening? I am assuming it has something to do with the reset operation, as without it it works fine everytime. But is there a way to do the reset operation and not get this bug?

Thanks and Best Regards

AP

Edit with New Information:

So it seems that when you use the reset operation, rather than give you the new state vector, it causes the collapse of the state vector and gives full probability to a specific state. I have these images from the IBMQ lab that show what I am taking about. Does anyone know how to make it so that it gives the correct state vector and not the collapsed state?

Reset instruction is composed of a mid-circuit measurement followed by an X-gate conditioned on the outcome of the measurement[1]. So, the collapse is inevitable due to this implicit measurement.

In your case, you will always get two state vectors, one for the case where the state after reset is $$|00\rangle$$, and the other for the case where the state is $$|10\rangle$$. Unless, of course, you prepared the state without non-unitary operations.

In run_circuit function you are printing probabilities 2 times may be i.e it is happening you can refactor your code as follow:

def run_circuit(circuit:QuantumCircuit)
print(circuit)
simulator = aer.Aer.get_backend("statevector_simulator")
result1 = simulator.run(circuit).result()
statevector1 = result1.get_statevector(circuit)
prob_vector1 = Statevector(statevector1).probabilities()
return prob_vector1

• Hey Raghav, my question was more so with regards to why, when the circuit is run twice do I get different state vectors for the same circuit. Should the state-vector not be the same, as none of the operators are changing? and does this change have something to do with non-unitary nature of the reset qubit that I am not understanding or is it the specific implementation of the statevector_simulator that is causing this issue. Commented Aug 25, 2023 at 13:45