Reset global phase of the full state simulator #35
Description
ResetAll
on all qubits and/or deallocating all qubits should reset the global phase of the full state simulator.
The global phase of the wavefunction is arbitrary and has no effect on measurements. However, it is reflected in the DumpMachine
and DumpRegister
outputs. Currently, the simulator retains a nontrivial phase even when the user goes through a sequence that should reset it to a clean state, such as deallocating all qubits. This leads to the confusing behavior that the same gate sequence applied to supposedly identical initial states (created, e.g., by releasing and allocating all qubits or applying ResetAll
to all qubits) leads to different machine states, as observed through the dumps. It also makes the process of checking dumps against reference states for debugging purposes more involved than needed.
An alternative would be to have the dump functions normalize the global phase in a consistent and reproducible way. However, this would not cover some debugging scenarios where one would like the phase between different state dumps to be consistent. (E.g.: Apply the same gate sequence to the computational basis states in order to reconstruct the full unitary matrix implemented by the computation.)