Quantum system API#

cudaq_pulse.quantum_system(
name=None,
*,
qudits=None,
couplings=(),
residual_zz=(),
model=TransmonModel(),
attribution='',
layout=None,
calibration=None,
measurement_run=None,
control_system=None,
clock_ghz=None,
parameter_drift=False,
parameter_drift_seed=None,
frames='dressed',
)[source]#

A quantum system: a registered one by name, or one built from its qudits.

quantum_system("transmon_surface17") is a registered quantum system, with every carrier in order (a name takes its argument after a colon, as in "transmon_lattice:4"); cudaq_pulse.quantum_systems.available_quantum_systems() lists the names. A string is always a name: QuantumSystem.load(path) reads a system file, and QuantumSystem.from_dict(data) its data. quantum_system() is the process quantum system, named by CUDAQ_PULSE_QUANTUM_SYSTEM (python -m cudaq_pulse --quantum-system NAME sets it); without one it raises NoProcessQuantumSystemError.

quantum_system(name="chip", qudits={0: PhysicalQudit(...), ...}) builds one: qudits are its PhysicalQudit carriers by index, couplings and residual_zz its Coupling and ResidualZZ entries, model how the simulator treats its qudits and how many levels each has (a SimulationModel class or instance, TransmonModel by default, TransmonModel(levels={0: 4}) to give qudit 0 four levels, or None for a system with no simulation model) and attribution where its values come from. Its couplings and residual ZZ entries are checked, and a problem is at its path (couplings[3].qudits[1]). These keywords build a system, so a registered name takes none of them.

layout[i] is the carrier that qudit i names; by default every carrier of the quantum system, in order. calibration is a Calibration, the name of a shipped one or the path of a calibration file, and measurement_run one of its measurement runs; the calibration’s couplings replace the system’s, and QuantumSystem.calibration holds it. The transmon_surface17 quantum system uses the shipped transmon_surface17 calibration by default. control_system is a ControlSystem, whose lines must be carriers of the quantum system. clock_ghz is the program clock kernels count cycles of (QuantumSystem.clock_ghz); by default the fastest controller clock when the others divide it, else the quantum system’s (2 GHz for one built here). Controller clocks that do not divide evenly into one need it, and the problem lists the clocks that work.

frames is where the drive tones of a system with couplings play: "dressed" (the default) at each qudit’s 0-1 frequency with the couplings included (Qudit.dressed_frequency_hz), so that a qudit does not precess at its neighbours’ shift; "bare" at its frequency_hz. A system without couplings is the same either way.

parameter_drift makes the simulated system’s qudit parameters drift (cudaq_pulse.quantum_systems.drift): True for the default ParameterDrift() on every qudit, a drift model for that model on every qudit, or {qudit: model} for only those qudits (keyed as physical_qudits). Compiling reads only the calibrated values, so the system equals its non-drifting twin; simulate plays its true values, QuantumSystem.true_qudits. parameter_drift_seed (an int) makes the drift repeat; by default each system drifts its own way.

Arguments with problems raise QuantumSystemDefinitionError listing all of them, each at the argument it is in.

Parameters:
Return type:

QuantumSystem

class cudaq_pulse.QuantumSystem(
target,
*,
name,
layout=None,
source='',
calibration=None,
control_system=None,
clock_ghz=None,
_variant=False,
)[source]#

Bases: object

A read-only machine description; see the module docstring.

clock_ghz is the program clock: kernels count time in its cycles. pulse.quantum_system(..., clock_ghz=) (a system file’s "clock_ghz") sets it; else the fastest clock of the control system’s controllers, when every other one divides it (controllers whose clocks do not divide evenly need it declared); else the quantum system’s own. Each controller may run its own clock, a whole-cycle ratio of it (see cudaq_pulse.controller).

qudit_freq[q] is the 0-1 transition frequency of qudit q (Hz) and transition_freq[q, i, j] that of levels i and j (the upper level’s energy less the lower’s, in either order of i and j), over the levels the system’s model gives each qudit (NaN past a qudit’s last level); both are indexed by the user’s qudit numbering and are read-only arrays. control_system is the ControlSystem that plays it, if given; compile(kernel, quantum_system=dev) checks every program against it.

A quantum system built with parameter_drift= drifts (see cudaq_pulse.quantum_systems.drift): physical_qudits are its calibrated values, all that compiling reads, and true_qudits the values simulate plays, which drift as it runs and as advance(duration) moves time on; parameter_drift is the model of each drifting qudit and parameter_drift_time the drift time so far. It equals its non-drifting twin: the same fingerprint, compiled programs and exports. Without drift, true_qudits is physical_qudits, parameter_drift and parameter_drift_time are None and advance raises.

Parameters:
  • target (_Description)

  • name (str)

  • layout (Sequence[int] | None)

  • source (str)

  • calibration (Any)

  • control_system (ControlSystem | None)

  • clock_ghz (float | None)

  • _variant (bool)

property qudit_freq: Any#

Read-only array; qudit_freq[q] gives qudit q’s 0-1 transition frequency in Hz.

property transition_freq: Any#

Read-only array of transition frequencies in Hz.

transition_freq[q, i, j] gives the transition between levels i and j of qudit q. Qudits use the user’s numbering; entries beyond a qudit’s last modeled level are NaN.

qudit(label)[source]#

The handle of the qudit labelled label (PhysicalQudit.label), as in qs.qudit("D1"); a NotFoundError names the labels there are.

Parameters:

label (str)

Return type:

Qudit

coupling(a, b)[source]#

The coupling of the quantum system’s qudits a and b (handles, in either order), as calibrated: qs.coupling(a, b).get_calibration( pulse.gates.CZ) is its CZ. A NotFoundError names the qudits a couples to.

Parameters:
Return type:

Coupling

static load(path, /)[source]#

