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 QuantumCircuit into 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.

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.

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, 2)
>>> qc.r(np.pi / 2, 0, 0)
>>> qc.cz(0, 1)
>>> qc.measure_all()
>>> json_str = qiskit_to_iqm_json(qc, backend)