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.
- class Job¶
A job represents a submitted quantum program execution.
- 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.
- 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 program_format: ProgramFormat¶
The format of the submitted program.
- class ProgramFormat¶
Bases:
enum.EnumEnumeration 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.EnumEnumeration of device status.
- OFFLINE = 0¶
- IDLE = 1¶
- BUSY = 2¶
- ERROR = 3¶
- MAINTENANCE = 4¶
- CALIBRATION = 5¶
- regular_sites() list[Site]¶
Returns the list of regular sites (without zone sites) available on the device.
- coupling_map() list[tuple[Site, Site]] | None¶
Returns the coupling map of the device as a list of site pairs.
- 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.
- class Site¶
A site represents a potential qubit location on a quantum device.
- 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.
- site_pairs() list[tuple[Device, Device]] | None¶
Returns the list of site pairs the local 2-qubit operation can be performed on.
- 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:
- 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)