The quantum system of a system file, as as_dict writes one: JSON with its format (cudaq-pulse.system/1), its quantum system (a registered name, or every value inline), layout, calibration, measurement run, control system and program clock, each as data. A file with problems raises QuantumSystemDefinitionError listing all of them, each with its path in the file, its line and its column; python -m cudaq_pulse.doctor --system FILE runs the same checks.

Parameters:

path (str | PathLike[str])

Return type:

QuantumSystem

static from_dict(data, /)[source]#

The quantum system of a system file’s data, as as_dict returns it or json.load reads it; see load.

Parameters:

data (Mapping[str, Any])

Return type:

QuantumSystem

replace(**changes)[source]#

A variant of the quantum system, as dataclasses.replace makes one: the quantum system pulse.quantum_system(name=..., qudits=...) builds from this one’s name, qudits (its physical_qudits), couplings, residual_zz, model, attribution, frames, readout_crosstalk, layout, control_system and clock_ghz, with changes in their place: qs.replace(qudits={**qs.physical_qudits, 0: qudit}) changes one qudit. The values are the calibrated ones, so the variant has no calibration of its own.

parameter_drift and parameter_drift_seed give the variant drift, as pulse.quantum_system takes them; a variant without them does not drift. qs.replace(parameter_drift=True) changes nothing else, so it keeps the calibration and the fingerprint.

Parameters:

changes (Any)

Return type:

QuantumSystem

as_dict()[source]#

The quantum system as JSON-serializable data, which QuantumSystem.from_dict reads back: its format (cudaq-pulse.system/1), the version that wrote it, its quantum system (a registered name, or every value inline), layout and calibration, and its control system.

Return type:

dict[str, Any]

class cudaq_pulse.Qudit(quantum_system, index, logical)[source]#

Bases: object

A handle naming one carrier of a quantum system.

index is the carrier’s index in the quantum system (the layout is applied when the handle is created); logical is the position the user indexed. A handle is identity, not location.

Parameters:
quantum_system: QuantumSystem#
carrier: str#
index: int#
logical: int#
property dressed_frequency_hz: float | None#

The qudit’s 0-1 frequency in Hz with its quantum system’s couplings included: the frequency its drive tone plays at. Without couplings it is the qudit’s frequency_hz, which stays the bare value the Hamiltonian uses. Where the qudits give their frequencies as offsets from a shared reference it is an Offset from it, and where they give none it is None.

get_calibration(
gate: Literal[Gate.X, Gate.X90, Gate.Y, Gate.Y90],
transition: tuple[int, int] = (0, 1),
) → DragPulse[source]#
get_calibration(
gate: Literal[Gate.Z, Gate.S, Gate.T],
transition: tuple[int, int] = (0, 1),
) → VirtualZ
get_calibration(
gate: Literal[Gate.READOUT],
transition: tuple[int, int] = (0, 1),
) → ReadoutPulse
get_calibration(
gate: Gate,
transition: tuple[int, int] = (0, 1),
) → DragPulse | VirtualZ | ReadoutPulse

The calibrated pulse of gate on this qudit of its quantum system, as get_drive_line(q).get_calibration(gate) (X to T) and get_readout_line(q).get_calibration(pulse.gates.READOUT) give it in a kernel; see PhysicalQudit.get_calibration.

Parameters:
  • gate (Any)

  • transition (tuple[int, int])

Return type:

Any

class cudaq_pulse.Register(qudits)[source]#

Bases: Sequence[Qudit]

An ordered selection of qudit handles of one quantum system.

Make one from a system’s qudits: qs.qudits[0:4] takes the first four, qs.qudits[[0, 2]] takes qudits 0 and 2. A kernel parameter annotated pulse.Register is a runtime value: the kernel compiles once for each register length and then runs on any qudits of the system. A register supports len(), indexing, slicing and iteration: indexing with an int gives a Qudit, while a slice or a list of indexes gives another Register.

Example:

qs = pulse.quantum_system("transmon_surface17")
reg = qs.qudits[0:4]
len(reg)                    # 4
reg[1::2]                   # Register([1, 3])
[q.logical for q in reg]    # [0, 1, 2, 3]

See “Quantum systems” for how a system names its qudits, and “Arguments” in “Calling and Compiling Kernels” for how a register parameter is compiled.

Parameters:

qudits (Sequence[Qudit])

Clocks#

A quantum system’s clock_ghz is its program clock. A controller with a slower clock, or several cycles per timestep, starts operations only every few program cycles, its lines’ timestep; round_duration rounds a length to whole timesteps in a kernel.

cudaq_pulse.round_duration(line, duration, direction=RoundDirection.UP)[source]#

duration, an int number of program cycles or a time (10.5 * pulse.ns), rounded to whole timesteps of line: the nearest length (or start) its controller can time, "up" (default), "down" or "nearest", in program cycles.

Call it in a kernel with a line from get_drive_line or get_readout_line; duration must be known while the kernel compiles. A line whose timestep is one cycle takes every whole cycle, so round_duration(line, n) is ceil(n).

Parameters:
Return type:

int

class cudaq_pulse.RoundDirection(*values)[source]#

Bases: StrEnum

Which way round_duration rounds a length onto its line’s grid; the strings "up", "down" and "nearest" mean the same.

UP = 'up'#
DOWN = 'down'#
NEAREST = 'nearest'#

Times with units#

A bare int duration is a number of cycles of the program clock. 20 * pulse.ns is a time: the compiler converts it to cycles exactly, for the quantum system the kernel compiles for, and rejects a time that is not a whole number of cycles. A plain float in a duration is an error, since it could mean either.

class cudaq_pulse.Time(nanoseconds)[source]#

Bases: float

A wall-clock time: a float of nanoseconds holding its exact value.

Made by multiplying a unit, 20 * pulse.ns; durations, waits and pulse.round_duration take it, and convert it to cycles of the clock the kernel compiles for.

