qrunch.quantum.backends.amazon.amazon_braket_backend

Module with implementation of Amazon Braket backend for running quantum circuits.

Classes

AmazonBraketBackend

Class for handling Amazon Braket's quantum devices.

BraketHardwareJob

Job class for handling a quantum job run via a ProgramSet on Amazon Braket.

BraketSimulatedJob

Job class for handling simulated jobs on Amazon Braket.

class AmazonBraketBackend

Bases: Backend

Class for handling Amazon Braket’s quantum devices.

__init__(device: _IQM | _IonQ | _Rigetti | _Amazon | DeviceData, *, compiler: Compiler | None = None, layout_synthesizer: LayoutSynthesizer | None = None, max_cost: float = 10000) None

Initialize a Amazon Braket Backend.

The backend can be used to launch quantum circuits to quantum devices on Amazon Braket.

The backend supports all devices on Amazon Braket from IQM, IonQ, Rigetti and Amazon. The devices can be specified using the Devices enum from braket.devices or by providing DeviceData for simulators.

Parameters:
  • device (_IQM | _IonQ | _Rigetti | _Amazon | DeviceData) – Device to run circuit on.

  • compiler (Compiler | None) – Compiler for changing into universal gates. The compiler must implement the to_universal_gates method.

  • layout_synthesizer (LayoutSynthesizer | None) – Layout synthesizer to change into topology. Defaults to QubitDependentLayoutSynthesizer.

  • max_cost (float) – Maximum price of a single run-method, only limits QPUs. Defaults to $10,000.

Return type:

None

cost(shots: int) float

Estimate the cost of running on hardware.

Parameters:

shots (int) – number of shots

Return type:

float

property device: AwsDevice

Return AWS device.

get_device_data() DeviceData

Device data is not available for the local Braket simulator.

Return type:

DeviceData

property name: str

Name of the backend.

run(circuits: Circuit | Sequence[Circuit], shots: int | None) BraketHardwareJob | BraketSimulatedJob

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:

BraketHardwareJob | BraketSimulatedJob

supports_shots_equals_none() bool

Return whether the backend supports shots = None.

Braket backends do not support exact simulations without shots.

Return type:

bool

class BraketHardwareJob

Bases: BackendJob

Job class for handling a quantum job run via a ProgramSet on Amazon Braket.

__init__(backend: Backend, job_id: str, task: AwsQuantumTask, mappings: tuple[Mapping[int, int], ...], shots: int, error_log: str) None

Initialize an Amazon Braket job.

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

  • job_id (str) – id of the job as a string.

  • task (AwsQuantumTask) – The task running on Amazon Braket.

  • mappings (tuple[Mapping[int, int], ...]) – dictionary of the mapping in each task, with task.id as key

  • shots (int) – number of shots

  • error_log (str) – Error log for the job.

Return type:

None

property backend: Backend

Backend used for the job.

cancel() None

Cancel all tasks in the job.

Return type:

None

property job_id: str

ID of the job.

result() BackendResult

Get the results of the tasks.

Return type:

BackendResult

status() BackendJobStatus

Return the collective status of all tasks in 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 BraketSimulatedJob

Bases: BackendJob

Job class for handling simulated jobs on Amazon Braket.

__init__(backend: Backend, job_id: str, tasks: list[AwsQuantumTask], mappings: dict[str, Mapping[int, int]], shots: int) None

Initialize an Amazon Braket job.

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

  • job_id (str) – id of the job as a string.

  • tasks (list[AwsQuantumTask]) – list of the tasks running on Amazon Braket.

  • mappings (dict[str, Mapping[int, int]]) – dictionary of the mapping in each task, with task.id as key

  • shots (int) – number of shots

Return type:

None

property backend: Backend

Backend used for the job.

cancel() None

Cancel all tasks in the job.

Return type:

None

property job_id: str

ID of the job.

result() BackendResult

Get the results of the tasks.

Return type:

BackendResult

status() BackendJobStatus

Return the collective status of all tasks in 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