qrunch.quantum.backends.amazon.amazon_braket_backend
Module with implementation of Amazon Braket backend for running quantum circuits.
Classes
Class for handling Amazon Braket's quantum devices. |
|
Job class for handling a quantum job run via a ProgramSet on Amazon Braket. |
|
Job class for handling simulated jobs on Amazon Braket. |
- class AmazonBraketBackend
Bases:
BackendClass 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.
- 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:
- property name: str
Name of the backend.
- run(circuits: Circuit | Sequence[Circuit], shots: int | None) BraketHardwareJob | BraketSimulatedJob
Run circuit on the backend.
- Parameters:
- Return type:
- 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:
BackendJobJob 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
- 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:
- status() BackendJobStatus
Return the collective status of all tasks in the job.
- Return type:
- wait_for_final_state(timeout: float | None = None) None
Wait until the job status is in a final state, i.e.,
DONE,CANCELLED, orFAILED.- 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:
BackendJobJob 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
- 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:
- status() BackendJobStatus
Return the collective status of all tasks in the job.
- Return type:
- wait_for_final_state(timeout: float | None = None) None
Wait until the job status is in a final state, i.e.,
DONE,CANCELLED, orFAILED.- 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