mqt.core.qdmi

QDMI entities and access to MQT Core’s QDMI driver.

Submodules

Package Contents

class Job

A job represents a submitted quantum program execution.

check() Status

Returns the current status of the job.

wait(timeout: int = 0) bool

Waits for the job to complete.

Parameters:

timeout – The maximum time to wait in seconds. If 0, waits indefinitely.

Returns:

True if the job completed within the timeout, False otherwise.

cancel() None

Cancels the job.

get_shots() list[str]

Returns the raw shot results from the job.

get_counts() dict[str, int]

Returns the measurement counts from the job.

get_dense_statevector() list[complex]

Returns the dense statevector from the job (typically only available from simulator devices).

get_dense_probabilities() list[float]

Returns the dense probabilities from the job (typically only available from simulator devices).

get_sparse_statevector() dict[str, complex]

Returns the sparse statevector from the job (typically only available from simulator devices).

get_sparse_probabilities() dict[str, float]

Returns the sparse probabilities from the job (typically only available from simulator devices).

query_custom_property(custom_property: CustomProperty, value_type: type[str]) str | None
query_custom_property(custom_property: CustomProperty, value_type: type[bool]) bool | None
query_custom_property(custom_property: CustomProperty, value_type: type[int]) int | None
query_custom_property(custom_property: CustomProperty, value_type: type[float]) float | None
query_custom_property(custom_property: CustomProperty, value_type: type[bytes]) bytes | None
query_custom_property(custom_property: CustomProperty, value_type: type[str | bool | int | float | bytes]) str | bool | int | float | bytes | None

Query an implementation-defined custom job property.

The caller must provide the type documented by the device implementation. Use bytes to retrieve the value without interpretation. Returns None when the custom slot is unsupported.

get_custom_result(custom_property: CustomProperty, value_type: type[str]) str | None
get_custom_result(custom_property: CustomProperty, value_type: type[bool]) bool | None
get_custom_result(custom_property: CustomProperty, value_type: type[int]) int | None
get_custom_result(custom_property: CustomProperty, value_type: type[float]) float | None
get_custom_result(custom_property: CustomProperty, value_type: type[bytes]) bytes | None
get_custom_result(custom_property: CustomProperty, value_type: type[str | bool | int | float | bytes]) str | bool | int | float | bytes | None

Return an implementation-defined custom job result.

The caller must provide the type documented by the device implementation. Use bytes to retrieve the value without interpretation. Returns None when the custom slot is unsupported.

property id: str

The job ID.

property program_format: ProgramFormat

The format of the submitted program.

property program: str

The submitted program.

property program_bytes: bytes

The exact bytes of the submitted program.

property num_shots: int

The number of shots.

property queue_position: int | None

The number of jobs ahead in the queue, or None if unavailable or not applicable in the current state.

__eq__(arg: object, /) bool
__ne__(arg: object, /) bool
class Status

Bases: enum.Enum

Enumeration of job status.

CREATED = 0
SUBMITTED = 1
QUEUED = 2
RUNNING = 3
DONE = 4
CANCELED = 5
FAILED = 6
class ProgramFormat

Bases: enum.Enum

Enumeration of program formats.

QASM2 = 0
QASM3 = 1
QIR_BASE_STRING = 2
QIR_BASE_MODULE = 3
QIR_ADAPTIVE_STRING = 4
QIR_ADAPTIVE_MODULE = 5
CALIBRATION = 6
QPY = 7
IQM_JSON = 8
BATCH_JOB = 9
CUSTOM1 = 999999995
CUSTOM2 = 999999996
CUSTOM3 = 999999997
CUSTOM4 = 999999998
CUSTOM5 = 999999999
class CustomProperty

Bases: enum.Enum

An implementation-defined custom property or result slot.

CUSTOM1 = 1
CUSTOM2 = 2
CUSTOM3 = 3
CUSTOM4 = 4
CUSTOM5 = 5
class Device

A device represents a quantum device with its properties and capabilities.

class Status

Bases: enum.Enum

Enumeration of device status.

OFFLINE = 0
IDLE = 1
BUSY = 2
ERROR = 3
MAINTENANCE = 4
CALIBRATION = 5
name() str

Returns the name of the device.

version() str

Returns the version of the device.

status() Status

Returns the current status of the device.

library_version() str

Returns the version of the library used to define the device.

qubits_num() int

Returns the number of qubits available on the device.

sites() list[Site]

Returns the list of all sites (zone and regular sites) available on the device.

regular_sites() list[Site]

Returns the list of regular sites (without zone sites) available on the device.

zones() list[Site]

Returns the list of zone sites (without regular sites) available on the device.

operations() list[Operation]

Returns the list of operations supported by the device.

coupling_map() list[tuple[Site, Site]] | None

Returns the coupling map of the device as a list of site pairs.

needs_calibration() int | None

Returns whether the device needs calibration.

queue_length() int | None

Returns the current queue length, or None if unavailable.

length_unit() str | None

Returns the unit of length used by the device.

length_scale_factor() float | None

Returns the scale factor for length used by the device.

duration_unit() str | None

Returns the unit of duration used by the device.

duration_scale_factor() float | None

Returns the scale factor for duration used by the device.

min_atom_distance() int | None

Returns the minimum atom distance on the device.

supported_program_formats() list[ProgramFormat]

Returns the list of program formats supported by the device.

child_devices() list[Device]

Returns the direct child devices managed by this device.

query_custom_operations(custom_property: CustomProperty) list[Operation] | None

Query a custom device property that contains operation handles.

Returns normal Device.Operation objects, or None when the custom slot is unsupported. A supported empty list is returned as an empty list.

