TimeBox#
- class iqm.pulse.timebox.TimeBox(label, locus_components, atom, children=<factory>, scheduling=SchedulingStrategy.ASAP, scheduling_algorithm=SchedulingAlgorithm.HARD_BOUNDARY, neighborhood_components=<factory>)#
Bases:
object
Container for one or more instruction schedule fragments, to be scheduled according to a given strategy.
Each TimeBox can be labeled using a human-readable label describing it, and operates on a number of locus components, using some of their control channels. It can be either atomic or composite.
An atomic box only contains a single
Schedule
.A composite box contains a sequence of other TimeBoxes as its children. The locus components are the union of the locus components of the children. If two children use the same channel so that they cannot happen simultaneously, they must happen in the order they occur in the sequence.
A box can be made atomic by resolving it using
ScheduleBuilder.resolve_timebox
. The time duration of the box is determined by its contents and the way they are scheduled during the resolution.TimeBoxes can be concatenated with the following rules:
Addition concatenates the children of the operands into a single TimeBox.
The pipe operation groups two TimeBoxes together without concatenating.
Iterables of Boxes are treated as the sum of the elements.
Let
a, b, c, d
be TimeBoxes. Thena_then_b = a + b c_then_d = (c + d).set_alap() abcd = a_then_b | c_then_d abb = a + [b, b] ccd = [c, c] | d all_together = abcd | abb + ccd # is equivalent to: all_together = a + b | (c + d).set_alap() | a + b + b + c + (c | d)
Module:
iqm.pulse.timebox
Attributes
Determines how the contents of a composite TimeBox are scheduled by ScheduleBuilder.
Determines the algorithm used in converting the TimeBox to a Schedule.
Description the contents of the box for users' convenience.
Names of the QPU components on which this timebox operates.
Resolved contents of the TimeBox, or None if not resolved.
Further Timeboxes inside this TimeBox.
Dict of neighborhood range integers mapped to sets of components neighboring the locus of this
TimeBox
.Methods
Build an atomic timebox from a schedule.
Build a composite timebox from a sequence of timeboxes.
Print a simple representation of the contents of this box.
Set the scheduling strategy to As late as possible (ALAP).
Set the scheduling strategy to As soon as possible (ASAP).
Validate the contents of the TimeBox.
- Parameters:
- locus_components: set[str]#
Names of the QPU components on which this timebox operates. These can include additional components to the ones included in one of the channels occupied by this
TimeBox
. The components included in this attribute will be blocked in scheduling, in addition to the ones dictated by the neighborhood range (seeneighborhood_components
).
- scheduling: SchedulingStrategy = 'ASAP'#
Determines how the contents of a composite TimeBox are scheduled by ScheduleBuilder. Has no meaning for an atomic TimeBox.
- scheduling_algorithm: SchedulingAlgorithm = 'HARD_BOUNDARY'#
Determines the algorithm used in converting the TimeBox to a Schedule.
- neighborhood_components: dict[int, set[str]]#
Dict of neighborhood range integers mapped to sets of components neighboring the locus of this
TimeBox
. These are used in the scheduling when the corresponding neighborhood range is used. The scheduling algorithm computes the neighborhood components (unless it has been already precomputed by e.g. the GateImplementation) and caches them under this attribute. Neighborhood range 0 means just the components affected by one of the channels inself.atom
+self.locus
, 1 means also neighboring couplers, 2 the components connected to those couplers, and so on. Note: range 0 may differ fromself.locus_components
: it can have additional components that have occupied channels inself
but are not defined as a part of the ‘locus’ of thisTimeBox
for any reason.
- static composite(boxes, *, label='', scheduling=SchedulingStrategy.ASAP, scheduling_algorithm=SchedulingAlgorithm.HARD_BOUNDARY)#
Build a composite timebox from a sequence of timeboxes.
- Parameters:
boxes (Iterable[TimeBox | Iterable[TimeBox]]) – contents of the new timebox. Any iterables of timeboxes will be flattened (recursively) and extended to the contents in the same order.
label (str) – label of the new timebox
scheduling (SchedulingStrategy) – scheduling strategy to use when resolving the new timebox
scheduling_algorithm (SchedulingAlgorithm) – scheduling algorithm to use when resolving the new timebox
- Returns:
composite timebox containing
boxes
as its children- Return type:
- static atomic(schedule, *, locus_components, label)#
Build an atomic timebox from a schedule.
- validate(path=())#
Validate the contents of the TimeBox.