qrunch.quantum.backends.ibm.ibm_quantum_platform_backend

Module with implementation of IBM’s backend for running quantum circuits.

Classes

IbmBackendJob

Job class for handling job on IBM's backend.

IbmQuantumPlatformBackend

Class for handling IBM's quantum devices.

IbmQuantumPlatformDevices

Available IBM devices.

class IbmBackendJob

Bases: BackendJob

Job class for handling job on IBM’s backend.

Requirements:
  • Qrunch install requirements: qrunch[ibm] (or qrunch[all]).

__init__(backend: IbmQuantumPlatformBackend, job_id: str, ibm_job: RuntimeJobV2, callback: BackendCallback | None = None) None

Initialize a IBM job.

Parameters:
  • backend (IbmQuantumPlatformBackend) – Backend used for the job.

  • job_id (str) – id of the job.

  • ibm_job (RuntimeJobV2) – IBM job.

  • callback (BackendCallback | None) – Callback to record backend events.

Return type:

None

property backend: IbmQuantumPlatformBackend

Backend used for the job.

cancel() None

Cancel the job.

Return type:

None

property job_id: str

ID of the job.

result() BackendResult

Get the result of the job.

Return type:

BackendResult

status() BackendJobStatus

Get the status of the job.

Return type:

BackendJobStatus

wait_for_final_state(timeout: float | None = None) None

Wait until the job status is in a final state, i.e., DONE, CANCELLED, or FAILED.

Parameters:

timeout (float | None) – Seconds to wait for the job. If None, wait forever.

Raises:

TimeoutError – If the job does not reach a final state before the specified timeout.

Return type:

None

class IbmQuantumPlatformBackend

Bases: HardwareBackend

Class for handling IBM’s quantum devices.

Requirements:
  • Qrunch install requirements: qrunch[ibm] (or qrunch[all]).

__init__(device: IbmQuantumPlatformDevices = IbmQuantumPlatformDevices.LEAST_BUSY, token: str | None = None, instance: str | None = None, transpiler: Transpiler[QuantumCircuit] | None = None, *, callback: BackendCallback | None = None) None

Initialize an IBM backend.

The backend can be used to launch quantum circuits to quantum devices on IBM Quantum Platform. To do so, an instance for a region (us-east or eu-de) must be created. The api token and instance CRN (or name) is then supplied to the backend. The region for the instance must match the region of the device.

Parameters:
  • transpiler (Transpiler[QuantumCircuit] | None) – Transpiler for converting circuits into a format suitable for the backend.

  • device (IbmQuantumPlatformDevices) – Device to run circuit on. Defaults to LEAST_BUSY.

  • token (str | None) – Token used to access IBM’s cloud. All hardware devices require a token.

  • instance (str | None) – CRN or name of instance to be used. Default is to choose instance according to priority defined by IBM Quantum Platform.

  • callback (BackendCallback | None) – A callback that can be used to record the input circuit, backend job, and measurement result.

Return type:

None

get_device_data() DeviceData

Get device data if available.

Return type:

DeviceData

property name: str

Name of the backend.

run(circuits: Circuit | Sequence[Circuit], shots: int | None) IbmBackendJob | SimulatedJob

Run circuit on the backend.

Parameters:
  • circuits (Circuit | Sequence[Circuit]) – circuits to run on backend

  • shots (int | None) – number of shots. Must be a positive integer

Return type:

IbmBackendJob | SimulatedJob

validate_shots_type(shots_type: Type[int | None]) list[str]

Validate that the sampler supports the given shots type. Return a list of error messages if not supported.

Parameters:

shots_type (Type[int | None])

Return type:

list[str]

verify_backend_works() None

Verify that the backend works by running a simple circuit.

The circuit is run on the actual hardware, so this requires a valid token and may take some time and cost a small number of credits.

Return type:

None

class IbmQuantumPlatformDevices

Bases: Enum

Available IBM devices.

AACHEN = 'aachen'
BOSTON = 'boston'
BRUSSELS = 'brussels'
FAKE_BRISBANE = 'fake_brisbane'
FAKE_FEZ = 'fake_fez'
FAKE_MARRAKESH = 'fake_marrakesh'
FAKE_TORINO = 'fake_torino'
FEZ = 'fez'
KINGSTON = 'kingston'
LEAST_BUSY = 'least_busy'
MARRAKESH = 'marrakesh'
MIAMI = 'miami'
PITTSBURGH = 'pittsburgh'
STRASBOURG = 'strasbourg'
TORINO = 'torino'