Path: blob/main/notebooks/algorithms/phase-kickback.ipynb
3855 views
Phase Kickback
In this page, we'll cover a behaviour of controlled quantum gates known as "phase kickback". This interesting quantum effect is a building block in many famous quantum algorithms, including Shor's factoring algorithm, and Grover's search algorithm.
Eigenvectors
You should already be familiar with eigenvectors and eigenvalues, but if not, you can read a nice introduction here. If you are familiar, then you should recognise the eigenvector equation:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-A}{A}\…This is even simpler in quantum computing. Since all our state vectors have a magnitude of 1, our eigenvalues also need to have a magnitude of 1, i.e. . So for a quantum gate and its eigenstate , we have:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-U}{U}\…To sum up: If a gate rotates (and only rotates) all the amplitudes of a state vector by the same amount, then that state is an eigenstate of that gate.
Exploring eigenvectors
Use the widget below to see how a single-qubit gate transforms a single-qubit state. Can you work out which states are eigenstates of which gates?
Controlled gates & eigenstates
Once you're comfortable with the concept of eigenstates, we can start to think about what happens when we control these circuits on the state of another qubit. For example, we know the Z-gate acting on the state introduces a negative global phase (), let's work out what happens when we control this operation.
The controlled-Z gate
|10〉
If the control qubit is , then the behaviour is trivial; nothing happens.
|11〉
If the control qubit is , the gate introduces a global phase (note the minus sign in the image to the right), but the qubit's states are unchanged.
|1+〉
The controlled-Z gate does nothing when the control is , and introduces a negative phase when the control is . When the control qubit is in superposition, the gate changes the relative phase between the and states of the control qubit.
When the control is , and the target is , the controlled-Z gate changes the state of the control qubit, but leaves the target qubit unchanged. This effect is called "phase kickback", since the eigenvalue makes its way back into the state of the control qubit.
More generally, If we have a quantum gate , and it's eigenstate , then acting on will add a global phase as we saw above.
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-U}{U}\…If we control the operation by another qubit in a superposition of and , then this will have the effect of rotating the control qubit around the Z-axis by angle . I.e.:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-CU}{CU…In the example above, we see that the 'control' of the controlled-Z gate is actually doing a Z-rotation; something that should have only been observing the qubit has actually changed it. For this reason, you will often see the controlled-Z gate drawn as two controls.
The CNOT Gate
Let's look at the phase kickback effect with a different two-qubit gate. Since the state is an eigenstate of the X-gate, with eigenvalue , we get:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-CX}{CX…Again, in this case the phase change , so our control qubit is flipped around the Z-axis.
Worked example
Kickback with the CNOT gate (click to expand)
When we remember that the H-gate does the transformation and (and vice versa), we get the following identity:
Deutsch's problem
We've just seen that conditioning an action on the state of a qubit can actually change the state of the controlling qubit. This is a 'quantum' effect, i.e., something we don't see happen with classical bits.
In quantum computing, we want to create algorithms that classical computers can't carry out, so a good place to start is to try and reframe this effect as a problem to be solved. This way, we can prove quantum computers are at least slightly better at something than classical computers.
Deutsch's problem does exactly this. Deutsch's is a 'black box' problem; an artificial problem where we're allowed to apply a function to our bits, but we're not allowed to look at how the function works. The challenge is to discover some properties of the box by trying different inputs and outputs.
Deutsch's problem is as follows: We're given a classical, reversible function, (which we'll call as a shorthand), that acts on two bits, & . The function will leave bit alone, but may, or may not, flip bit . Deutsch's problem asks us to work out whether behaves differently depending on the value of (we'll call this "balanced" behaviour), or if it ignores and always does the same thing to ("constant" behaviour). The challenge is to do this while applying as few times as possible.
The best classical algorithm for this problem applies twice with different values of , then looks to see if the behaved differently.
Deutsch's algorithm
As you may have guessed, we can use phase kickback to create a quantum algorithm that does even better than the classical algorithm. If we put qubit in the state, and qubit in the state, then any flip conditioned on will kick back a negative relative phase, flipping qubit from to . We can then apply a H-gate to to see whether kickback occurred or not.
More info
If constant, the function can either do nothing, or flip qubit . If balanced, the function can either flip only when is , or flip only when is . You can see all four scenarios in the image below.
With both constant functions, the topmost qubit will remain unchanged (since we're not doing anything to it), and in the balanced functions, the kickback effect flips the topmost qubit from to .
This isn't the most impressive example of quantum speedup; it's very specific, and we don't find black box problems in the wild. Instead, Deutsch's problem gives us an encouraging result, and some interesting effects to explore. In the rest of this course, we'll extend this simple experiment to solve even more impressive problems, including factoring.
Exercise
Make a function, deutsch() that takes a Deutsch function as a QuantumCircuit and uses the Deutsch algorithm to solve it on a quantum simulator. Your function should return True if the Deutsch funciton is balanced, and False if it's constant.
You can use the function deutsch_problem() to create a QuantumCircuit you can use as input to your deutsch() function.
Summary
In this page, we have:
recapped the concept of eigenvalues and eigenvectors
explored the phase kickback effect and covered some specific examples
introduced Deutsch's problem as a scenario where quantum computers have an advantage over classical computers
If you forget everything else from this page, the most important thing to remember and be comfortable with is this summary of phase kickback below:
Reminder: Phase kickback
If we have a quantum gate , and it's eigenstate , then acting on will add a global phase . I.e.:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-U}{U}\…If we control the operation by another qubit in a superposition of and , then this will have the effect of rotating the control qubit around the Z-axis by angle . I.e.:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{_matrix-CU}{CU…