qiskit.providers.ibmq.AccountProvider
class AccountProvider(credentials, access_token)
Provider for a single IBM Quantum Experience account.
The account provider class provides access to the IBM Quantum Experience services available to this account.
You can access a provider by enabling an account with the IBMQ.enable_account()
method, which returns the default provider you have access to:
from qiskit import IBMQ
provider = IBMQ.enable_account(<INSERT_IBM_QUANTUM_EXPERIENCE_TOKEN>)
To select a different provider, use the IBMQ.get_provider()
method and specify the hub, group, or project name of the desired provider.
Each provider may offer different services. The main service, IBMQBackendService
, is available to all providers and gives access to IBM Quantum Experience devices and simulators.
You can obtain an instance of a service using the service()
method or as an attribute of this AccountProvider
instance. For example:
backend_service = provider.service('backend')
backend_service = provider.service.backend
Since IBMQBackendService
is the main service, some of the backend-related methods are available through this class for convenience.
The backends()
method returns all the backends available to this account:
backends = provider.backends()
The get_backend()
method returns a backend that matches the filters passed as argument. An example of retrieving a backend that matches a specified name:
simulator_backend = provider.get_backend('ibmq_qasm_simulator')
It is also possible to use the backend
attribute to reference a backend. As an example, to retrieve the same backend from the example above:
simulator_backend = provider.backend.ibmq_qasm_simulator
The backend
attribute can be used to autocomplete the names of backends available to this provider. To autocomplete, press tab
after provider.backend.
. This feature may not be available if an error occurs during backend discovery. Also note that this feature is only available in interactive sessions, such as in Jupyter Notebook and the Python interpreter.
AccountProvider constructor.
Parameters
- credentials (
Credentials
) – IBM Quantum Experience credentials. - access_token (
str
) – IBM Quantum Experience access token.
__init__
__init__(credentials, access_token)
AccountProvider constructor.
Parameters
- credentials (
Credentials
) – IBM Quantum Experience credentials. - access_token (
str
) – IBM Quantum Experience access token.
Methods
__init__ (credentials, access_token) | AccountProvider constructor. |
backends ([name, filters]) | Return all backends accessible via this provider, subject to optional filtering. |
get_backend ([name]) | Return a single backend matching the specified filtering. |
service (name) | Return the specified service. |
services () | Return all available services. |
Attributes
backend | Return the backend service. |
experiment | Return the experiment service. |
random | Return the random number service. |
version |
backend
Return the backend service.
Return type
IBMQBackendService
Returns
The backend service instance.
backends
backends(name=None, filters=None, **kwargs)
Return all backends accessible via this provider, subject to optional filtering.
Parameters
-
name (
Optional
[str
]) – Backend name to filter by. -
filters (
Optional
[Callable
[[List
[IBMQBackend
]],bool
]]) –More complex filters, such as lambda functions. For example:
AccountProvider.backends(filters=lambda b: b.configuration().n_qubits > 5)
-
kwargs (
Any
) –Simple filters that specify a
True
/False
criteria in the backend configuration, backends status, or provider credentials. An example to get the operational backends with 5 qubits:AccountProvider.backends(n_qubits=5, operational=True)
Return type
List
[IBMQBackend
]
Returns
The list of available backends that match the filter.
experiment
Return the experiment service.
Return type
ExperimentService
Returns
The experiment service instance.
Raises
IBMQNotAuthorizedError – If the account is not authorized to use the experiment service.
get_backend
get_backend(name=None, **kwargs)
Return a single backend matching the specified filtering.
Parameters
- name (str) – name of the backend.
- **kwargs – dict used for filtering.
Returns
a backend matching the filtering.
Return type
Raises
QiskitBackendNotFoundError – if no backend could be found or more than one backend matches the filtering criteria.
random
Return the random number service.
Return type
IBMQRandomService
Returns
The random number service instance.
Raises
IBMQNotAuthorizedError – If the account is not authorized to use the service.
service
service(name)
Return the specified service.
Parameters
name (str
) – Name of the service.
Return type
Any
Returns
The specified service.
Raises
- IBMQInputValueError – If an unknown service name is specified.
- IBMQNotAuthorizedError – If the account is not authorized to use the service.
services
services()
Return all available services.
Return type
Dict
Returns
All services available to this provider.