Qiskit Runtime program architecture¶
A Qiskit Runtime program is a Python file/object that is built using a Qiskit-like main framework. This quantum program can generate quantum circuits, and has the capability to execute classical computation if necessary.
Qiskit Runtime program template¶
"""Runtime program template. The ``main()`` method is the entry point of a runtime program. It takes a :class:`ProgramBackend` and a :class:`UserMessenger` that can be used to send circuits to the backend and messages to the user, respectively. """ from qiskit.providers.ibmq.runtime import UserMessenger, ProgramBackend def program(backend: ProgramBackend, user_messenger: UserMessenger, **kwargs): """Function that does classical-quantum calculation.""" # UserMessenger can be used to publish interim results. user_messenger.publish("This is an interim result.") return "final result" def main(backend: ProgramBackend, user_messenger: UserMessenger, **kwargs): """This is the main entry point of a runtime program. The name of this method must not change. It also must have ``backend`` and ``user_messenger`` as the first two positional arguments. Args: backend: Backend for the circuits to run on. user_messenger: Used to communicate with the program user. kwargs: User inputs. """ # Massage the input if necessary. result = program(backend, user_messenger, **kwargs) # UserMessenger can be used to publish final results. user_messenger.publish(result, final=True)
This initial release of Qiskit Runtime uses Qiskit version
0.26.0, Terra version
0.17.3, and IBM Quantum Provider version
Qiskit Runtime on Github¶
Visit the Github repository at this link.
IBM Quantum Provider API documentation¶
See the API documentation for Qiskit Runtime in the IBM Quantum Provider at this link.
Public REST API¶
You can also implement Qiskit Runtime by using the public REST API.