control_flow_library ==================== .. py:module:: quantify_scheduler.operations.control_flow_library .. autoapi-nested-parse:: Standard control flow operations for use with the quantify_scheduler. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quantify_scheduler.operations.control_flow_library.ControlFlowOperation quantify_scheduler.operations.control_flow_library.LoopOperation quantify_scheduler.operations.control_flow_library.ConditionalOperation quantify_scheduler.operations.control_flow_library.ControlFlowSpec quantify_scheduler.operations.control_flow_library.Loop quantify_scheduler.operations.control_flow_library.Conditional .. py:class:: ControlFlowOperation(name: str) Bases: :py:obj:`quantify_scheduler.operations.operation.Operation` Control flow operation that can be used as an ``Operation`` in ``Schedule``. This is an abstract class. Each concrete implementation of the control flow operation decides how and when their ``body`` operation is executed. .. py:property:: body :type: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule :abstractmethod: Body of a control flow. .. py:class:: LoopOperation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, repetitions: int, t0: float = 0.0) Bases: :py:obj:`ControlFlowOperation` Loop over another operation predefined times. Repeats the operation defined in ``body`` ``repetitions`` times. The actual implementation depends on the backend. :param body: Operation to be repeated :param repetitions: Number of repetitions :param t0: Time offset, by default 0 .. py:property:: body :type: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule Body of a control flow. .. py:property:: duration :type: float Duration of a control flow. .. py:class:: ConditionalOperation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, qubit_name: str, t0: float = 0.0) Bases: :py:obj:`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. :param body: Operation to be repeated :param repetitions: Number of repetitions :param t0: Time offset, by default 0 .. rubric:: Example A conditional reset can be implemented as follows: .. admonition:: example .. jupyter-execute # relevant imports from quantify_scheduler import Schedule from quantify_scheduler.operations.control_flow_library import Conditional from quantify_scheduler.operations.gate_library import Measure, X # define schedule schedule = Schedule("main schedule") # define a subschedule containing conditional reset conditional_reset = Schedule("conditional reset") conditional_reset.add(Measure("q0", feedback_trigger_label="q0")) sub_schedule = Schedule("conditional x") sub_schedule.add(X("q0")) conditional_reset.add(ConditionalOperation(sub_schedule, "q0")) # add conditional reset as an operation schedule.add(conditional_reset) .. py:property:: body :type: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule Body of a control flow. .. py:property:: duration :type: float Duration of a control flow. .. py:class:: ControlFlowSpec 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. .. py:method:: create_operation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) -> quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule :abstractmethod: Transform the control flow specification to an operation or schedule. .. py:class:: Loop(repetitions: int, t0: float = 0.0) Bases: :py:obj:`ControlFlowSpec` Loop control flow specification to be used at ``Schedule.add``. For more information, see ``LoopOperation``. :param repetitions: Number of repetitions :param t0: Time offset, by default 0 .. py:attribute:: repetitions .. py:attribute:: t0 .. py:method:: create_operation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) -> LoopOperation Transform the control flow specification to an operation or schedule. .. py:class:: Conditional(qubit_name: str, t0: float = 0.0) Bases: :py:obj:`ControlFlowSpec` Conditional control flow specification to be used at ``Schedule.add``. For more information, see ``ConditionalOperation``. :param qubit_name: Number of repetitions :param t0: Time offset, by default 0 .. py:attribute:: qubit_name .. py:attribute:: t0 .. py:method:: create_operation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule) -> ConditionalOperation Transform the control flow specification to an operation or schedule.