Describe Your Control System#

This page covers how to describe control electronics to the compiler: each controller, its lines, its clocks, its waveform memory and its limits. It is for people who own the control electronics.

Fields#

A control system is made of four kinds of object. The API reference has the full text of each: Quantum system API for Controller and ControlSystem, Classical Calls API for Link, and Controller Backends API for the lines and UpdateBus.

pulse.Controller#

One controller: what it can run, its wiring and its processors. Every limit is in its own clock cycles.

Field

Default

What to put there

clock_ghz

None

The controller’s clock; None is the program clock. It must be a whole-cycle ratio of the program clock.

cycles_per_timestep

1

The controller starts and times operations only every this many of its own cycles.

instruction_cycles

1

The controller issues one instruction per this many cycles: two operations on one line start exactly this far apart, or at least instruction_cycles + min_idle_cycles apart.

min_idle_cycles

0

The least the controller idles between two operations on one line.

min_pulse_cycles

0

The shortest drive or readout its lines play; 0 is no limit.

max_pulse_cycles

None

The longest drive or readout its lines play; None is no limit. It may not be below min_pulse_cycles.

sample_rate_ghz

None

The rate its lines play samples at; None is one per cycle of its clock. Its ratio to the clock may be a fraction.

waveform_memory_samples

None

What one waveform memory holds, in samples at sample_rate_ghz.

max_frequencies_per_line

None

The distinct frequencies one line plays over a program.

max_amplitude

None

The largest magnitude of a sample its lines play; None is no limit.

detectors

{}

The detector reading each qudit.

detector_recovery_cycles

0

A readout holds its detector for its duration plus this many cycles.

feedback_latency_cycles

0

The least time from the end of a readout to the start of any operation that depends on its outcome.

max_pulses

None

The most drives and readouts one program holds; None is no limit. A controller that supports "loop" holds the body of a rolled loop once; for any other, every iteration counts.

max_fine_delay_ns

0.0

The longest delay, below one grid step, each line can add to its output, a time or a number of ns; 0 is none.

alignment_tolerance_cycles

0

How far its pulses may land from where they are meant to be on other controllers, and, without fine delay, how far a line’s delay may be from a whole number of grid steps.

supports_timeouts

True

Whether the controller can stop waiting for an answer after a timeout.

max_instructions

None

The operations one program may hold, as the kernel traces them; None is no limit.

max_program_duration

None

The longest program the controller runs, a time or a number of ns; None is no limit.

waveform_memory

"per_line"

"per_line" (each line has a memory of waveform_memory_samples) or "shared" (one memory serves every line).

persistent_frames

False

Whether the tone state of each tone, its frequency and phase, persists from one shot to the next.

blocks_on_calls

False

Whether the controller plays nothing while one of its classical calls is out.

drive_lines

()

The drive lines it plays, each a DriveLine or a bare carrier index for an undelayed line. The only controller of a system that lists none plays every line.

readout_lines

()

The readout lines it plays, each a ReadoutLine or a bare carrier index for an undelayed line.

update_buses

()

The groups of its lines whose updates share one bus (UpdateBus), which carries one update at a time.

space_updates

False

Whether compiling spaces the updates on its update buses instead of refusing them.

peer_latency_cycles

0

The time an outcome this controller reads takes to reach another controller, in this controller’s own cycles: one number for every receiver, or a mapping from the receiving controller’s index.

clock_skew_cycles

0

How far its clock may be from the system’s.

supports

None

Its capabilities; None is everything. A program that needs one it lacks fails to compile.

backend

None

The controller backend that lowers its programs, by entry-point name.

model

None

With version, identifies the description it was made from.

version

None

With model, identifies the description it was made from.

processors

()

Its classical processors (Processor): the classical functions it computes itself, and their limits.

pulse.ControlSystem#

The controllers of one QPU and what connects them.

Field

Default

What to put there

controllers

()

The controllers of the QPU. A system without controllers states only its links, lanes, reference clock and line delays, and nothing checks what its controllers can run.

links

{}

The links to classical services, by name. A classical function’s link= names one or gives its id, its position; the first is link 0, the default.

max_concurrent_drives

None

The most drives the system plays at once, counted on every controller. None: the rcp schedules play at most 4 at once, and nothing else checks them.

max_concurrent_readouts

None

The most readouts the system plays at once, counted on every controller. None: the rcp schedules play at most 2 at once, and nothing else checks them.

line_switch_penalty_cycles

0

Under the rcp and alap_rcp schedules, a lane stays busy for this many cycles after each drive or readout on it, so the next one on that lane starts at least that much later. asap and alap do not use it.

