quantify_scheduler.backends.circuit_to_device
¶
Compilation backend for quantum-circuit to quantum-device layer.
Module Contents¶
Classes¶
A datastructure containing the information required to compile an individual |
|
A datastructure containing the information required to compile a |
Functions¶
Adds the information required to represent operations on the quantum-device |
|
Ensures that each pulse/acquisition-level clock resource has either been added |
|
|
|
|
|
|
|
|
|
|
- class OperationCompilationConfig[source]¶
Bases:
quantify_scheduler.structure.DataStructure
A datastructure containing the information required to compile an individual operation to the representation at the device level.
- Parameters:
factory_func – A callable designating a factory function used to create the representation of the operation at the quantum-device level.
factory_kwargs – a dictionary containing the keyword arguments and corresponding values to use when creating the operation by evaluating the factory function.
gate_info_factory_kwargs – A list of keyword arguments of the factory function for which the value must be retrieved from the gate_info of the operation.
- class DeviceCompilationConfig[source]¶
Bases:
quantify_scheduler.structure.DataStructure
A datastructure containing the information required to compile a schedule to the representation at the quantum-device layer.
- Parameters:
backend – a . separated string specifying the location of the compilation backend this configuration is intended for e.g.,
compile_circuit_to_device()
.clocks – a dictionary specifying the clock frequencies available on the device e.g.,
{"q0.01": 6.123e9}
.elements – a dictionary specifying the elements on the device, what operations can be applied to them and how to compile them.
edges – a dictionary specifying the edges, links between elements on the device to which operations can be applied, the operations tha can be applied to them and how to compile them.
Examples
The DeviceCompilationConfig is structured such that it should allow the specification of the circuit-to-device compilation for many different qubit platforms. Here we show a basic configuration for a two-transmon quantum device. In this example, the DeviceCompilationConfig is created by parsing a dictionary containing the relevant information.
Important
Although it is possible to manually create a configuration using dictionaries, this is not recommended. The
QuantumDevice
is responsible for managing and generating configuration files.from quantify_scheduler.backends.circuit_to_device import DeviceCompilationConfig import pprint from quantify_scheduler.schemas.examples.circuit_to_device_example_cfgs import ( example_transmon_cfg, ) pprint.pprint(example_transmon_cfg)
{'backend': 'quantify_scheduler.backends.circuit_to_device.compile_circuit_to_device', 'clocks': {'q0.01': 6020000000.0, 'q0.ro': 7040000000.0, 'q1.01': 5020000000.0, 'q1.ro': 6900000000.0}, 'edges': {'q0_q1': {'CZ': {'factory_func': 'quantify_scheduler.operations.pulse_factories.composite_square_pulse', 'factory_kwargs': {'square_amp': 0.5, 'square_clock': 'cl0.baseband', 'square_duration': 2e-08, 'square_port': 'q0:fl', 'virt_z_child_qubit_clock': 'q1.01', 'virt_z_child_qubit_phase': 63, 'virt_z_parent_qubit_clock': 'q0.01', 'virt_z_parent_qubit_phase': 44}}}}, 'elements': {'q0': {'Rxy': {'factory_func': 'quantify_scheduler.operations.pulse_factories.rxy_drag_pulse', 'factory_kwargs': {'amp180': 0.32, 'clock': 'q0.01', 'duration': 2e-08, 'motzoi': 0.45, 'port': 'q0:mw'}, 'gate_info_factory_kwargs': ['theta', 'phi']}, 'Z': {'factory_func': 'quantify_scheduler.operations.pulse_library.SoftSquarePulse', 'factory_kwargs': {'amp': 0.23, 'clock': 'cl0.baseband', 'duration': 4e-09, 'port': 'q0:fl'}}, 'measure': {'factory_func': 'quantify_scheduler.operations.measurement_factories.dispersive_measurement', 'factory_kwargs': {'acq_channel': 0, 'acq_delay': 1.2e-07, 'acq_duration': 3e-07, 'clock': 'q0.ro', 'port': 'q0:res', 'pulse_amp': 0.25, 'pulse_duration': 1.6e-07, 'pulse_type': 'SquarePulse'}, 'gate_info_factory_kwargs': ['acq_index', 'bin_mode', 'acq_protocol']}, 'reset': {'factory_func': 'quantify_scheduler.operations.pulse_library.IdlePulse', 'factory_kwargs': {'duration': 0.0002}}}, 'q1': {'Rxy': {'factory_func': 'quantify_scheduler.operations.pulse_factories.rxy_drag_pulse', 'factory_kwargs': {'amp180': 0.4, 'clock': 'q1.01', 'duration': 2e-08, 'motzoi': 0.25, 'port': 'q1:mw'}, 'gate_info_factory_kwargs': ['theta', 'phi']}, 'measure': {'factory_func': 'quantify_scheduler.operations.measurement_factories.dispersive_measurement', 'factory_kwargs': {'acq_channel': 1, 'acq_delay': 1.2e-07, 'acq_duration': 3e-07, 'clock': 'q1.ro', 'port': 'q1:res', 'pulse_amp': 0.21, 'pulse_duration': 1.6e-07, 'pulse_type': 'SquarePulse'}, 'gate_info_factory_kwargs': ['acq_index', 'bin_mode', 'acq_protocol']}, 'reset': {'factory_func': 'quantify_scheduler.operations.pulse_library.IdlePulse', 'factory_kwargs': {'duration': 0.0002}}}}}
The dictionary can be parsed using the
parse_obj
method.device_cfg = DeviceCompilationConfig.parse_obj(example_transmon_cfg) device_cfg
DeviceCompilationConfig(backend='quantify_scheduler.backends.circuit_to_device.compile_circuit_to_device', clocks={'q0.01': 6020000000.0, 'q0.ro': 7040000000.0, 'q1.01': 5020000000.0, 'q1.ro': 6900000000.0}, elements={'q0': {'reset': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_library.IdlePulse', factory_kwargs={'duration': 0.0002}, gate_info_factory_kwargs=None), 'Rxy': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_factories.rxy_drag_pulse', factory_kwargs={'amp180': 0.32, 'motzoi': 0.45, 'port': 'q0:mw', 'clock': 'q0.01', 'duration': 2e-08}, gate_info_factory_kwargs=['theta', 'phi']), 'Z': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_library.SoftSquarePulse', factory_kwargs={'amp': 0.23, 'duration': 4e-09, 'port': 'q0:fl', 'clock': 'cl0.baseband'}, gate_info_factory_kwargs=None), 'measure': OperationCompilationConfig(factory_func='quantify_scheduler.operations.measurement_factories.dispersive_measurement', factory_kwargs={'port': 'q0:res', 'clock': 'q0.ro', 'pulse_type': 'SquarePulse', 'pulse_amp': 0.25, 'pulse_duration': 1.6e-07, 'acq_delay': 1.2e-07, 'acq_duration': 3e-07, 'acq_channel': 0}, gate_info_factory_kwargs=['acq_index', 'bin_mode', 'acq_protocol'])}, 'q1': {'reset': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_library.IdlePulse', factory_kwargs={'duration': 0.0002}, gate_info_factory_kwargs=None), 'Rxy': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_factories.rxy_drag_pulse', factory_kwargs={'amp180': 0.4, 'motzoi': 0.25, 'port': 'q1:mw', 'clock': 'q1.01', 'duration': 2e-08}, gate_info_factory_kwargs=['theta', 'phi']), 'measure': OperationCompilationConfig(factory_func='quantify_scheduler.operations.measurement_factories.dispersive_measurement', factory_kwargs={'port': 'q1:res', 'clock': 'q1.ro', 'pulse_type': 'SquarePulse', 'pulse_amp': 0.21, 'pulse_duration': 1.6e-07, 'acq_delay': 1.2e-07, 'acq_duration': 3e-07, 'acq_channel': 1}, gate_info_factory_kwargs=['acq_index', 'bin_mode', 'acq_protocol'])}}, edges={'q0_q1': {'CZ': OperationCompilationConfig(factory_func='quantify_scheduler.operations.pulse_factories.composite_square_pulse', factory_kwargs={'square_port': 'q0:fl', 'square_clock': 'cl0.baseband', 'square_amp': 0.5, 'square_duration': 2e-08, 'virt_z_parent_qubit_phase': 44, 'virt_z_parent_qubit_clock': 'q0.01', 'virt_z_child_qubit_phase': 63, 'virt_z_child_qubit_clock': 'q1.01'}, gate_info_factory_kwargs=None)}})
- elements: Dict[str, Dict[str, OperationCompilationConfig]][source]¶
- edges: Dict[str, Dict[str, OperationCompilationConfig]][source]¶
- compile_circuit_to_device(schedule: quantify_scheduler.schedules.schedule.Schedule, device_cfg: Optional[Union[DeviceCompilationConfig, dict]] = None) quantify_scheduler.schedules.schedule.Schedule [source]¶
Adds the information required to represent operations on the quantum-device abstraction layer to operations that contain information on how to be represented on the quantum-circuit layer.
- Parameters:
schedule – The schedule to be compiled.
device_cfg – Device specific configuration, defines the compilation step from the quantum-circuit layer to the quantum-device layer description. Note, if a dictionary is passed, it will be parsed to a
DeviceCompilationConfig
.
- set_pulse_and_acquisition_clock(schedule: quantify_scheduler.schedules.schedule.Schedule, device_cfg: Optional[Union[DeviceCompilationConfig, dict]] = None) quantify_scheduler.schedules.schedule.Schedule [source]¶
Ensures that each pulse/acquisition-level clock resource has either been added to the schedule or, if present in device_cfg, adds it 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.
device_cfg – Device specific configuration, defines the compilation step from the quantum-circuit layer to the quantum-device layer description. Note, if a dictionary is passed, it will be parsed to a
DeviceCompilationConfig
.
- Warns:
RuntimeWarning – When clock has conflicting frequency definitions.
- Raises:
RunTimeError – When operation is not at pulse/acquisition-level.
ValueError – When clock frequency is unknown.
ValueError – When clock frequency is NaN.
- _add_device_repr_from_cfg(operation: quantify_scheduler.operations.operation.Operation, operation_cfg: OperationCompilationConfig)[source]¶
- _add_device_repr_from_cfg_multiplexed(operation: quantify_scheduler.operations.operation.Operation, operation_cfg: OperationCompilationConfig, mux_idx: int)[source]¶