Since the QX emulator is an emulator that tries to mimic real quantum systems there is no direct way to reset a qubit to ground state, without affecting the full system of entangled qubits, just like in real systems.

There is one trick that you can use when you use the QX Emulator: You can use the `prep_z`

within an algorithm. What this will do is the following: This will perform a measurement on that qubit, but will force it that the result is the ground state! This means that for an entangled system, the other qubit will also be affected.

Two important notes about this:

- This trick can only be used on an emulator backend, not on real hardware
- You have to be aware of the consequences on the system state, which we explain below

An example makes clear how this works. Let’s consider this algorithm (A):

` ````
version 1.0
qubits 2
x q[0]
x q[1]
prep_z q[0]
```

q[0] | ||||
---|---|---|---|---|

q[1] |

When you run this algorithm, you will get the following outcome with 100% probability:

- Qubit0 = 0 (ground state
- Qubit1 = 1 (excited state)

which you would expect.

Now try this algorithm (B):

` ````
version 1.0
qubits 2
H q[0]
cnot q[0],q[1]
prep_z q[0]
```

q[0] | ||||
---|---|---|---|---|

q[1] |

When you run this algorithm (use number of shots = 1 again) you will get the following outcome with 100% probability:

- Qubit0 = 0 (ground state)
- Qubit1 = 0 (ground state)

This is because the system was entangled and the result of a measurement on qubit0 (which is what prep_z does) will force the other qubit to go to the same measurement outcome. But because prep_z is not a true measurement, but a measurement forcing qubit0 to ground state, qubit1 will also go to ground state.

Although this feature in QX emulator can be handy, you have to use it with care, because this can never be done on real quantum hardware.