Part A · Lesson 1
The stack in one picture
A quantum program is four lines of text. A quantum computer is a cryostat, cables, converters and a dozen small processors. This lesson follows one program through every layer in between.
No background is needed. If a word is underlined with dots, hover over it for a one-sentence definition. The background chapter on qubits explains the physics this lesson only names.
1A program is not enough
What does it take to run h q[0] on a real machine?
Here is the program this lesson follows. It prepares two entangled qubits, measures one, and flips a third qubit if the measurement gave 1. Experimentalists call the last step feed-forward: a later operation depends on a result obtained during the same run.
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
bit c;
h q[0];
cx q[0], q[1];
c = measure q[0];
if (c) x q[2];
None of these lines can be executed by the qubits themselves. A transmon qubit responds to a microwave pulse of a precise frequency, amplitude, phase and duration, arriving on its drive line at a precise nanosecond. Something has to decide every one of those numbers, store them, and release them on time. That something is the control system, and most of this course is about it.
2Five layers
In this section: the five representations a program passes through, and which part of the machine owns each.
h q[0] looks like at each layer of the run in this lesson. Schematic drawing.Layers 1 to 3 are programs. They are produced by compilers and can be read like text. Layers 4 and 5 are hardware. In a laboratory you would observe them with an oscilloscope. Here they are simulated: the firmware of layer 3 runs in a model of the controller, written in Lean, and every event it produces is recorded in a trace.
3From source to hardware instructions
The first compiler step replaces each gate by operations the hardware can perform, and gives each one a start time.
On this eight-transmon machine the native operations are a 90° rotation (x90), a 180° rotation
(x), a two-qubit cz and a measure. A rotation about the Z axis is not played at
all: it becomes a virtual Z, a phase added to every later pulse of
that qubit. The hardware program lists these as frame instructions of zero duration.
The line h q[0] becomes which hardware instructions?
- One
x90pulse on qubit 0. - Frame updates (virtual Z) around one
x90pulse on qubit 0. - A
czbetween qubit 0 and itself. - Nothing: a Hadamard is free.
x90. Only the x90 plays a pulse: 36 ns
on qubit 0's drive line.Run the program. How many hardware instructions does it compile to in all?
How many of those instructions play no pulse at all?
frame instruction is a virtual Z: it changes a number in the firmware and plays
nothing. On superconducting machines most single-qubit gates are mostly phase bookkeeping.4From hardware instructions to firmware
The second step writes a program for each control core. This machine has one core per qubit, each a small RISC-V processor next to its qubit's converters. A core does not produce samples. It writes registers: which entry of a pulse table to play, and at which batch to start it. Those writes are issued about 96 batches early; lesson B2 explains why.
The machine has eight cores. How many of them issue at least one timed write in this run?
5Running it
Start the run below. The workspace shows the four program layers on the right and the machine on the left. Press Play and watch pulses leave the cores, cross the converters and reach the chip. Each step of the trace is one event: an instruction, a register write, a pulse window opening, a bit crossing between cores.
From the first event to the last, how long does the run take on the machine?
x on qubit 2, has finished and every
core has stopped. The total includes the readout, the time the bit needs to cross the board, and the scheduling
lead.6Why the last gate waits
The conditioned x q[2] cannot be scheduled with the rest. Its condition is measured by qubit 0's core,
but the pulse is played by qubit 2's core. The bit has to travel across the board first. The compiler therefore
splits the program into segments: the first ends with the measurement; the cores then meet at a
barrier, read the bit, and start the second segment together.
Why does if (c) x q[2]; start a new segment?
- Qubit 2 is busy with an earlier gate.
- Its condition is measured on another core, so the bit must reach qubit 2's core first.
- An
xpulse is longer than anx90. - The virtual Z of qubit 0 must be applied first.
What to remember
- A program passes through five layers: source, hardware instructions, firmware, controller, wires and qubits.
- Gates become calibrated pulses; Z rotations become phase bookkeeping and play nothing.
- Control cores write registers ahead of time. Converters and channels play the samples.
- A measured bit that conditions a gate on another core forces the cores to meet before that gate.
- Everything you see in the workspace is read from the trace of the firmware's execution.