circuit_to_device#
Compilation backend for quantum-circuit to quantum-device layer.
Module Contents#
Functions#
Add pulse information to all gates in the schedule. |
|
Add pulse information to all gates in the schedule. |
|
Ensures that each pulse/acquisition-level clock resource is added to the schedule, |
|
Ensures that each pulse/acquisition-level clock resource is added to the schedule. |
|
|
Asserts that valid clock is present. Returns whether clock is already in schedule. |
|
Compare device config and schedule resources for compatibility of their clocks. |
Verifies that the operation has been compiled to device level. |
|
|
Compiles gate with multiple qubits. |
Compiles gate with multiple qubits. |
|
|
Compiles gate with multiple qubits. |
- compile_circuit_to_device_with_config_validation(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig | quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None, *, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None) quantify_scheduler.schedules.schedule.Schedule [source]#
Add pulse information to all gates in the schedule.
Before calling this function, the schedule can contain abstract operations (gates or measurements). This function adds pulse and acquisition information with respect to
config
as they are expected to arrive to device (latency or distortion corrections are not taken into account).From a point of view of Compilation, this function converts a schedule defined on a quantum-circuit layer to a schedule defined on a quantum-device layer.
- Parameters:
schedule – The schedule to be compiled.
config – Compilation config for
QuantifyCompiler
, of which only theCompilationConfig.device_compilation_config
is used in this compilation step.device_cfg – (deprecated) Device compilation config. Pass a full compilation config instead using
config
argument. Note, if a dictionary is passed, it will be parsed to aDeviceCompilationConfig
.
- Returns:
The modified
schedule
with pulse information added to all gates.- Raises:
ValueError – When both
config
anddevice_cfg
are supplied.
- _compile_circuit_to_device(operation: quantify_scheduler.schedules.schedule.Schedule, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig) quantify_scheduler.schedules.schedule.Schedule [source]#
- _compile_circuit_to_device(operation: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule
- compile_circuit_to_device(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig | quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None, *, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None) quantify_scheduler.schedules.schedule.Schedule [source]#
Add pulse information to all gates in the schedule.
- set_pulse_and_acquisition_clock(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig | quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None, *, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None = None) quantify_scheduler.schedules.schedule.Schedule [source]#
Ensures that each pulse/acquisition-level clock resource is added to the schedule, and validates the given configuration.
If a pulse/acquisition-level clock resource has not been added to the schedule and is present in device_cfg, it is added to the schedule.
A warning is given when a clock resource has conflicting frequency definitions, and an error is raised if the clock resource is unknown.
- Parameters:
schedule – The schedule to be compiled.
config – Compilation config for
QuantifyCompiler
, of which only theCompilationConfig.device_compilation_config
is used in this compilation step.device_cfg – (deprecated) Device compilation config. Pass a full compilation config instead using
config
argument. Note, if a dictionary is passed, it will be parsed to aDeviceCompilationConfig
.
- Returns:
The modified
schedule
with all clock resources added.- Warns:
RuntimeWarning – When clock has conflicting frequency definitions.
- Raises:
RuntimeError – When operation is not at pulse/acquisition-level.
ValueError – When both
config
anddevice_cfg
are supplied.ValueError – When clock frequency is unknown.
ValueError – When clock frequency is NaN.
- _set_pulse_and_acquisition_clock(schedule: quantify_scheduler.schedules.schedule.Schedule, operation: quantify_scheduler.schedules.schedule.Schedule, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig, verified_clocks: List) quantify_scheduler.schedules.schedule.Schedule [source]#
- _set_pulse_and_acquisition_clock(schedule: quantify_scheduler.schedules.schedule.Schedule, operation: quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig, verified_clocks: List) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule
Ensures that each pulse/acquisition-level clock resource is added to the schedule.
- Parameters:
schedule – The resources from
operation
are added toschedule
ifoperation
is not aSchedule
.operation – The
operation
to collect resources from.device_cfg – Device compilation config.
verified_clocks – Already verified clocks.
- Returns:
The modified
operation
with all clock resources added.
- _valid_clock_in_schedule(clock: str, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig, schedule: quantify_scheduler.schedules.schedule.Schedule, operation: quantify_scheduler.operations.operation.Operation) bool [source]#
Asserts that valid clock is present. Returns whether clock is already in schedule.
- Parameters:
clock – Name of the clock
device_cfg – Device config that potentially contains the clock.
schedule – Schedule that potentially has the clock in its resources
operation – Quantify operation, to which the clock belongs. Only used for error message.
- Raises:
ValueError – Returns ValueError if (i) the device config is the only defined clock and contains nan values or (ii) no clock is defined.
- _clocks_compatible(clock, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig, schedule) bool [source]#
Compare device config and schedule resources for compatibility of their clocks.
Clocks can be defined in the device_cfg and in the schedule. They are consistent if
they have the same value
if the clock in the device config is nan (not the other way around)
These conditions are also generalized to numpy arrays. Arrays of different length are only equal if all frequencies in the device config are nan.
If the clocks are inconsistent, a warning message is emitted.
- Parameters:
clock – Name of the clock found in the device config and schedule
device_cfg – Device config containing the
clock
schedule – Schedule containing the
clock
- Returns:
True if the clock frequencies are consistent.
- _assert_operation_valid_device_level(operation: quantify_scheduler.operations.operation.Operation) None [source]#
Verifies that the operation has been compiled to device level.
- Parameters:
operation – Quantify operation
- _compile_multiplexed(operation: quantify_scheduler.operations.operation.Operation, qubits: Sequence[str], operation_type: str, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule [source]#
Compiles gate with multiple qubits.
Note: it updates the operation, if it can directly add pulse representation.
- _compile_single_qubit(operation: quantify_scheduler.operations.operation.Operation, qubit: str, operation_type: str, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule [source]#
Compiles gate with multiple qubits.
Note: it updates the operation, if it can directly add pulse representation.
- _compile_two_qubits(operation: quantify_scheduler.operations.operation.Operation, qubits: Sequence[str], operation_type: str, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule [source]#
Compiles gate with multiple qubits.
Note: it updates the operation, if it can directly add pulse representation.
- _get_device_repr_from_cfg(operation: quantify_scheduler.operations.operation.Operation, operation_cfg: quantify_scheduler.backends.graph_compilation.OperationCompilationConfig) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule [source]#
- _get_device_repr_from_cfg_multiplexed(operation: quantify_scheduler.operations.operation.Operation, operation_cfg: quantify_scheduler.backends.graph_compilation.OperationCompilationConfig, mux_idx: int) quantify_scheduler.operations.operation.Operation | quantify_scheduler.schedules.schedule.Schedule [source]#
- _validate_and_extract_device_cfg(config: quantify_scheduler.backends.graph_compilation.CompilationConfig | quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None, device_cfg: quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig | Dict | None, caller_function_name: str) quantify_scheduler.backends.graph_compilation.DeviceCompilationConfig [source]#