qblox_scheduler.operations.control_flow_library#
Standard control flow operations for use with the qblox_scheduler.
Classes#
Control flow operation that can be used as an |
|
Strategy to use for implementing loops. |
|
Loop over another operation predefined times. |
|
Conditional over another operation. |
|
Control flow specification to be used at |
|
Loop control flow specification to be used at |
|
Conditional control flow specification to be used at |
Module Contents#
- class ControlFlowOperation(name: str)[source]#
Bases:
qblox_scheduler.operations.operation.OperationControl flow operation that can be used as an
Operationin.TimeableSchedule.This is an abstract class. Each concrete implementation of the control flow operation decides how and when their
bodyoperation is executed.- property body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- Abstractmethod:
Body of a control flow.
- class LoopStrategy[source]#
Bases:
qblox_scheduler.enums.StrEnumStrategy to use for implementing loops.
REALTIME: Use native loops. UNROLLED: Unroll loop at compilation time into separate instructions.
- 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:
ControlFlowOperationLoop over another operation predefined times.
Repeats the operation defined in
bodyrepetitionstimes. The actual implementation depends on the backend.One of
domainorrepetitionsmust 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 domain: dict[qblox_scheduler.operations.variables.Variable, qblox_scheduler.operations.loop_domains.LinearDomain][source]#
Linear domain to loop over.
- 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:
ControlFlowOperationConditional over another operation.
If a preceding thresholded acquisition on
qubit_nameresults 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_timemight be required to ensure the correct timing of the operations. This will be added to the duration of thebodyto prevent overlap with other operations.- property body: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
Body 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_flowargument toSchedule.add. TheControlFlowSpecis only a type which by itself cannot be used for thecontrol_flowargument, 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:
ControlFlowSpecLoop 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
- 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:
ControlFlowSpecConditional 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
- 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.