reference_clock_ghz

None

A clock every controller locks to, if they share one: each controller’s clock must be a whole multiple of it.

DriveLine and ReadoutLine#

A line of a controller, from cudaq_pulse.controller, in the controller’s drive_lines or readout_lines. A bare carrier index there is an undelayed line.

Field

Default

What to put there

qudits

required

The qudit the line drives or reads out, by carrier index, or a list of them for a line that reaches several.

delay_ns

0.0

Its calibrated delay, a time or a number of ns.

max_concurrent_tones

1

The most tones it plays at once; at most the qudits it reaches.

broadcast

False

Whether its one tone reaches all its qudits at once: for a DriveLine given a list of qudits. A ReadoutLine given a list of qudits refuses broadcast=True with an UnsupportedError.

frequency_hz

None

The frequency a broadcast line states for its tone; it may be left out when the line’s qudits share one frequency. Only with broadcast=True.

UpdateBus#

A bus that carries the updates of a group of a controller’s lines one at a time, from cudaq_pulse.controller, in the controller’s update_buses.

Field

Default

What to put there

drive_lines

()

The drive lines on the bus, by carrier index.

readout_lines

()

The readout lines on the bus, by carrier index.

cycles_per_update

1

The cycles of the controller’s clock one update holds the bus for.

What your electronics must provide#

For programs that call classical code during a shot (see Call Classical Code During a Shot):

A controller that runs these programs needs, beyond its pulse sequencer: a way to send a request on a link at a scheduled time and to receive the answer into registers; branching on an answer; frequency, phase and amplitude updates from an answer; and, for variable waits, a wait whose length comes from a register, after which the rest of the segment is released together. The emulation artifact gives every event its segment and its time from the segment’s start for that purpose. A segment holds the lines of its barrier’s timeline, so segments of different timelines move independently: an segment’s shift adds to that of the segment it follows, which is the one before it unless the segment names another in after.

A worked program#

This controller has a 1 GHz clock, starts an instruction every 4 cycles, and needs 200 cycles to act on a measurement:

import cudaq_pulse as pulse
from cudaq_pulse.quantum_systems import PhysicalQudit

box = pulse.Controller(
    clock_ghz=1.0,
    cycles_per_timestep=4,
    sample_rate_ghz=1.0,
    min_pulse_cycles=16,
    waveform_memory_samples=16384,
    max_frequencies_per_line=4,
    max_amplitude=1.0,
    feedback_latency_cycles=200,
)

A control system holds the controllers. One controller that lists no lines plays every line. The control system belongs to the quantum system, here one qubit at 5 GHz:

control_system = pulse.ControlSystem(controllers=[box])

qudit = PhysicalQudit(
    index=0,
    frequency_hz=5.0e9,
    t1_us=50.0,
    t2_star_us=30.0,
    anharmonicity_hz=-2.0e8,
)
system = pulse.quantum_system(
    name="one-qubit",
    qudits={0: qudit},
    clock_ghz=1.0,
    control_system=control_system,
)
print(len(control_system.controllers), "controller")
print("clock:", system.clock_ghz, "GHz")

Output

1 controller
clock: 1.0 GHz

The kernel is an active reset: a π pulse, a readout, and a second π pulse only if the qubit read 1:

@pulse.kernel
def active_reset(
    qudit,
    flip_duration,
    flip_sigma,
    flip_amplitude: float,
    readout_duration,
):
    drive_line = get_drive_line(qudit)
    readout_line = get_readout_line(qudit)
    flip = gaussian(flip_duration, flip_amplitude, flip_sigma)

    drive(drive_line, flip)
    sync(drive_line, readout_line)
    outcome = readout(readout_line, square(readout_duration, 0.05))

    sync(drive_line, readout_line)
    if outcome:
        drive(drive_line, flip)

lower compiles the call for the quantum system of its qudit, control system included, and schedules it. The conditional pulse starts 200 cycles after the readout ends, the controller’s feedback latency:

scheduled = active_reset.lower(
    system.qudits[0],
    flip_duration=40 * pulse.ns,
    flip_sigma=10 * pulse.ns,
    flip_amplitude=0.5,
    readout_duration=200 * pulse.ns,
)
print("length:", scheduled.duration)
print(f"{'kind':8} {'line':>4} {'start':>6} {'end':>6}")
for event in scheduled.schedule:
    print(f"{event.kind:8} {event.line:>4} {event.start:>6} {event.end:>6}")

Output

length: 480 ns
kind     line  start    end
drive       0      0     40
readout     1     40    240
drive       0    440    480

