control_flow_library#

Standard control flow operations for use with the quantify_scheduler.

Module Contents#

Classes#

ControlFlowOperation

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

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.

class ControlFlowOperation(name: str)[source]#

Bases: 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.

property body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[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 LoopOperation(body: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, repetitions: int, t0: float = 0.0)[source]#

Bases: ControlFlowOperation

Loop over another operation predefined times.

Repeats the operation defined in body repetitions times. 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.

property duration: float[source]#

Duration 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: 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 qubit 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': 'bcd0de5f-c3a2-4105-9478-b363f4529f85', 'operation_id': '4430535804590397595', 'timing_constraints': [{'rel_time': 3.64e-07, 'ref_schedulable': None, 'ref_pt_new': None, 'ref_pt': None}], 'label': 'bcd0de5f-c3a2-4105-9478-b363f4529f85'}

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: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule[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: 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: 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

repetitions[source]#
t0 = 0.0[source]#
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: ControlFlowSpec

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

For more information, see ConditionalOperation.

Parameters:
  • qubit_name – Number of repetitions

  • t0 – Time offset, by default 0

qubit_name[source]#
t0 = 0.0[source]#
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.