float(t) is the time in nanoseconds, whatever unit made it. A bare int duration in a kernel is a number of clock cycles instead, so it depends on the quantum system’s clock. Times compare with times; comparing one with a bare number, with == or an ordering, raises TypeError: write t == 20 * pulse.ns or float(t) == 20.0. A time never hashes like a number, so a set or dict can hold 20 * pulse.ns and 20.0 as different keys, and finding a number in it never compares it with a time; in on a list or tuple compares with ==, and raises when it meets a time and a number.

Parameters:

nanoseconds (Fraction | int | float)

Return type:

Time

property exact_ns: Fraction#

The time in nanoseconds, exactly.

The units, each a Time:

cudaq_pulse.ns#

One nanosecond.

cudaq_pulse.us#

One microsecond.

cudaq_pulse.ms#

One millisecond.

cudaq_pulse.s#

One second.

Errors are on Errors; what a quantum system is built from is on Quantum system components API.

Control systems#

A quantum system’s control_system is the controllers that play it, their wiring and the links beside them. pulse.controller("vendor.model", drive_lines=..., readout_lines=...) loads a Controller from an installed description (or a TOML file, by path) with the installation’s wiring; each file is parsed once. The wiring includes peer_latency_cycles: the latency of an outcome the controller reads to each receiving controller, counted in the sending controller’s own cycles and keyed by the receiver’s index in the control system (one number for every receiver; a receiver not listed: 0). QuantumSystem.as_dict() writes the whole QPU as one system file, format cudaq-pulse.system/1, which QuantumSystem.load reads back, raising a QuantumSystemDefinitionError that lists every problem with its line. python -m cudaq_pulse.doctor --system FILE checks a system file.

A controller’s processors run the classical functions called on their links. Compiling checks each function there (the operations it uses, its size, its state and its compute time at the processor’s cycles_per_op, an OpCycles such as OpCycles(div=20), against its max_latency_ns) and each processor’s totals; a processor with OpClass.LOOP unsupported runs loops unrolled, and their size is counted so. scheduled.controller_usage is the report: print it for a table, or read .within_limits and .controllers[i].processors[j]. In a description or a system file, a processor is a [[processors]] table, with [processors.dispatch_keys] beneath it.

class cudaq_pulse.Controller(
clock_ghz=None,
cycles_per_timestep=1,
instruction_cycles=1,
min_idle_cycles=0,
min_pulse_cycles=0,
max_pulse_cycles=None,
sample_rate_ghz=None,
waveform_memory_samples=None,
max_frequencies_per_line=None,
max_amplitude=None,
detectors=...,
detector_recovery_cycles=0,
feedback_latency_cycles=0,
max_pulses=None,
max_fine_delay_ns=0.0,
alignment_tolerance_cycles=0,
supports_timeouts=True,
max_instructions=None,
max_program_duration=None,
waveform_memory='per_line',
persistent_frames=False,
blocks_on_calls=False,
drive_lines=(),
readout_lines=(),
update_buses=(),
space_updates=False,
peer_latency_cycles=0,
clock_skew_cycles=0,
supports=None,
backend=None,
model=None,
version=None,
processors=(),
)[source]#

Bases: object

One controller: what it can play, its wiring and its processors; every limit is in its own clock cycles.

clock_ghz: the controller’s clock (None: the program clock, QuantumSystem.clock_ghz). It must be a whole-cycle ratio of the program clock; its program counts its own cycles. cycles_per_timestep: the controller starts and times operations only every this many of its own cycles; every operation on its lines must start and last whole timesteps (see “Clocks” in the controller backends guide; pulse.round_duration rounds a length to them). instruction_cycles and min_idle_cycles: two operations on one line start exactly instruction_cycles apart, or at least instruction_cycles + min_idle_cycles apart, because the controller issues one instruction per instruction_cycles and idles no less than min_idle_cycles. min_pulse_cycles: the shortest drive or readout its lines play (0: no limit), as some instruments require a minimum pulse length; a shorter one is a violation naming its line. Exports list it among the limits only when it is set. max_pulse_cycles: the longest drive or readout its lines play (None: no limit), as some instruments cap a pulse’s length; a longer one is a violation naming its line. It may not be below min_pulse_cycles. Exports list it among the limits only when it is set. sample_rate_ghz: the rate its lines play samples at (None: one per cycle of its clock). Its ratio to the clock may be a fraction, and every operation on its lines must start and last a whole number of samples, which the timestep includes: at 2.4 GHz on a 1 GHz clock, whole multiples of 5 cycles. A length off them is a compile error, never rounded. waveform_memory_samples: a waveform memory holds this many samples, at sample_rate_ghz; waveforms of one shape at different amplitudes share it (shape_key). waveform_memory: "per_line" (each line has a memory of waveform_memory_samples) or "shared" (one memory serves every line); see WaveformMemoryScope. max_frequencies_per_line: distinct frequencies one line plays over a program. max_amplitude: the largest magnitude of a sample its lines play (None: no limit). The compiler sets no amplitude limit of its own; a drive or readout whose envelope peaks above this one is a violation naming its line. Exports list it among the limits only when it is set. detectors and detector_recovery_cycles: the detector reading each qudit. A readout holds its detector for its duration plus detector_recovery_cycles, and the check refuses a readout that starts while an earlier one on the same detector holds it on a path of the program they share (readouts in the two arms of one measured if share none). In rolled loops the readouts are held against every iteration, from the loops’ periods; only when pairing the iterations of two readouts takes more than 32,768 trials (several long loops of different periods around each) are the first two iterations and the last of those loops compared alone. The scheduler does not place readouts around a shared detector; ControlSystem(max_concurrent_readouts=...) limits the readouts it places at once. feedback_latency_cycles: the least time from the end of a readout to the start of any operation that depends on its outcome (in a branch on it, on a tone whose frame a branch on it changed, computed from it, or a request that sends it); every schedule waits it. supports_timeouts: whether the controller can stop waiting for an answer after a timeout (result(timeout=...), latency_mode= "timeout"); without, only waits that block or are budgeted are allowed. max_pulses: the drives and readouts of one program; a controller that supports "loop" holds a rolled loop’s body once. max_instructions: the operations one program may hold, as the kernel traces them (None: no limit). An unrolled loop holds its body once per iteration, a rolled one once; tracing stops when the program grows past the limit, and the error names the loop that unrolled it. Exports list it among the limits only when it is set. max_program_duration: the longest program the controller runs, a time or a number of ns (None: no limit). The scheduled program, to the end of its last operation on the controller’s lines (line delays and the waits for feedback, lines and links included), is checked against it, on one controller or several, so operations that play together on different lines count once; a longer one is a compile error giving its length (with a wait whose length floats set, an error at the call). A wait whose length is known only when the program runs counts at its highest length for the lines it holds back, and is a compile error where it has no highest, as is a blocking classical call that an operation on those lines follows. When the module is built the compiler also sums the traced program op after op, every iteration of its loops, and refuses it where the sum passes the limit times the lines the program takes: no schedule of it fits then. Without the limit, a program may last up to 2**60 cycles. Exports list it only when it is set. max_fine_delay_ns: the longest delay, below one grid step, each line can add to its output (0: none), a time or a number of ns; it plays the part of a line’s calibrated delay (DriveLine, ReadoutLine) that whole grid steps cannot. alignment_tolerance_cycles: 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 (the compiler rounds it to the nearest one). persistent_frames: whether the frame of each tone, its frequency and phase, persists from one shot to the next. Without, every shot starts from the reset frame, and the export gives a frame change no later operation uses on some path as a frame update of its own; with, it exports instead the frame each tone ends the shot in (frame_state). blocks_on_calls: whether the controller plays nothing while one of its classical calls is out: each call holds every line from its submission until its answer is due, after the lines before it are done. The scheduler places calls so, and a program played on such a controller is checked for it; a call in a kernel with its own schedule= then does not compile. Exports list it among the limits only when it is set. In a control system of several controllers, a call holds the lines of each such controller that issues it, reads a measurement it sends or plays a pulse that uses its answer.

