Phase kickback: the trick behind quantum algorithms
The control flips, the target sits still. One strange move that unlocks half the algorithms in the field, built and run in Qiskit.
I bounced off quantum algorithms for a while. Every explanation reached a point where you "query the oracle" and somehow the answer materialised, and that step always felt like a magic trick I was supposed to nod along with. The function gets evaluated, and then, hand wave, the qubits know something. I could follow the code without understanding the move.
The thing that finally unlocked it was a single mechanism with an odd name: phase kickback. It is the move underneath almost every quantum algorithm, the actual mechanics of how an oracle does its work, and once I saw it clearly, half the algorithms stopped being black boxes. This post is just that one move, slowly, with the code to watch it happen.
The setup you already have
Two ideas from earlier posts come together here. From the phase post, relative phase is real information that a measurement cannot see directly but the next gate can. From the gates post, every gate is a matrix that acts on a state. Phase kickback lives exactly at the intersection: it is a way to make a gate write a phase onto a qubit you did not act on directly. To see it, you need one new idea, and it is simpler than its name.
Eigenstates, in plain words
An eigenstate of a gate is a state the gate does not really change. Apply the gate, and the state comes out pointing the same way it went in, only possibly scaled by a number. That number is called the eigenvalue. Most states get genuinely transformed by a gate, rotated to somewhere new. An eigenstate is special: the gate just multiplies it by a constant and leaves its direction alone.
The X gate has a beautiful one. The state |−⟩, which is (|0⟩ minus |1⟩) over √2, is an eigenstate of X, and its eigenvalue is minus one.
import numpy as np
minus = np.array([1, -1]) / np.sqrt(2)
X = np.array([[0, 1], [1, 0]])
print(np.allclose(X @ minus, -minus)) # True
Run it. Applying X to |−⟩ gives back exactly |−⟩, multiplied by minus one. X did not turn |−⟩ into some other state. It just stamped a minus sign on it and handed it back unchanged in direction. That minus sign, that eigenvalue, is the phase we are about to put to work. The whole trick hinges on this one fact: X leaves |−⟩ alone except for a sign.
For completeness, X has a second eigenstate, and it is the partner you would guess. The state |+⟩, which is (|0⟩ plus |1⟩) over √2, is also an eigenstate of X, but its eigenvalue is plus one: X leaves |+⟩ entirely alone, sign and all.
plus = np.array([1, 1]) / np.sqrt(2)
print(np.allclose(X @ plus, plus)) # True, eigenvalue +1
Run it. So X has two eigenstates, |+⟩ with eigenvalue plus one and |−⟩ with eigenvalue minus one, and the interesting one for us is |−⟩, because its minus one is a phase worth kicking around. |+⟩ would kick back a phase of plus one, which is no change at all, so it does nothing visible. The minus sign on |−⟩ is where the action is.
The kickback itself
Now the move. Take a controlled X gate, a CNOT, with the control qubit in |+⟩ and the target qubit in |−⟩. Your instinct, trained on classical logic, says the control acts on the target: the control decides whether the target flips. Watch what actually happens.
import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(2)
qc.h(0) # control, qubit 0, becomes |+>
qc.x(1); qc.h(1) # target, qubit 1, becomes |->
qc.cx(0, 1) # CNOT: control q0, target q1
print(np.round(Statevector(qc).data.real, 3)) # [0.5 -0.5 -0.5 0.5]
Run it. The resulting state is [0.5, minus 0.5, minus 0.5, 0.5], and the important thing is what that factors into. It is |−⟩ on the control tensored with |−⟩ on the target. The target is still |−⟩, exactly as it started, completely unchanged. But the control is no longer |+⟩. It has become |−⟩. The control qubit, the one that was supposed to be doing the acting, is the one that changed.
That is phase kickback. Here is why it happened. The CNOT only does something on the branch where the control is |1⟩, and on that branch it applies X to the target. But the target is |−⟩, and X just multiplies |−⟩ by minus one. So the |1⟩ branch of the control picks up a minus sign, while the |0⟩ branch does not. A minus sign on the |1⟩ part and not the |0⟩ part is precisely the difference between |+⟩ and |−⟩. The phase that the operation produced on the target got kicked back up onto the control, flipping it from |+⟩ to |−⟩, while the target sailed through untouched.
What happens without the eigenstate
To see that the eigenstate is the essential ingredient, change one thing and watch the trick fail. Keep the control in |+⟩, but put the target in plain |0⟩ instead of |−⟩, and apply the same CNOT.
qc = QuantumCircuit(2)
qc.h(0) # control still |+>
qc.cx(0, 1) # target is plain |0>, not an eigenstate
print(np.round(Statevector(qc).data.real, 3)) # [0.707 0 0 0.707]
Run it. Now you get [0.707, 0, 0, 0.707], which is the Bell state, the entangled pair from the entanglement post. The control and target are now tangled together, and neither has a clean separate state at all. No phase got kicked cleanly onto the control, because |0⟩ is not an eigenstate of X, so X genuinely transforms it rather than just stamping a phase. The whole magic of kickback depended on the target being an eigenstate, a state the gate leaves alone except for a phase. Feed the gate a non eigenstate and instead of a clean phase kick you get entanglement, a messier outcome where the action does not move cleanly upstream. The eigenstate is not a detail. It is the entire reason the phase comes back clean.
Control and target are just labels
One more thing that deepened my understanding, and it is a little unsettling at first. We keep saying control and target as though the control acts on the target. Kickback already strained that, since the control changed and the target did not. The controlled Z gate, which flips the sign only when both qubits are 1, strains it further: it is completely symmetric between the two qubits.
import numpy as np
CZ = np.diag([1, 1, 1, -1])
print(np.allclose(CZ, CZ.T)) # True: the matrix is its own transpose
Run it. The controlled Z matrix is its own transpose, and more to the point it is diagonal, with the minus sign sitting only on |11⟩, so swapping which qubit you call the control and which the target changes nothing whatsoever. There is no fact of the matter about which one is in charge. The labels control and target are a convenience we impose, a story we tell about a two qubit gate, not something the physics distinguishes. Once you accept that, kickback stops being paradoxical. Of course the phase can land on the control, because control was never a privileged role to begin with. A two qubit gate acts on both qubits together, and which one ends up carrying a phase depends on their states, not on our names for them.
Why this is the whole trick
Sit with the strangeness for a second, because it is the good kind. We applied a gate whose entire job is to flip the target, and the target did not flip. Instead the control changed. The target acted like a catalyst: it made a phase happen, that phase landed on the control, and the target came out exactly as it went in. The action moved upstream, from target to control, carried by a phase.
And it generalises. This was X and |−⟩, but the same thing works for any controlled gate whose target sits in an eigenstate of that gate. The eigenvalue, the phase the gate would stamp on its eigenstate, gets kicked back onto the control instead. Put the target in the right eigenstate and you have turned a controlled operation into a phase writer for the control qubits. That is a tool, and it is the tool the algorithms are built from.
Any phase, not just a sign
The minus one from X is the simplest case, but the eigenvalue that gets kicked back can be any phase at all, and that generality is where some of the deepest algorithms live. A phase gate like S or T has |1⟩ as an eigenstate, with an eigenvalue that is not minus one but a partial turn, i for S, a forty five degree turn for T, exactly the rotations from the complex numbers post. A controlled version of such a gate, with its target in |1⟩, kicks that partial phase back onto the control rather than a mere sign. So kickback is not limited to flipping signs. It can write any rotation onto the control, as finely as you like.
This is the seed of one of the most important quantum algorithms, phase estimation, which I will not unpack here but which is worth naming. The whole idea of phase estimation is to take a gate whose eigenvalue encodes some quantity you want, kick that eigenvalue back onto a register of control qubits as a precise phase, and then use interference to read the phase out as a number. It is kickback turned into a measuring instrument: a way to extract the hidden phase of a gate, digit by digit. The famous applications, including the quantum part of Shor's factoring algorithm, are built on exactly this. You do not need the details yet. You just need to see that the simple sign flip you watched above is the small end of a tool that scales all the way up to the algorithms that make quantum computing genuinely powerful.
How oracles actually use it
Here is where it connects to the magic I could not follow. A quantum oracle is a gate that encodes some function f. Run it naively and it just computes f into an output qubit, which is not obviously useful. But arrange things with phase kickback, put the output qubit (the ancilla) into the |−⟩ eigenstate, and something much better happens. The oracle's answer, the value of f, becomes a phase stamped onto the input qubits, the controls, instead of a value sitting in the output. The function's output has been kicked back into the phases of the inputs.
Now recall the engine from the phase post. A relative phase is invisible to a direct measurement, but a layer of Hadamards turns relative phases into measurable outcomes through interference. So the full pattern is two beats. Phase kickback is the write: the oracle stamps f's answer into the phases of the input register, where no measurement can yet see it. Interference is the read: a Hadamard layer converts those phases into a definite outcome you can measure. Kickback writes the answer into phase, interference reads it back out. That two beat rhythm, write into phase then interfere to read, is the skeleton of nearly every quantum algorithm there is.
What this unlocks
I am not going to run a full algorithm here, because each one deserves its own post and the next several are exactly that. But every one of them is this move, dressed differently. Deutsch and Jozsa use kickback to detect a global property of a function in one query. Bernstein and Vazirani use it to read an entire hidden string in one shot. Grover uses it to mark a search target with a phase so interference can amplify it. Different problems, different oracles, same underlying trick: get the answer into a phase with kickback, then interfere to read it. Once you see that the oracle is not magic but a phase writer, the algorithms stop being black boxes and start being variations on a theme you understand.
A quick test before you move on
Close this and answer in your own words.
What is an eigenstate of a gate, and what is the eigenvalue? If you cannot say a state the gate leaves pointing the same way, scaled by a number, reread the eigenstate section, because everything rests on it.
In the kickback circuit, the CNOT was supposed to flip the target. What actually changed, and why? If your answer is not the control changed, because the minus sign from X on the |−⟩ target landed on the control's |1⟩ branch, reread the kickback section.
And what are the two beats of nearly every quantum algorithm? If write the answer into phase, then interfere to read it is not roughly your answer, revisit the oracle section, because that rhythm is the thing the next posts all run on.
Where I am learning it
Free. Phase kickback is covered in the IBM Quantum learning materials and in most serious algorithm introductions, though I found that no description landed until I built the two qubit circuit above and watched the control flip when it had no business flipping. The eigenstate idea comes straight from linear algebra, so the 3Blue1Brown series helps if eigenvectors are hazy. As always, I keep this as a tiny runnable circuit, because a phase that I have only read about getting kicked back does not convince me until I have watched the control qubit change on my own machine.
The magic was one move
For a while, oracles were the wall I could not get past, the place every algorithm explanation turned into hand waving. The wall turned out to be one mechanism. A gate acts on a target that happens to be an eigenstate, the eigenvalue's phase kicks back onto the control, and suddenly a function's answer is sitting in the phases of qubits the gate never touched, ready for interference to read out.
That is phase kickback, and it is the engine room of quantum algorithms. Not a different trick for each one, but the same move, reused. The next few posts are all this, applied to actual algorithms, and they will feel less like magic and more like recognition. You have already seen the move. The rest is watching it work.