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.

DAC, 8 GS/s ADC, 2 GS/s batch 320batch 321batch 322 One batch = one dspClk cycle = 2 ns on x6y3: 16 DAC samples or 4 ADC samples computed together.
Batches. The converter logic handles one batch of samples per dspClk cycle. Sample counts are those of the 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.

The machine runs at 500 MHz, and 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".

Step 355 of the feed-forward run: the window of the 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?

1,239 × 2,000 ps = 2,478,000 ps. The answer is read from the atPs of the pulse frame of h20, which the Lean model computed the same way.
A 32-bit counter. The batch-time register is 32 bits wide (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 pulseDuration÷ 2 nsWindowWindow length
X90 (90° drive)35 ns17.518 batches36 ns
X (180° drive)70 ns3535 batches70 ns
CZ tone, each qubit400 ns200200 batches400 ns
Readout tone500 ns250250 batches500 ns
Delay to the acquisition window398.57 ns199.285200 batches400 ns
Acquisition (demodulation) window656.67 ns328.335329 batches658 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.

window opens: batch 320 closes: batch 338 0 ns35 ns36 18 batches of 2 ns. The calibrated 35 ns pulse ends half a batch before the window closes.
A 35 ns pulse in an 18-batch window. Grid lines mark batches. The envelope is drawn only to show the lengths; the model does not compute samples. Schematic drawing.

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.

35 ns / 2 ns = 17.5, rounded up to 18. The pulse-table entry of the 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?

The tone lasts 250 batches. The window starts after 200 batches and lasts 329, so it ends at batch 529 of the instruction. 529 × 2 ns = 1,058 ns. Each part is rounded up separately, so the total is not ⌈(398.57 + 656.67) / 2⌉ = 528 batches.

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?

  1. Because 17.5 rounds to 18 anyway.
  2. Because the DAC needs an even number of batches.
  3. Because a window of 17 batches would end before the calibrated pulse does.
  4. Because the queue releases parameters two batches apart.
The rule is ⌈·⌉, not rounding to the nearest: a 34.1 ns pulse also gets 18 batches. A window must contain the whole calibrated pulse. Answer (a) is true of 17.5 by accident; the code uses 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?

The QCCD machine is built at 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".
Rule of thumb. To read a trace, divide picoseconds by 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

  1. A batch is one cycle of the converter clock dspClk: 2 ns, 16 DAC samples and 4 ADC samples on the transmon ring.
  2. Every time in the controller is a whole number of batches. atPs = atBatch × dspPeriodPs.
  3. Calibrated durations are rounded up to whole batches: the 35 ns x90 plays in an 18-batch, 36 ns window.
  4. The ion and atom machines here run at 100 MHz: one batch is 10 ns.
  5. The model counts batches; it does not compute the samples inside them.