Shortcuts

qiskit.providers.ibmq.IBMQBackend

class IBMQBackend(configuration, provider, credentials, api_client)[source]

Backend class interfacing with an IBM Quantum Experience device.

You can run experiments on a backend using the run() method after assembling them into the Qobj format. The run() method returns an IBMQJob instance that represents the submitted job. Each job has a unique job ID, which can later be used to retrieve the job. An example of this flow:

from qiskit import IBMQ, assemble, transpile
from qiskit.circuit.random import random_circuit

provider = IBMQ.load_account()
backend = provider.backends.ibmq_vigo
qx = random_circuit(n_qubits=5, depth=4)
qobj = assemble(transpile(qx, backend=backend), backend=backend)
job = backend.run(qobj)
retrieved_job = backend.retrieve_job(job.job_id())

Note

You should not instantiate the IBMQBackend class directly. Instead, use the methods provided by an AccountProvider instance to retrieve and handle backends.

Other methods return information about the backend. For example, the status() method returns a BackendStatus instance. The instance contains the operational and pending_jobs attributes, which state whether the backend is operational and also the number of jobs in the server queue for the backend, respectively:

status = backend.status()
is_operational = status.operational
jobs_in_queue = status.pending_jobs

It is also possible to see the number of remaining jobs you are able to submit to the backend with the job_limit() method, which returns a BackendJobLimit instance:

job_limit = backend.job_limit()

IBMQBackend constructor.

Parameters
  • configuration (Union[QasmBackendConfiguration, PulseBackendConfiguration]) – Backend configuration.

  • provider (AccountProvider) – IBM Quantum Experience account provider

  • credentials (Credentials) – IBM Quantum Experience credentials.

  • api_client (AccountClient) – IBM Quantum Experience client used to communicate with the server.

__init__(configuration, provider, credentials, api_client)[source]

IBMQBackend constructor.

Parameters
  • configuration (Union[QasmBackendConfiguration, PulseBackendConfiguration]) – Backend configuration.

  • provider (AccountProvider) – IBM Quantum Experience account provider

  • credentials (Credentials) – IBM Quantum Experience credentials.

  • api_client (AccountClient) – IBM Quantum Experience client used to communicate with the server.

Methods

__init__(configuration, provider, …)

IBMQBackend constructor.

active_jobs([limit])

Return the unfinished jobs submitted to this backend.

configuration()

Return the backend configuration.

defaults([refresh])

Return the pulse defaults for the backend.

job_limit()

Return the job limit for the backend.

jobs([limit, skip, status, job_name, …])

Return the jobs submitted to this backend, subject to optional filtering.

name()

Return the backend name.

properties([refresh, datetime])

Return the backend properties, subject to optional filtering.

provider()

Return the backend Provider.

remaining_jobs_count()

Return the number of remaining jobs that could be submitted to the backend.

reservations([start_datetime, end_datetime])

Return backend reservations.

retrieve_job(job_id)

Return a single job submitted to this backend.

run(qobj[, job_name, job_share_level, …])

Run a Qobj asynchronously.

status()

Return the backend status.

version()

Return the backend version.

active_jobs(limit=10)[source]

Return the unfinished jobs submitted to this backend.

Return the jobs submitted to this backend, with this provider, that are currently in an unfinished job status state. The unfinished JobStatus states include: INITIALIZING, VALIDATING, QUEUED, and RUNNING.

Parameters

limit (int) – Number of jobs to retrieve.

Return type

List[IBMQJob]

Returns

A list of the unfinished jobs for this backend on this provider.

configuration()

Return the backend configuration.

Returns

the configuration for the backend.

Return type

BackendConfiguration

defaults(refresh=False)[source]

Return the pulse defaults for the backend.

Parameters

refresh (bool) – If True, re-query the server for the backend pulse defaults. Otherwise, return a cached version.

Return type

Optional[PulseDefaults]

Returns

The backend pulse defaults or None if the backend does not support pulse.

job_limit()[source]

Return the job limit for the backend.

The job limit information includes the current number of active jobs you have on the backend and the maximum number of active jobs you can have on it.

Note

Job limit information for a backend is provider specific. For example, if you have access to the same backend via different providers, the job limit information might be different for each provider.

If the method call was successful, you can inspect the job limit for the backend by accessing the maximum_jobs and active_jobs attributes of the BackendJobLimit instance returned. For example:

backend_job_limit = backend.job_limit()
maximum_jobs = backend_job_limit.maximum_jobs
active_jobs = backend_job_limit.active_jobs

If maximum_jobs is equal to None, then there is no limit to the maximum number of active jobs you could have on the backend.

Return type

BackendJobLimit

Returns

The job limit for the backend, with this provider.

Raises

IBMQBackendApiProtocolError – If an unexpected value is received from the server.

jobs(limit=10, skip=0, status=None, job_name=None, start_datetime=None, end_datetime=None, job_tags=None, job_tags_operator='OR', descending=True, db_filter=None)[source]

Return the jobs submitted to this backend, subject to optional filtering.

Retrieve jobs submitted to this backend that match the given filters and paginate the results if desired. Note that the server has a limit for the number of jobs returned in a single call. As a result, this function might involve making several calls to the server. See also the skip parameter for more control over pagination.

