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. Then

a_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

scheduling

Determines how the contents of a composite TimeBox are scheduled by ScheduleBuilder.

scheduling_algorithm

Determines the algorithm used in converting the TimeBox to a Schedule.

label

Description the contents of the box for users' convenience.

locus_components

Names of the QPU components on which this timebox operates.

atom

Resolved contents of the TimeBox, or None if not resolved.

children

Further Timeboxes inside this TimeBox.

neighborhood_components

Dict of neighborhood range integers mapped to sets of components neighboring the locus of this TimeBox.

Methods

atomic

Build an atomic timebox from a schedule.

composite

Build a composite timebox from a sequence of timeboxes.

print

Print a simple representation of the contents of this box.

set_alap

Set the scheduling strategy to As late as possible (ALAP).

set_asap

Set the scheduling strategy to As soon as possible (ASAP).

validate

Validate the contents of the TimeBox.

Parameters:
label: str#

Description the contents of the box for users’ convenience. Has no functional effect.

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 (see neighborhood_components).

atom: Schedule | None#

Resolved contents of the TimeBox, or None if not resolved.

children: tuple[TimeBox, ...]#

Further Timeboxes inside this TimeBox.

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 in self.atom + self.locus, 1 means also neighboring couplers, 2 the components connected to those couplers, and so on. Note: range 0 may differ from self.locus_components: it can have additional components that have occupied channels in self but are not defined as a part of the ‘locus’ of this TimeBox 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:

TimeBox

static atomic(schedule, *, locus_components, label)#

Build an atomic timebox from a schedule.

Parameters:
  • schedule (Schedule) – contents of the new timebox

  • locus_components (Iterable[str]) – names QPU components schedule operates on

  • label (str) – label of the new timebox

Returns:

atomic timebox containing schedule

Return type:

TimeBox

validate(path=())#

Validate the contents of the TimeBox.

Parameters:

path (tuple[str, ...]) – Labels of ancestor boxes, to generate a better error message.

Return type:

None

set_asap()#

Set the scheduling strategy to As soon as possible (ASAP).

Return type:

TimeBox

set_alap()#

Set the scheduling strategy to As late as possible (ALAP).

Return type:

TimeBox

print(_idxs=())#

Print a simple representation of the contents of this box.

Parameters:

_idxs (tuple[int, ...]) –

Return type:

None