IQMBackend#

IQMBackend(api_token, device_instance=None, server_url=None, compilation_options=None, transpiler=None)[source]#

This function creates a BatchedBackend for executing circuits on IQM hardware.

Parameters:
api_tokenstr

An API token retrieved from the IQM Resonance website or IQM backend.

device_instancestr

The device instance of the IQM backend such as garnet. For an up-to-date list, see the IQM Resonance website. Required if server_url is not provided.

server_urlstr, optional

The server URL of the IQM backend. If not provided, it defaults to IQM resonance using the device_instance. If a server URL is provided, a device instance should not be provided.

compilation_options: CircuitCompilationOptions

An object to specify several options regarding pulse-level compilation.

transpilercallable, optional

A function receiving and returning a QuantumCircuit, mapping the given circuit to a hardware friendly circuit. By default the transpile_to_iqm function will be used.

Examples

We evaluate a QuantumFloat multiplication on the 20-qubit IQM Garnet.

>>> from qrisp.interface import IQMBackend
>>> qrisp_garnet = IQMBackend(api_token = "YOUR_IQM_RESONANCE_TOKEN", device_instance = "garnet")
>>> from qrisp import QuantumFloat
>>> a = QuantumFloat(2)
>>> a[:] = 2
>>> b = a*a
>>> b.get_measurement(backend = qrisp_garnet, shots = 1000)
{4: 0.548,
 5: 0.082,
 0: 0.063,
 6: 0.042,
 8: 0.031,
 2: 0.029,
 12: 0.014,
 10: 0.03,
 1: 0.027,
 7: 0.025,
 15: 0.023,
 9: 0.021,
 14: 0.021,
 13: 0.018,
 11: 0.014,
 3: 0.012}

Manual qubit selection and routing

In the next example we showcase how to prevent automatic selection of qubits. For this we overide the transpilation procedure. The default transpilation calls the transpile_to_IQM function, which performs routing, automatic selection of suitable qubits, basis-gate transformation and other optimizations.

For our example we will just transform to the required basis gates and ensure manually that our circuit has the correct connectivity.

from qrisp import QuantumCircuit

# The custom transpiler should receive and return a QuantumCircuit
def custom_transpiler(qc: QuantumCircuit) -> QuantumCircuit:
    return qc.transpile(basis_gates = ["cz", "r", "measure", "reset"])

custom_transpiled_garnet = IQMBackend("YOUR_IQM_RESONANCE_TOKEN", 
                           device_instance = "garnet",
                           transpiler = custom_transpiler)

# Create a bell state
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure(0)

# execute
meas_res = qc.run(shots = 10000, backend = custom_transpiled_garnet)