Part E · Lesson 4
Limits: bandwidth, concurrency, depth
A virtual machine that admits a program promises that every shared service stays below its capacity. This lesson finds the capacities of the controller itself: how many bits per microsecond the board can share, how many pulses one core can start at once, how short a pulse train can be, and how deep a link the lead still covers.
Read lessons E1 and E2 first. Lesson B2 explains the lead and the timed queues, lesson B4 the board hub.
1Capacities, not latencies
When does a schedule stop fitting the controller?
Lessons E1 and E2 measured latencies: how long one bit or one decode takes. The fault-tolerant virtual machine of the
companion paper also needs capacities. It describes a machine by a qubit capacity and six shared services: gate slots of the
control system, ancilla preparation, routing, decoders, factories and classical bandwidth. A call holds a rate
r(N, D) = ⌈1000 N / D⌉ on a service for its whole interval, concurrent calls add up, and the sum must stay below
the capacity. A request that does not fit waits. The paper shows that this is where finite services turn into runtime: lowering
one capacity of its reference machine multiplies the makespan of a feedback workload by 2.1 to 4.8.
The functions in riscq/limits.mjs build small synthetic programs, compile them, run them in the Lean model and
report where the modeled RISC-Q build stops keeping the schedule. tests/riscq-limits.test.mjs pins each result.
These functions run in Node, not in this page, so the exercises use the quantities that also appear in the runs you can open
here, or ask you to apply the formulas the tests confirm.
2Classical bandwidth of the hub
In this section: how many shared bits per µs one board can move, and what happens beyond that.
Every message between cores goes through the board hub: a published bit, a barrier
arrival, a mailbox word. Each core has a queue of eight in front of the hub, and one round-robin arbiter passes one message
per batch for the whole board (RISC-Q PutHub.md). Two theorems of the Lean model,
nextSource_waiting and nextSource_isSome, state that the arbiter grants only a core that has a
message waiting and grants one in every batch in which any core has. A publish carries one bit, so:
publishBurst(n) lets n cores publish one bit on the same batch. Alone, a bit reaches every core's board
register 23 batches after the store, the number PutHub.md documents for a 4-stage link. With eight cores the
arbiter grants them in order c0 to c7, one per batch, and bit k reaches every core after 23 + k batches.
Nothing is lost; the last bit waits seven batches.
publishFlood(n, 40) lets each of n cores publish 40 bits back to back. A core needs four batches per
publish, so one core offers a quarter of the hub's capacity.
| Cores publishing | Offered per batch | Served | Dropped | Longest wait |
|---|---|---|---|---|
| 4 | 1 | 160 of 160 | 0 | 3 batches |
| 5 | 1.25 | 196 of 200 | 4 | 39 batches |
| 8 | 2 | 220 of 320 | 100 | 63 batches |
Four cores fill the hub exactly. Beyond that the queues grow, every message waits longer, and once a queue of eight is full a new message is dropped and the model reports a fault. A real system would stall the core instead or lose the bit; either way the schedule no longer holds. The four- and eight-core rows are asserted by the tests; the five-core row comes from the same function.
The repetition round of lesson E2 runs on the x6y3 build. Read its clock from the run (machine.dspPeriodPs). How
many shared bits per µs can its hub pass at most?
In the companion paper's model of Gidney and Ekerå's machine, one magic-state factory run holds 132,496 bits/µs of classical bandwidth. How many hubs of 500 bits/µs would carry that one factory's traffic?
3Barrier fan-in
In this section: what it costs for n cores to agree on one time.
A barrier is how cores start a segment together. Each core stores its arrival
to the hub and stalls until the last arrival releases everyone with the hub's time. Arrivals pass the same arbiter as bits, and
PutHub.md adds one rule: an arrival directly behind another for the same barrier waits one more batch. Simultaneous
arrivals are therefore counted two batches apart. barrierFanIn(n) confirms it: with eight cores the arrivals are
counted 11, 13, 15, … 25 batches after the stores, and every core holds the common time after
You can see this in the repetition round. When its first segment ends, six cores arrive at the barrier within a few batches,
and the hub counts them two apart. The run's summary records the longest wait of any message at the hub in
summary.hub.maxWait and the most messages waiting at once in summary.hub.peakWaiting.
Run the repetition round with both checks fired. What is the longest any message waited at the hub?
summary.hub.maxWait.A build has nine cores, eight qubit cores and a decoder, with a 4-stage link. All nine arrive at a barrier on the same batch. After how many batches does every core hold the common time?
4Gate concurrency of one core
In this section: why many simultaneous pulses from one core delay the whole segment.
A core issues its timed writes one at a time. When a segment is a plain list of timed writes, the firmware issues it with a
loop over a table of four words per write, and the compiler budgets 32 core cycles per write (TABLE_COST in
riscq/firmware.mjs). If n pulses must open on the same batch, the first must be issued
(n − 1) · 32 batches before the usual lead. The compiler then starts the segment later by that amount, its
preroll, for every core, so that all pulses still open on one batch.
concurrency(n) confirms the formula for 1, 2, 4, 8 and 16 pulses, and that every pulse still opens on the same
batch. The run bundle records the preroll of each segment in preroll. The QCCD example qccd-rotation
shows it on a real program: each transport cycle engages 24 electrode channels, issued by three transport cores.
Run qccd-rotation and read its preroll in batches from the bundle. Using the formula above, how many
simultaneous writes does its busiest core issue?
As a capacity this is a gate-slot limit with a twist. The core can start any number of pulses on one batch, but it pays for the width of the burst in time beforehand. A virtual machine that charges a gate slot only while the gate runs does not see that cost; one that charges a burst of n gates on one core an extra (n − 1) · 32 batches does.
5Pulse rate of one channel
In this section: the shortest pulse a back-to-back train can use, and what the queue depth buys.
A channel's timed queues hold one entry more than the build's queue depth.
Each fire is issued one lead, 96 batches, before it starts. shortestTrainPulse(depth) searches for the shortest
pulse at which a train of 60 back-to-back pulses on one channel still compiles:
| Queue depth | 1 | 4 | 8 | 32 |
|---|---|---|---|---|
| Shortest pulse, 60-pulse train | 48 | 31 | 29 | 16 |
| Shortest pulse, 1,000-pulse train | 48 | 32 | 32 | 32 |
Two limits meet here. The queue must hold every write issued ahead: with depth 1, two entries must cover the 96-batch lead,
so a pulse must last at least 48 batches. With deeper queues the core's issue rate takes over: one write per 32 cycles. A
deeper queue lets the core run ahead of a train of shorter pulses for a while, so a 60-pulse train of 16-batch pulses fits at
depth 32. A train that never ends cannot borrow time forever. The second row is not in the tests; it comes from the same
function with a longer train, shortestTrainPulse(depth, 1000), and shows that the sustained limit is the issue
cost.
At queue depth 32 a 60-pulse train of 16-batch pulses fits, but a 1,000-pulse train needs 32-batch pulses. Why?
- Long trains heat the DAC.
- The core issues one timed write per 32 cycles. The queue only buffers a lead the core builds up early; a long enough train uses it up.
- The queue depth is reset after 60 entries.
- The lead grows with the number of pulses.
6Link depth and program memory
In this section: two build parameters that do not show up as a rate but bound what a core can do.
Link depth. A deeper posted link lets a board run at a higher clock or reach
farther. In this model it costs the lead twice per stage: the core's copy of the time lags by the link, and the write crosses
the link once more. deepestLink() finds that a pulse issued 96 batches ahead still opens on time with up to 13
stages. At 14, the phase, whose queue lead of 35 batches is the longest of the fired parameters, no longer lands on the same batch as the others while the window still opens, and the model
reports misaligned parameters. That the core's time lags by exactly the link depth is an assumption: RISC-Q states a
constant lag without a number. The Lean theorem land_late states the general rule: a write that misses its
margin lands late by exactly the amount it missed.
Program memory. The table loop stores four words per timed write: issue time, start time, register address, data. A core of 16,384 words keeps 320 for its classical bit table and stack, leaving 16,064. In the H2 GHZ program of QCCD Studio, 16 electrode channels on one core need 16,577 words, so the lowering splits them over three transport cores. Memory is not a service of the virtual machine, but it bounds how long a straight-line schedule one core can hold, which is why the FTQVM keeps loops symbolic.
7From limits to a machine declaration
| Limit in the model | Value | What it means for a system call |
|---|---|---|
| Hub bandwidth | 1 bit per batch per board | Capacity of the classical-bandwidth service: 500 bits/µs at 500 MHz |
| Barrier fan-in | 23 + 2(n − 1) batches | Part of every latency that crosses a segment boundary; grows with the cores involved |
| Gate concurrency | (n − 1) · 32 batches of preroll | A gate-slot cost paid before a burst, not while it runs |
| Pulse rate | 48 / 31 / 29 / 16 batches at depth 1 / 4 / 8 / 32, 60 pulses | Gate throughput per channel; sustained, one pulse per 32 batches |
| Link depth | 13 stages at a lead of 96 | A build constraint the declared latencies assume |
| Program memory | 4 words per timed write | Bounds the unrolled schedule per core |
What to remember
- The board hub passes one message per batch: 500 shared bits/µs at 500 MHz. Four publishing cores fill it; eight overflow it.
- n cores meet at a barrier in 23 + 2(n − 1) batches at a 4-stage link.
- n simultaneous pulses from one core cost (n − 1) · 32 batches of preroll before the segment.
- Deeper queues admit shorter pulses in a finite train; a sustained train is bounded by the core's issue cost.
- A lead of 96 batches covers at most 13 link stages in this model; a timed write costs four words of program memory.