Compilation API#
This page documents pulse.compile and pulse.load and the objects
they produce: the compiled and scheduled kernels, the passes that
transform them, the idle windows and exposure a scheduled kernel reports,
and the compile metrics. See Compile and Inspect a Program
for how calling a kernel compiles it and reuses the compilation.
-
cudaq_pulse.compile(
)[source]#kernel,/,*,schedule=None,passes=None,control_system=None,quantum_system=None,flatten_schedules=False,unroll_threshold=None,unit_warnings=False,loop_exit=None,
Compile a
@cudaq_pulse.kernelwithout its arguments.Returns a
CompiledKernel, a family of specializations. Calling it with the kernel’s arguments runs the kernel on the quantum system of the qudit handles passed and returns what the kernel returns. Float parameters stay symbolic: the module takes them as function arguments, so calls with new values never recompile. Parameters of any other type (qudits, ints) shape the program; each distinct value, on each quantum system, is compiled on first use and kept for the life of the compiled object.- Parameters:
kernel (Kernel[P]) – A
@cudaq_pulse.kernel.schedule (str | None) – Scheduling policy of kernel itself:
"asap","alap","rcp","alap_rcp"; by default the kernel’s ownschedule=, else"alap". Kernels it calls keep their own.passes (Sequence[str] | None) – Optimization passes (
Passmembers or their names), run in the order given;DEFAULT_PASSESby default,()for none.control_system (ControlSystem | Controller | None) – The
ControlSystemto compile for: every program is checked against its controllers’ wiring, capabilities and limits, and its links and lanes set the schedule. OneControllerstands for a system of that controller alone; what it cannot take (a line it does not play, a link it does not have) is an error that says to describe the whole system. By default the control system of quantum_system, if it has one.flatten_schedules (bool) – Ignore the
schedule=of every called kernel and schedule the whole program with schedule.unroll_threshold (int | None) – A
for ... in range(n)loop whose variable the body never reads is unrolled while tracing when n times the number of calls in its body is at most this, and emitted once as a rolled loop otherwise. By default the kernel’s ownunroll_threshold=, else 8. A non-negativeint; 0 never unrolls, so every such loop stays rolled, even one of no or one iteration. Either way the program, its schedule and its simulation are the same.unit_warnings (bool) – Issue a
UnitWarningat each kernel line that gives a time without units (a bare number as a duration, a wait, or a pulse’ssigma,betaorwidth, which counts clock cycles) or a frequency far below the quantum system’s carriers (one probably in MHz or kHz rather than Hz). Off by default. The warnings are issued when the kernel traces; they do not change the program.loop_exit (str | None) – What a loop that is left when the program runs (
if flag: breakon a measurement result or an answer, infor _ in range(budget)) compiles to on a control system that cannot leave a counted loop early, which is refused without it. With"run_out"the loop runs its whole budget: once it is left, the rounds that remain do nothing and take the time they would have taken, so the program always lasts as long."host"is not available yet. By default the kernel’s ownloop_exit=. A compilation withloop_exit=keeps every loop one loop, asunroll_threshold=0does (any other unroll_threshold with it is refused), so that a short loop can be left too; the program, its schedule and its simulation are the same either way.quantum_system (QuantumSystem | None) – Pin the compiled kernel to one quantum system: a call with handles of another raises
QuantumSystemMismatchError, and a call without handles runs on it. A pinned kernel without static parameters is built now.
- Return type:
-
cudaq_pulse.load(
)[source]#module,/,*,entry,qudits,control_system=None,classical=(),links=None,
The compiled program of entry, a scheduled function of module.
module is the assembly or the bytecode of an MLIR module of the Pulse dialect, written by any compiler. entry names a function in it that takes one
!pulse.quditper qudit it plays on and nothing else, gets its lines from them (pulse.get_drive_line,pulse.get_readout_line) and is scheduled: every timed operation has itsstart_cyclesandduration_cycles, in cycles of the quantum system’s clock, and the function is markedpulse.schedule_state = #pulse.schedule_state<timed>. A call in it states its start (pulse.start_cycles) and is written in place. A module that states its clock (pulse.control_systemwithclock_period_fs) must state the quantum system’s.Bytecode holds an operation’s properties by position, in the shape of the writer’s copy of the dialects, so it is read only with the dialect source that wrote it. A writer states that source in the bytecode’s producer string, as
cudaq-pulse-dialects=<source>, as this package andcudaq-pulse-optdo, and bytecode that states another source than this build’s is refused (CompilationError): give the module as assembly, which holds properties by name. Two sources are the same when their digests and the major and minor of their LLVM versions are: a writer built with another patch release of the same LLVM minor writes bytecode this build reads. A stated source that is not such a version, a hyphen and a digest is refused. Assembly states no source, and bytecode that states none is read as it is given.qudits gives, for each argument in order, the qudit of the quantum system it plays on; their quantum system is the program’s. The lines get that system’s frequencies. control_system is as for
compile; without it, the quantum system’s own control system is used.The classical functions the function calls are the module’s
classical.callabledeclarations: their types, latency, link and dispatch key. classical gives functions declared here (pulse.classical) for them, by name: each must take and give what the module states, with its latency mode and submit policy, and its latency and implementation replace the module’s. The links are the control system’s: the module names each link its calls travel on (classical.links), and links gives the control system’s name for a link the module names otherwise or only numbers (links={"host": "nvqlink"}). The dispatch keys are the control system’s too, as forcompile: a key a controller fixes for a function replaces the module’s, and a reserved key or two functions on one link and key are refused. A schedule that takes an answer before the latency and the link allow, or gives a submission less time than the link takes, is refused.The schedule is kept as written:
loaddoes not schedule again. The function is verified on its qudits and control system as every scheduled program is, and checked against what the controllers can play; either raisesCompilationError. A control system with line delays, or a controller withmax_instructionsormax_program_duration, is refused:loaddoes not apply or check those yet. The function and the functions it calls play on the qudits the entry takes and allocate none. A line, a tone and a link stay one from where they start: a branch whose arms give two as one result, a loop that yields another than it takes in, one made by anything but a Pulse or classical operation,scf.iforscf.for, and a qudit picked by another operation or passed through a branch or a loop are refused. What the function returns is dropped: read a record from its readout in the export. Attributes another compiler put on the function or on its operations are not part of the program: an operation keeps its own attributes and those namedpulse., apulse.waitwhose length is computed from the answer of a classical call itsclassical.variable(it then reserves its lowest length:duration_cyclesis itspulse.min_cycles), and apulse.driveits two phases, each a finitef64:frame_phase_offset, a phase shift folded into the drive, ascompilewrites it, andphase_offset, the phase of that drive alone, whichcompiledoes not write and the export and the simulator read.A frame change keeps the start the module gives it. Which changes no drive or readout takes on some path, and so are frame updates in the export, is decided from the function’s operations as
compiledecides it: the module does not have to say, and what it says of that (the markscompilewrites on such changes, loops and branches) is not read.The result is what
kernel.lower(...)returns:schedule,timeline(),export_to_controller()and the backends take it.- Parameters:
module (str | bytes)
entry (str)
qudits (Sequence[Qudit])
control_system (ControlSystem | Controller | None)
classical (Sequence[Any])
links (Mapping[int | str, str] | None)
- Return type:
- class cudaq_pulse.CompiledKernel(kernel, opts, qs)[source]#
Bases:
Generic[P]A kernel compiled ahead of its call by
cudaq_pulse.compile.ck(*args)runs the kernel on the quantum system of the qudit handles passed and returns what the kernel returns. It holds one specialization per quantum system and static argument values, built on first use and never evicted. A kernel pinned to a quantum system and without static parameters is built when it is compiled.It pickles as its kernel (by reference), options and quantum system, without its specializations, which compile again on first use where it is unpickled; pickle
ck.lower(*args)to send a program that runs without compiling.- Parameters:
kernel (Kernel[P])
opts (CompileOptions)
qs (QuantumSystem | None)
- lower(*args, **kwargs)[source]#
The module for these arguments, specialized and scheduled.
- Parameters:
args (P.args)
kwargs (P.kwargs)
- Return type:
- mlir(stage='pulse')[source]#
MLIR text of the compiled module; see
ScheduledKernel.mlir.- Parameters:
stage (str)
- Return type:
str
- property schedule: Sequence[Any]#
The scheduled events; see
ScheduledKernel.schedule.
- timeline(*, figsize=(14, 4), title=None)[source]#
The schedule’s plot; see
ScheduledKernel.timeline.- Parameters:
figsize (tuple[float, float])
title (str | None)
- Return type:
Any
- property metrics: Any#
The compile metrics, a
CompileMetrics; seeScheduledKernel.metrics.
- property parameters: tuple[str, ...]#
The float parameters, function arguments of the module.
- cache_info()[source]#
Return cache statistics for calls to
ck(...).Compiled-kernel specializations are never evicted, so
capacityisNone.- Return type:
CacheInfo
- replace_idle(rule)[source]#
This kernel, compiled as it is, with each idle window of its programs replaced as rule (a
pulse.IdleReplacement) says: each stretch of at least the rule’s threshold in which a qudit idles gets the rule’s fill written in, and every operation of the kernel keeps its start, which compiling checks.lower(...)of the result gives programs whoseidle_windowsreport each window and what was done there; this one is unchanged.- Parameters:
rule (IdleReplacement)
- Return type:
-
class cudaq_pulse.ScheduledKernel(
)[source]#module,*,quantum_system,metrics,parameters,qudits,options,scheduled=True,waits=None,
Bases:
objectOne compiled module of a kernel: read-only text, schedule and metrics.
kernel.lower(*args)andcompiled.lower(*args)return the module of one call. Float parameters stay function arguments of the module, and the call’s values are kept beside it inarguments, so a call with new values shares the module;genericis the module without values.mlir()of a call shows its values substituted.A wait whose length is computed from float parameters keeps the module generic too: without values it is scheduled at its lowest length, and a call’s schedule, text and simulation come from the module with the call’s values bound and scheduled again: the call is
rescheduled.quditsholds the quantum system qudits the program drives or measures (gets a line on), in increasing order: the quditssimulate()models.A module pickles as MLIR bytecode with its quantum system and options, and runs unpickled without compiling again, in any process of the build that compiled it; another build raises
UnsupportedError. A call’s view pickles its values with its generic module.Qudit parameters annotated
QuditorRegisterare runtime qudits: the module takes them as slots, numbered in parameter order, and a call binds each slot to its handle’s carrier (carriers), on the call’s quantum system. Calls with other handles of the same shape share the module.The module with a call’s values substituted is shared by every view with them once they recur, so exporting or lowering the same call again does not build it again; values seen once keep nothing. The latest few are kept per module, fewer for a large one.
- Parameters:
module (Any)
quantum_system (QuantumSystem)
metrics (CompileMetrics)
parameters (tuple[str, ...])
qudits (tuple[int, ...])
options (CompileOptions)
scheduled (bool)
waits (_WaitLengths | None)
- clocks: _clocks.ClockPlan | None = None#
- fine_delays: Mapping[tuple[str, int], float] | None = None#
- carriers: tuple[int, ...] = ()#
- quantum_system#
- metrics#
- parameters#
- arguments: tuple[float, ...]#
- qudits#
- options#
- scheduled#
- waits#
- classical: tuple[Any, ...]#
- runtime_selects#
- bind(values)[source]#
This module with values for its float parameters, sharing it.
values holds one real number per entry of
parameters, in that order; a mapping, a str or a bytes is anInvalidTypeError. Too few or too many values are anInvalidTypeErrornaming the parameters, and a wait length computed from the values that is not a non-negative number of cycles within the wait’s bounds aValueError. A value that is not a real number (a bool, a numpy bool or a str) is anInvalidTypeError, and a NaN anInvalidValueError, each raised here and naming the parameter, on the first bind of a module and on every later one; an infinity is anInvalidValueErrornaming it where the module is used: run, simulated, exported or printed. The call’sargumentsare floats, whatever real numbers were given.A module of one call, as
lower()with values returns, has no parameters left: binding no values returns that call, and binding any is anInvalidTypeError.- Parameters:
values (Sequence[float])
- Return type:
- property generic: ScheduledKernel#
The module without values: the one a call’s view shares, or this module when it holds no values.
generic.bind(values)makes a call of it with new values.
- property rescheduled: bool#
Whether the call’s float values set a wait length, so its times come from scheduling the module again with them bound, rather than from the module’s own schedule.
Truefor a call whose float values set a wait length, and for a module that could not be scheduled without values.Falsefor a module scheduled without values (its waits stand at their lowest lengths) and for a call of it whose values move no op, which keeps that module’s times. Whether the module itself was scheduled again for new line delays isrescheduled_for_line_delays.It records how
lower()orbind()made the program, so reading it does no work: a call’s schedule is still computed when it is first read. Copies and pickles keep it.
- property rescheduled_for_line_delays: bool#
Whether the module was compiled again with only other line delays, scheduling its kernel’s earlier trace again for the new delays rather than tracing the kernel anew.
Truefor such a module and for every call of it.Falsefor a module traced by its own compile, such as the first compile of a kernel, a compile with the line delays it was last compiled with, any compile of a kernel with list or qudit parameters, and a compile after a change to what the kernel read while it was traced. It does not depend onrescheduled: a call of such a module whose float values set a wait length is both.It records how the module was made, so reading it does no work. Copies and pickles keep it.
- mlir(level=IRLevel.PULSE)[source]#
The module as MLIR text at level (an
IRLevelor its name):"pulse", the scheduled Pulse dialect;"qop","cudm"and"llvm", after lowering it that far (pulse -> qop -> cudm -> LLVM). Every level but"pulse"needs the float parameters’ values, and a program that measures lowers only along a measurement-outcome path, assimulatedoes.- Parameters:
level (IRLevel | str)
- Return type:
str
- property duration: Time#
How long the program runs: the latest end of its operations, over both arms of every branch, as a time (
float(duration)is in ns).Only a lowered program has a duration: a kernel or
CompiledKernelhas none until it is lowered for a call, since the call’s arguments decide it. A wait a float parameter sets counts once the module has values.
- property schedule: Sequence[ScheduledEvent]#
The drives, readouts and waits with their timing.
Ops in a loop are listed once per iteration; both arms of a measurement-conditioned branch are listed. Without values, a wait whose length a float parameter sets is listed at its lowest length. Up to 10,000 events this is a list; past that, a sequence that builds each event when it is read, from its op and its loops’ iterations:
len()is exact, and indexing, slicing and iterating give what the list would.
- segments()[source]#
The segments of the program, separated by variable and blocking waits.
A program without such waits has one segment.
- Return type:
list[Segment]
- property controller_usage: UsageReport#
What the classical functions use of the processors of the quantum system’s control system (
cudaq_pulse.controller.UsageReport), built when read;printit for a table.
- classical_report()[source]#
Every call to a classical function, with its timing and slack.
Calls in a loop are listed once per iteration, in program order.
- Return type:
list[ClassicalCall]
- property idle_windows: IdleWindows | None#
The idle windows of a program lowered by
compiled.replace_idle(rule): each stretch of at least the rule’s threshold in which a qudit idles, with what was done there (seeIdleWindow).Nonefor a program whose idle windows were not replaced.
- property exposure: Exposure#
What the schedule does to each qudit over time, built when read: per qudit and per outermost loop it has a pulse in, the cycles of one round in which the qudit is driven, read out and idle, the number of rounds, and what the idle time costs at the qudit’s T1 and T2 star (see
QuditExposure);printit for a table. Loops stay rolled, so it costs the same for 2 rounds as for a million.UnsupportedErrorfor a program whose schedule depends on its arguments’ values.
- property timing: Timing#
Where the program’s timing is exact and where it can move while it runs, built when read (
cudaq_pulse.compiler.Timing);printit. Itsbreaksare the points that can move it, a wait whose length is an answer of a classical call or an answer waited for as long as it takes: oneTimingBreakper kernel line, with the lines that move together after it, the lines that keep their time, how far it moves them and how often it runs. An answer waited for as long as it takes has no recorded kernel line: the answers of one function that hold the same lines are oneTimingBreak, which counts them all. A loop is read once, so it costs the same for 2 rounds as for a million.reservedis the time the schedule keeps for each classical function’s answers, andlatest_end_cyclesthe latest the program can end.
- export_to_emulator(*, controller=None)[source]#
The program for a controller emulator: its schedule by segment, its calls and the manifest of its classical functions (see
cudaq_pulse.classical.emulation). On a control system of several controllers, that of the one controller indexes, in its cycles.- Parameters:
controller (int | None)
- Return type:
dict[str, Any]
-
export_to_controller(
)[source]#sample_rate_ghz=None,*,controller=None,version=1,
The program for an out-of-tree controller backend: its lines and every timed operation with its waveform, tone, frame and branches (see
cudaq_pulse.controller); with sample_rate_ghz, each envelope’s samples too. On a control system of several controllers, the program of the one controller indexes, in its own cycles (a program that plays the lines of more than one needs it). Exporting each controller in turn walks and checks the whole program once: the program keeps that until every controller’s part is exported.version=2gives the structured format, which keeps loops rolled.- Parameters:
sample_rate_ghz (float | None)
controller (int | None)
version (int)
- Return type:
dict[str, Any]
- timeline(*, figsize=(14, 4), title=None)[source]#
Plot the schedule, one row per line, in a figure of figsize inches with title (needs matplotlib); see
viz.plot_schedule.- Parameters:
figsize (tuple[float, float])
title (str | None)
- Return type:
Figure
- class cudaq_pulse.Pass(*values)[source]#
Bases:
StrEnumAn optimization pass of
pulse.compile(k, passes=).Each member is a string, and the plain string (
"fold_phases") is accepted wherever a member is. Passes run in the order given, any subset in any order; the pattern passes (all butVERIFYandHOIST_LOOP_INVARIANTS) that follow one another run as one rewrite of the program, and each of them also removes the operations its rewrites leave unused.- VERIFY = 'verify'#
Check waveform durations and that each line is used once at each step.
- FOLD_CONSTANTS = 'fold_constants'#
Compute constant arithmetic at compile time and merge equal constants.
- REMOVE_UNUSED = 'remove_unused'#
Remove operations whose results nothing uses, unreachable blocks and unused block arguments.
- MERGE_WAITS = 'merge_waits'#
Join constant waits in a row on one line into one wait.
- SIMPLIFY_CONTROL_FLOW = 'simplify_control_flow'#
Remove syncs that order nothing, inline schedule blocks that take no time, branch on
is_set, and inline or remove loops that run once or never.
- FOLD_PHASES = 'fold_phases'#
Fold constant frame changes (
shift_phase) into the next drive.
- FUSE_PULSES = 'fuse_pulses'#
Merge back-to-back square-pulse drives of the same amplitude into one.
- HOIST_LOOP_INVARIANTS = 'hoist_loop_invariants'#
Move operations that compute the same value in every iteration out of loops.
-
class cudaq_pulse.IdleReplacement(
)[source]#fill,/,*,threshold,qudits=None,leading=False,trailing=False,align='center',
Bases:
objectWhat
compiled.replace_idle(rule)replaces idle time with.fill is a
@pulse.kernelthat takes(qudit, window): the idle qudit and the length of its idle window in clock cycles. It is traced once for each window, where the window is, as a kernel called there;Nonereplaces nothing and only lists the windows (ScheduledKernel.idle_windows). In this version a fill drives and waits on its own qudit’s drive line, at that line’s tone, and may shift the tone’s phase by constants that add up to zero. threshold is the shortest idle that is a window, anintof clock cycles or a time (100 * pulse.ns); an idle of exactly that length is one. qudits keeps the rule to those qudits. The idle before a qudit’s first operation and after its last is left alone unless leading or trailing is true. align places a fill shorter than its window in it, completed with waits:"center","start"or"end"; a fill longer than its window is aCompilationError. A centred fill starts on a timestep of its line: the wait before it is half of what the fill leaves over, rounded down to the line’s timestep, and the wait after it takes the rest, so the fill sits early by less than one timestep.A rule is immutable; two rules are equal when they hold the same kernel and settings.
- Parameters:
- leading: bool#
- trailing: bool#
- align: str#
- class cudaq_pulse.compiler.IdleWindow(qudit, start, end, rounds, before, filled, result)[source]#
Bases:
objectOne idle window of a compiled program: a stretch of at least the threshold in which a qudit’s drive line has no operation, none of its tones plays, and its readout does not run.
startandendare in clock cycles, of the window’s first execution;roundscounts its executions (the iterations of a loop it lies in), and when they differ the shortest is given.beforenames the operation the window ends at, as"drive() at line 12 of cycle()", or isNonefor a window that lasts to the program’s end.filledsays whether the window was replaced, andresultwhat was done:"filled by echo()", or why it was left alone.- Parameters:
qudit (int)
start (int)
end (int)
rounds (int)
before (str | None)
filled (bool)
result (str)
- qudit: int#
- start: int#
- end: int#
- rounds: int#
- before: str | None#
- filled: bool#
- result: str#
- property cycles: int#
The window’s length in clock cycles.
- class cudaq_pulse.compiler.IdleWindows(iterable=(), /)[source]#
Bases:
tuple[IdleWindow, …]The idle windows of a compiled program, in the order of their qudits and, per qudit, of the program.
print()shows them as a table.
-
class cudaq_pulse.compiler.QuditExposure(
)[source]#qudit,loop,rounds,cycles,drive_cycles,readout_cycles,idle_cycles,exact,decay=0.0,dephasing=0.0,
Bases:
objectOne qudit in one stretch of the program:
loopis the loop’s place among the program’s outermost loops that hold an operation (0 for the first), orNonefor the rest of the program’s length: everything outside those loops, and the loops the qudit has no pulse in (left out when that is no time at all).cyclesis the length of one round, during which the qudit is driven fordrive_cycles(a pulse on its drive line, or at its tone from another line), read out forreadout_cyclesand idle foridle_cycles; a wait is idle, and a drive during a readout counts in both.roundsis how often the stretch runs.exactis false where the schedule does not fix these figures.decayanddephasingare what the idle time of one round costs, from the qudit’s T1 and T2 star: the probability1 - exp(-t / T1)that an excited qudit relaxes, and the probability(1 - exp(-t / T_phi)) / 2of a phase flip from pure dephasing,1 / T_phi = 1 / T2 - 1 / (2 T1). A T1 or T2 star the quantum system gives as 0 counts as none. What a pulse costs is not in them.- Parameters:
qudit (int)
loop (int | None)
rounds (int)
cycles (int)
drive_cycles (int)
readout_cycles (int)
idle_cycles (int)
exact (bool)
decay (float)
dephasing (float)
- qudit: int#
- loop: int | None#
- rounds: int#
- cycles: int#
- drive_cycles: int#
- readout_cycles: int#
- idle_cycles: int#
- exact: bool#
- decay: float = 0.0#
- dephasing: float = 0.0#
- class cudaq_pulse.compiler.Exposure(iterable=(), /)[source]#
Bases:
tuple[QuditExposure, …]The rows of
ScheduledKernel.exposure, by qudit and then in program order;printit for a table.
- class cudaq_pulse.compiler.Timing(program, lines, breaks, reserved=(), ends=(), moves=())[source]#
Bases:
objectWhere a compiled program’s timing is exact and where it can move (
ScheduledKernel.timing);printit.exactis whether no point of the program can move its timing;breaksare the points that can, oneTimingBreakper kernel line in program order (those without a recorded kernel line: one per function and the lines it holds);linesgives each of the program’s lines as (role, qudit), in the orderScheduledEvent.linenumbers them, whether or not the program calls a classical function;reservedis what the schedule keeps for answers, oneReservedAnswerper classical function the program calls, in the order of their first calls.- Parameters:
program (ScheduledKernel)
lines (tuple[tuple[str, int], ...])
breaks (tuple[TimingBreak, ...])
reserved (tuple[ReservedAnswer, ...])
ends (tuple[int, ...])
moves (tuple[tuple[int, ...], ...])
- lines#
- breaks#
- reserved#
- property exact: bool#
Whether the program’s timing cannot move while it runs.
- property latest_end_cycles: int | None#
The latest cycle the program can end at: the latest any line can, each ending later by what the points that hold it back add, and never before the program’s length as scheduled;
Nonewhen a point has no limit.
-
class cudaq_pulse.compiler.TimingBreak(
)[source]#cause,source_file,source_line,function,wait_line,bounds_cycles,shift_cycles,held_lines,free_lines,trips,first_cycles,
Bases:
objectOne point where a program’s timing can move while it runs, from
ScheduledKernel.timing: a kernel line, however often it runs. Where no kernel line is recorded (an answer waited for as long as it takes, a program read from MLIR text) it is every such point of one function that holds the same lines, andtripscounts them all.causeis"wait", a wait whose length is an answer of a classical call, on linewait_linewithbounds_cyclesits lowest and highest length (None: no highest); or"answer", an answer waited for as long as it takes.functionis the classical function whose answer decides it, as the kernel calls it (empty for a length taken from a value carried around a loop).source_fileandsource_lineare the kernel line (Noneand 0 where the program does not know it: one read from MLIR text, or an answer of a function declaredlatency_mode="blocking"); every otherlinehere is a control line, numbered asScheduledEvent.linenumbers them.The schedule places the point at its lowest length, first at cycle
first_cycles, in the schedule of the call’s own values where the program is a call that binds wait lengths. Each time it runs, what follows onheld_linesstarts later by a number of cycles withinshift_cycles(the upper endNone: no limit); it runstripstimes. The held lines wait for the point and move together, so they stay exact relative to each other.free_linesare the lines that have a drive, readout or wait after the point in the program, or in a loop around it, and are not held: they keep their scheduled time, whatever the point takes. Lines are numbered asScheduledEvent.linenumbers them.- Parameters:
cause (str)
source_file (str | None)
source_line (int)
function (str)
wait_line (int | None)
bounds_cycles (tuple[int, int | None] | None)
shift_cycles (tuple[int, int | None])
held_lines (tuple[int, ...])
free_lines (tuple[int, ...])
trips (int)
first_cycles (int)
- cause: str#
- source_file: str | None#
- source_line: int#
- function: str#
- wait_line: int | None#
- bounds_cycles: tuple[int, int | None] | None#
- shift_cycles: tuple[int, int | None]#
- held_lines: tuple[int, ...]#
- free_lines: tuple[int, ...]#
- trips: int#
- first_cycles: int#
- class cudaq_pulse.compiler.ReservedAnswer(function, calls, cycles)[source]#
Bases:
objectThe time a program’s schedule reserves for the answers of one classical function, from
ScheduledKernel.timing.reserved:callsexecutions, each with at mostcyclesfrom the start of its submission to when its answer is due. Reserved time is part of the schedule: nothing moves when an answer comes earlier. How long each execution holds back a pulse is inclassical_report().- Parameters:
function (str)
calls (int)
cycles (int)
- function: str#
- calls: int#
- cycles: int#
- class cudaq_pulse.compiler.IRLevel(*values)[source]#
Bases:
StrEnumA level of the program’s IR, for
mlir(level): each lowers the one before it. The plain string ("qop") is accepted wherever a member is.- PULSE = 'pulse'#
The scheduled Pulse dialect.
- QOP = 'qop'#
Quantum operators: the program’s Hamiltonian and dissipators.
- CUDM = 'cudm'#
cuDensityMat operators and evolution.
- LLVM = 'llvm'#
LLVM dialect, ready to compile.
- class cudaq_pulse.compiler.ScheduledEvent(kind, line, qudit, start_cycles, duration_cycles)[source]#
Bases:
objectOne timed operation of a compiled kernel.
linenumbers the kernel’s drive and readout lines in allocation order.start_cyclesandduration_cyclesareNoneuntil the kernel is scheduled (a kernel with float parameters is scheduled when it is called with their values).startandendare the scheduled times in clock cycles, and raiseValueErrorbefore then.A call to a classical function adds a
"submit"event, while the request holds its link, and a zero-length"answer"event, when the answer is taken. For those,lineis the link id andquditis -1.- Parameters:
kind (str)
line (int)
qudit (int)
start_cycles (int | None)
duration_cycles (int | None)
- kind: str#
- line: int#
- qudit: int#
- start_cycles: int | None#
- duration_cycles: int | None#
- property start: int#
The clock cycle the event starts at;
ValueErrorif not scheduled.
- property end: int#
The clock cycle the event ends at;
ValueErrorif not scheduled.
- property link: int | None#
The link of a classical call’s event, else
None.
-
class cudaq_pulse.compiler.CompileMetrics(
)[source]#trace_ms=0.0,ffi_ms=0.0,passes_ms=0.0,schedule_ms=0.0,total_ms=0.0,op_count=0,quantum_system='',
Bases:
objectPer-stage timing of one compilation (milliseconds) and its size.
- Parameters:
trace_ms (float)
ffi_ms (float)
passes_ms (float)
schedule_ms (float)
total_ms (float)
op_count (int)
quantum_system (str)
- trace_ms: float = 0.0#
Milliseconds spent tracing the kernel’s bytecode into the packed operation buffer (stage 1).
- ffi_ms: float = 0.0#
Milliseconds spent sending the packed buffer to C++, building the MLIR module from it and setting the module’s link attributes and clocks (stage 2, “FFI to C++”).
- passes_ms: float = 0.0#
Milliseconds spent lowering runtime selects and running the compiler passes on the module (stage 3).
- schedule_ms: float = 0.0#
Milliseconds spent scheduling the module (stage 4). A module that is only scheduled again for other line delays reports just this stage.
- total_ms: float = 0.0#
Milliseconds for the sum of the four stages:
trace_ms,ffi_ms,passes_msandschedule_ms.
- op_count: int = 0#
The number of pulse-program operations the kernel recorded, not counting qudit binding or region yields.
- quantum_system: str = ''#
The name of the quantum system the kernel was compiled for.