Part A · Lesson 2
Batches: the clock everything runs on
A converter takes billions of samples per second. The logic that feeds it runs a hundred times slower and handles many samples at once. That slower clock cycle is the unit of every time in the controller. This lesson shows how long it is and what it does to the durations of your gates.
You should have read A1 · The stack in one picture. The background chapter on classical control systems explains digital-to-analog converters and clocks in more depth.
1One clock for the converters
Why does a controller not count time in nanoseconds?
On the eight-transmon ring of lesson A1, each drive line ends at a DAC
that produces 8 billion samples per second (8 GS/s). The returning readout signal is sampled by an
ADC at 2 GS/s. These are the rates of the RISC-Q x6y3 build
that this machine copies (RISC-Q,
software/configs/x6y3.json, as listed in docs/riscq-controller.md).
FPGA logic cannot run at 8 GHz. It runs at a much lower clock and computes many samples in parallel in each
cycle. RISC-Q calls that clock dspClk. On x6y3 it runs at 500 MHz, so one cycle lasts 2 ns.
In that time the DAC needs 8 GS/s × 2 ns = 16 samples and the ADC delivers 2 GS/s × 2 ns = 4 samples.
One dspClk cycle, with its 16 DAC samples or 4 ADC samples, is called a batch.
Every time inside the controller is a whole number of batches: when a pulse starts, how long it lasts, what the
cores read from their clock register, when a bit reaches another core. The model states this in
riscq/soc.mjs as BATCH_SIZE = 16, ADC_BATCH = 4, and the Lean model counts its time in
the same unit.
x6y3 build. Schematic drawing.Run the feed-forward program of lesson A1. How long is one batch on this machine, in nanoseconds? The run bundle
states it as machine.dspPeriodPs; the workspace shows it above the hardware instructions.
dspPeriodPs = round(10¹² / dsp_freq_hz) = 2,000 ps
(socSpec in riscq/soc.mjs). The header of the Hardware instructions layer reads
"one batch is 2 ns".2Batches and picoseconds
In this section: the two clocks every trace frame carries, and how to convert between them.
Each event of the trace is a frame.
A frame carries its time twice: atBatch, the batch count since reset, and atPs, the same
time in picoseconds. The second is always computed from the first:
atPs = atBatch × dspPeriodPs
The Lean model only knows batches. The picoseconds are there for people and for the wire delays of lesson A3, which are not whole batches. The workspace prints both: the step card on the stage reads, for example, "batch 320 · 640 ns".
x90 on qubit 0 opens at batch 320, which is 640 ns.The conditioned x on qubit 2 (hardware instruction h20) opens its window at batch 1,239.
At what time is that, in nanoseconds?
atPs of the pulse frame of
h20, which the Lean model computed the same way.QControl/RiscQ/Timing.lean).
The theorem land_exact of lesson B2 assumes a start time less than 2³¹ batches
ahead. At 2 ns per batch that is about 4.3 s, far longer than any program in this course.3Durations become whole batches
The calibration says a 90° pulse lasts 35 ns. How long is its window in the run?
The pulses of the ring come from RISC-Q's example calibration for x6y3
(examples/cal-config-x6y3.yaml, extracted to validation/riscq/x6y3-calibration.json).
It states durations in seconds. A pulse window, however, opens on one batch and closes on another. The
superconducting lowering converts each duration with
batches = ⌈ duration / batch length ⌉
(span in riscq/platforms/superconducting.mjs). The table shows the durations of qubit 0.
| Calibrated pulse | Duration | ÷ 2 ns | Window | Window length |
|---|---|---|---|---|
| X90 (90° drive) | 35 ns | 17.5 | 18 batches | 36 ns |
| X (180° drive) | 70 ns | 35 | 35 batches | 70 ns |
| CZ tone, each qubit | 400 ns | 200 | 200 batches | 400 ns |
| Readout tone | 500 ns | 250 | 250 batches | 500 ns |
| Delay to the acquisition window | 398.57 ns | 199.285 | 200 batches | 400 ns |
| Acquisition (demodulation) window | 656.67 ns | 328.335 | 329 batches | 658 ns |
Only three of these are not already whole batches, and the 35 ns pulse is the one you meet most. Its window is 18
batches, 36 ns. That is why the Hardware instructions layer lists every x90 with a duration of
36 ns, and why the frame update after it (h3) starts at 36 ns, not 35.
In the run, how many batches does the window of the first x90 on qubit 0 last? Read the
dur field of its pulse frame (step 355) in the workspace's Step inspector.
x90 stores this
duration as the code 18, and the window closes at batch 320 + 18 = 338.The measure instruction (h19) plays the readout tone and, after the delay, opens the
acquisition window. Its duration covers whichever ends later. Using the table, how long is the hardware
instruction, in nanoseconds?
4Why round up
A window can only open and close on batch boundaries, so a 35 ns pulse needs either 17 or 18 batches. Seventeen batches end at 34 ns: the last nanosecond of the calibrated pulse would have no window to play in. Eighteen batches hold the whole pulse, at the price of half a batch that the next operation on this qubit must wait for.
The pulse table stores the duration in batches. What the 16 samples of each batch contain is the business of the
envelope memory and the pulse generator, and the model does not compute them. It records the codes of each window
and draws a waveform from them for display only (docs/riscq-controller.md, "Not modeled"). The 1 ns
difference is therefore a statement about scheduling, not about what the qubit sees.
Why does the lowering round a 35 ns pulse up to 18 batches instead of to the nearest whole number?
- Because 17.5 rounds to 18 anyway.
- Because the DAC needs an even number of batches.
- Because a window of 17 batches would end before the calibrated pulse does.
- Because the queue releases parameters two batches apart.
Math.ceil.5Other machines, other batches
The batch length is a property of the build, not of the controller design. The trapped-ion and neutral-atom machines
of this simulator are built at 100 MHz (DSP_HZ in riscq/platforms/qccd.mjs and
riscq/platforms/neutral.mjs), a model choice: one batch is 10 ns there. Their operations are much
slower than transmon pulses. A single-ion rotation of 5 µs, the standard value from Pino et al.
(Nature 592, 209 (2021), arXiv:2003.01293, Table III), is 500
batches. One QCCD Studio time unit of shuttling, which this model takes as 63.8 µs (58 µs from the same paper's
Table II plus 10%, see riscq/standards.mjs), is 6,380 batches.
A coarser batch makes the rounding of section 3 coarser too: every duration is a multiple of 10 ns. For operations of microseconds that costs little. The lead of 96 batches of lesson B2 is also counted in batches, so on these machines the firmware works 960 ns ahead instead of 192 ns.
Run the trapped-ion example qccd-ghz3 (GHZ state of three ions). How long is one batch there, in
nanoseconds?
dsp_freq_hz = 100e6, so dspPeriodPs is
10,000 ps. Open it in the workspace and the Hardware instructions header reads "one batch is 10 ns".dspPeriodPs to get batches
and multiply to go back. Before you compare two durations, convert both to batches and round each up where the
lowering does.What to remember
- A batch is one cycle of the converter clock dspClk: 2 ns, 16 DAC samples and 4 ADC samples on the transmon ring.
- Every time in the controller is a whole number of batches.
atPs = atBatch × dspPeriodPs. - Calibrated durations are rounded up to whole batches: the 35 ns
x90plays in an 18-batch, 36 ns window. - The ion and atom machines here run at 100 MHz: one batch is 10 ns.
- The model counts batches; it does not compute the samples inside them.