From a Kernel to Your Control Electronics has the rest: what the compiler refuses, and the program a backend reads.

Clocks#

A kernel counts time in cycles of the quantum system’s program clock, QuantumSystem.clock_ghz (pulse.quantum_system(..., clock_ghz=), else the quantum system’s own); a duration written as a time converts to them when the kernel compiles (see Durations: cycles or times). A controller may run its own clock, Controller.clock_ghz, at a whole-cycle ratio of it; may start and time operations only every Controller.cycles_per_timestep of its own cycles (default 1); and may play samples at Controller.sample_rate_ghz (default one per cycle of its clock), at any ratio of whole numbers to its clock.

A line’s timestep is the shortest time, in program cycles, at whose multiples its controller can start and end operations: the fewest whole program cycles that are a whole number of the controller’s steps and of its samples. On the program clock with one sample per cycle it is cycles_per_timestep; at a / b of the program clock (in lowest terms), with one cycle per step, it is b; at 2.4 GHz samples on a 1 GHz clock it is 5 cycles, 12 samples. A length off the samples is an error like any other off its timesteps; it is never rounded.

The scheduler places every operation on whole timesteps of its line and meets a sync on a multiple of every synced line’s timestep; a length that is not a whole number of timesteps fails to compile with ControllerLimitError, which names the line and the fix: line d3 moves in timesteps of 4 cycles; 22 cycles isn't a whole number of timesteps. pulse.round_duration(line, duration) in a kernel rounds a length to whole timesteps (direction="up" by default, "down" or "nearest", or a pulse.RoundDirection), so a kernel can be written for any controller:

drive(line, gaussian(pulse.round_duration(line, 41), 0.1, 10.0))

The export counts the controller’s own cycles: clock_ghz is the controller’s clock, and when that is not the program clock the export also gives program_clock_ghz, converts every time to the controller’s cycles (exactly for operations on its lines; rounded up for classical calls and segments) and scales each waveform’s time parameters (duration, sigma, beta, risefall) with them. A program for a controller at the program clock is unchanged. ControlSystem(reference_clock_ghz=...) states a clock the controllers share; every controller’s clock must be a whole multiple of it, and the export gives it as reference_clock_ghz. Without one, each controller’s start is known only to within one of its own cycles, which budgets between controllers count.

Each pulse.Controller of a control system may run its own clock. Without a declared "clock_ghz" the quantum system’s program clock is the fastest controller clock when it is a whole multiple of every other; clocks that are not are a QuantumSystemDefinitionError listing the program clocks that would work, never one picked for you. Every line is then scheduled on the timesteps of the controller that plays it, and checked against that controller’s limits in its own cycles. A sync, and a wait whose length comes from a classical answer, meet where every line’s timesteps do. A kernel with runtime qudits is scheduled for the qudits each call binds: the call’s lines are on the timesteps of their own controllers, with their delays and their controllers’ latencies, and the call’s schedule is the one the same kernel written for those qudits has. What its trace takes of a runtime qudit’s line is taken for the qudit a call binds too: a duration from round_duration, the timestep a float wait length is checked on, the rate custom() is sampled at. Where the controllers differ in their timesteps or sample rates, such a kernel has one program for each distinct combination of them its runtime qudits’ lines have: the first call with a new combination traces the kernel, running its Python once as compiling the kernel written for those qudits would, and the calls with the same combination share that program; a kernel that takes none of these is traced once for every call. A line’s delay is split by its own controller’s fine delay, and every schedule keeps an operation that depends on a readout for the reading controller’s feedback_latency_cycles converted to program cycles, counted from where the readout ends on its delayed line (its fine delay rounded up to a cycle). custom(duration, f) samples f at the rate of the line that plays it, the waveforms made from it too; samples given to custom_samples play only on lines of the rate they were made for. On a runtime qudit’s line both are sampled and checked at the rate of the line of the qudit a call binds.

Each controller gets its own program: scheduled.export_to_controller(controller=k) is controller k’s part, in its own cycles, with "controller": k, its lines and limits, and the events it takes part in: those on its lines, a sync with only its lines, the submit of a call whose measurements it reads and the answer it takes, whether to branch on or to compute with. Event and line ids stay the program’s, so a value computed from an answer names the answer by the same index in every controller’s program. A program that plays the lines of more than one controller needs controller=; one on a single controller exports it without, and one that plays no lines is exported by the controller that makes its calls. A controller the program does not use exports a valid empty program: no lines, events or calls. export_to_emulator(controller=k) gives the same part for an emulator. Exporting every controller in turn walks the program and checks it against the whole control system once, not once per controller: the program keeps what its parts share until each one has been exported, and every export is a fresh copy, whatever the order.

