Schedule#

class qiskit.pulse.Schedule(*schedules, name=None, metadata=None)[fuente]#

Bases: object

A quantum program schedule with exact time constraints for its instructions, operating over all input signal channels and supporting special syntaxes for building.

Pulse program representation for the original Qiskit Pulse model [1]. Instructions are not allowed to overlap in time on the same channel. This overlap constraint is immediately evaluated when a new instruction is added to the Schedule object.

It is necessary to specify the absolute start time and duration for each instruction so as to deterministically fix its execution time.

The Schedule program supports some syntax sugar for easier programming.

  • Appending an instruction to the end of a channel

    sched = Schedule()
    sched += Play(Gaussian(160, 0.1, 40), DriveChannel(0))
    
  • Appending an instruction shifted in time by a given amount

    sched = Schedule()
    sched += Play(Gaussian(160, 0.1, 40), DriveChannel(0)) << 30
    
  • Merge two schedules

    sched1 = Schedule()
    sched1 += Play(Gaussian(160, 0.1, 40), DriveChannel(0))
    
    sched2 = Schedule()
    sched2 += Play(Gaussian(160, 0.1, 40), DriveChannel(1))
    sched2 = sched1 | sched2
    

A PulseError is immediately raised when the overlap constraint is violated.

In the schedule representation, we cannot parametrize the duration of instructions. Thus we need to create a new schedule object for each duration. To parametrize an instruction鈥檚 duration, the ScheduleBlock representation may be used instead.

Referencias

[1]: https://arxiv.org/abs/2004.06755

Create an empty schedule.

Par谩metros:
  • *schedules (ScheduleComponent | Tuple[int, ScheduleComponent]) 鈥 Child Schedules of this parent Schedule. May either be passed as the list of schedules, or a list of (start_time, schedule) pairs.

  • name (str | None) 鈥 Name of this schedule. Defaults to an autogenerated string if not provided.

  • metadata (dict | None) 鈥 Arbitrary key value metadata to associate with the schedule. This gets stored as free-form data in a dict in the metadata attribute. It will not be directly used in the schedule.

Muestra:

TypeError 鈥 if metadata is not a dict.

Attributes

channels#

Returns channels that this schedule uses.

children#

Return the child schedule components of this Schedule in the order they were added to the schedule.

Notas

Nested schedules are returned as-is. If you want to collect only instructions, use py:meth:~Schedule.instructions instead.

Devuelve:

A tuple, where each element is a two-tuple containing the initial scheduled time of each NamedValue and the component itself.

duration#

Duration of this schedule.

instances_counter = count(0)#
instructions#

Get the time-ordered instructions from self.

metadata#

The user provided metadata associated with the schedule.

User provided dict of metadata for the schedule. The metadata contents do not affect the semantics of the program but are used to influence the execution of the schedule. It is expected to be passed between all transforms of the schedule and that providers will associate any schedule metadata with the results it returns from the execution of that schedule.

name#

Name of this Schedule

parameters#

Parameters which determine the schedule behavior.

prefix = 'sched'#
start_time#

Starting time of this schedule.

stop_time#

Stopping time of this schedule.

timeslots#

Time keeping attribute.

Methods

append(schedule, name=None, inplace=False)[fuente]#

Return a new schedule with schedule inserted at the maximum time over all channels shared between self and schedule.

\[t = \textrm{max}(\texttt{x.stop_time} |\texttt{x} \in \texttt{self.channels} \cap \texttt{schedule.channels})\]
Par谩metros:
  • schedule (Schedule | Instruction) 鈥 Schedule to be appended.

  • name (str | None) 鈥 Name of the new Schedule. Defaults to name of self.

  • inplace (bool) 鈥 Perform operation inplace on this schedule. Otherwise return a new Schedule.

Tipo del valor devuelto:

Schedule

assign_parameters(value_dict, inplace=True)[fuente]#

Assign the parameters in this schedule according to the input.

Par谩metros:
Devuelve:

Schedule with updated parameters.

Tipo del valor devuelto:

Schedule

