compilation#

Compiler for the quantify_scheduler.

Module Contents#

Classes#

_ControlFlowReturn

An operation that signals the end of the current control flow statement.

Functions#

determine_absolute_timing(...)

Determine the absolute timing of a schedule based on the timing constraints.

_get_start_time(→ float)

_get_port_clocks(→ set)

Recursively collect all port-clock combinations in a Schedule.

resolve_control_flow(...)

If control flow is used, insert virtual operations before and after the schedulable.

flatten_schedule(...)

Recursively flatten subschedules based on the absolute timing.

_insert_op_at_time(→ None)

validate_config(→ bool)

Validate a configuration using a schema.

Attributes#

logger

logger[source]#
class _ControlFlowReturn(t0: float = 0)[source]#

Bases: quantify_scheduler.operations.operation.Operation

An operation that signals the end of the current control flow statement.

Cannot be added to Schedule manually.

Parameters

t0 (float, optional) – time offset, by default 0

determine_absolute_timing(schedule: quantify_scheduler.schedules.schedule.Schedule, time_unit: Literal[physical, ideal, None] = 'physical', config: quantify_scheduler.backends.graph_compilation.CompilationConfig | None = None, keep_original_schedule: bool = True) quantify_scheduler.schedules.schedule.Schedule[source]#

Determine the absolute timing of a schedule based on the timing constraints.

This function determines absolute timings for every operation in the schedulables. It does this by:

  1. iterating over all and elements in the schedulables.

  2. determining the absolute time of the reference operation - reference point "ref_pt" of the reference operation defaults to "end" in case it is not set (i.e., is None).

  3. determining the start of the operation based on the rel_time and duration of operations - reference point "ref_pt_new" of the added operation defaults to "start" in case it is not set.

Parameters
  • schedule – The schedule for which to determine timings.

  • config – Compilation config for QuantifyCompiler.

  • time_unit – Whether to use physical units to determine the absolute time or ideal time. When time_unit == "physical" the duration attribute is used. When time_unit == "ideal" the duration attribute is ignored and treated as if it is 1. When time_unit == None it will revert to "physical".

  • keep_original_schedule – If True, this function will not modify the schedule argument. If False, the compilation modifies the schedule, thereby making the original schedule unusable for further usage; this improves compilation time. Warning: if False, the returned schedule references objects from the original schedule, please refrain from modifying the original schedule after compilation in this case!

Returns

The modified schedule where the absolute time for each operation has been determined.

Raises

NotImplementedError – If the scheduling strategy is not “asap”

_get_start_time(schedule: quantify_scheduler.schedules.schedule.Schedule, t_constr: dict[str, str | float], curr_op: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, time_unit: str) float[source]#
_get_port_clocks(schedule: quantify_scheduler.schedules.schedule.Schedule) set[source]#

Recursively collect all port-clock combinations in a Schedule.

resolve_control_flow(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig | None = None, port_clocks: set | None = None) quantify_scheduler.schedules.schedule.Schedule[source]#

If control flow is used, insert virtual operations before and after the schedulable.

Parameters
  • schedule – The schedule for which to fill relative timings.

  • config – Compilation config for QuantifyCompiler, which is currently not used in this compilation step.

  • port_clocks – Port-clock combinations to be used for control flow. Determined automatically for the outermost schedule.

Returns

a new schedule object where the timing constraints for each operation have been determined.

flatten_schedule(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig | None = None) quantify_scheduler.schedules.schedule.Schedule[source]#

Recursively flatten subschedules based on the absolute timing.

Parameters
  • schedule (Schedule) – schedule to be flattened

  • config (CompilationConfig | None, optional) – Compilation config for QuantifyCompiler, which is currently not only used to detect if the function is called directly. by default None

Returns

Equivalent schedule without subschedules

Return type

Schedule

_insert_op_at_time(schedule: quantify_scheduler.schedules.schedule.Schedule, operation: quantify_scheduler.operations.operation.Operation, abs_time: float) None[source]#
validate_config(config: dict, scheme_fn: str) bool[source]#

Validate a configuration using a schema.

Parameters
  • config – The configuration to validate

  • scheme_fn – The name of a json schema in the quantify_scheduler.schemas folder.

Returns

True if valid