A link is shared by default: every controller it reaches sends its requests to one instance, which holds slots requests for all of them. A link that each controller has its own instance of, a decoder beside each controller for example, is declared per controller:

import cudaq_pulse as pulse

links = {"decoder": pulse.Link(fixed_ns=10, slots=1, per_controller=True)}

or per_controller = true in the link’s table of a system file ([control_system.links.decoder]). Each controller’s calls over it then use that controller’s slots, so calls on two controllers are scheduled without waiting for each other’s slots, and each controller exports only its own calls, with the call’s "controller" in its submit, answer and calls entries. A call never crosses between controllers, so its answer is due without the start uncertainty of a second controller. The call’s measurements and the pulses that use its answer must be on one controller, or the program fails to compile with a CompilationError naming the function and both controllers. A pulse uses an answer when the answer decides it: a pulse in a branch on the answer, one whose amplitude, waveform or length the answer sets, and the pulses of a tone whose phase or frequency it shifts. What a branch on the answer hands on carries the answer further: a tone an arm shifts, an outcome an arm reads out, a number an arm sets. A sync inside an arm of such a branch holds its lines only when the arm is taken, so the controllers of all its lines use the answer. A line that only waited for the answer does not: the answer is due at a cycle known when compiling, so a sync of that line with another controller’s lines lines up known cycles. An answer taken when it comes (latency_mode="blocking" or "timeout", or result(timeout=...)) holds its lines for a time only a run tells, and the controllers of the lines synced with them count as its users too. When the scheduler cannot tell a call’s controller (it reads no measurement and its answer is unused, or leaves the kernel), the link’s calls share one set of slots, as on a shared link. Each controller may place the link on one of its own processors; controller_usage counts each instance’s calls on its controller’s processor, and its links have a row per instance.

Times between controllers are budgeted with how well each one’s start is known: its clock_skew_cycles, plus one of its own cycles without a reference_clock_ghz. A pulse that branches on, or computes with, another controller’s readout starts once the outcome can reach it: the reader’s feedback_latency_cycles and its peer_latency_cycles to the user, in the reader’s cycles, and both controllers’ start uncertainty. Every schedule waits that long for each pair of reader and user, and a pulse on the reader’s own controller waits its feedback latency alone; a program scheduled for other controllers that starts the pulse sooner fails their check with the cycle it may start at. An answer taken on another controller than the one that sent the request is budgeted with the two controllers’ start uncertainty, and due_cycles includes it; one controller sending and taking it adds none. When the scheduler cannot tell which controllers they are (the request carries no measurement, or the answer leaves the kernel), the budget adds the start uncertainty of the two controllers the link reaches that are known least well.

A sync of lines on several controllers lines up the first pulse after it on each of its lines. Each of those lands within its controller’s start uncertainty of where it is meant to, plus how far its line delay is rounded to its grid when the controller has no fine delay, all in the controller’s cycles, and that must fit the controller’s alignment_tolerance_cycles; otherwise the program fails to compile, suggesting a shared reference_clock_ghz or the tolerance it needs. Under rcp and alap_rcp, max_concurrent_drives and max_concurrent_readouts count pulses on every controller: a pulse that follows another controller’s on the same lane starts their start uncertainty after it, so the two never overlap. Given to a control system with controllers, they are checked under every schedule, counted the same way. A program that asap places past them is placed as rcp places it, and one that alap places past them as alap_rcp does; its options.schedule names the policy that placed it. A program that asap or alap places within them keeps its schedule exactly. It fails to compile with a ControllerLimitError naming the count and the first cycle when that placement does not keep to every limit either, or when the values a call binds place its pulses past one.

A wait whose length is computed at run time (wait(line, value, bounds=(low, high))) is scheduled at its lowest length, and what follows it on its lines starts later in a run, by up to high - low cycles; lines the wait does not hold back keep their times. A blocking wait for an answer is such a wait without an upper end. These limits, and a shared line’s max_concurrent_tones, count pulses as they can slide: two pulses the schedule places apart are refused when some run plays them at once, with the first cycle they can and the waits that let them (2 drives can play at once from cycle 600: what follows the wait on d0 that ends at cycle 117 (up to 3984 cycles later) starts later in a run than it is placed). Each wait’s length is counted as independent of the others’, also where two are computed from one answer, and every trip of a loop with such a wait as able to slide as far as its last. A wait without an upper bound lets what follows it play at any later time. To keep such pulses apart, sync their lines after the wait, so that they wait together, or give the wait bounds that keep them apart; rcp and alap_rcp hold a line back at the wait when the drive or readout limit could bind. Pulses in the two arms of one branch are kept apart where they follow the same wait, and counted together where they follow different ones. A program without such a wait, and pulses on lines that all wait together, are counted as scheduled. A long loop with such a wait whose pulses can slide against another line’s is counted from the trips the check walks and the rest of its trips together, whatever their number. Where that cannot be done (for example a pulse in the loop on a line its waits do not hold back, a loop in a loop, a long loop of counted pulses without such a wait in the same program, or line delays that put a pulse before one of an earlier wait) the program is counted trip by trip, up to the 1,048,576 copies of loops a check plays; past that the check stops with an UnsupportedError.

