QDMI v1.0.0
Quantum Device Management Interface
|
This page contains example implementations of devices and other components of the software stack that use QDMI. All examples distributed with QDMI are contained in the examples/
directory in the repository.
Below you find mock implementations of two QDMI devices: One is implemented in C++ and the other one in C.
Every device has to provide a name, its version, and the implemented QDMI library version through the query interface. The corresponding properties are
All of those properties are of type char*
(string). Since they are properties of the device, they are returned by the QDMI_query_device_property_dev function. Below you find the respective implementation in C++ and C.
Both implementations use an auxiliary macro to add the string properties to the device. For an explanation of the macro, see the next section Auxiliary Macros.
The following macro is used to add string properties to the device. The macro is used, e.g., in the implementation of the QDMI_query_device_property_dev function.
A similar macro is defined for other (fixed length) data types, e.g., int
, double
.
Another macro is defined for list properties of the data types above.
The usage of the two latter macros is demonstrated in the following sections.
The following two examples demonstrate how to return integer or enumeration properties of the device.
Some properties are returned as a list of various data types. The following example shows how to return the coupling map of the device as a list of pairs of QDMI_Site's. The pairs are flattened into a single list of QDMI_Site's.
The properties that are returned by QDMI_query_operation_property_dev may depend on the actual site. The available QDMI_Operation's and QDMI_Site's, first, need to be retrieved through QDMI_query_get_operations_dev and QDMI_query_get_sites_dev, respectively. Following is an example of how to implement the QDMI_query_get_sites_dev function.
With the handles for a QDMI_Operation and QDMI_Site, corresponding properties can be queried. The following example demonstrates how different properties of operations, e.g., varying fidelities of two-qubit gates can be returned.
One crucial part of QDMI is, that it allows to submit a job to the device for execution. The following example provides a mock implementation of the necessary functions to submit a job. The first example shows a mock implementation of QDMI_control_create_job_dev.
The function QDMI_control_set_parameter_dev allows to set different parameters for the job, e.g., the number of shots (QDMI_JOB_PARAMETER_SHOTS_NUM).
After the job is set up, it can be submitted to the device. The following example shows a mock implementation of QDMI_control_submit_job_dev.
For the full implementation of the example devices we refer to the respective source files in the QDMI repository, i.e., device.cpp
for the C++ implementation and device.c
for the C implementation.