Skip to main content
IBM Quantum Platform

Migrate from qiskit_ibmq_provider

Note

This documentation is relevant to the new IBM Quantum® Platform. If you need the previous version, return to the IBM Quantum Platform Classic documentation.

This topic describes how to migrate code from the legacy IBMQ provider qiskit-ibmq-provider package to use Qiskit Runtime qiskit-ibm-runtime.


Changes in Class name and location

The classes related to Qiskit Runtime that were included in qiskit-ibmq-provider are now part of qiskit-ibm-runtime. Previously, the provider populated the qiskit.providers.ibmq.runtime namespace with objects for Qiskit Runtime. These now live in the qiskit_ibm_runtime module.

The following table contains example access patterns in qiskit.providers.ibmq.runtime and their new form in qiskit_ibm_runtime:

Class in qiskit-ibmq-providerClass in qiskit-ibm-runtimeNotes
qiskit.providers.ibmq.runtime.IBMRuntimeServiceqiskit_ibm_runtime.QiskitRuntimeServiceIBMRuntimeService class was removed from qiskit-ibm-runtime 0.6 and replaced by the new class in qiskit-ibm-runtime.
qiskit.providers.ibmq.runtime.RuntimeEncoderqiskit_ibm_runtime.RuntimeEncoder
qiskit.providers.ibmq.runtime.RuntimeDecoderqiskit_ibm_runtime.RuntimeDecoder

The following classes were used for custom programs, which are no longer supported. Therefore, the classes are no longer supported:

  • qiskit.providers.ibmq.runtime.RuntimeProgram
  • qiskit.providers.ibmq.runtime.UserMessenger
  • qiskit.providers.ibmq.runtime.ProgramBackend
  • qiskit.providers.ibmq.runtime.ResultDecoder
  • qiskit.providers.ibmq.runtime.ParameterNamespace

Import path

The import path has changed as follows:

from qiskit_ibm_runtime import QiskitRuntimeService

Save accounts

Use the updated code to work save accounts.

For information on retrieving account credentials, see Set up your IBM Cloud account.

QiskitRuntimeService.save_account(channel="ibm_cloud", token="<API_TOKEN>", overwrite=True, set_as_default=True)

Additionally, you can now name your saved credentials and load the credentials by name.

# Save different accounts for open and premium access
 
QiskitRuntimeService.save_account(channel="ibm_cloud", token="<API_TOKEN>", instance="<CRN for premium>", name="premium")
QiskitRuntimeService.save_account(channel="ibm_cloud", token="<API_TOKEN>", instance="<CRN for open>", name="open")
 
# Load the "open" credentials
 
service = QiskitRuntimeService(name="open")

Instance selection (get a provider)

Use the updated code to select an instance.

The new syntax combines the functionality from load_account() and get_provider() in one statement. Use the instance keyword to specify your Cloud Resource Name (CRN).

# To access saved credentials for the IBM quantum channel and select an instance
service = QiskitRuntimeService(channel="ibm_cloud", instance="<CRN>")

Get a backend

Use the updated code to specify a backend.

# You can specify the instance in service.backend() instead of initializing a new service
backend = service.backend("ibm_backend", instance="h1/g1/p1")

If you don't know what backend you want to use, you can instead use code such as the following:

from qiskit_ibm_runtime import QiskitRuntimeService
 
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=<num_qubits>)

With Qiskit Runtime, you can also run in local testing mode.

# Define a local backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
backend = FakeManilaV2()
 
# You could use an Aer simulator instead by using the following code:
# from qiskit_aer import AerSimulator
# backend = AerSimulator()
Was this page helpful?
Report a bug or request content on GitHub.