drive_lines and readout_lines are the drive and readout lines it plays: DriveLine(5, delay_ns=4.0) and ReadoutLine(5, delay_ns=12.0), each with its qudit (its carrier index in the quantum system) and calibrated delay, or a bare carrier index for an undelayed line (they read back as lines); the only controller of a system that lists none plays every line. A line may reach several qudits (ReadoutLine([0, 1, 2, 3], max_concurrent_tones=4), a shared line); each qudit is reached by at most one line of each kind. update_buses: the groups of its lines whose updates share one bus (UpdateBus), which carries one update at a time; updates on one bus must start cycles_per_update apart, else the program is a violation naming the bus, the lines and the times (none by default: no limit). Exports list it among the limits only when it is set. space_updates: whether compiling spaces the updates on its update buses, holding each back as little as it must, instead of refusing them (see “Update buses” in the controller backends guide). Off by default; exports list it only when it is set. peer_latency_cycles is 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 in the system (a receiver it does not list: 0). clock_skew_cycles bounds how far its clock is from the system’s. supports lists its capabilities (None: everything); a program that needs one it lacks fails to compile. backend is the controller backend that lowers its programs, by entry-point name. model and version identify the description it was made from. processors are its classical processors (Processor): the classical functions it computes itself, and their limits.

Parameters:
  • clock_ghz (float | None)

  • cycles_per_timestep (int)

  • instruction_cycles (int)

  • min_idle_cycles (int)

  • min_pulse_cycles (int)

  • max_pulse_cycles (int | None)

  • sample_rate_ghz (float | None)

  • waveform_memory_samples (int | None)

  • max_frequencies_per_line (int | None)

  • max_amplitude (float | None)

  • detectors (Mapping[int, int])

  • detector_recovery_cycles (int)

  • feedback_latency_cycles (int)

  • max_pulses (int | None)

  • max_fine_delay_ns (float | Time)

  • alignment_tolerance_cycles (float)

  • supports_timeouts (bool)

  • max_instructions (int | None)

  • max_program_duration (float | Time | None)

  • waveform_memory (WaveformMemoryScope | str)

  • persistent_frames (bool)

  • blocks_on_calls (bool)

  • drive_lines (Sequence[DriveLine | int])

  • readout_lines (Sequence[ReadoutLine | int])

  • update_buses (Sequence[UpdateBus])

  • space_updates (bool)

  • peer_latency_cycles (int | Mapping[int, int])

  • clock_skew_cycles (int)

  • supports (Sequence[Capability | str] | None)

  • backend (str | None)

  • model (str | None)

  • version (str | None)

  • processors (Sequence[Processor])

clock_ghz: float | None = None#
cycles_per_timestep: int = 1#
instruction_cycles: int = 1#
min_idle_cycles: int = 0#
min_pulse_cycles: int = 0#
max_pulse_cycles: int | None = None#
sample_rate_ghz: float | None = None#
waveform_memory_samples: int | None = None#
max_frequencies_per_line: int | None = None#
max_amplitude: float | None = None#
detectors: Mapping[int, int]#
detector_recovery_cycles: int = 0#
feedback_latency_cycles: int = 0#
max_pulses: int | None = None#
max_fine_delay_ns: float | Time = 0.0#
alignment_tolerance_cycles: float = 0#
supports_timeouts: bool = True#
max_instructions: int | None = None#
max_program_duration: float | Time | None = None#
waveform_memory: WaveformMemoryScope | str = 'per_line'#
persistent_frames: bool = False#
blocks_on_calls: bool = False#
drive_lines: Sequence[DriveLine | int] = ()#
readout_lines: Sequence[ReadoutLine | int] = ()#
update_buses: Sequence[UpdateBus] = ()#
space_updates: bool = False#
peer_latency_cycles: int | Mapping[int, int] = 0#
clock_skew_cycles: int = 0#
supports: Sequence[Capability | str] | None = None#
backend: str | None = None#
model: str | None = None#
version: str | None = None#
processors: Sequence[Processor] = ()#
as_dict()[source]#

