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.

      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)


Qiskit Runtime uses the latest versions of Qiskit and the IBM Quantum Provider.

Other resources

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.


You can also implement Qiskit Runtime by using the public REST API.