Parameters
  • limit (int) – Number of jobs to retrieve.

  • skip (int) – Starting index for the job retrieval.

  • status (Union[JobStatus, str, List[Union[JobStatus, str]], None]) – Only get jobs with this status or one of the statuses. For example, you can specify status=JobStatus.RUNNING or status=”RUNNING” or status=[“RUNNING”, “ERROR”]

  • job_name (Optional[str]) – Filter by job name. The job_name is matched partially and regular expressions can be used.

  • start_datetime (Optional[datetime]) – Filter by the given start date, in local time. This is used to find jobs whose creation dates are after (greater than or equal to) this local date/time.

  • end_datetime (Optional[datetime]) – Filter by the given end date, in local time. This is used to find jobs whose creation dates are before (less than or equal to) this local date/time.

  • job_tags (Optional[List[str]]) – Filter by tags assigned to jobs.

  • job_tags_operator (Optional[str]) –

    Logical operator to use when filtering by job tags. Valid values are “AND” and “OR”:

    • If “AND” is specified, then a job must have all of the tags specified in job_tags to be included.

    • If “OR” is specified, then a job only needs to have any of the tags specified in job_tags to be included.

  • descending (bool) – If True, return the jobs in descending order of the job creation date (newest first). If False, return in ascending order.

  • db_filter (Optional[Dict[str, Any]]) –

    A loopback-based filter. This is an interface to a database where filter. Some examples of its usage are:

    Filter last five jobs with errors:

    job_list = backend.jobs(limit=5, status=JobStatus.ERROR)
    

    Filter last five jobs with hub name ibm-q:

    filter = {'hubInfo.hub.name': 'ibm-q'}
    job_list = backend.jobs(limit=5, db_filter=filter)
    

Return type

List[IBMQJob]

Returns

A list of jobs that match the criteria.

Raises

IBMQBackendValueError – If a keyword value is not recognized.

name()

Return the backend name.

Returns

the name of the backend.

Return type

str

properties(refresh=False, datetime=None)[source]

Return the backend properties, subject to optional filtering.

Parameters
  • refresh (bool) – If True, re-query the server for the backend properties. Otherwise, return a cached version.

  • datetime (Optional[datetime]) – By specifying datetime, this function returns an instance of the BackendProperties whose timestamp is closest to, but older than, the specified datetime.

Return type

Optional[BackendProperties]

Returns

The backend properties or None if the backend properties are not currently available.

Raises

TypeError – If an input argument is not of the correct type.

provider()

Return the backend Provider.

Returns

the Provider responsible for the backend.

Return type

BaseProvider

remaining_jobs_count()[source]

Return the number of remaining jobs that could be submitted to the backend.

Note

The number of remaining jobs for a backend is provider specific. For example, if you have access to the same backend via different providers, the number of remaining jobs might be different for each. See BackendJobLimit for the job limit information of a backend.

If None is returned, there are no limits to the maximum number of active jobs you could have on the backend.

Return type

Optional[int]

Returns

The remaining number of jobs a user could submit to the backend, with this provider, before the maximum limit on active jobs is reached.

Raises

IBMQBackendApiProtocolError – If an unexpected value is received from the server.

reservations(start_datetime=None, end_datetime=None)[source]

Return backend reservations.

If start_datetime and/or end_datetime is specified, reservations with time slots that overlap with the specified time window will be returned.

Some of the reservation information, such as scheduling mode, is only available if you are the owner of the reservation.

Parameters
  • start_datetime (Optional[datetime]) – Filter by the given start date/time, in local timezone.

  • end_datetime (Optional[datetime]) – Filter by the given end date/time, in local timezone.

Return type

List[BackendReservation]

Returns

A list of reservations that match the criteria.

retrieve_job(job_id)[source]

Return a single job submitted to this backend.

Parameters

job_id (str) – The ID of the job to retrieve.

Return type

IBMQJob

Returns

The job with the given ID.

Raises

IBMQBackendError – If job retrieval failed.

run(qobj, job_name=None, job_share_level=None, job_tags=None, validate_qobj=False)[source]

Run a Qobj asynchronously.

Parameters
  • qobj (Union[QasmQobj, PulseQobj]) – The Qobj to be executed.

  • job_name (Optional[str]) – Custom name to be assigned to the job. This job name can subsequently be used as a filter in the jobs() method. Job names do not need to be unique.

  • job_share_level (Optional[str]) –

    Allows sharing a job at the hub, group, project, or global level. The possible job share levels are: global, hub, group, project, and none.

    • global: The job is public to any user.

    • hub: The job is shared between the users in the same hub.

    • group: The job is shared between the users in the same group.

    • project: The job is shared between the users in the same project.

    • none: The job is not shared at any level.

    If the job share level is not specified, the job is not shared at any level.

  • job_tags (Optional[List[str]]) – Tags to be assigned to the jobs. The tags can subsequently be used as a filter in the jobs() function call.

  • validate_qobj (bool) – If True, run JSON schema validation against the submitted payload

Return type

IBMQJob

Returns

The job to be executed, an instance derived from BaseJob.

Raises
status()[source]

Return the backend status.

Return type

BackendStatus

Returns

The status of the backend.

Raises

IBMQBackendApiProtocolError – If the status for the backend cannot be formatted properly.

version()

Return the backend version.

Returns

the X.X.X version of the backend.

Return type

str

You are viewing lang: English
Languages
English
Japanese
German
Korean