| title | Migrate from backend.run to Qiskit Runtime primitives |
|---|---|
| description | Migrate from using backend.run to using Qiskit Runtime primitives (qiskit-ibm-runtime) |
| in_page_toc_max_heading_level | 2 |
This guide is no longer maintained. It is archived in GitHub for historical reference only.
This guide describes key patterns of behavior and use cases with code
examples to help you migrate code from the legacy backend.run interface to use the Qiskit Runtime primitives interface (qiskit-ibm-runtime package).
The qiskit-ibm-runtime package provides cloud access to the IBM® quantum processing units (QPUs) through the primitives interface. The backend.run interface coexisted with the original (V1) primitives model as the dedicated “direct hardware access” entry point. With the introduction of the V2 primitives interface, the new SamplerV2 class fulfills that role. Consequentially, backend.run and qiskit-ibm-provider, which only exposed the backend.run interface, are no longer supported.
The Qiskit Runtime primitives implement the reference Sampler V2 and Estimator V2 interfaces found in qiskit.primitives, and enable capabilities not available with the legacy backend.run interface. These capabilities include application of advanced processing techniques for error suppression and mitigation in Estimator, the ability to efficiently sweep between arrays of parameter value sets or observables in both Sampler and Estimator, and access to the new local testing mode. Additionally, Qiskit Runtime lets users run iterative algorithm circuits back to back (session mode) or in collections of circuits without having to re-queue each job (batch mode). This results in more efficient quantum processor use and reduces the time spent running complex computations.
The backend.run interface was the primary access point to quantum hardware and simulators offered by IBM, as well as third-party providers that integrate with Qiskit. The evolution of user access patterns for quantum processing units (QPUs) led to the Qiskit primitives (Sampler and Estimator) superseding this interface.
For backward compatibility, the backend.run interface continues to exist in Qiskit. However, it is no longer supported
in Qiskit Runtime after the deprecation period, as most IBM Quantum® users have migrated to V2 primitives due to their improved
usability and efficiency.
When migrating, the key to writing an equivalent algorithm using primitives is to first identify what minimal unit of information your algorithm is based on:
-
If it uses an expectation value of a certain observable with respect to a quantum state (a real number), you will now use Estimator.
An expectation value of an observable could be the target quantity in scenarios where knowing a quantum state is not relevant. This often occurs in optimization problems or chemistry applications. For example, when trying to discover the extremal energy of a system.
-
If it uses a probability distribution from sampling the device, you will now use Sampler.
A probability distribution is often of interest in optimization problems that return a classical bit string, encoding a certain solution to a problem at hand. In these cases, you might be interested in finding a bit string that corresponds to a ket value with the largest probability of being measured from a quantum state, for example.
Follow the steps in the appropriate topic to change your import options and other setup information:
See these topics for instructions if you are using qiskit-ibm-runtime:
- Update code that performs circuit sampling
- Update code that calculates expectation values
- Common use cases (basic, parameterized, and dynamic circuits)
- Replace any
backend.runoptions withqiskit_ibm_runtimeoptions:- Migrate options
- Common use cases Options section
See the following topic for instructions if you are using a third-party provider that only exposes backend.run:
The following migration guides can help users with the following tasks:
- [Get started with Estimator](/docs/guides/get-started-with-primitives#start-estimator) - [Get started with Sampler](/docs/guides/get-started-with-primitives#start-sampler) - Explore [execution modes](/docs/guides/execution-modes) - [Run a primitive in a session](/docs/guides/run-jobs-session) - [Run a primitive in a batch](/docs/guides/run-jobs-batch) - Experiment with the [Compare transpiler settings tutorial](/docs/tutorials/circuit-transpilation-settings#compare-transpiler-settings)