QiskitRuntimeBackend#

class QiskitRuntimeBackend(api_token, backend=None, channel='ibm_cloud', mode='job', instance=None)[source]#

A Backend that wraps an IBM Quantum Runtime backend.

This allows easy access to IBM Quantum Runtime backends through the Qrisp backend interface. Circuits are transpiled and submitted through Qiskit’s SamplerV2 primitive, using either a direct job or a persistent session.

It is important to close the session after execution when using mode="session" (see close_session()).

Parameters:
api_tokenstr

IBM Cloud API token used to authenticate with the Qiskit Runtime service.

backendstr or None, optional

Name of the IBM Quantum backend. If None, the least-busy available backend is selected automatically.

channelstr, optional

Channel type for the Runtime service. Available: "ibm_cloud" or "ibm_quantum_platform". Defaults to "ibm_cloud".

modestr, optional

Execution mode. "job" submits each circuit batch as an independent job; "session" opens a persistent session for lower latency across multiple submissions. Defaults to "job".

instancestr or None, optional

The Cloud Resource Name (CRN) for IBM Cloud. Passed to QiskitRuntimeService. Defaults to None.

Attributes:
sessionSession

The Qiskit Runtime session. Only set when mode="session" is passed at construction time.

Examples

>>> from qrisp import QuantumFloat
>>> from qrisp.interface import QiskitRuntimeBackend
>>> example_backend = QiskitRuntimeBackend(api_token="YOUR_IBM_CLOUD_TOKEN", backend="ibm_brisbane", channel="ibm_cloud")
>>> qf = QuantumFloat(2)
>>> qf[:] = 2
>>> res = qf * qf
>>> result = res.get_measurement(backend=example_backend)
>>> print(result)
>>> # example_backend.close_session()  # Only needed when mode="session"
{4: 0.6133,
8: 0.1126,
0: 0.0838,
12: 0.0798,
5: 0.0272,
6: 0.016,
9: 0.0125,
1: 0.0117,
13: 0.0081,
14: 0.0073,
3: 0.0071,
2: 0.0062,
10: 0.0051,
7: 0.0044,
11: 0.0035,
15: 0.0014}

Methods#

QiskitRuntimeBackend.close_session()

Close the IBM Runtime session opened during construction.