mqt.core.fomac

Module Contents

class Session(*, token: str | None = None, auth_file: str | None = None, auth_url: str | None = None, username: str | None = None, password: str | None = None, project_id: str | None = None, custom1: str | None = None, custom2: str | None = None, custom3: str | None = None, custom4: str | None = None, custom5: str | None = None)

A FoMaC session for managing QDMI devices.

Allows creating isolated sessions with independent authentication settings. All authentication parameters are optional and can be provided as keyword arguments to the constructor.

get_devices() list[Device]

Get available devices from this session.

Returns:

List of available devices.

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).

property id: str

The job ID.

property program_format: ProgramFormat

The format of the submitted program.

property program: str

The submitted program.

property num_shots: int

The number of shots.

__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
CUSTOM1 = 999999995
CUSTOM2 = 999999996
CUSTOM3 = 999999997
CUSTOM4 = 999999998
CUSTOM5 = 999999999
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.

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.

submit_job(program: str, program_format: ProgramFormat, num_shots: int) Job

Submits a job to the device.

__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.

__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.

__eq__(arg: object, /) bool
__ne__(arg: object, /) bool
add_dynamic_device_library(library_path: str, prefix: str, *, base_url: str | None = None, token: str | None = None, auth_file: str | None = None, auth_url: str | None = None, username: str | None = None, password: str | None = None, custom1: str | None = None, custom2: str | None = None, custom3: str | None = None, custom4: str | None = None, custom5: str | None = None) Device

Load a dynamic device library into the QDMI driver.

This function loads a shared library (.so, .dll, or .dylib) that implements a QDMI device interface and makes it available for use in sessions.

Parameters:
  • library_path – Path to the shared library file to load.

  • prefix – Function prefix used by the library (e.g., “MY_DEVICE”).

  • base_url – Optional base URL for the device API endpoint.

  • token – Optional authentication token.

  • auth_file – Optional path to authentication file.

  • auth_url – Optional authentication server URL.

  • username – Optional username for authentication.

  • password – Optional password for authentication.

  • custom1 – Optional custom configuration parameter 1.

  • custom2 – Optional custom configuration parameter 2.

  • custom3 – Optional custom configuration parameter 3.

  • custom4 – Optional custom configuration parameter 4.

  • custom5 – Optional custom configuration parameter 5.

Returns:

The newly loaded device that can be used to create backends.

Return type:

Device

Raises:

RuntimeError – If library loading fails or configuration is invalid.

Examples

Load a device library with configuration:

>>> import mqt.core.fomac as fomac
>>> device = fomac.add_dynamic_device_library(
...     "/path/to/libmy_device.so", "MY_DEVICE", base_url="http://localhost:8080", custom1="API_V2"
... )

Now the device can be used directly:

>>> from mqt.core.plugins.qiskit import QDMIBackend
>>> backend = QDMIBackend(device=device)