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.

1 · Source What the programmer writes: OpenQASM, a QCCD Studio program, a ZAC program, system calls. h q[0]; 2 · Hardware instructions Timed physical operations of one platform: pulses, shuttles, moves, measurements, in picoseconds. x90 q0 @0, 36 ns 3 · Firmware RV32I machine code for each control core: register writes issued ahead of their start times. sw x0, 0(x6) 4 · Controller Cores, links, timed queues, converters. Here a Lean model executes the firmware and records every event. window opens @ batch 320 5 · Wires and qubits Coax, fibre or free-space light carries each signal to the qubit, trap electrode or atom it acts on. qubit0 @ 657.003 ns
The stack. Each layer is produced from the one above it. The right column shows what 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.

What is not simulated. No quantum state. The simulator follows every classical signal to the qubit it reaches, but the qubit's response is not computed. A measurement result is an input you choose.

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?

  1. One x90 pulse on qubit 0.
  2. Frame updates (virtual Z) around one x90 pulse on qubit 0.
  3. A cz between qubit 0 and itself.
  4. Nothing: a Hadamard is free.
A Hadamard is Z(π/2) · X(π/2) · Z(π/2) up to a global phase. The two Z rotations become frame updates, and the calibration adds two more around each 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?

The compiler emits one instruction per native operation, including every frame update and the frame corrections that end a CZ. Count them in the Hardware instructions column of the workspace.

How many of those instructions play no pulse at all?

Every 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?

Only qubits 0, 1 and 2 are used, so only their cores have work. The other five run a six-word program that parks them at once.

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.

Live run of this program with the measured bit set to 1. Hover any part for what it is.

From the first event to the last, how long does the run take on the machine?

The run ends when the last pulse, the conditioned 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?

  1. Qubit 2 is busy with an earlier gate.
  2. Its condition is measured on another core, so the bit must reach qubit 2's core first.
  3. An x pulse is longer than an x90.
  4. The virtual Z of qubit 0 must be applied first.
A segment boundary is where a measured bit has to cross between cores. Lesson B4 follows that bit through the board hub, and lesson E1 measures how long it takes.

What to remember

  1. A program passes through five layers: source, hardware instructions, firmware, controller, wires and qubits.
  2. Gates become calibrated pulses; Z rotations become phase bookkeeping and play nothing.
  3. Control cores write registers ahead of time. Converters and channels play the samples.
  4. A measured bit that conditions a gate on another core forces the cores to meet before that gate.
  5. Everything you see in the workspace is read from the trace of the firmware's execution.