query_custom_property(custom_property: CustomProperty, value_type: type[str]) str | None
query_custom_property(custom_property: CustomProperty, value_type: type[bool]) bool | None
query_custom_property(custom_property: CustomProperty, value_type: type[int]) int | None
query_custom_property(custom_property: CustomProperty, value_type: type[float]) float | None
query_custom_property(custom_property: CustomProperty, value_type: type[bytes]) bytes | None
query_custom_property(custom_property: CustomProperty, value_type: type[str | bool | int | float | bytes]) str | bool | int | float | bytes | None

Query an implementation-defined custom device property.

The caller must provide the type documented by the device implementation. Use bytes to retrieve the value without interpretation. Returns None when the custom slot is unsupported.

submit_job(program: str, program_format: ProgramFormat, num_shots: int, *, custom1: str | bool | float | None = None, custom2: str | bool | float | None = None, custom3: str | bool | float | None = None, custom4: str | bool | float | None = None, custom5: str | bool | float | None = None) Job
submit_job(program: bytes, program_format: ProgramFormat, num_shots: int, *, custom1: str | bool | float | None = None, custom2: str | bool | float | None = None, custom3: str | bool | float | None = None, custom4: str | bool | float | None = None, custom5: str | bool | float | None = None) Job

Submits an exact byte payload to the device.

submit_calibration_job(program: str | bytes | None = None, *, custom1: str | bool | float | None = None, custom2: str | bool | float | None = None, custom3: str | bool | float | None = None, custom4: str | bool | float | None = None, custom5: str | bool | float | None = None) Job

Triggers a calibration run on the device.

QDMI does not require a program for a calibration run, so program is optional and may be a string or bytes. When it is given, the device defines what it means, which is usually a configuration for the run. A calibration run executes no circuit, so it takes no shot count.

retrieve_job_by_id(job_id: str) Job

Retrieves an existing job by its device-provided ID.

__eq__(arg: object, /) bool
__ne__(arg: object, /) bool
class Site

A site represents a potential qubit location on a quantum device.

index() int

Returns the index of the site.

t1() int | None

Returns the T1 coherence time of the site.

t2() int | None

Returns the T2 coherence time of the site.

name() str | None

Returns the name of the site.

x_coordinate() int | None

Returns the x coordinate of the site.

y_coordinate() int | None

Returns the y coordinate of the site.

z_coordinate() int | None

Returns the z coordinate of the site.

is_zone() bool

Returns whether the site is a zone.

x_extent() int | None

Returns the x extent of the site.

y_extent() int | None

Returns the y extent of the site.

z_extent() int | None

Returns the z extent of the site.

module_index() int | None

Returns the index of the module the site belongs to.

submodule_index() int | None

Returns the index of the submodule the site belongs to.

query_custom_property(custom_property: CustomProperty, value_type: type[str]) str | None
query_custom_property(custom_property: CustomProperty, value_type: type[bool]) bool | None
query_custom_property(custom_property: CustomProperty, value_type: type[int]) int | None
query_custom_property(custom_property: CustomProperty, value_type: type[float]) float | None
query_custom_property(custom_property: CustomProperty, value_type: type[bytes]) bytes | None
query_custom_property(custom_property: CustomProperty, value_type: type[str | bool | int | float | bytes]) str | bool | int | float | bytes | None

Query an implementation-defined custom site property.

The caller must provide the type documented by the device implementation. Use bytes to retrieve the value without interpretation. Returns None when the custom slot is unsupported.

__eq__(arg: object, /) bool
__ne__(arg: object, /) bool
class Operation

An operation represents a quantum operation that can be performed on a quantum device.

name(sites: Sequence[Device] = ..., params: Sequence[float] = ...) str

Returns the name of the operation.

qubits_num(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None

Returns the number of qubits the operation acts on.

parameters_num(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int

Returns the number of parameters the operation has.

duration(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None

Returns the duration of the operation.

fidelity(sites: Sequence[Device] = ..., params: Sequence[float] = ...) float | None

Returns the fidelity of the operation.

interaction_radius(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None

Returns the interaction radius of the operation.

blocking_radius(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None

Returns the blocking radius of the operation.

idling_fidelity(sites: Sequence[Device] = ..., params: Sequence[float] = ...) float | None

Returns the idling fidelity of the operation.

is_zoned() bool

Returns whether the operation is zoned.

sites() list[Device] | None

Returns the list of sites the operation can be performed on.

site_pairs() list[tuple[Device, Device]] | None

Returns the list of site pairs the local 2-qubit operation can be performed on.

mean_shuttling_speed(sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None

Returns the mean shuttling speed of the operation.

query_custom_property(custom_property: CustomProperty, value_type: type[str], sites: Sequence[Device] = ..., params: Sequence[float] = ...) str | None
query_custom_property(custom_property: CustomProperty, value_type: type[bool], sites: Sequence[Device] = ..., params: Sequence[float] = ...) bool | None
query_custom_property(custom_property: CustomProperty, value_type: type[int], sites: Sequence[Device] = ..., params: Sequence[float] = ...) int | None
query_custom_property(custom_property: CustomProperty, value_type: type[float], sites: Sequence[Device] = ..., params: Sequence[float] = ...) float | None
query_custom_property(custom_property: CustomProperty, value_type: type[bytes], sites: Sequence[Device] = ..., params: Sequence[float] = ...) bytes | None
query_custom_property(custom_property: CustomProperty, value_type: type[str | bool | int | float | bytes], sites: Sequence[Device] = ..., params: Sequence[float] = ...) str | bool | int | float | bytes | None

Query an implementation-defined custom operation property.

The caller must provide the type documented by the device implementation. Use bytes to retrieve the value without interpretation. Returns None when the custom slot is unsupported.

__eq__(arg: object, /) bool
__ne__(arg: object, /) bool