control_flow_library#
Standard control flow operations for use with the quantify_scheduler.
Module Contents#
Classes#
Control flow operation that can be used as an |
|
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 |
- class ControlFlowOperation(name: str)[source]#
Bases:
quantify_scheduler.operations.operation.OperationControl flow operation that can be used as an
OperationinSchedule.This is an abstract class. Each concrete implementation of the control flow operation decides how and when their
bodyoperation is executed.- property body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[source]#
- Abstractmethod:
Body of a control flow.
- class LoopOperation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, repetitions: int, t0: float = 0.0)[source]#
Bases:
ControlFlowOperationLoop over another operation predefined times.
Repeats the operation defined in
bodyrepetitionstimes. The actual implementation depends on the backend.- Parameters:
body – Operation to be repeated
repetitions – Number of repetitions
t0 – Time offset, by default 0
- property body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[source]#
Body of a control flow.
- class ConditionalOperation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, qubit_name: str, t0: float = 0.0, hardware_buffer_time: float = 0.0)[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 0
Example
A conditional reset can be implemented as follows:
# relevant imports from quantify_scheduler import Schedule from quantify_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': '49a07311-59ac-48fe-bee0-e23ac1f7f790', 'operation_id': '-3299324919748219966', 'timing_constraints': [TimingConstraint(ref_schedulable=None, ref_pt=None, ref_pt_new=None, rel_time=3.64e-07)], 'label': '49a07311-59ac-48fe-bee0-e23ac1f7f790'}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: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[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: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[source]#
Transform the control flow specification to an operation or schedule.
- class Loop(repetitions: int, t0: float = 0.0)[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
- create_operation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) 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: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) ConditionalOperation[source]#
Transform the control flow specification to an operation or schedule.