What the program computes at run time is converted by the same rule. A variable wait’s length is clamped to its bounds, as the run clamps it (an integer max and min), and then wrapped in {"op": "controller_cycles", "type": "int", "of": [x], "num": a, "den": b, "timestep": g}: the length x program cycles is x * a / b of the controller’s, and the controller must fail the run when x is not a whole number of the line’s timesteps of g program cycles. A controller with the program’s clock but longer timesteps gets the wrapper too, with num and den 1, as that check. min_cycles rounds down and max_cycles up. A run-time duration is wrapped the same way, and a run-time sigma, beta or risefall is multiplied by a / b (a float mul). A run-time length whose values are all known while the kernel compiles (it selects between constants) and include one off the timesteps is a ControllerLimitError then. A run-time operand of a waveform whose parameters the export does not name can’t be converted, so on a controller with its own clock it is a ControllerLimitError too, never exported in program cycles.

Line delays#

Cables and electronics delay each line differently. The calibrated delay of a line belongs to the line, as its controller declares it: DriveLine(5, delay_ns=4.0) and ReadoutLine(5, delay_ns=12.0) (from cudaq_pulse.controller) in the controller’s drive_lines and readout_lines, as times (2.3 * pulse.ns) or numbers of ns; a bare carrier index is an undelayed line. Every operation on a delayed line starts that much later than scheduled. Whole timesteps of the line move its operations, which are then checked against the controller’s limits like any others; the rest, less than one timestep, is the line’s fine_delay_ns in the export, for a controller that can delay a line’s output by less than that (Controller.max_fine_delay_ns). A controller without fine delay rounds the delay to the nearest timestep if that is within its alignment_tolerance_cycles, and otherwise the program fails to compile with an error naming the line, the rest and the fixes. A kernel with runtime qudits has the delays of the lines each call places it on, as the kernel written for those qudits has:

from cudaq_pulse.controller import DriveLine, ReadoutLine

box = pulse.Controller(
    clock_ghz=1.0,
    max_fine_delay_ns=1.0,
    drive_lines=[DriveLine(0, delay_ns=2.3), 1],
    readout_lines=[ReadoutLine(0, delay_ns=41.0), 1],
)
control_system = pulse.ControlSystem(controllers=[box])
# The drive line of qudit 0 moves 2 ns (4 cycles of a 2 GHz program
# clock) and plays with fine_delay_ns = 0.3.

In a system file a delayed line is {"qudit": 0, "delay_ns": 2.3} and an undelayed one its carrier index. Compiling a kernel again with only other delays, such as a control system calibrated again, reuses its trace and optimized module and schedules it again, with the same result, byte for byte, as compiling it anew. The rescheduled_for_line_delays of what lower() returns says which it did, so a calibration loop can check that each round took that path: True when the earlier trace was scheduled again, False when the kernel was traced, such as the first time, with the line delays it was last compiled with, the first time it is compiled with line delays at all (only a compile with line delays keeps its trace), for a kernel with list or qudit parameters, and after a change to what the kernel read while it was traced. A call’s rescheduled says something else: whether its float values set a wait length (see Wait lengths).

Shared lines#

A line may reach several qudits: a readout feedline multiplexing the readout of the qudits along it, or a drive line combining several drive tones. ReadoutLine([0, 1, 2, 3], max_concurrent_tones=4, delay_ns=12.0) reads out qudits 0 to 3 and plays up to four tones at once; a line reaching one qudit, ReadoutLine(5) or ReadoutLine([5]), is dedicated, as before. max_concurrent_tones is 1 by default, and at most the qudits the line reaches. Every line has qudits, a tuple, and max_concurrent_tones; only a dedicated line has qudit, which is an error on a shared one. A qudit is reached by at most one line of each kind in the control system: a second one is an error (choosing between lines is not supported yet).

A kernel is written as for dedicated lines: get_readout_line(q) of a qudit on the feedline gives one of its tones, for q, with q’s frequency, and each call gives a line of its own:

