schedule#
Module containing the core concepts of the scheduler.
Module Contents#
Classes#
Interface to be used for |
|
A modifiable schedule. |
|
A representation of an element on a schedule. |
|
A schedule that contains compiled instructions ready for execution using the |
|
A description of the shape and type of data that a schedule will return when executed. |
- class ScheduleBase(dict=None, /, **kwargs)[source]#
Bases:
quantify_scheduler.json_utils.JSONSchemaValMixin
,collections.UserDict
,abc.ABC
Interface to be used for
Schedule
.The
ScheduleBase
is a data structure that is at the core of the Quantify-scheduler and describes when what operations are applied where.The
ScheduleBase
is a collection ofquantify_scheduler.operations.operation.Operation
objects and timing constraints that define relations between the operations.The schedule data structure is based on a dictionary. This dictionary contains:
- operation_dict - a hash table containing the unique
quantify_scheduler.operations.operation.Operation
s added to the schedule.
- schedulables - a dictionary of all timing constraints added
between operations.
The
Schedule
provides an API to create schedules. TheCompiledSchedule
represents a schedule after it has been compiled for execution on a backend.The
Schedule
contains information on theoperations
andschedulables
. Theoperations
is a dictionary of all unique operations used in the schedule and contain the information on what operation to apply where. Theschedulables
is a dictionary of Schedulables describing timing constraints between operations, i.e. when to apply an operation.JSON schema of a valid Schedule
JSON schema for a quantify schedule.
type
object
properties
name
Name of the schedule.
type
string
repetitions
The amount of times the schedule will be repeated.
type
integer
default
1
schedulables
A dictionary containing schedulables.
type
object
operation_dict
A dictionary of operations. Keys correspond to the hash attribute of operations.
type
object
resource_dict
A dictionary of resources.
type
object
compiled_instructions
A containing compiled instructions.
type
object
duration
Duration of the schedule.
type
number
additionalProperties
False
- property repetitions: int[source]#
Returns the amount of times this Schedule will be repeated.
- Returns
The repetitions count.
- property operations: dict[str, quantify_scheduler.operations.operation.Operation | Schedule][source]#
A dictionary of all unique operations used in the schedule.
This specifies information on what operation to apply where.
The keys correspond to the
hash
and values are instances ofquantify_scheduler.operations.operation.Operation
.
- property schedulables: dict[str, Any][source]#
A list of schedulables describing the timing of operations.
A schedulable uses timing constraints to constrain the operation in time by specifying the time (
"rel_time"
) between a reference operation and the added operation. The time can be specified with respect to a reference point ("ref_pt"') on the reference operation (:code:
”ref_op”) and a reference point on the next added operation (:code:”ref_pt_new”’). A reference point can be either the “start”, “center”, or “end” of an operation. The reference operation ("ref_op"
) is specified using its label property.Each item in the list represents a timing constraint and is a dictionary with the following keys:
['label', 'rel_time', 'ref_op', 'ref_pt_new', 'ref_pt', 'operation_repr']
The label is used as a unique identifier that can be used as a reference for other operations, the operation_repr refers to the string representation of a operation in
operations
.Note
timing constraints are not intended to be modified directly. Instead use the
add()
- property resources: dict[str, quantify_scheduler.resources.Resource][source]#
A dictionary containing resources.
Keys are names (str), values are instances of
Resource
.
- property timing_table: pandas.io.formats.style.Styler[source]#
A styled pandas dataframe containing the absolute timing of pulses and acquisitions in a schedule.
This table is constructed based on the abs_time key in the
schedulables
. This requires the timing to have been determined.- Parameters
schedule – a schedule for which the absolute timing has been determined.
- Returns
styled_timing_table, a pandas Styler containing a dataframe with an overview of the timing of the pulses and acquisitions present in the schedule. The data frame can be accessed through the .data attribute of the Styler.
- Raises
ValueError – When the absolute timing has not been determined during compilation.
- property duration: float | None[source]#
Determine the cached duration of the schedule.
Will return None if get_schedule_duration() has not been called before.
- to_json() str [source]#
Convert the Schedule data structure to a JSON string.
- Returns
The json string result.
- classmethod from_json(data: str) Schedule [source]#
Convert the JSON data to a Schedule.
- Parameters
data – The JSON data.
- Returns
The Schedule object.
- plot_circuit_diagram(figsize: tuple[int, int] = None, ax: matplotlib.axes.Axes | None = None, plot_backend: Literal[mpl] = 'mpl') tuple[matplotlib.figure.Figure, matplotlib.axes.Axes | list[matplotlib.axes.Axes]] [source]#
Create a circuit diagram visualization of the schedule using the specified plotting backend.
The circuit diagram visualization depicts the schedule at the quantum circuit layer. Because quantify-scheduler uses a hybrid gate-pulse paradigm, operations for which no information is specified at the gate level are visualized using an icon (e.g., a stylized wavy pulse) depending on the information specified at the quantum device layer.
Alias of
quantify_scheduler.schedules._visualization.circuit_diagram.circuit_diagram_matplotlib()
.- Parameters
schedule – the schedule to render.
figsize – matplotlib figsize.
ax – Axis handle to use for plotting.
plot_backend – Plotting backend to use, currently only ‘mpl’ is supported
- Returns
fig – matplotlib figure object.
ax – matplotlib axis object.
Each gate, pulse, measurement, and any other operation are plotted in the order of execution, but no timing information is provided.
Example
from quantify_scheduler import Schedule from quantify_scheduler.operations.gate_library import Reset, X90, CZ, Rxy, Measure sched = Schedule(f"Bell experiment on q0-q1") sched.add(Reset("q0", "q1")) sched.add(X90("q0")) sched.add(X90("q1"), ref_pt="start", rel_time=0) sched.add(CZ(qC="q0", qT="q1")) sched.add(Rxy(theta=45, phi=0, qubit="q0") ) sched.add(Measure("q0", acq_index=0)) sched.add(Measure("q1", acq_index=0), ref_pt="start") sched.plot_circuit_diagram();
Note
Gates that are started simultaneously on the same qubit will overlap.
from quantify_scheduler import Schedule from quantify_scheduler.operations.gate_library import X90, Measure sched = Schedule(f"overlapping gates") sched.add(X90("q0")) sched.add(Measure("q0"), ref_pt="start", rel_time=0) sched.plot_circuit_diagram();
Note
If the pulse’s port address was not found then the pulse will be plotted on the ‘other’ timeline.
- plot_pulse_diagram(port_list: list[str] | None = None, sampling_rate: float = 1000000000.0, modulation: Literal[off, if, clock] = 'off', modulation_if: float = 0.0, plot_backend: Literal[mpl, plotly] = 'mpl', plot_kwargs: dict | None = None, **backend_kwargs: Any) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] | plotly.graph_objects.Figure [source]#
Create a visualization of all the pulses in a schedule using the specified plotting backend.
The pulse diagram visualizes the schedule at the quantum device layer. For this visualization to work, all operations need to have the information present (e.g., pulse info) to represent these on the quantum-circuit level and requires the absolute timing to have been determined. This information is typically added when the quantum-device level compilation is performed.
Alias of
quantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_matplotlib()
andquantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_plotly()
.- Parameters
port_list – A list of ports to show. If None (default) the first 8 ports encountered in the sequence are used.
modulation – Determines if modulation is included in the visualization.
modulation_if – Modulation frequency used when modulation is set to “if”.
sampling_rate – The time resolution used to sample the schedule in Hz.
plot_backend – Plotting library to use, can either be ‘mpl’ or ‘plotly’.
plot_kwargs – Keyword arguments to be passed on to the plotting backend. The arguments that can be used for either backend can be found in the documentation of
quantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_matplotlib()
andquantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_plotly()
.backend_kwargs – Keyword arguments to be passed on to the plotting backend. The arguments that can be used for either backend can be found in the documentation of
quantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_matplotlib()
andquantify_scheduler.schedules._visualization.pulse_diagram.pulse_diagram_plotly()
.
- Returns
the plot
- Return type
Union[Tuple[Figure, Axes],
plotly.graph_objects.Figure
]
Example
A simple plot with matplotlib can be created as follows:
from quantify_scheduler.operations.pulse_library import DRAGPulse, SquarePulse, RampPulse from quantify_scheduler.compilation import determine_absolute_timing schedule = Schedule("Multiple waveforms") schedule.add(DRAGPulse(G_amp=0.2, D_amp=0.2, phase=0, duration=4e-6, port="P", clock="C")) schedule.add(RampPulse(amp=0.2, offset=0.0, duration=6e-6, port="P")) schedule.add(SquarePulse(amp=0.1, duration=4e-6, port="Q"), ref_pt='start') schedule = determine_absolute_timing(schedule) _ = schedule.plot_pulse_diagram(sampling_rate=20e6)
The backend can be changed to the plotly backend by specifying the
plot_backend=plotly
argument. With the plotly backend, pulse diagrams include a separate plot for each port/clock combination:schedule.plot_pulse_diagram(sampling_rate=20e6, plot_backend='plotly')