iqm.qdmi.serializers¶
Serialization of Qiskit circuits into the IQM JSON program format.
MQT Core loads qiskit_to_iqm_json() through the
mqt.core.qiskit.program_serializers entry point, so any QDMI backend over an
IQM device submits IQM JSON without naming this package.
Module Contents¶
- qiskit_to_iqm_json(circuit: QuantumCircuit, backend: QDMIBackend) str[source]¶
Serialize a Qiskit
QuantumCircuitinto IQM JSON.The IQM JSON format is a device-specific format that encodes quantum operations as JSON objects with site names, operation names, and arguments. Circuit metadata is preserved using Python’s JSON encoding (including tuples as arrays), with string object keys and finite numbers required at every level. Metadata that cannot be encoded is dropped with a warning; the circuit and its metadata are not modified.
Measurements must be terminal and write each classical bit exactly once. Each qubit may be measured once. Measurements are emitted in classical-bit order so counts and memory use the circuit’s register layout. Barriers in the readout suffix are emitted before the measurements.
Qiskit initializes untouched classical bits to zero, but the IQM JSON result path does not reconstruct those slots. When using
measure_all(), create the circuit without preallocated classical bits, as in the example below.Note
The serialization currently supports only operations that are natively supported by the IQM hardware. Unsupported operations will raise
UnsupportedOperationError.- Parameters:
circuit – The Qiskit quantum circuit to serialize.
backend – The backend that runs the circuit. Its device provides the site names the format uses as loci. For
IQMBackend, circuit indices follow the calibrated target’s site order.
- Returns:
JSON string representation of the circuit in IQM format.
- Raises:
UnsupportedOperationError – If the circuit contains operations not supported by IQM hardware.
TranslationError – If the serialization fails.
Examples
>>> from qiskit import QuantumCircuit >>> import numpy as np >>> from iqm.qdmi.serializers import qiskit_to_iqm_json >>> qc = QuantumCircuit(2) >>> qc.r(np.pi / 2, 0, 0) >>> qc.cz(0, 1) >>> qc.measure_all() >>> json_str = qiskit_to_iqm_json(qc, backend)