from cudaq_pulse.controller import ReadoutLine

box = pulse.Controller(
    drive_lines=[0, 1, 2, 3],
    readout_lines=[ReadoutLine([0, 1, 2, 3], max_concurrent_tones=4)],
)

@pulse.kernel
def measure(a, b, c, d):
    lines = [get_readout_line(a), get_readout_line(b), get_readout_line(c), get_readout_line(d)]
    sync(lines[0], lines[1], lines[2], lines[3])
    for line in lines:
        readout(line, square(400, 0.05))

The compiler checks every line that reaches more than one qudit, whatever its max_concurrent_tones, for the tones it plays at once: more than max_concurrent_tones drives or readouts on it overlapping in time is a ControllerLimitError naming the line, the cycle and the qudits (with one tone at once, its qudits’ pulses must not overlap at all). Pulses in the two arms of one branch never play together. The scheduler does not move pulses to keep within it: play some after the others end, with a sync between them. A dedicated line is never checked for it, and a program on dedicated lines costs nothing more to compile or export.

The other limits of a Controller apply as follows on a shared line. Per tone, as each tone is its own sequencer: the spacing of its operations (instruction_cycles, min_idle_cycles) and max_amplitude (the sum of concurrent tones is not checked yet). Per physical line: its waveform memory (waveform_memory_samples with "per_line", the distinct shapes of all its tones) and max_frequencies_per_line (the distinct tone frequencies of all its tones). max_pulses counts every drive and readout, as on dedicated lines. A kernel with runtime qudits compiles on shared lines, and each call is checked for the tones at once when it binds its qudits.

Format /2 of the export lists a shared line once, with its max_concurrent_tones, and gives each event on it a tone_slot and the qudits it is for (see The structured format). Format /1 keeps a line for each qudit, as the kernel has: each line on a shared line also has, after its qudit, the shared line’s qudits and max_concurrent_tones (lines with the same role and qudits are tones of one line), and each drive, readout, wait and frame_update event on it its tone_slot, after its qudit, the slot /2 gives it; so do the runtime_tones and frame_state entries of a line that keeps one slot. /1 lists every execution, so it gives slots to handles taking turns in a loop too. Format /1 is the one for a shared line on a control system of several controllers (each controller’s part has its own lines’ keys), on a controller with its own clock, or with line delays, which /2 does not take. On dedicated lines none of these keys are present. The simulator plays each tone on its own qudit. In a system file a shared line is {"qudits": [0, 1, 2, 3], "max_concurrent_tones": 4, "delay_ns": 12.0}, without the keys at their defaults. examples/transmon/transmon_surface17_multiplexed_readout.py reads out the four X-check ancillas of transmon_surface17 on one feedline.

Broadcast lines#

A drive line may reach several qudits with one tone: a beam or an antenna that drives every qudit under it at once. DriveLine([0, 1, 2], broadcast=True) declares one. Where a shared line has a tone per qudit and a drive on it reaches one qudit, a broadcast line has one tone, and a drive on it reaches all its qudits; max_concurrent_tones does not apply to it, and a line is one or the other. broadcast and frequency_hz are for a line given a list of qudits: DriveLine([0], broadcast=True) is an error, and on one qudit given as an int, DriveLine(0, broadcast=True), they are ignored.

A kernel gets the line from any one of its qudits, or from all of them, which says in the kernel what the drive reaches; either way it is the one line:

from cudaq_pulse.controller import DriveLine

box = pulse.Controller(drive_lines=[DriveLine([0, 1, 2], broadcast=True)])

@pulse.kernel
def together(a, b, c):
    beam = get_drive_line(a, b, c)      # get_drive_line(b) is the same line
    drive(beam, gaussian(400 * pulse.ns, 0.5, 100 * pulse.ns))    # reaches a, b and c
    shift_phase(beam.tone, 0.3)         # the line's one tone

Several qudits must be all the qudits of one broadcast line, each once, in any order; other qudits are a CompilationError, as are several qudits where the control system has no broadcast line and the first qudit’s line is not yet taken. A kernel that holds only one of the line’s qudits still drives all of them, and the compiled program’s qudits lists them all. Pulses on the line follow each other, as on a dedicated line, and the line has one tone state: a phase or frequency change of beam.tone applies to every later drive on it, for every qudit, so there is no virtual Z of one of its qudits alone. The line has no tones of other transitions and no calibrations.