The controller as JSON-serializable data, which Controller(**data) reads back after _controller_fields.

Return type:

dict[str, Any]

supports_capability(capability)[source]#

Whether the controller can do capability.

Parameters:

capability (Capability)

Return type:

bool

class cudaq_pulse.ControlSystem(
controllers=(),
links=...,
max_concurrent_drives=None,
max_concurrent_readouts=None,
line_switch_penalty_cycles=0,
reference_clock_ghz=None,
)[source]#

Bases: object

The controllers of one QPU and what connects them; see the module docstring.

A system without controllers states only its links, lanes, reference clock and line delays, and nothing checks what its controllers can play. links are the links to classical services, by name ("feedback", "controller"); a classical function’s link= names one, or gives its id: the links’ positions, so the first is link 0, the default. A link id a program uses that is not listed gets Link(). Link.controllers says which controllers a link reaches. Their slots and latencies apply to every schedule, because they are hardware. max_concurrent_drives and max_concurrent_readouts, when given, are the most drives and readouts the system plays at once, counted on every controller: the rcp and alap_rcp schedules keep to them, and a program whose schedule plays more at once fails to compile under any schedule. None (not given): the rcp schedules play at most 4 drives and 2 readouts at once, and nothing else checks them. max_concurrent_drives, max_concurrent_readouts and line_switch_penalty_cycles apply to the rcp and alap_rcp schedules, which keep pulses of two controllers that follow each other on one lane their start uncertainty apart. Every schedule keeps an operation that depends on a readout at least the feedback_latency_cycles of the controller that read it after the readout ends (on another controller, its peer latency and both start uncertainties too). reference_clock_ghz is a clock every controller locks to, if they share one: each controller’s clock must be a whole multiple of it, and without it each controller’s start is known only to within one of its own cycles. The calibrated delay of each line is part of the line, as its controller declares it (DriveLine, ReadoutLine).

Parameters:
  • controllers (Sequence[Controller])

  • links (Mapping[str, Link])

  • max_concurrent_drives (int | None)

  • max_concurrent_readouts (int | None)

  • line_switch_penalty_cycles (int)

  • reference_clock_ghz (float | None)

controllers: Sequence[Controller] = ()#
max_concurrent_drives: int | None = None#
max_concurrent_readouts: int | None = None#
line_switch_penalty_cycles: int = 0#
reference_clock_ghz: float | None = None#
as_dict()[source]#

The control system as JSON-serializable data; links name the controllers they reach by index.

Return type:

dict[str, Any]

class cudaq_pulse.Processor(
links=('controller',),
clock_ghz=None,
cycles_per_op=...,
unsupported=(),
max_concurrent_calls=1,
max_ops_per_function=None,
max_ops_total=None,
max_state_bytes_per_function=None,
max_state_bytes_total=None,
max_calls_per_shot=None,
max_bytes_per_shot=None,
fixed_cost_only=False,
dispatch_keys=...,
)[source]#

Bases: object

A classical processor on a controller, which runs the classical functions called on its links (link names of the control system, or link ids). A link belongs to at most one processor of a system; a function on no processor runs off the controllers, and only its link is checked.

clock_ghz: its clock (None: the controller’s, else the program’s). cycles_per_op: an OpCycles, the cycles of one operation of each class, and of loop, a rolled loop’s counter and jump per iteration; one cycle when not given. branch is an if or else. unsupported: the classes it cannot run (OpClass); a function that uses one does not compile, except OpClass.LOOP: a processor without it runs each loop unrolled, so its code is counted unrolled. max_concurrent_calls: the calls it computes at once, from submission to the time the answer is due. max_ops_per_function and max_ops_total: the operations one function, and all its functions, may hold. max_state_bytes_per_function and max_state_bytes_total: the bytes of arguments, results and locals of one function, and of all of them. max_calls_per_shot and max_bytes_per_shot: the calls, and the bytes of requests and answers, of one shot. None is no limit. fixed_cost_only: every function’s cost must be fixed when the program compiles (no while, recursion or allocation). dispatch_keys: the dispatch key of each function it runs, by function name, when the processor fixes them; it then lists every function it runs.

Parameters:
  • links (Sequence[int | str])

  • clock_ghz (float | None)

  • cycles_per_op (OpCycles)

  • unsupported (Sequence[OpClass])

  • max_concurrent_calls (int)

  • max_ops_per_function (int | None)

  • max_ops_total (int | None)

  • max_state_bytes_per_function (int | None)

  • max_state_bytes_total (int | None)

  • max_calls_per_shot (int | None)

  • max_bytes_per_shot (int | None)

  • fixed_cost_only (bool)

  • dispatch_keys (Mapping[str, int])

clock_ghz: float | None = None#
cycles_per_op: OpCycles#
unsupported: Sequence[OpClass] = ()#
max_concurrent_calls: int = 1#
max_ops_per_function: int | None = None#
max_ops_total: int | None = None#
max_state_bytes_per_function: int | None = None#
max_state_bytes_total: int | None = None#
max_calls_per_shot: int | None = None#
max_bytes_per_shot: int | None = None#
fixed_cost_only: bool = False#
dispatch_keys: Mapping[str, int]#
property loops: bool#

Whether it runs a rolled loop as a loop ("loop" is not unsupported); without, its loops are unrolled.