ch_duration(*channels)[fuente]#

Return the time of the end of the last instruction over the supplied channels.

Par谩metros:

*channels (Channel) 鈥 Channels within self to include.

Tipo del valor devuelto:

int

ch_start_time(*channels)[fuente]#

Return the time of the start of the first instruction over the supplied channels.

Par谩metros:

*channels (Channel) 鈥 Channels within self to include.

Tipo del valor devuelto:

int

ch_stop_time(*channels)[fuente]#

Return maximum start time over supplied channels.

Par谩metros:

*channels (Channel) 鈥 Channels within self to include.

Tipo del valor devuelto:

int

draw(style=None, backend=None, time_range=None, time_unit='dt', disable_channels=None, show_snapshot=True, show_framechange=True, show_waveform_info=True, show_barrier=True, plotter='mpl2d', axis=None)#

Plot the schedule.

Par谩metros:
  • style (Dict[str, Any] | None) 鈥 Stylesheet options. This can be dictionary or preset stylesheet classes. See IQXStandard, IQXSimple, and IQXDebugging for details of preset stylesheets.

  • backend (Optional[BaseBackend]) 鈥 Backend object to play the input pulse program. If provided, the plotter may use to make the visualization hardware aware.

  • time_range (Tuple[int, int] | None) 鈥 Set horizontal axis limit. Tuple (tmin, tmax).

  • time_unit (str) 鈥 The unit of specified time range either dt or ns. The unit of ns is available only when backend object is provided.

  • disable_channels (List[Channel] | None) 鈥 A control property to show specific pulse channel. Pulse channel instances provided as a list are not shown in the output image.

  • show_snapshot (bool) 鈥 Show snapshot instructions.

  • show_framechange (bool) 鈥 Show frame change instructions. The frame change represents instructions that modulate phase or frequency of pulse channels.

  • show_waveform_info (bool) 鈥 Show additional information about waveforms such as their name.

  • show_barrier (bool) 鈥 Show barrier lines.

  • plotter (str) 鈥

    Name of plotter API to generate an output image. One of following APIs should be specified:

    mpl2d: Matplotlib API for 2D image generation.
        Matplotlib API to generate 2D image. Charts are placed along y axis with
        vertical offset. This API takes matplotlib.axes.Axes as ``axis`` input.
    

    axis and style kwargs may depend on the plotter.

  • axis (Any | None) 鈥 Arbitrary object passed to the plotter. If this object is provided, the plotters use a given axis instead of internally initializing a figure object. This object format depends on the plotter. See plotter argument for details.

Devuelve:

Visualization output data. The returned data type depends on the plotter. If matplotlib family is specified, this will be a matplotlib.pyplot.Figure data.

exclude(*filter_funcs, channels=None, instruction_types=None, time_ranges=None, intervals=None, check_subroutine=True)[fuente]#

Return a Schedule with only the instructions from this Schedule failing at least one of the provided filters. This method is the complement of py:meth:~self.filter, so that:

self.filter(args) | self.exclude(args) == self
Par谩metros:
  • filter_funcs (Callable) 鈥 A list of Callables which take a (int, Union[鈥淪chedule鈥, Instruction]) tuple and return a bool.

  • channels (Iterable[Channel] | None) 鈥 For example, [DriveChannel(0), AcquireChannel(0)].

  • instruction_types (Iterable[ABCMeta] | ABCMeta | None) 鈥 For example, [PulseInstruction, AcquireInstruction].

  • time_ranges (Iterable[Tuple[int, int]] | None) 鈥 For example, [(0, 5), (6, 10)].

  • intervals (Iterable[Tuple[int, int]] | None) 鈥 For example, [(0, 5), (6, 10)].

  • check_subroutine (bool) 鈥 Set True to individually filter instructions inside of a subroutine defined by the Call instruction.

Tipo del valor devuelto:

Schedule

filter(*filter_funcs, channels=None, instruction_types=None, time_ranges=None, intervals=None, check_subroutine=True)[fuente]#