The tone starts each shot at the frequency the line states, DriveLine([0, 1, 2], broadcast=True, frequency_hz=5.1e9). It may be left out when the line’s qudits share one frequency, which is then the tone’s; when they differ, a program that takes the line is a CompilationError asking for it. On a quantum system whose qudits give an Offset from one reference, the tone is the Offset its qudits share, and a line that states frequency_hz, or whose qudits differ, is a CompilationError: the line cannot state an offset yet. On a system whose qudits give no frequency, each tone is an offset from its own qudit’s carrier, and the line’s one tone is at the carrier of every qudit it reaches: a drive on it is resonant with each of them, and a change of the tone’s frequency (shift_frequency(beam.tone, 1e6)) is that offset from each reached qudit’s own carrier. The line cannot state frequency_hz there (a CompilationError for a program that takes it), its native_frequency_hz in the exports is 0.0 as for every line of such a system, and each event’s frequency_hz is the offset every qudit in its qudits sees. A drive on the line at another qudit’s tone, or on another line at the line’s tone, is refused as between any two qudits of such a system. Each qudit is driven off resonance by the difference between the tone and its own frequency: the simulator drives every qudit of the line with the same envelope, the tone’s frequency and phase, and that qudit’s own amplitude scale.

The scheduler, the tone-state bookkeeping and the limits of a Controller treat the line as a dedicated one: one pulse counts once toward max_pulses, and max_amplitude, the grid, the pulse lengths and max_frequencies_per_line apply to its one tone. A kernel with runtime qudits compiles for a control system with a broadcast line, and each call is checked when it binds its qudits: a runtime qudit that takes a drive line cannot be bound to a qudit of a broadcast line, since its line was compiled as that qudit’s alone (pass such a qudit when the kernel is lowered). ReadoutLine has no broadcast.

Both formats of the export write the line once, with "broadcast": true, all its qudits and the one native_frequency_hz of its tone, and one event for each drive, with the line’s qudits and no tone_slot. In format /1 the line’s qudit, and that of its events, is the lowest of them:

{"line": 0, "role": "drive", "qudit": 0, "qudits": [0, 1, 2], "broadcast": true,
 "native_frequency_hz": 5100000000.0}

In format /2 the line has native_frequency_hz in place of native_frequencies_hz, and each play and frame_update event on it has qudits after its line:

{"kind": "play", "line": 0, "qudits": [0, 1, 2], "start_cycles": 0,
 "duration_cycles": 400, "waveform": 0,
 "tones": [{"frequency_hz": 5100000000.0, "phase_rad": 0.0}]}

frame_state and runtime_tones entries on the line have its qudits too, and so does each of its drives in export_to_emulator(), after its qudit. A backend must drive every qudit in qudits: one that reads only the line’s first qudit would drive one. unroll does not take a program with a broadcast line yet; export it in format /1. load does not take a control system with one yet. The part of one controller of several lists the line’s lowest qudit alone in its top-level qudits. A program that takes no broadcast line exports as it does without one, and a control system without one loads nothing for them. In a system file the line is {"qudits": [0, 1, 2], "broadcast": true, "frequency_hz": 5100000000.0}.

Waveform memory#

Two plain values of Controller describe the memory a controller plays waveforms from, the same in Python and in a controller description in TOML (waveform_memory_samples = 65536, waveform_memory = "shared"):

import cudaq_pulse as pulse

limits = pulse.Controller(
    sample_rate_ghz=2.0,
    waveform_memory_samples=65536,     # what one memory holds, in samples
    waveform_memory="shared",   # one memory for every line; "per_line" by default
)

Compiling checks that every waveform of a program fits at once: in the memory of its line, or once over all lines when "shared". The controller plays one stored shape at any amplitude and phase, so waveforms that differ only in those share memory, even when a float parameter sets the amplitude. A limit that only some float values exceed is checked once when a call binds them, never per shot. A shared memory reaches the export’s controller as waveform_memory, with the waveform ids and parameter roles of /2; a memory per line leaves the key out.

Controller limits#

Controller states what a controller can play, in its own clock cycles: its clock, how closely two operations on one line can follow each other, its waveform memory and distinct frequencies per line, which detector reads each qudit and how long a readout holds it, the least feedback latency from a readout to an operation that branches on it, whether it can stop waiting for an answer after a timeout, and the most drives and readouts in one program. Given to pulse.compile(control_system=...), alone or in its ControlSystem, it makes every compilation check the scheduled program, so that a program the controller cannot play fails at compile time with ControllerLimitError, which lists each violated limit. A limit that only some values of a float parameter exceed, such as the tones a frequency shift adds or the memory a waveform width takes, is checked when a call supplies the values, once per distinct values, so a call that compiles also exports. cudaq_pulse.controller.check(compiled, limits) returns the violations without raising. A control system without controllers checks nothing more.

