Quantum system API#
-
cudaq_pulse.quantum_system(
)[source]#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',
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, andQuantumSystem.from_dict(data)its data.quantum_system()is the process quantum system, named byCUDAQ_PULSE_QUANTUM_SYSTEM(python -m cudaq_pulse --quantum-system NAMEsets it); without one it raisesNoProcessQuantumSystemError.quantum_system(name="chip", qudits={0: PhysicalQudit(...), ...})builds one:quditsare itsPhysicalQuditcarriers by index,couplingsandresidual_zzitsCouplingandResidualZZentries,modelhow the simulator treats its qudits and how many levels each has (aSimulationModelclass or instance,TransmonModelby default,TransmonModel(levels={0: 4})to give qudit 0 four levels, orNonefor a system with no simulation model) andattributionwhere 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 quditinames; by default every carrier of the quantum system, in order.calibrationis aCalibration, the name of a shipped one or the path of a calibration file, andmeasurement_runone of its measurement runs; the calibration’s couplings replace the system’s, andQuantumSystem.calibrationholds it. Thetransmon_surface17quantum system uses the shippedtransmon_surface17calibration by default.control_systemis aControlSystem, whose lines must be carriers of the quantum system.clock_ghzis 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.framesis 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 itsfrequency_hz. A system without couplings is the same either way.parameter_driftmakes the simulated system’s qudit parameters drift (cudaq_pulse.quantum_systems.drift):Truefor the defaultParameterDrift()on every qudit, a drift model for that model on every qudit, or{qudit: model}for only those qudits (keyed asphysical_qudits). Compiling reads only the calibrated values, so the system equals its non-drifting twin;simulateplays 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
QuantumSystemDefinitionErrorlisting all of them, each at the argument it is in.- Parameters:
name (str | None)
qudits (Mapping[int, PhysicalQudit] | None)
couplings (Sequence[Coupling])
residual_zz (Sequence[ResidualZZ])
model (SimulationModel | type[SimulationModel] | None)
attribution (str)
layout (Sequence[int] | None)
calibration (Calibration | str | os.PathLike[str] | None)
measurement_run (str | None)
control_system (ControlSystem | None)
clock_ghz (float | None)
parameter_drift (bool | ParameterDriftModel | Mapping[int, ParameterDriftModel])
parameter_drift_seed (int | None)
frames (str)
- Return type:
-
class cudaq_pulse.QuantumSystem(
)[source]#target,*,name,layout=None,source='',calibration=None,control_system=None,clock_ghz=None,_variant=False,
Bases:
objectA read-only machine description; see the module docstring.
clock_ghzis 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 (seecudaq_pulse.controller).qudit_freq[q]is the 0-1 transition frequency of quditq(Hz) andtransition_freq[q, i, j]that of levelsiandj(the upper level’s energy less the lower’s, in either order ofiandj), 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_systemis theControlSystemthat plays it, if given;compile(kernel, quantum_system=dev)checks every program against it.A quantum system built with
parameter_drift=drifts (seecudaq_pulse.quantum_systems.drift):physical_quditsare its calibrated values, all that compiling reads, andtrue_quditsthe valuessimulateplays, which drift as it runs and asadvance(duration)moves time on;parameter_driftis the model of each drifting qudit andparameter_drift_timethe drift time so far. It equals its non-drifting twin: the same fingerprint, compiled programs and exports. Without drift,true_quditsisphysical_qudits,parameter_driftandparameter_drift_timeareNoneandadvanceraises.- 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 quditq’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 levelsiandjof quditq. 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 inqs.qudit("D1"); aNotFoundErrornames the labels there are.- Parameters:
label (str)
- Return type:
- 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. ANotFoundErrornames the qudits a couples to.
- static load(path, /)[source]#
The quantum system of a system file, as
as_dictwrites 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 raisesQuantumSystemDefinitionErrorlisting all of them, each with its path in the file, its line and its column;python -m cudaq_pulse.doctor --system FILEruns the same checks.- Parameters:
path (str | PathLike[str])
- Return type:
- static from_dict(data, /)[source]#
The quantum system of a system file’s data, as
as_dictreturns it orjson.loadreads it; seeload.- Parameters:
data (Mapping[str, Any])
- Return type:
- replace(**changes)[source]#
A variant of the quantum system, as
dataclasses.replacemakes one: the quantum systempulse.quantum_system(name=..., qudits=...)builds from this one’sname,qudits(itsphysical_qudits),couplings,residual_zz,model,attribution,frames,readout_crosstalk,layout,control_systemandclock_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 nocalibrationof its own.parameter_driftandparameter_drift_seedgive the variant drift, aspulse.quantum_systemtakes 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:
- as_dict()[source]#
The quantum system as JSON-serializable data, which
QuantumSystem.from_dictreads 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:
objectA handle naming one carrier of a quantum system.
indexis the carrier’s index in the quantum system (the layout is applied when the handle is created);logicalis the position the user indexed. A handle is identity, not location.- Parameters:
quantum_system (QuantumSystem)
index (int)
logical (int)
- 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 anOffsetfrom it, and where they give none it isNone.
-
get_calibration(
) DragPulse[source]#gate: Literal[Gate.X, Gate.X90, Gate.Y, Gate.Y90],transition: tuple[int, int] = (0, 1),
-
get_calibration(
) VirtualZgate: Literal[Gate.Z, Gate.S, Gate.T],transition: tuple[int, int] = (0, 1),
-
get_calibration(
) ReadoutPulsegate: Literal[Gate.READOUT],transition: tuple[int, int] = (0, 1),
-
get_calibration(
) DragPulse | VirtualZ | ReadoutPulsetransition: tuple[int, int] = (0, 1),
The calibrated pulse of gate on this qudit of its quantum system, as
get_drive_line(q).get_calibration(gate)(XtoT) andget_readout_line(q).get_calibration(pulse.gates.READOUT)give it in a kernel; seePhysicalQudit.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 annotatedpulse.Registeris a runtime value: the kernel compiles once for each register length and then runs on any qudits of the system. A register supportslen(), indexing, slicing and iteration: indexing with anintgives aQudit, while a slice or a list of indexes gives anotherRegister.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_lineorget_readout_line; duration must be known while the kernel compiles. A line whose timestep is one cycle takes every whole cycle, soround_duration(line, n)isceil(n).- Parameters:
line (Any)
duration (float)
direction (RoundDirection | str)
- Return type:
int
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:
floatA wall-clock time: a float of nanoseconds holding its exact value.
Made by multiplying a unit,
20 * pulse.ns; durations, waits andpulse.round_durationtake 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, raisesTypeError: writet == 20 * pulse.nsorfloat(t) == 20.0. A time never hashes like a number, so a set or dict can hold20 * pulse.nsand20.0as different keys, and finding a number in it never compares it with a time;inon a list or tuple compares with==, and raises when it meets a time and a number.- Parameters:
nanoseconds (Fraction | int | float)
- Return type:
- 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(
)[source]#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=(),
Bases:
objectOne 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_durationrounds a length to them).instruction_cyclesandmin_idle_cycles: two operations on one line start exactlyinstruction_cyclesapart, or at leastinstruction_cycles + min_idle_cyclesapart, because the controller issues one instruction perinstruction_cyclesand idles no less thanmin_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 belowmin_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, atsample_rate_ghz; waveforms of one shape at different amplitudes share it (shape_key).waveform_memory:"per_line"(each line has a memory ofwaveform_memory_samples) or"shared"(one memory serves every line); seeWaveformMemoryScope.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.detectorsanddetector_recovery_cycles: the detector reading each qudit. A readout holds its detector for its duration plusdetector_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 measuredifshare 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 ownschedule=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_linesandreadout_linesare the drive and readout lines it plays:DriveLine(5, delay_ns=4.0)andReadoutLine(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 startcycles_per_updateapart, 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_cyclesis 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_cyclesbounds how far its clock is from the system’s.supportslists its capabilities (None: everything); a program that needs one it lacks fails to compile.backendis the controller backend that lowers its programs, by entry-point name.modelandversionidentify the description it was made from.processorsare 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#
- alignment_tolerance_cycles: float = 0#
- supports_timeouts: bool = True#
- max_instructions: int | None = None#
- waveform_memory: WaveformMemoryScope | str = 'per_line'#
- persistent_frames: bool = False#
- blocks_on_calls: bool = False#
- readout_lines: Sequence[ReadoutLine | int] = ()#
- 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#
- 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(
)[source]#controllers=(),links=...,max_concurrent_drives=None,max_concurrent_readouts=None,line_switch_penalty_cycles=0,reference_clock_ghz=None,
Bases:
objectThe 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.
linksare the links to classical services, by name ("feedback","controller"); a classical function’slink=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 getsLink().Link.controllerssays which controllers a link reaches. Their slots and latencies apply to every schedule, because they are hardware.max_concurrent_drivesandmax_concurrent_readouts, when given, are the most drives and readouts the system plays at once, counted on every controller: thercpandalap_rcpschedules keep to them, and a program whose schedule plays more at once fails to compile under any schedule.None(not given): thercpschedules play at most 4 drives and 2 readouts at once, and nothing else checks them.max_concurrent_drives,max_concurrent_readoutsandline_switch_penalty_cyclesapply to thercpandalap_rcpschedules, 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 thefeedback_latency_cyclesof the controller that read it after the readout ends (on another controller, its peer latency and both start uncertainties too).reference_clock_ghzis 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#
-
class cudaq_pulse.Processor(
)[source]#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=...,
Bases:
objectA 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: anOpCycles, the cycles of one operation of each class, and ofloop, a rolled loop’s counter and jump per iteration; one cycle when not given.branchis aniforelse.unsupported: the classes it cannot run (OpClass); a function that uses one does not compile, exceptOpClass.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_functionandmax_ops_total: the operations one function, and all its functions, may hold.max_state_bytes_per_functionandmax_state_bytes_total: the bytes of arguments, results and locals of one function, and of all of them.max_calls_per_shotandmax_bytes_per_shot: the calls, and the bytes of requests and answers, of one shot.Noneis no limit.fixed_cost_only: every function’s cost must be fixed when the program compiles (nowhile, 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])
- links: Sequence[int | str] = ('controller',)#
- clock_ghz: float | None = None#
- 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 notunsupported); 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_nsonly when the processor hasclock_ghz(elseNone), andcalls_per_shotNone(a compiled program’scontroller_usagehas 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:
- class cudaq_pulse.Capability(*values)[source]#
Bases:
StrEnumWhat a controller can do, for
Controller.supports.playa drive;readouta qudit;wait, of any length: one fixed when the program compiles, one a call binds, and one computed while the QPU runs;synclines;calla classical function and take itsanswer;branchon an outcome or an answer;runtime_frame_updatea tone’s frequency or phase from a value computed while the QPU runs;forward_outcomeof one of its readouts to another controller, which branches on it;loop: run a rolled loop itself, holding its body once. A controller withoutloopplays a rolled loop unrolled, so each iteration counts against itsmax_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:
objectWhat one link to a classical service costs, for scheduling.
fixed_nsis the fixed cost of sending a request andbytes_per_nsits bandwidth (0 for unlimited): a request holds the link forfixed_ns + bytes / bytes_per_ns, at least one clock cycle.feedback_nsis added to every latency: the time from an answer arriving to a pulse being able to use it.fixed_nsandfeedback_nsare times (100 * pulse.ns) or numbers of ns.slotsis how many requests the link holds at once (its slots), andslot_bytesthe largest request or answer, its 24-byte header included.controllersare the controllers of aControlSystemthe 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_controllerwhen 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 samePhysicalQudittype), whichpulse.simulateplays. 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:
objectA stationary Gaussian process around zero, with standard deviation
sigmaand correlation timecorrelation_time: an offset that wanders and returns.ParameterDriftuses it for a qudit’s frequency offset (sigmain Hz) and its drive amplitude (sigmarelative to the calibrated amplitude).- Parameters:
sigma (float)
correlation_time (Time)
- sigma: float#
- class cudaq_pulse.quantum_systems.drift.ParameterDrift(frequency=..., t1=..., amplitude=...)[source]#
Bases:
objectThe built-in drift model: a qudit’s frequency, T1 and drive amplitude drift independently, each part
Noneto 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)
- 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:
calibrated (PhysicalQudit)
rng (Generator)
- Return type:
- advance(true, calibrated, seconds, rng)[source]#
- Parameters:
true (PhysicalQudit)
calibrated (PhysicalQudit)
seconds (float)
rng (Generator)
- Return type:
- class cudaq_pulse.quantum_systems.drift.ParameterDriftModel(*args, **kwargs)[source]#
Bases:
ProtocolHow 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_seedto repeat a run. A model may also havecorrelation_time(aTime):simulatethen 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:
calibrated (PhysicalQudit)
rng (Generator)
- Return type:
- 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:
true (PhysicalQudit)
calibrated (PhysicalQudit)
seconds (float)
rng (Generator)
- Return type:
- class cudaq_pulse.quantum_systems.drift.TelegraphT1(low_fraction, dwell_time)[source]#
Bases:
objectT1 switching at random between the calibrated value and
low_fractionof it, staying a meandwell_timein 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#
Calibrations and the transmon circuit model#
- class cudaq_pulse.quantum_systems.Calibration(data, *, name, measurement_run=None)[source]#
Bases:
objectOne 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:
- 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]
- 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:
- 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:
- 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
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:
objectTwo transmons coupled by g_c n_a n_b. Product states are
|i_a i_b>.With the data (lower-frequency) transmon as
aand the auxiliary asb,|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)
- 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, withaatinteraction_frequency_hzandbswept through f12 = that frequency (withinspanflux quanta).If
b’s 1-2 transition cannot reach that frequency,bstays at the nearer sweet spot andais 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:
objectAn asymmetric-SQUID transmon;
asymmetryis 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
fluxflux 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
fluxflux quanta, in Hz.- Parameters:
flux (float)
- Return type:
float
- f12_hz(flux)[source]#
The 1-2 transition frequency at
fluxflux quanta, in Hz.- Parameters:
flux (float)
- Return type:
float
- anharmonicity_hz(flux)[source]#
E_2 - 2 E_1 (f12 - f01) at
fluxflux 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 lowestlevel_countlevels atfluxflux quanta (dimensionless), with the signs ofeigensystem.- 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
-
cudaq_pulse.quantum_systems.transmon_model.anchored_charge_coupling_hz(
)[source]#data,auxiliary,g_11_20_hz,interaction_frequency_hz,level_count=5,
The g_c for which the pair’s
|11>-|20>coupling J_2 isg_11_20_hzat its interaction point: the data transmon atinteraction_frequency_hzand 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:
data (TransmonCircuit)
auxiliary (TransmonCircuit)
g_11_20_hz (float)
interaction_frequency_hz (float)
level_count (int)
- Return type:
float