ScheduleBlock¶
-
class
ScheduleBlock
(name=None, metadata=None, alignment_context=None)[source]¶ Bases:
object
A
ScheduleBlock
is a time-ordered sequence of instructions and transform macro to manage their relative timing. The relative position of the instructions is managed by thecontext_alignment
. This allowsScheduleBlock
to support instructions with a parametric duration and allows the lazy scheduling of instructions, i.e. allocating the instruction time just before execution.ScheduleBlock
s should be initialized with one of the following alignment contexts:AlignLeft
: Align instructions in the as-soon-as-possible manner. Instructions are scheduled at the earliest possible time on the channel.AlignRight
: Align instructions in the as-late-as-possible manner. Instructions are scheduled at the latest possible time on the channel.AlignSequential
: Align instructions sequentially even though they are allocated in different channels.AlignEquispaced
: Align instructions with equal interval within a specified duration. Instructions on different channels are aligned sequentially.AlignFunc
: Align instructions with arbitrary position within the given duration. The position is specified by a callback function taking a pulse indexj
and returning a fractional coordinate in [0, 1].
The
ScheduleBlock
defaults to theAlignLeft
alignment. The timing overlap constraint of instructions is not immediately evaluated, and thus we can assign a parameter object to the instruction duration. Instructions are implicitly scheduled at optimum time when the program is executed.Note that
ScheduleBlock
can containInstruction
and otherScheduleBlock
to build an experimental program, butSchedule
is not supported. This should be added as aCall
instruction. This conversion is automatically performed with the pulse builder.By using
ScheduleBlock
representation we can fully parametrize pulse waveforms. For example, Rabi schedule generator can be defined asduration = Parameter('rabi_dur') amp = Parameter('rabi_amp') block = ScheduleBlock() rabi_pulse = pulse.Gaussian(duration=duration, amp=amp, sigma=duration/4) block += Play(rabi_pulse, pulse.DriveChannel(0)) block += Call(measure_schedule)
Note that such waveform cannot be appended to the
Schedule
representation.In the block representation, the interval between two instructions can be managed with the
Delay
instruction. Because the schedule block lacks an instruction start timet0
, we cannotinsert
orshift
the target instruction. In addition, stored instructions are not interchangable because the schedule block is sensitive to the relative position of instructions. Apart from these differences, the block representation can provide compatible functionality withSchedule
representation.Create an empty schedule block.
- Parameters
name (
Optional
[str
]) – Name of this schedule. Defaults to an autogenerated string if not provided.metadata (
Optional
[dict
]) – Arbitrary key value metadata to associate with the schedule. This gets stored as free-form data in a dict in themetadata
attribute. It will not be directly used in the schedule.alignment_context (AlignmentKind) –
AlignmentKind
instance that manages scheduling of instructions in this block.
- Raises
TypeError – if metadata is not a dict.
Methods
Return a new schedule block with
block
appended to the context block.Assign the parameters in this schedule according to the input.
Return the time of the end of the last instruction over the supplied channels.
Return the time of the start of the first instruction over the supplied channels.
Return maximum start time over supplied channels.
Plot the schedule.
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::.Return a new
Schedule
with only the instructions from thisScheduleBlock
which pass though the provided filters; i.e. an instruction will be retained iff every function infilter_funcs
returnsTrue
, the instruction occurs on a channel type contained inchannels
, the instruction type is contained ininstruction_types
, and the period over which the instruction operates is fully contained in one specified intime_ranges
orintervals
.Get parameter object bound to this schedule by string name.
Create new schedule object with metadata of another schedule object.
This method will be removed.
Return True iff the instruction is parameterized.
Return
True
if all durations are assigned.Return a
ScheduleBlock
with theold
component replaced with anew
component.This method will be removed.
Attributes
-
alignment_context
¶ Return alignment instance that allocates block component to generate schedule.
-
blocks
¶ Get the time-ordered instructions from self.
- Return type
Tuple
[Union
[ScheduleBlock
,Instruction
]]
-
channels
¶ Returns channels that this schedule clock uses.
- Return type
Tuple
[Channel
]
-
duration
¶ Duration of this schedule block.
- Return type
int
-
instances_counter
= count(0)¶
-
instructions
¶ Get the time-ordered instructions from self.
- Return type
Tuple
[Tuple
[int
,Instruction
]]
-
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.- Return type
Dict
[str
,Any
]
-
name
¶ Name of this Schedule
- Return type
str
-
parameters
¶ Parameters which determine the schedule behavior.
- Return type
Set
-
prefix
= 'block'¶
-
start_time
¶ Starting time of this schedule block.
- Return type
int
-
stop_time
¶ Stopping time of this schedule block.
- Return type
int
-
timeslots
¶ Time keeping attribute.
- Return type
Dict
[Channel
,List
[Tuple
[int
,int
]]]