Some instruments require a minimum pulse length. Controller(min_pulse_cycles=16) makes every drive and readout shorter than 16 of the controller’s cycles a violation naming its line, its start and its length; on a control system of several controllers, each checks its own lines. It is 0, no limit, by default, and the export lists it among the limits only when it is set. Likewise, an instrument that caps a pulse’s length declares Controller(max_pulse_cycles=4095): every drive and readout longer than 4095 of the controller’s cycles is a violation naming its line, its start and its length. It is None, no limit, by default, may not be below min_pulse_cycles, and is listed among the limits only when it is set.

A controller that plays nothing while one of its classical calls is out declares Controller(blocks_on_calls=True). Each call then holds every line from its submission until its answer is due: the scheduler sends it once the lines before it are done and starts nothing after it before then, in every schedule, and a program played on such a controller is checked for it, naming each pulse that plays while a call is out. A call in a kernel with its own schedule=, which is placed whole, does not compile for it. The export lists blocks_on_calls among the limits only when it is set. In a control system of several controllers, a call holds each controller that blocks on calls and issues it (whose instance of a per-controller link runs it, else those that send its measurements, else, over a shared link, every controller that plays), reads a measurement the call sends or plays a pulse that uses its answer (branches on it, or computes with it); the lines of the others play on while it is out.

Update buses#

Some instruments retune a group of lines over one shared bus that carries one update at a time. Controller(update_buses=[...]) lists such groups, each a cudaq_pulse.controller.UpdateBus: its lines by carrier index, as the controller’s own are given, and the cycles of the controller’s clock one update holds the bus for:

from cudaq_pulse.controller import UpdateBus

box = pulse.Controller(
    drive_lines=[0, 1, 2, 3],
    readout_lines=[0, 1, 2, 3],
    update_buses=[UpdateBus(drive_lines=[0, 1, 2, 3], cycles_per_update=8)],
)

An update is what changes the tone a line plays, read from the program alone:

  • each tone change that no later drive or readout takes (the export’s frame_update event, see Exporting a program);

  • each drive or readout whose frequency_hz differs from that of the drive or readout before it on its line, or whose phase_rad differs other than as the tone runs on: a tone at its line’s own frequency keeps its phase, and one retuned from the line’s own frequency gains phase at its detuning, so neither is an update by itself. A frequency or phase known only at run time is an update.

The first drive or readout on a line is not an update, its tone being set before the shot, and neither is a pulse that changes only its envelope or amplitude. An update holds the bus for the cycles_per_update before it takes effect, so updates on one bus must start at least that far apart; two in the two arms of one branch never meet. A program that has them closer is a ControllerLimitError naming the bus, its lines, both updates and their times. A line is on at most one bus, and a bus reaches only lines its controller plays. In a system file each bus is {"drive_lines": [0, 1], "readout_lines": [], "cycles_per_update": 8}; like the lines, the buses are wiring, given when a description is loaded (pulse.controller(name, ..., update_buses=[...])), and the export lists them among the limits only when there are any.

By default the scheduler does not place updates for the bus, and timing never changes: space them with waits or syncs. A controller that asks for it, Controller(update_buses=[...], space_updates=True), has compiling space them instead. After scheduling, it takes the updates of each bus in time order and holds the first that clashes back on its line by the fewest cycles that put it cycles_per_update after the one before it, and schedules the program again: what follows it on its line moves, and syncs carry the move to their other lines, as the scheduler places them, on the controller’s grid. A delay can change which later pulses are updates (a tone retuned across a wait gains phase over it), so it checks the whole program again, and repeats until no update clashes, at most 256 times, else CompilationError. An op is held back in every execution: in a rolled loop, in every iteration. Updates in the two arms of a branch stay independent. The export, the simulator and the controller checks all read the spaced program, so feedback latency, syncs and every other limit hold on it; a program with nothing to space keeps its schedule. Spacing works on the program as compiled, so a kernel whose waits a call’s float values set keeps the holds its compile found, and each call is checked; one with runtime qudits is checked when a call binds them.

The check of a rolled loop does not play every iteration. Whether a pulse is an update depends only on the pulse before it on its line, and a clash only on the update before it on its bus; from a loop’s iteration 1 on, both are those of the iteration before, a period later and a phase step on. On one clock the check plays each loop it keeps rolled at iterations 0 (the entry), 1 and 2 (every later iteration clashes as these do) and its last two (which what follows the loop follows), and lists violations, when there are any, from a walk of every execution. A program on controllers with their own clocks, or on several controllers, is checked on every execution.

Where to go next#