Return a new Schedule with only the instructions from this Schedule which pass though the provided filters; i.e. an instruction will be retained iff every function in filter_funcs returns True, the instruction occurs on a channel type contained in channels, the instruction type is contained in instruction_types, and the period over which the instruction operates is fully contained in one specified in time_ranges or intervals.

If no arguments are provided, self is returned.

Par谩metros:
  • filter_funcs (Callable) 鈥 A list of Callables which take a (int, Union[鈥淪chedule鈥, Instruction]) tuple and return a bool.

  • channels (Iterable[Channel] | None) 鈥 For example, [DriveChannel(0), AcquireChannel(0)].

  • instruction_types (Iterable[ABCMeta] | ABCMeta | None) 鈥 For example, [PulseInstruction, AcquireInstruction].

  • time_ranges (Iterable[Tuple[int, int]] | None) 鈥 For example, [(0, 5), (6, 10)].

  • intervals (Iterable[Tuple[int, int]] | None) 鈥 For example, [(0, 5), (6, 10)].

  • check_subroutine (bool) 鈥 Set True to individually filter instructions inside of a subroutine defined by the Call instruction.

Tipo del valor devuelto:

Schedule

get_parameters(parameter_name)[fuente]#

Get parameter object bound to this schedule by string name.

Because different Parameter objects can have the same name, this method returns a list of Parameter s for the provided name.

Par谩metros:

parameter_name (str) 鈥 Name of parameter.

Devuelve:

Parameter objects that have corresponding name.

Tipo del valor devuelto:

List[Parameter]

classmethod initialize_from(other_program, name=None)[fuente]#

Create new schedule object with metadata of another schedule object.

Par谩metros:
  • other_program (Any) 鈥 Qiskit program that provides metadata to new object.

  • name (str | None) 鈥 Name of new schedule. Name of schedule is used by default.

Devuelve:

New schedule object with name and metadata.

Muestra:

PulseError 鈥 When other_program does not provide necessary information.

Tipo del valor devuelto:

Schedule

insert(start_time, schedule, name=None, inplace=False)[fuente]#

Return a new schedule with schedule inserted into self at start_time.

Par谩metros:
  • start_time (int) 鈥 Time to insert the schedule.

  • schedule (Schedule | Instruction) 鈥 Schedule to insert.

  • name (str | None) 鈥 Name of the new schedule. Defaults to the name of self.

  • inplace (bool) 鈥 Perform operation inplace on this schedule. Otherwise return a new Schedule.

Tipo del valor devuelto:

Schedule

is_parameterized()[fuente]#

Return True iff the instruction is parameterized.

Tipo del valor devuelto:

bool

replace(old, new, inplace=False)[fuente]#

Return a Schedule with the old instruction replaced with a new instruction.

The replacement matching is based on an instruction equality check.

from qiskit import pulse

d0 = pulse.DriveChannel(0)

sched = pulse.Schedule()

old = pulse.Play(pulse.Constant(100, 1.0), d0)
new = pulse.Play(pulse.Constant(100, 0.1), d0)

sched += old

sched = sched.replace(old, new)

assert sched == pulse.Schedule(new)

Only matches at the top-level of the schedule tree. If you wish to perform this replacement over all instructions in the schedule tree. Flatten the schedule prior to running:

.. code-block::

sched = pulse.Schedule()

sched += pulse.Schedule(old)

sched = sched.flatten()

sched = sched.replace(old, new)

assert sched == pulse.Schedule(new)

Par谩metros:
Devuelve:

The modified schedule with old replaced by new.

Muestra:

PulseError 鈥 If the Schedule after replacements will has a timing overlap.

Tipo del valor devuelto:

Schedule

shift(time, name=None, inplace=False)[fuente]#

Return a schedule shifted forward by time.

Par谩metros:
  • time (int) 鈥 Time to shift by.

  • name (str | None) 鈥 Name of the new schedule. Defaults to the name of self.

  • inplace (bool) 鈥 Perform operation inplace on this schedule. Otherwise return a new Schedule.

Tipo del valor devuelto:

Schedule