usage(function)[source]#

What the classical function uses of this processor on its own: its operations, state and messages, and its cycles on the longest path; compute_ns only when the processor has clock_ghz (else None), and calls_per_shot None (a compiled program’s controller_usage has both). A function whose list lengths come from its calls has a cost per version: ask for one, processor.usage(flip.specialize(outcomes=3)).

Parameters:

function (Any)

Return type:

FunctionUsage

as_dict()[source]#

The processor as JSON-serializable data, as a system file holds it: its cycles_per_op a table of the classes not 1 cycle.

Return type:

dict[str, Any]

class cudaq_pulse.Capability(*values)[source]#

Bases: StrEnum

What a controller can do, for Controller.supports.

play a drive; readout a qudit; wait, of any length: one fixed when the program compiles, one a call binds, and one computed while the QPU runs; sync lines; call a classical function and take its answer; branch on an outcome or an answer; runtime_frame_update a tone’s frequency or phase from a value computed while the QPU runs; forward_outcome of one of its readouts to another controller, which branches on it; loop: run a rolled loop itself, holding its body once. A controller without loop plays a rolled loop unrolled, so each iteration counts against its max_pulses. Unrolling does not change its waveform memory: a waveform is stored once per shape however often it plays, so only the pulse count goes up.

PLAY = 'play'#
READOUT = 'readout'#
WAIT = 'wait'#
SYNC = 'sync'#
CALL = 'call'#
ANSWER = 'answer'#
BRANCH = 'branch'#
RUNTIME_FRAME_UPDATE = 'runtime_frame_update'#
FORWARD_OUTCOME = 'forward_outcome'#
LOOP = 'loop'#
class cudaq_pulse.Link(
fixed_ns=0.0,
bytes_per_ns=0.0,
feedback_ns=0.0,
slots=64,
slot_bytes=1024,
controllers=None,
per_controller=False,
)

Bases: object

What one link to a classical service costs, for scheduling.

fixed_ns is the fixed cost of sending a request and bytes_per_ns its bandwidth (0 for unlimited): a request holds the link for fixed_ns + bytes / bytes_per_ns, at least one clock cycle. feedback_ns is added to every latency: the time from an answer arriving to a pulse being able to use it. fixed_ns and feedback_ns are times (100 * pulse.ns) or numbers of ns. slots is how many requests the link holds at once (its slots), and slot_bytes the largest request or answer, its 24-byte header included.

controllers are the controllers of a ControlSystem the link reaches (None: all of them): a call over it can send only their measurements, and only they can use its answers.

A link is one service the controllers share. With per_controller, each controller it reaches has an instance of its own, with its own slots, its own processor (Processor.links) and its own dispatch keys: a call over it runs on the instance of the controller that sends its measurements and uses its answer, which must be one controller, so no answer crosses between controllers.

Parameters:
  • fixed_ns (float | Time)

  • bytes_per_ns (float)

  • feedback_ns (float | Time)

  • slots (int)

  • slot_bytes (int)

  • controllers (Sequence[Controller] | None)

  • per_controller (bool)

attribute(uncertainty_ns=0.0, name=None)[source]

The link as an entry of the module attribute classical.links; uncertainty_ns is how far apart the starts of the controllers it joins may be, which an answer taken on another controller than the one that sent the request adds to its budget. A per-controller link is marked so, with its name.

Parameters:
  • uncertainty_ns (float)

  • name (str | None)

Return type:

str

bytes_per_ns: float = 0.0
controllers: Sequence[Controller] | None = None
cost()[source]

What the link costs, as JSON-serializable data (with per_controller when it has an instance per controller).

Return type:

dict[str, float | int]

feedback_ns: float | Time = 0.0
fixed_ns: float | Time = 0.0
per_controller: bool = False
slot_bytes: int = 1024
slots: int = 64

Parameter drift#

Parameter drift of a simulated quantum system.

pulse.quantum_system(..., parameter_drift=True) builds a quantum system whose qudit parameters drift while it runs, as a real chip’s do. It holds two sets of values:

  • the calibrated values (qs.physical_qudits), which are all that compiling reads: a drifting system compiles, caches, fingerprints and exports exactly as its non-drifting twin does;

  • the true values (qs.true_qudits, each the same PhysicalQudit type), which pulse.simulate plays. They start at the calibrated values (a freshly calibrated chip) and move as drift time passes.

Drift time follows the run clock of what the system runs. Each simulate call advances it by its shots: shots_count times the program’s duration plus reset_time (without shots_count, one shot). The true values are held for the call, except that a call whose shots take longer than the shortest correlation time of the system’s drift models is split, by whole shots, into chunks each at least that long, and each chunk plays the true values at its start. qs.advance(20 * pulse.ms) moves time on outside simulate: the idle time between experiments.

parameter_drift takes True (the default model, ParameterDrift(), on every qudit), a model (on every qudit) or {qudit: model} (only those qudits, keyed as physical_qudits is). A model is a ParameterDrift or any object with the two methods of ParameterDriftModel. parameter_drift_seed seeds every qudit’s own random stream.

class cudaq_pulse.quantum_systems.drift.OrnsteinUhlenbeck(sigma, correlation_time)[source]#

Bases: object

A stationary Gaussian process around zero, with standard deviation sigma and correlation time correlation_time: an offset that wanders and returns. ParameterDrift uses it for a qudit’s frequency offset (sigma in Hz) and its drive amplitude (sigma relative to the calibrated amplitude).

Parameters:
  • sigma (float)

  • correlation_time (Time)

sigma: float#
correlation_time: Time#
class cudaq_pulse.quantum_systems.drift.ParameterDrift(frequency=..., t1=..., amplitude=...)[source]#

Bases: object

The built-in drift model: a qudit’s frequency, T1 and drive amplitude drift independently, each part None to leave it fixed.

