qblox_scheduler.compilation#
Compiler for the qblox_scheduler.
Attributes#
Classes#
Datastructure to help readability for scale_phase_domains. |
Functions#
|
|
|
|
|
|
Determine the absolute timing of a schedule based on the timing constraints. |
|
|
Check the schedulable references for circular references. |
|
Add nodes and edges to the graph containing schedulable references. |
|
|
|
|
|
|
|
|
|
Validate a configuration using a schema. |
Show the schedulable reference graph. |
|
Schedule repetitions are deprecated in favor of the more versatile loops. |
|
|
|
Recursively collect every |
|
Scales each DType.AMPLITUDE and DType.DRAG_BETA domain to be between [-1,+1], |
|
Introduces new phase domains for each usage of an expression with a DType.PHASE variable. |
|
Module Contents#
- _shift_timing(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, delta: float) None[source]#
- _shift_timing_from(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, schedulable: qblox_scheduler.schedules.schedule.Schedulable, delta: float) None[source]#
- _shift_timing_at(schedulable: qblox_scheduler.schedules.schedule.Schedulable, operation: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule, delta: float) None[source]#
- _determine_absolute_timing(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, time_unit: Literal['physical', 'ideal', None] = 'physical', config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- _determine_absolute_timing(schedule: qblox_scheduler.operations.operation.Operation, time_unit: Literal['physical', 'ideal', None] = 'physical', config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule
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:iterating over all and elements in the
schedulables.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., isNone).determining the start of the operation based on the
rel_timeanddurationof 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
ScheduleCompiler.time_unit – Whether to use physical units to determine the absolute time or ideal time. When
time_unit == "physical"the duration attribute is used. Whentime_unit == "ideal"the duration attribute is ignored and treated as if it is1. Whentime_unit == Noneit will revert to"physical".
- Returns:
: The modified .TimeableSchedule` where the absolute time for each operation has been determined.
- Raises:
NotImplementedError – If the scheduling strategy is not SchedulingStrategy.ASAP
- _determine_absolute_timing_schedule(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, time_unit: Literal['physical', 'ideal', None], config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- _determine_scheduling_strategy(config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.enums.SchedulingStrategy[source]#
- _validate_schedulable_references(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, references_graph: networkx.DiGraph) None[source]#
Check the schedulable references for circular references.
- _populate_references_graph(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule) networkx.DiGraph[source]#
Add nodes and edges to the graph containing schedulable references.
- _make_timing_constraints_explicit(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, strategy: qblox_scheduler.enums.SchedulingStrategy) None[source]#
- _make_timing_constraints_explicit_for_schedulable(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, schedulable_name: str, default_reference_schedulable_name: str | None, strategy: qblox_scheduler.enums.SchedulingStrategy) None[source]#
- _determine_default_ref_pt(strategy: qblox_scheduler.enums.SchedulingStrategy) Literal['start', 'end'][source]#
- _determine_default_ref_pt_new(strategy: qblox_scheduler.enums.SchedulingStrategy) Literal['start', 'end'][source]#
- _determine_default_ref_schedulables_by_schedulable(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, strategy: qblox_scheduler.enums.SchedulingStrategy) list[tuple[str, str | None]][source]#
- _get_start_time(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, t_constr: qblox_scheduler.schedules.schedule.TimingConstraint, curr_op: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule, time_unit: Literal['physical', 'ideal', None]) float[source]#
- _normalize_absolute_timing(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- _unroll_loops(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- _unroll_loops(schedule: qblox_scheduler.operations.operation.Operation, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule
- _unroll_single_loop(op: qblox_scheduler.operations.control_flow_library.LoopOperation) qblox_scheduler.schedules.schedule.TimeableSchedule[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 qblox_scheduler.schemas folder.
- Returns:
: True if valid
- plot_schedulable_references_graph(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule) None[source]#
Show the schedulable reference graph.
Can be used as a debugging tool to spot any circular references.
- schedule_repetitions_to_loop(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
Schedule repetitions are deprecated in favor of the more versatile loops. In implementation, we only process loops to not make the code redundant. We intentionally set the schedule repetitions to None to disallow anyone using it.
- _extract_used_clocks(operation: qblox_scheduler.schedules.schedule.TimeableSchedule | qblox_scheduler.operations.operation.Operation, clocks_used: set[str]) None[source]#
- _add_schedule_repetition_to_append(operation: qblox_scheduler.operations.operation.Operation | qblox_scheduler.schedules.schedule.TimeableSchedule, schedule_repetition_variable: qblox_scheduler.operations.variables.Variable) None[source]#
- _variables_in_expression(expr: qblox_scheduler.operations.expressions.Expression) set[qblox_scheduler.operations.variables.Variable][source]#
Recursively collect every
Variablereferenced within an expression tree.
- scale_amplitude_variables(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None, substitutions: dict[qblox_scheduler.operations.expressions.Expression, qblox_scheduler.operations.expressions.Expression | int | float | complex] | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- scale_amplitude_variables(schedule: qblox_scheduler.operations.operation.Operation, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None, substitutions: dict[qblox_scheduler.operations.expressions.Expression, qblox_scheduler.operations.expressions.Expression | int | float | complex] | None = None) qblox_scheduler.operations.operation.Operation
Scales each DType.AMPLITUDE and DType.DRAG_BETA domain to be between [-1,+1], and each time the variable is used is scaled back with the same number.
This is supposed to be a temporary solution until backend does not allow amplitude variables to be outside of the range [-1,+1].
Currently the backend compiler does not allow variables to go outside of the range [-1,+1] in case the variable is used as an amplitude. But the compiler allows expressions of the form amplitude=c*var. So we get around the range problem by scaling the domain ranges and variable usages.
- class _DomainForVariable[source]#
Datastructure to help readability for scale_phase_domains.
- domain: qblox_scheduler.operations.loop_domains.LinearDomain[source]#
Domain for the variable.
- domain_dict_to_change: dict[qblox_scheduler.operations.variables.Variable, qblox_scheduler.operations.loop_domains.LinearDomain][source]#
When we introduce new domains, we need to do this into this dictionary.
- scale_phase_domains(schedule: qblox_scheduler.schedules.schedule.TimeableSchedule, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None, domain_for_variable: dict[qblox_scheduler.operations.variables.Variable, _DomainForVariable] | None = None) qblox_scheduler.schedules.schedule.TimeableSchedule[source]#
- scale_phase_domains(schedule: qblox_scheduler.operations.operation.Operation, config: qblox_scheduler.backends.graph_compilation.CompilationConfig | None = None, domain_for_variable: dict[qblox_scheduler.operations.variables.Variable, _DomainForVariable] | None = None) qblox_scheduler.operations.operation.Operation
Introduces new phase domains for each usage of an expression with a DType.PHASE variable. It’s needed, because currently wherever DType.PHASE variable is used, we cannot use a generic expression but only a variable. So we introduce a new compatible domain for every expression is used, and introduce a new variable for that, and use that single variable there instead.
This is supposed to be a temporary solution until backend does not allow generic expressions where phase is allowed.
This step is only implemented for a few operation types and few arguments of them.
- Parameters:
schedule – The schedule.
config – Compilation config.
domain_for_variable – This is the domain for a variable we need to modify. We introduce a new variable in place of an expression where a variable is used, and then introduce a new domain in the domain specification.
- Raises:
NotImplementedError – If a
phase_shiftexpression still contains a DType.PHASE variable that is not driven by a LoopOperation domain (e.g. a free-standing variable declared viaTimeableSchedule.declareand set viaAssign). Such an expression cannot be reduced to the single nativeVariablethe backend requires.
- _variable_is_in_linear_expression(expression: qblox_scheduler.operations.expressions.Expression | float | int | complex, variable: qblox_scheduler.operations.variables.Variable) bool[source]#