qblox_scheduler.operations.control_flow_library#

Standard control flow operations for use with the qblox_scheduler.

Classes#

ControlFlowOperation

Control flow operation that can be used as an Operation in .TimeableSchedule.

LoopStrategy

Strategy to use for implementing loops.

LoopOperation

Loop over another operation predefined times.

ConditionalOperation

Conditional over another operation.

ControlFlowSpec

Control flow specification to be used at Schedule.add.

Loop

Loop control flow specification to be used at Schedule.add.

Conditional

Conditional control flow specification to be used at Schedule.add.

Module Contents#

class ControlFlowOperation(name: str)[source]#

Bases: qblox_scheduler.operations.operation.Operation

Control flow operation that can be used as an Operation in .TimeableSchedule.

This is an abstract class. Each concrete implementation of the control flow operation decides how and when their body operation is executed.

property body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
Abstractmethod:

Body of a control flow.

get_used_port_clocks() set[tuple[str, str]][source]#

Extracts which port-clock combinations are used in this control flow operation.

Returns:

: All (port, clock) combinations that operations in the body of this control flow operation uses.

class LoopStrategy[source]#

Bases: qblox_scheduler.enums.StrEnum

Strategy to use for implementing loops.

REALTIME: Use native loops. UNROLLED: Unroll loop at compilation time into separate instructions.

REALTIME = 'realtime'[source]#
UNROLLED = 'unrolled'[source]#
class LoopOperation(body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule | qblox_scheduler.schedule.Schedule, *, repetitions: int | None = None, domain: dict[qblox_scheduler.operations.variables.Variable, qblox_scheduler.operations.loop_domains.LinearDomain] | None = None, t0: float = 0.0, strategy: LoopStrategy | None = None)[source]#

Bases: ControlFlowOperation

Loop over another operation predefined times.

Repeats the operation defined in body repetitions times. The actual implementation depends on the backend.

One of domain or repetitions must be specified.

Parameters:
  • body – Operation to be repeated

  • repetitions – Number of repetitions, by default None

  • domain – Linear domain to loop over, by default None

  • t0 – Time offset, by default 0

  • strategy – Strategy to use for implementing this loop, by default None to make own decision

property body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#

Body of a control flow.

property duration: float[source]#

Duration of a control flow.

property domain: dict[qblox_scheduler.operations.variables.Variable, qblox_scheduler.operations.loop_domains.LinearDomain][source]#

Linear domain to loop over.

property repetitions: int[source]#

Number of times the body will execute.

property strategy: LoopStrategy | None[source]#

What strategy to use for implementing this loop.

class ConditionalOperation(body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule | qblox_scheduler.schedule.Schedule, qubit_name: str, t0: float = 0.0, hardware_buffer_time: float = constants.MIN_TIME_BETWEEN_OPERATIONS * 1e-09)[source]#

Bases: ControlFlowOperation

Conditional over another operation.

If a preceding thresholded acquisition on qubit_name results in a “1”, the body will be executed, otherwise it will generate a wait time that is equal to the time of the subschedule, to ensure the absolute timing of later operations remains consistent.

Parameters:
  • body – Operation to be conditionally played

  • qubit_name – Name of the device element on which the body will be conditioned

  • t0 – Time offset, by default 0

  • hardware_buffer_time – Time buffer, by default the minimum time between operations on the hardware

Example

A conditional reset can be implemented as follows:

# relevant imports
from qblox_scheduler import Schedule
from qblox_scheduler.operations import ConditionalOperation, Measure, X

# define conditional reset as a Schedule
conditional_reset = Schedule("conditional reset")
conditional_reset.add(Measure("q0", feedback_trigger_label="q0"))
conditional_reset.add(
    ConditionalOperation(body=X("q0"), qubit_name="q0"),
    rel_time=364e-9,
)
{'name': '18f7dde6-f8f1-49ab-9dfb-9e27892ba196', 'operation_id': '-3509406785361409810', 'timing_constraints': [TimingConstraint(ref_schedulable=None, ref_pt=None, ref_pt_new=None, rel_time=3.64e-07)], 'label': '18f7dde6-f8f1-49ab-9dfb-9e27892ba196'}

Added in version 0.22.0: For some hardware specific implementations, a hardware_buffer_time might be required to ensure the correct timing of the operations. This will be added to the duration of the body to prevent overlap with other operations.

property body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#

Body of a control flow.

property duration: float[source]#

Duration of a control flow.

class ControlFlowSpec[source]#

Control flow specification to be used at Schedule.add.

The users can specify any concrete control flow with the control_flow argument to Schedule.add. The ControlFlowSpec is only a type which by itself cannot be used for the control_flow argument, use any concrete control flow derived from it.

abstract create_operation(body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule) qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#

Transform the control flow specification to an operation or schedule.

class Loop(repetitions: int, t0: float = 0.0, strategy: LoopStrategy | None = None)[source]#

Bases: ControlFlowSpec

Loop control flow specification to be used at Schedule.add.

For more information, see LoopOperation.

Parameters:
  • repetitions – Number of repetitions

  • t0 – Time offset, by default 0

  • strategy – Strategy to use for implementing the loop, by default None

repetitions[source]#
t0 = 0.0[source]#
strategy = None[source]#
create_operation(body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule) LoopOperation[source]#

Transform the control flow specification to an operation or schedule.

class Conditional(qubit_name: str, t0: float = 0.0)[source]#

Bases: ControlFlowSpec

Conditional control flow specification to be used at Schedule.add.

For more information, see ConditionalOperation.

Parameters:
  • qubit_name – Target device element.

  • t0 – Time offset, by default 0

device_element_name[source]#
t0 = 0.0[source]#
create_operation(body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule) ConditionalOperation[source]#

Transform the control flow specification to an operation or schedule.