The defaults are of the size measured on superconducting transmons (see the user guide): the frequency wanders by about 20 kHz over an hour (OrnsteinUhlenbeck(20e3, 3600 * pulse.s)), T1 drops to half its calibrated value and back, staying about ten minutes in each (TelegraphT1(0.5, 600 * pulse.s)), and the drive amplitude wanders by about 0.2% over an hour (OrnsteinUhlenbeck(0.002, 3600 * pulse.s)). They are slow: a run of seconds barely drifts, so an example that wants visible drift passes faster parts.

Parameters:
frequency: OrnsteinUhlenbeck | None#
t1: TelegraphT1 | None#
amplitude: OrnsteinUhlenbeck | None#
property correlation_time: Time#

The shortest time scale of its parts: a correlation time or a T1 dwell time.

start(calibrated, rng)[source]#

The calibrated qudit: drift starts from a freshly calibrated chip.

Parameters:
Return type:

PhysicalQudit

advance(true, calibrated, seconds, rng)[source]#
Parameters:
Return type:

PhysicalQudit

class cudaq_pulse.quantum_systems.drift.ParameterDriftModel(*args, **kwargs)[source]#

Bases: Protocol

How one qudit’s true parameters drift: any object with these two methods. The state is the true qudit itself, so a model needs no state of its own; randomness must come from rng for parameter_drift_seed to repeat a run. A model may also have correlation_time (a Time): simulate then splits calls longer than it. Models reach worker processes pickled.

start(calibrated, rng)[source]#

The true qudit when the system is built, from its calibrated one.

Parameters:
Return type:

PhysicalQudit

advance(true, calibrated, seconds, rng)[source]#

The true qudit seconds after true: a changed copy (true.replace(...)) of any of the fields the simulator reads.

Parameters:
Return type:

PhysicalQudit

class cudaq_pulse.quantum_systems.drift.TelegraphT1(low_fraction, dwell_time)[source]#

Bases: object

T1 switching at random between the calibrated value and low_fraction of it, staying a mean dwell_time in each, as when a two-level defect near the qudit switches in and out of resonance.

Parameters:
  • low_fraction (float)

  • dwell_time (Time)

low_fraction: float#
dwell_time: Time#

Calibrations and the transmon circuit model#

class cudaq_pulse.quantum_systems.Calibration(data, *, name, measurement_run=None)[source]#

Bases: object

One measurement run of a calibration file; see the module docstring.

Qubits and pairs are named by their labels ("D4", "X2-D4" with the auxiliary first).

Parameters:
  • data (Mapping[str, Any])

  • name (str)

  • measurement_run (str | None)

property quantum_system: str | None#

The quantum system the calibration was made for, if its file names one.

classmethod load(source='transmon_surface17', *, measurement_run=None)[source]#

A shipped calibration by name, or a calibration file by path.

Parameters:
  • source (str | PathLike[str])

  • measurement_run (str | None)

Return type:

Calibration

measurement_runs()[source]#

Each measurement run of the file and what it is.

Return type:

Mapping[str, str]

entry(*path)[source]#

The leaf at path with its provenance, e.g. entry("qudits", "D4", "ec").

Parameters:

path (str)

Return type:

Mapping[str, Any]

value(*path)[source]#

The value of the leaf at path.

Parameters:

path (str)

Return type:

Any

property fingerprint: str#
property flux_qudits: tuple[str, ...]#

The qudits whose circuit, including d, is calibrated.

circuit(qudit)[source]#

The circuit of qudit, for flux in flux quanta.

Parameters:

qudit (str)

Return type:

TransmonCircuit

idle_flux(qudit)[source]#

The flux at which qudit idles: its calibrated sweet spot.

Parameters:

qudit (str)

Return type:

float

property pairs: tuple[str, ...]#

The coupled pairs, auxiliary first.

charge_coupling_hz(pair)[source]#

g_c of pair ("X2-D4"): the system-wide charge coupling.

Parameters:

pair (str)

Return type:

float

pair(pair, level_count=5)[source]#

The charge-coupled pair, data transmon first (so |02> is the auxiliary’s second excited state).

Parameters:
  • pair (str)

  • level_count (int)

Return type:

ChargeCoupledPair

exchange_hz(pair, auxiliary_hz=None, data_hz=None)[source]#

The 0-1 exchange J_qq of pair with its qubits at these 0-1 frequencies; at their idle points by default.

Parameters:
  • pair (str)

  • auxiliary_hz (float | None)

  • data_hz (float | None)

Return type:

float

idle_zz_hz(pair)[source]#

The static ZZ of pair at its idle points, from the dressed levels of the charge-coupled pair.

Parameters:

pair (str)

Return type:

float

detuning_for_flux(qudit, flux)[source]#

The 0-1 detuning (Hz) from the idle point that a flux of flux flux quanta tunes qudit to.

Parameters:
  • qudit (str)

  • flux (float)

Return type:

float

flux_for_detuning(qudit, detuning_hz)[source]#

The flux (flux quanta, in [0, 1/2]) that detunes qudit by detuning_hz from its idle point.

Parameters:
  • qudit (str)

  • detuning_hz (float)

Return type:

float

Flux-tunable transmons and their charge coupling, from circuit values.

A transmon is a Cooper-pair box diagonalized in the charge basis,

H = 4 E_C n^2 - E_J(Phi) cos(phi), E_J(Phi) = E_J,max sqrt(cos^2(pi Phi) + d^2 sin^2(pi Phi)),

with Phi in flux quanta and d the asymmetry of its SQUID (Koch et al., PRA 76, 042319 (2007); Hellings et al., arXiv:2503.04610, eq. B2). The offset charge is omitted: for E_J / E_C > 70 its dispersion is below 1 kHz. Two transmons couple through g_c n_a n_b, with no rotating-wave approximation; their 0-1 exchange is J_qq = g_c <0|n_a|1> <0|n_b|1>.

