7
$\begingroup$

In implementing a quantum subroutine it is important to uncompute temporary registers after use, to ensure the output state of the subroutine is not entangled with them (which would affect its behaviour).

Why is it necessary to perform this through uncomputation rather than simply setting temporary registers to zero afterwards?

$\endgroup$
2
$\begingroup$

Because all operations you carry out (besides measurement) need to be unitary and this one would not.

$\endgroup$
  • 3
    $\begingroup$ There is one thing you don't address in your answer --- why not use a measurement then, and then flip the bit if the outcome is 1? That would effectively reset the qubit. Not that this is actually a good idea, but could you elaborate your answer to describe why this is not a good idea? $\endgroup$ – Niel de Beaudrap Jan 18 at 17:28
  • $\begingroup$ @NieldeBeaudrap If you measure you collapse into one possibility. But say you want to continue applying operations on this output state (in the register of interest)... you see why this is not a good idea? $\endgroup$ – cnada Jan 18 at 18:12
  • 1
    $\begingroup$ My comment was that it is something you don't address, which is conspicuous given that 'resetting' the state is exactly what the OP asked about. While I know why it isn't a good idea, I'm not the one who asked the original question. $\endgroup$ – Niel de Beaudrap Jan 18 at 19:30
4
$\begingroup$

Uncomputing temporary registers seem to me to be the most efficient way to set temporary registers back to zero.

You can't measure these and classically flip them

  1. because a measurement of $1$ doesn't necessarily mean the state of the temporary register is $|1\rangle$

  2. because measuring would cause entangled qubits to collapse into a corresponding state so that would defeat the purpose of uncomputing temporary registers that you mentioned in your question.

And somehow implementing a circuit that detected a temporary register's state moved it back to 0 would be much more difficult than simply uncomputing the temporary register.

$\endgroup$
2
$\begingroup$

While it is definitely possible to reset registers after using them (namely, by simply measuring them) the issue is that doing so can potentially destroy interference that one might want to achieve by subsequent computations with the quantum data. Unfortunately, this is the most common case encountered in quantum algorithms, such as e.g. the computation of arithmetic in Shor's factoring and dlog algorithms or the computation of a Boolean predicate in case of Grover's search algorithm.

Concretely, assume that we have two registers, a data register $A$, an output register $B$, and an ancilla register $C$ and that half-way through the computation we arrived at an entangled state $\sum_{x} \alpha_{x} |x\rangle |f(x)\rangle |g(x)\rangle$, where the inputs are held in $A$, the function values $f(x)$ are computed into $B$, and the values $g(x)$ are results of some intermediate computations that is stored in the scratch register $C$.

If we now, instead of uncomputing the register $C$ so that it holds $|0\rangle$ (or some other state that is unentangled with registers $A$ and $B$), we decide to reset the register $C$, this will have the following detrimental effect: we will measure (at random) some value $c_0$ and the state will collapse to the superposition of all $x$ that are consistent with this measured value, so that the state will become (up to normalization):

$$ \sum_{x: g(x) = c_0} \alpha_x |x\rangle |f(x)\rangle. $$

Note that this can be vastly different from the state $\sum_x \alpha_x |x\rangle |f(x)\rangle$ that we really wanted (and actually only for constant functions $g$ yields the correct result). Indeed, if $g$ is a permutation, only a single $x$ will survive from the initial superposition! Hence, temporary/scratch registers have to be uncomputed if we want to do subsequent computations with the data in the other registers.

$\endgroup$
  • $\begingroup$ From the perspective of this answer I feel it's not explained why resetting the register necessarily entails a measurement? Can't we just reset it without looking at it? Or would the differing energy required to reset (or not) the register entangle the computation with the power supply or such like? $\endgroup$ – Sideshow Bob Jan 21 at 13:06
  • $\begingroup$ I think people are referring to measurement because they are trying to guess what you mean when you talk about resetting a qubit. In general though, changing the state of a qubit in any way (that i can think of) other than uncomputing it will cause the states of entangled qubits to change accordingly. $\endgroup$ – Malcolm Regan Jan 21 at 19:04
  • $\begingroup$ @SideshowBob, the terminology 'setting qubits to zero' required some clarification. If a qubit is part of a register that is entangled across said qubit, then it is physically not possible to reset the qubit to zero (or any other pure quantum state) without destroying the quantum state of the register. $\endgroup$ – MartinQuantum Jan 22 at 5:08
  • $\begingroup$ @SideshowBob, the terminology 'resetting a qubit' is nonetheless used, e.g., by the quantum programming community, where it means the specific procedure to a) measure the qubit (e.g. in the standard computational basis), followed by b) a flip to bring it to the zero state. See e.g. projectq.readthedocs.io/en/latest/… for ProjectQ and docs.microsoft.com/en-us/qsharp/api/prelude/… for Q#. $\endgroup$ – MartinQuantum Jan 22 at 5:09
  • $\begingroup$ Would it not be possible to set the qubit to 0 in every component of a mixed state? i.e. leaving the rest of the entanglement unbroken: the entangled bits will behave the same after the qubit of concern has been reset, but the qubit of concern will always be 0 now whatever the other bits are? $\endgroup$ – Sideshow Bob Jan 22 at 9:56

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.