quantify_scheduler.backends.graph_compilation
Graph compilation backend of quantify-scheduler.
Module Contents
Classes
Datastructure specifying the structure of a simple compiler pass config. |
|
Information required to compile an individual operation to the quantum-device layer. |
|
Information required to compile a schedule to the quantum-device layer. |
|
Latency correction in seconds for a port-clock combination. |
|
Distortion correction information for a port-clock combination. |
|
Modulation frequencies for a port-clock combination. |
|
Datastructure containing the hardware options for each port-clock combination. |
|
Connectivity between the control hardware and port-clock combinations. |
|
Base class for a compilation config. |
|
A node representing a compiler pass. |
|
A node representing a single compilation pass. |
|
A compiler for quantify |
|
A compiler that executes compilation passes sequentially. |
|
A compilation config for a simple serial compiler. |
- exception CompilationError[source]
Bases:
RuntimeError
Custom exception class for failures in compilation of quantify schedules.
Initialize self. See help(type(self)) for accurate signature.
- class SimpleNodeConfig[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Datastructure specifying the structure of a simple compiler pass config.
See also
SimpleNode
.- compilation_func: Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule][source]
The function to perform the compilation pass as an importable string (e.g., “package_name.my_module.function_name”).
- _import_compilation_func_if_str(fun: Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule]) Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule] [source]
- class OperationCompilationConfig[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Information required to compile an individual operation to the quantum-device layer.
From a point of view of Compilation this information is needed to convert an operation defined on a quantum-circuit layer to an operation defined on a quantum-device layer.
- factory_func: Callable[Ellipsis, quantify_scheduler.operations.operation.Operation][source]
A callable designating a factory function used to create the representation of the operation at the quantum-device level.
- factory_kwargs: Dict[str, Any][source]
A dictionary containing the keyword arguments and corresponding values to use when creating the operation by evaluating the factory function.
- gate_info_factory_kwargs: Optional[List[str]][source]
A list of keyword arguments of the factory function for which the value must be retrieved from the gate_info of the operation.
- _import_factory_func_if_str(fun: Union[str, Callable[Ellipsis, quantify_scheduler.operations.operation.Operation]]) Callable[Ellipsis, quantify_scheduler.operations.operation.Operation] [source]
- class DeviceCompilationConfig[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Information required to compile a schedule to the quantum-device layer.
From a point of view of Compilation this information is needed to convert a schedule defined on a quantum-circuit layer to a schedule defined on a quantum-device layer.
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.import pprint from quantify_scheduler.backends.graph_compilation import ( DeviceCompilationConfig ) from quantify_scheduler.schemas.examples.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=<function compile_circuit_to_device at 0x7fe350c06a60>, clocks={'q0.01': 6020000000.0, 'q0.ro': 7040000000.0, 'q1.01': 5020000000.0, 'q1.ro': 6900000000.0}, elements={'q0': {'reset': OperationCompilationConfig(factory_func=<class 'quantify_scheduler.operations.pulse_library.IdlePulse'>, factory_kwargs={'duration': 0.0002}, gate_info_factory_kwargs=None), 'Rxy': OperationCompilationConfig(factory_func=<function rxy_drag_pulse at 0x7fe350b66310>, 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=<class '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=<function dispersive_measurement at 0x7fe347f0a160>, 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=<class 'quantify_scheduler.operations.pulse_library.IdlePulse'>, factory_kwargs={'duration': 0.0002}, gate_info_factory_kwargs=None), 'Rxy': OperationCompilationConfig(factory_func=<function rxy_drag_pulse at 0x7fe350b66310>, 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=<function dispersive_measurement at 0x7fe347f0a160>, 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=<function composite_square_pulse at 0x7fe347f07310>, 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)}})
- backend: Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule][source]
A . separated string specifying the location of the compilation backend this configuration is intended for e.g.,
"quantify_scheduler.backends.circuit_to_device.compile_circuit_to_device"
.
- clocks: Dict[str, float][source]
A dictionary specifying the clock frequencies available on the device e.g.,
{"q0.01": 6.123e9}
.
- elements: Dict[str, Dict[str, OperationCompilationConfig]][source]
A dictionary specifying the elements on the device, what operations can be applied to them and how to compile these.
- edges: Dict[str, Dict[str, OperationCompilationConfig]][source]
A dictionary specifying the edges, links between elements on the device to which operations can be applied, and the operations that can be applied to them and how to compile these.
- _import_backend_if_str(fun: Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule]) Callable[[quantify_scheduler.schedules.schedule.Schedule, Any], quantify_scheduler.schedules.schedule.Schedule] [source]
- class LatencyCorrection[source]
Bases:
float
Latency correction in seconds for a port-clock combination.
Positive values delay the operations on the corresponding port-clock combination, while negative values shift the operation backwards in time with respect to other operations in the schedule.
Note
If the port-clock combination of a signal is not specified in the corrections, it is set to zero in compilation. The minimum correction over all port-clock combinations is then subtracted to allow for negative latency corrections and to ensure minimal wait time (see
determine_relative_latency_corrections()
).Example
Let’s say we have specified two latency corrections in the CompilationConfig:
compilation_config.latency_corrections = { "q0:res-q0.ro": LatencyCorrection(-20e-9), "q0:mw-q0.01": LatencyCorrection(120e9), }
In this case, all operations on port
"q0:mw"
and clock"q0.01"
will be delayed by 140 ns with respect to operations on port"q0:res"
and clock"q0.ro"
.Initialize self. See help(type(self)) for accurate signature.
- class DistortionCorrection[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Distortion correction information for a port-clock combination.
- kwargs: Dict[str, Union[List, numpy.typing.NDArray]][source]
The keyword arguments that are passed to the filter_func.
- clipping_values: Optional[List][source]
The optional boundaries to which the corrected pulses will be clipped, upon exceeding.
Example
compilation_config.distortion_corrections = { "q0:fl-cl0.baseband": DistortionCorrection( filter_func = "scipy.signal.lfilter", input_var_name = "x", kwargs = { "b": [0, 0.25, 0.5], "a": [1] }, clipping_values = [-2.5, 2.5] ) }
- class ModulationFrequencies[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Modulation frequencies for a port-clock combination.
Example
compilation_config.modulation_frequencies = { "q0:res-q0.ro": ModulationFrequencies( interm_freq = None, lo_freq = 6e9, ) }
- class HardwareOptions[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Datastructure containing the hardware options for each port-clock combination.
Examples
Here, the HardwareOptions datastructure is created by parsing a dictionary containing the relevant information.
import pprint from quantify_scheduler.backends.graph_compilation import ( HardwareOptions ) from quantify_scheduler.schemas.examples.utils import ( load_json_example_scheme )
Example for the Qblox backend:
qblox_hw_options_dict=load_json_example_scheme("qblox_hardware_options.json") pprint.pprint(qblox_hw_options_dict)
{'distortion_corrections': {'q0:fl-cl0.baseband': {'clipping_values': [-2.5, 2.5], 'filter_func': 'scipy.signal.lfilter', 'input_var_name': 'x', 'kwargs': {'a': [1], 'b': [0, 0.25, 0.5]}}}, 'latency_corrections': {'q4:mw-q4.01': 8e-09, 'q5:mw-q5.01': 4e-09}, 'mixer_corrections': {'q4:mw-q4.01': {'amp_ratio': 0.9999, 'phase_error': -4.2}, 'q4:res-q4.ro': {'amp_ratio': 0.9997, 'dc_offset_i': -0.054, 'dc_offset_q': -0.034, 'phase_error': -4.0}}, 'modulation_frequencies': {'q0:mw-q0.01': {'interm_freq': 50000000.0, 'lo_freq': None}, 'q0:res-q0.ro': {'interm_freq': None, 'lo_freq': 7800000000.0}, 'q4:mw-q4.01': {'interm_freq': 200000000.0, 'lo_freq': None}, 'q4:res-q4.ro': {'interm_freq': None, 'lo_freq': 7200000000.0}, 'q5:mw-q5.01': {'interm_freq': 50000000.0, 'lo_freq': None}, 'q5:res-q5.ro': {'interm_freq': 50000000.0}, 'q6:mw-q6.01': {'lo_freq': 5000000000.0}}, 'power_scaling': {'q0:mw-q0.01': {'output_att': 4}, 'q0:res-q0.ro': {'output_att': 12}, 'q4:res-q4.ro': {'input_gain': [2, 3]}, 'q5:mw-q5.01': {'output_att': 4}, 'q5:res-q5.ro': {'input_att': 10}, 'q6:mw-q6.01': {'output_att': 6}}}
The dictionary can be parsed using the
parse_obj
method.qblox_hw_options = HardwareOptions.parse_obj(qblox_hw_options_dict) qblox_hw_options
HardwareOptions(latency_corrections={'q4:mw-q4.01': 8e-09, 'q5:mw-q5.01': 4e-09}, distortion_corrections={'q0:fl-cl0.baseband': DistortionCorrection(filter_func='scipy.signal.lfilter', input_var_name='x', kwargs={'b': [0, 0.25, 0.5], 'a': [1]}, clipping_values=[-2.5, 2.5])}, modulation_frequencies={'q0:res-q0.ro': ModulationFrequencies(interm_freq=None, lo_freq=7800000000.0), 'q0:mw-q0.01': ModulationFrequencies(interm_freq=50000000.0, lo_freq=None), 'q4:mw-q4.01': ModulationFrequencies(interm_freq=200000000.0, lo_freq=None), 'q4:res-q4.ro': ModulationFrequencies(interm_freq=None, lo_freq=7200000000.0), 'q5:mw-q5.01': ModulationFrequencies(interm_freq=50000000.0, lo_freq=None), 'q5:res-q5.ro': ModulationFrequencies(interm_freq=50000000.0, lo_freq=None), 'q6:mw-q6.01': ModulationFrequencies(interm_freq=None, lo_freq=5000000000.0)}, mixer_corrections={'q4:mw-q4.01': MixerCorrections(dc_offset_i=None, dc_offset_q=None, amp_ratio=0.9999, phase_error=-4.2), 'q4:res-q4.ro': MixerCorrections(dc_offset_i=-0.054, dc_offset_q=-0.034, amp_ratio=0.9997, phase_error=-4.0)}, power_scaling={'q0:mw-q0.01': PowerScaling(input_gain=None, output_gain=None, input_att=None, output_att=4.0), 'q0:res-q0.ro': PowerScaling(input_gain=None, output_gain=None, input_att=None, output_att=12.0), 'q4:res-q4.ro': PowerScaling(input_gain=(2.0, 3.0), output_gain=None, input_att=None, output_att=None), 'q5:mw-q5.01': PowerScaling(input_gain=None, output_gain=None, input_att=None, output_att=4.0), 'q5:res-q5.ro': PowerScaling(input_gain=None, output_gain=None, input_att=10.0, output_att=None), 'q6:mw-q6.01': PowerScaling(input_gain=None, output_gain=None, input_att=None, output_att=6.0)})
For the Zurich Instruments backend:
zi_hw_options_dict=load_json_example_scheme("zhinst_hardware_options.json") pprint.pprint(zi_hw_options_dict) zi_hw_options = HardwareOptions.parse_obj(zi_hw_options_dict) zi_hw_options
{'distortion_corrections': {'q0:fl-cl0.baseband': {'clipping_values': [-2.5, 2.5], 'filter_func': 'scipy.signal.lfilter', 'input_var_name': 'x', 'kwargs': {'a': [1], 'b': [0, 0.25, 0.5]}}}, 'latency_corrections': {'q0:mw-q0.01': 9.5e-08, 'q0:res-q0.ro': -9.5e-08, 'q1:mw-q1.01': 9.5e-08, 'q1:res-q1.ro': -9.5e-08}, 'mixer_corrections': {'q0:mw-q0.01': {'amp_ratio': 0.95, 'dc_offset_i': -0.0542, 'dc_offset_q': -0.0328, 'phase_error': 0.07}, 'q1:mw-q1.01': {'amp_ratio': 0.95, 'dc_offset_i': 0.042, 'dc_offset_q': 0.028, 'phase_error': 0.07}, 'q2:mw-q2.01': {'amp_ratio': 0.95, 'dc_offset_i': 0.042, 'dc_offset_q': 0.028, 'phase_error': 0.07}, 'q3:mw-q3.01': {'amp_ratio': 0.95, 'dc_offset_i': 0.042, 'dc_offset_q': 0.028, 'phase_error': 0.07}}, 'modulation_frequencies': {'q0:mw-q0.01': {'interm_freq': -100000000.0, 'lo_freq': None}, 'q0:res-q0.ro': {'interm_freq': 200000000.0, 'lo_freq': None}, 'q1:mw-q1.01': {'interm_freq': -100000000.0, 'lo_freq': None}, 'q2:mw-q2.01': {'interm_freq': -100000000.0, 'lo_freq': None}, 'q3:mw-q3.01': {'interm_freq': -100000000.0, 'lo_freq': None}}, 'power_scaling': {'q0:mw-q0.01': {'output_gain': [1, 1]}, 'q1:mw-q1.01': {'output_gain': [1, 1]}, 'q2:mw-q2.01': {'output_gain': [1, 1]}, 'q3:mw-q3.01': {'output_gain': [1, 1]}}}
HardwareOptions(latency_corrections={'q0:mw-q0.01': 9.5e-08, 'q1:mw-q1.01': 9.5e-08, 'q0:res-q0.ro': -9.5e-08, 'q1:res-q1.ro': -9.5e-08}, distortion_corrections={'q0:fl-cl0.baseband': DistortionCorrection(filter_func='scipy.signal.lfilter', input_var_name='x', kwargs={'b': [0, 0.25, 0.5], 'a': [1]}, clipping_values=[-2.5, 2.5])}, modulation_frequencies={'q0:mw-q0.01': ModulationFrequencies(interm_freq=-100000000.0, lo_freq=None), 'q0:res-q0.ro': ModulationFrequencies(interm_freq=200000000.0, lo_freq=None), 'q1:mw-q1.01': ModulationFrequencies(interm_freq=-100000000.0, lo_freq=None), 'q2:mw-q2.01': ModulationFrequencies(interm_freq=-100000000.0, lo_freq=None), 'q3:mw-q3.01': ModulationFrequencies(interm_freq=-100000000.0, lo_freq=None)}, mixer_corrections={'q0:mw-q0.01': MixerCorrections(dc_offset_i=-0.0542, dc_offset_q=-0.0328, amp_ratio=0.95, phase_error=0.07), 'q1:mw-q1.01': MixerCorrections(dc_offset_i=0.042, dc_offset_q=0.028, amp_ratio=0.95, phase_error=0.07), 'q2:mw-q2.01': MixerCorrections(dc_offset_i=0.042, dc_offset_q=0.028, amp_ratio=0.95, phase_error=0.07), 'q3:mw-q3.01': MixerCorrections(dc_offset_i=0.042, dc_offset_q=0.028, amp_ratio=0.95, phase_error=0.07)}, power_scaling={'q0:mw-q0.01': PowerScaling(input_gain=None, output_gain=(1.0, 1.0), input_att=None, output_att=None), 'q1:mw-q1.01': PowerScaling(input_gain=None, output_gain=(1.0, 1.0), input_att=None, output_att=None), 'q2:mw-q2.01': PowerScaling(input_gain=None, output_gain=(1.0, 1.0), input_att=None, output_att=None), 'q3:mw-q3.01': PowerScaling(input_gain=None, output_gain=(1.0, 1.0), input_att=None, output_att=None)})
- latency_corrections: Optional[Dict[str, LatencyCorrection]][source]
Dictionary containing the latency corrections (values) that should be applied to operations on a certain port-clock combination (keys).
- distortion_corrections: Optional[Dict[str, DistortionCorrection]][source]
Dictionary containing the distortion corrections (values) that should be applied to waveforms on a certain port-clock combination (keys).
- modulation_frequencies: Optional[Dict[str, ModulationFrequencies]][source]
Dictionary containing the modulation frequencies (values) that should be used for signals on a certain port-clock combination (keys).
- class Connectivity[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Connectivity between the control hardware and port-clock combinations.
Describes how the instruments are connected to port-clock combinations on the quantum device.
- class CompilationConfig[source]
Bases:
quantify_scheduler.structure.model.DataStructure
Base class for a compilation config.
Subclassing is generally required to create useful compilation configs, here extra fields can be defined.
- version: str = 'v0.4'[source]
The version of the CompilationConfig to facilitate backwards compatibility.
- backend: Type[QuantifyCompiler][source]
A reference string to the QuantifyCompiler class used in the compilation.
- device_compilation_config: Optional[Union[DeviceCompilationConfig, Dict]][source]
The DeviceCompilationConfig used in the compilation from the quantum-circuit layer to the quantum-device layer.
- hardware_options: Optional[HardwareOptions][source]
The HardwareOptions used in the compilation from the quantum-device layer to the control-hardware layer.
- connectivity: Optional[Union[Connectivity, Dict]][source]
Datastructure representing how the port-clocks on the quantum device are connected to the control hardware.
- _import_backend_if_str(class_: Union[Type[QuantifyCompiler], str]) Type[QuantifyCompiler] [source]
- class CompilationNode(name: str)[source]
A node representing a compiler pass.
Initialize a node representing a compiler pass.
Note
To compile, the
compile()
method should be used.- Parameters
name – The name of the node. Should be unique if it is added to a (larger) compilation graph.
- abstract _compilation_func(schedule: Union[quantify_scheduler.schedules.schedule.Schedule, quantify_scheduler.structure.model.DataStructure], config: quantify_scheduler.structure.model.DataStructure) Union[quantify_scheduler.schedules.schedule.Schedule, quantify_scheduler.structure.model.DataStructure] [source]
Private compilation method of this CompilationNode.
It should be completely stateless whenever inheriting from the CompilationNode, this is the object that should be modified.
- compile(schedule: Union[quantify_scheduler.schedules.schedule.Schedule, quantify_scheduler.structure.model.DataStructure], config: quantify_scheduler.structure.model.DataStructure) Union[quantify_scheduler.schedules.schedule.Schedule, quantify_scheduler.structure.model.DataStructure] [source]
Execute a compilation pass.
This method takes a
Schedule
and returns a new (updated)Schedule
using the information provided in the config.
- class SimpleNode(name: str, compilation_func: Callable)[source]
Bases:
CompilationNode
A node representing a single compilation pass.
Initialize a node representing a single compilation pass.
Note
To compile, the
compile()
method should be used.- Parameters
name – The name of the node. Should be unique if it is added to a (larger) compilation graph.
compilation_func – A Callable that will be wrapped in this object. A compilation function should take the intermediate representation (commonly
Schedule
) and a config as inputs and returns a new (modified) intermediate representation.
- _compilation_func(schedule: quantify_scheduler.schedules.schedule.Schedule, config: Union[quantify_scheduler.structure.model.DataStructure, dict]) quantify_scheduler.schedules.schedule.Schedule [source]
Private compilation method of this CompilationNode.
It should be completely stateless whenever inheriting from the CompilationNode, this is the object that should be modified.
- class QuantifyCompiler(name, quantum_device: Optional[quantify_scheduler.device_under_test.quantum_device.QuantumDevice] = None)[source]
Bases:
CompilationNode
A compiler for quantify
Schedule
s.The compiler defines a directed acyclic graph containing
CompilationNode
s. In this graph, nodes represent modular compilation passes.Initialize a QuantifyCompiler for quantify
Schedule
s.- Parameters
name – name of the compiler instance
quantum_device – quantum_device from which a
CompilationConfig
will be generated if None is provided for the compile step
- property input_node[source]
Node designated as the default input for compilation.
If not specified will return None.
- property output_node[source]
Node designated as the default output for compilation.
If not specified will return None.
- compile(schedule: quantify_scheduler.schedules.schedule.Schedule, config: Optional[CompilationConfig] = None) quantify_scheduler.schedules.schedule.CompiledSchedule [source]
Compile a
Schedule
using the information provided in the config.- Parameters
schedule – the schedule to compile.
config – describing the information required to compile the schedule. If not specified, self.quantum_device will be used to generate the config.
- Returns
a compiled schedule containing the compiled instructions suitable for execution on a (hardware) backend.
- Return type
- abstract construct_graph(config: CompilationConfig)[source]
Construct the compilation graph based on a provided config.
- draw(ax: matplotlib.axes.Axes = None, figsize: Tuple[float, float] = (20, 10), **options) matplotlib.axes.Axes [source]
Draws the graph defined by this backend using matplotlib.
Will attempt to position the nodes using the “dot” algorithm for directed acyclic graphs from graphviz if available. See https://pygraphviz.github.io/documentation/stable/install.html for installation instructions of pygraphviz and graphviz.
If not available will use the Kamada Kawai positioning algorithm.
- Parameters
ax – Matplotlib axis to plot the figure on
figsize – Optional figure size, defaults to something slightly larger that fits the size of the nodes.
options – optional keyword arguments that are passed to
networkx.draw_networkx
.
- class SerialCompiler(name, quantum_device: Optional[quantify_scheduler.device_under_test.quantum_device.QuantumDevice] = None)[source]
Bases:
QuantifyCompiler
A compiler that executes compilation passes sequentially.
Initialize a QuantifyCompiler for quantify
Schedule
s.- Parameters
name – name of the compiler instance
quantum_device – quantum_device from which a
CompilationConfig
will be generated if None is provided for the compile step
- construct_graph(config: SerialCompilationConfig)[source]
Construct the compilation graph based on a provided config.
For a serial backend, it is just a list of compilation passes.
- _compilation_func(schedule: quantify_scheduler.schedules.schedule.Schedule, config: SerialCompilationConfig) quantify_scheduler.schedules.schedule.CompiledSchedule [source]
Compile a schedule using the backend and the information provided in the config.
- Parameters
schedule – The schedule to compile.
config – A dictionary containing the information needed to compile the schedule. Nodes in this compiler specify what key they need information from in this dictionary.
- class SerialCompilationConfig[source]
Bases:
CompilationConfig
A compilation config for a simple serial compiler.
Specifies compilation as a list of compilation passes.
- backend: Type[SerialCompiler][source]
- compilation_passes: List[SimpleNodeConfig][source]
- _import_backend_if_str(class_: Union[Type[SerialCompiler], str]) Type[SerialCompiler] [source]