Energies are in Hz (E / h). Circuit values (E_C, E_J,max, d, g_c) are fitted, so they come from a calibration, never from a system’s published values.

class cudaq_pulse.quantum_systems.transmon_model.ChargeCoupledPair(a, b, g_c_hz, level_count=5)[source]#

Bases: object

Two transmons coupled by g_c n_a n_b. Product states are |i_a i_b>.

With the data (lower-frequency) transmon as a and the auxiliary as b, |02> is the auxiliary’s second excited state: the level the CZ brings into resonance with |11>.

Parameters:
a: TransmonCircuit#
b: TransmonCircuit#
g_c_hz: float#
level_count: int = 5#
hamiltonian(flux_a, flux_b)[source]#

The pair’s Hamiltonian in Hz, in the product basis |i_a i_b> (row i_a * level_count + i_b): each transmon’s levels above its ground state plus g_c n_a n_b, with fluxes in flux quanta.

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

NDArray[float64]

dressed_spectrum(flux_a, flux_b)[source]#

The dressed energy of each product state |i j>, by largest overlap.

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

dict[tuple[int, int], float]

j_qq_hz(flux_a, flux_b)[source]#

The 0-1 exchange g_c <0|n_a|1> <0|n_b|1>.

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

float

exchange_hz(f01_a_hz, f01_b_hz)[source]#

J_qq with the transmons tuned to these 0-1 frequencies: J(w_a, w_b).

Parameters:
  • f01_a_hz (float)

  • f01_b_hz (float)

Return type:

float

idle_zz_hz(flux_a, flux_b)[source]#

Static ZZ, E_11 - E_10 - E_01 + E_00 of the dressed levels.

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

float

gap_11_02_hz(flux_a, flux_b)[source]#

E_11 - E_02 of the dressed levels; its smallest magnitude over flux is 2 J_2, with J_2 the |11>-|02> coupling (about sqrt(2) J_qq).

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

float

splitting_11_02_hz(flux_a, flux_b)[source]#

The splitting of the two levels that share |11> and |02> most, which stays defined through their avoided crossing.

Parameters:
  • flux_a (float)

  • flux_b (float)

Return type:

float

j2_hz(interaction_frequency_hz, span=0.02)[source]#

J_2, half the smallest |11>-|02> splitting, with a at interaction_frequency_hz and b swept through f12 = that frequency (within span flux quanta).

If b’s 1-2 transition cannot reach that frequency, b stays at the nearer sweet spot and a is swept through the crossing.

Parameters:
  • interaction_frequency_hz (float)

  • span (float)

Return type:

float

class cudaq_pulse.quantum_systems.transmon_model.TransmonCircuit(ec_hz, ej_max_hz, asymmetry, label='')[source]#

Bases: object

An asymmetric-SQUID transmon; asymmetry is d = (E_J2 - E_J1) / E_JSigma.

Flux is in flux quanta; f01 falls monotonically from Phi = 0 to Phi = 1/2, its two sweet spots.

Parameters:
  • ec_hz (float)

  • ej_max_hz (float)

  • asymmetry (float)

  • label (str)

ec_hz: float#
ej_max_hz: float#
asymmetry: float#
label: str = ''#
ej_hz(flux)[source]#

The Josephson energy E_J(Phi) at flux flux quanta, in Hz: E_J,max at Phi = 0, down to abs(d) E_J,max at Phi = 1/2.

Parameters:

flux (float)

Return type:

float

eigensystem(flux, level_count=5)[source]#

Energies above the ground state and the charge matrix <i|n|j>.

Signs are fixed so that <i|n|i+1> > 0, which keeps n_ij continuous in flux.

Parameters:
  • flux (float)

  • level_count (int)

Return type:

tuple[NDArray[float64], NDArray[float64]]

f01_hz(flux)[source]#

The 0-1 transition frequency at flux flux quanta, in Hz.

Parameters:

flux (float)

Return type:

float

f12_hz(flux)[source]#

The 1-2 transition frequency at flux flux quanta, in Hz.

Parameters:

flux (float)

Return type:

float

anharmonicity_hz(flux)[source]#

E_2 - 2 E_1 (f12 - f01) at flux flux quanta, in Hz; negative for a transmon.

Parameters:

flux (float)

Return type:

float

charge_matrix(flux, level_count=5)[source]#

The charge matrix <i|n|j> of the lowest level_count levels at flux flux quanta (dimensionless), with the signs of eigensystem.

Parameters:
  • flux (float)

  • level_count (int)

Return type:

NDArray[float64]

flux_for_f01(f01_hz, tol=1e-09)[source]#

The flux in [0, 1/2] at which f01 is f01_hz.

Parameters:
  • f01_hz (float)

  • tol (float)

Return type:

float

flux_for_f12(f12_hz, tol=1e-09)[source]#

The flux in [0, 1/2] at which the 1-2 transition is f12_hz.

Parameters:
  • f12_hz (float)

  • tol (float)

Return type:

float

flux_curvature_hz(flux, step=0.001)[source]#

d^2 f01 / dPhi^2, the second-order flux-noise sensitivity (Hz per flux quantum squared).

Parameters:
  • flux (float)

  • step (float)

Return type:

float

cudaq_pulse.quantum_systems.transmon_model.anchored_charge_coupling_hz(
data,
auxiliary,
g_11_20_hz,
interaction_frequency_hz,
level_count=5,
)[source]#

The g_c for which the pair’s |11>-|20> coupling J_2 is g_11_20_hz at its interaction point: the data transmon at interaction_frequency_hz and the auxiliary’s 1-2 transition there.

J_2 is nearly linear in g_c, so a few fixed-point steps converge to machine precision.

Parameters:
Return type:

float