QiskitRuntimeBackend#

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

This class instantiates a VirtualBackend using a Qiskit Runtime backend. This allows easy access to Qiskit Runtime backends through the qrisp interface. It is imporant to close the session after the execution of the algorithm (as reported in the example below).

Parameters:
api_tokenstr

The token is necessary to create correctly the Qiskit Runtime service and be able to run algorithms on their backends.

backendstr, optional

A string associated to the name of a Qiskit Runtime backend. By default, the least busy available backend is selected.

channelstr, optional

The channel type. Available are ibm_cloud or ibm_quantum_platform. The default is ibm_cloud.

modestr, optional

The execution mode. Available are job and session. The default is job.

Attributes:
sessionSession

The Qiskit Runtime session.

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() # Use only 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()

Method to call in order to close the session started by the init method.