QDMI v1.1.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_device_session_query_device_property 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_device_session_query_device_property function.
A similar macro is defined for other (fixed length) data types, for example, 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 QDMI_Site pairs. The pairs are flattened into a single list of QDMI_Site's.
The properties that are returned by QDMI_device_session_query_operation_property may depend on the actual site. The available QDMI_Operation's and QDMI_Site's, first, need to be retrieved through QDMI_device_session_query_device_property. With the handles for a QDMI_Operation and QDMI_Site, corresponding properties can be queried. The following example demonstrates how different properties of operations, for example, varying fidelities of two-qubit gates can be returned.
One crucial part of QDMI is that it allows submitting 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_device_session_create_device_job.
The function QDMI_device_job_set_parameter allows setting different parameters for the job, for example, the number of shots (QDMI_JOB_PARAMETER_SHOTSNUM).
After the job is set up, it can be submitted to the device. The following example shows a mock implementation of QDMI_device_job_submit.
For the full implementation of the example devices we refer to the respective source files in the QDMI repository, that is, device.cpp
for the C++ implementation and device.c
for the C implementation.