Reading a Quantum Circuit
A circuit diagram is a schedule. Each flat line is one qubit's timeline. Boxes on the line are steps, done from left to right. Symbols joined by an up-and-down line act on several qubits at once. Left-to-right only sets the order when two steps share a qubit. Steps on different lines in the same column can happen together.
What does a circuit diagram actually show?
A quantum circuit diagram is the usual way to draw a quantum program. Why care? Every quantum tool, paper and machine uses these pictures. If you can read one, you can read them all.
Read it like sheet music. Time moves from left to right. Each flat line is one player in the band.
A qubit is the basic unit of quantum data. When you read it out, it always gives 0 or 1. Between steps, though, it can hold a weighted mix of both answers. That mix is described by numbers we will meet in a moment.
Each flat line is a wire. A wire is the timeline of one qubit. It is not a real cable, and nothing travels along it. The qubit stays in one place inside the machine. The wire just lists what happens to it, in order.
A gate is one step applied to one or more qubits. It is drawn as a box or symbol on the wires it touches.
The order rule is exact. On one wire, further left means earlier. Gates on different wires in the same column touch different qubits. So they can happen at the same time. The diagram only promises an order when two steps share a qubit.
Think of two cooks with a recipe card each. Cook A's card says "chop, then fry." Cook B's card says "boil." Cook A must chop before frying. But nobody cares if Cook B boils before or after Cook A chops. The example stops working in one place: cooks can pass food to each other anytime, but qubits only link up through gates drawn on both wires.
How do I read the common symbols?
A box marked H is the Hadamard gate. Give it a qubit that is surely 0. It makes an even mix of 0 and 1. This mix is called a superposition. It means the state keeps both possible answers, each with a number attached.
That attached number is the amplitude. Square it and you get the chance of seeing that answer when you measure. Unlike chances, amplitudes can be negative. That matters later, when a plus and a minus cancel out.
Picture a spinning coin on a table. While it spins, you can't say heads or tails yet. That part of the picture fits. But a spinning coin is just a hidden answer. A qubit is not. Its amplitudes can cancel, and a coin's chances never do.
Next, look for a filled dot on one wire, joined by an up-and-down line to a circle with a plus on another wire. That is the controlled-NOT, written CX. The dot marks the control, the qubit that decides. The circled plus marks the target, the qubit that gets flipped. It flips only in the part of the state where the control is 1.
A small meter symbol at the right end of a wire is a measurement. It reads the qubit and gives one ordinary bit, 0 or 1. In the Lab, every qubit is measured on its own at the end of the circuit.
Run it: the two-gate Bell circuit
Worked example: can I predict the Bell histogram by hand?
Before you run it, predict the result by hand. Both qubits start at 0. So the answer "both read 0" has amplitude 1. Every other answer has amplitude 0.
- After
Hon q0, two answers are left. Either q0 reads 0, or q0 reads 1. Each has amplitude 0.7071, which is 1/√2. Check the squares: 0.7071 × 0.7071 = 0.5. So each is a 50% answer. q1 is still 0 in both. - Then comes
CX, with q0 as control and q1 as target. Where q0 is 1, q1 flips to 1. The amplitudes just move. Now 0.7071 sits on "both 0" and 0.7071 sits on "both 1".
So here is the guess. Run it 1000 times. Each run is called a shot. About 500 shots read 00 and about 500 read 11. The mixed answers 01 and 10 never show up.
Expect the counts to wobble a little around 500. That wobble is sampling noise. It is the normal randomness of doing only so many runs. Flip a fair coin 1000 times and you rarely get exactly 500 heads. It is not a fault in the machine.
Worked example: what happens with two gates on the same wire?
Order matters on a shared wire. Take one qubit and apply H twice. Here is the rule for H:
- New amplitude of 0 = (old amp of 0 + old amp of 1) ÷ 1.4142.
- New amplitude of 1 = (old amp of 0 − old amp of 1) ÷ 1.4142.
Now do the arithmetic, one step at a time.
- Start: amplitudes (1, 0).
- First
H: ((1+0)÷1.4142, (1−0)÷1.4142) = (0.7071, 0.7071). - Second
H: ((0.7071+0.7071)÷1.4142, (0.7071−0.7071)÷1.4142) = (1.4142÷1.4142, 0) = (1, 0).
We are back to a sure thing. Every shot reads 0. Look at the minus sign in the second step. The two 0.7071 values cancel, so the chance of 1 drops to zero.
The second H undoes the first only because it works on the first one's output. That is exactly what left-to-right on one wire means. It is like turning a key one way and then back. The second turn only undoes the first because it comes after it.
What does the diagram not tell me?
The space between gates is not time in nanoseconds. The diagram only records dependencies. A dependency is a "this must happen before that" rule. Turning those rules into real timing is a later step called compiling. That step is different for every device. Each machine has its own built-in gates, its own wiring layout, and its own tuning. You can browse real devices at /hardware/qpus.
Here is the takeaway. Read a circuit as steps in order on each qubit. Find the control and the target on any symbol that spans several qubits. And remember: measurement is where amplitudes turn into ordinary bits. Build the Bell circuit yourself in the Lab. Point at each symbol as it acts.