braket.strawberryfields_plugin.braket_engine module
- class braket.strawberryfields_plugin.braket_engine.BraketEngine(device_arn: str, s3_destination_folder: S3DestinationFolder | None = None, aws_session: AwsSession | None = None, poll_timeout_seconds: float = 432000, poll_interval_seconds: float = 1)[source]
Bases:
object
A class for using Amazon Braket as a Strawberry Fields Engine
- Parameters:
device_arn (str) – AWS quantum device arn.
s3_destination_folder (AwsSession.S3DestinationFolder) – NamedTuple with bucket (index 0) and key (index 1) that is the results destination folder in S3.
aws_session (Optional[AwsSession]) – An AwsSession object created to manage interactions with AWS services, to be supplied if extra control is desired. Default: None
poll_timeout_seconds (float) – Total time in seconds to wait for results before timing out.
poll_interval_seconds (float) – The polling interval for results in seconds.
Examples
>>> from braket.strawberryfields_plugin import BraketEngine >>> eng = BraketEngine("device_arn_1")
- property aws_device: AwsDevice
The underlying AwsDevice that makes calls to the Amazon Braket service.
- Type:
AwsDevice
- property target: str
The name of the target device used by the engine.
- Type:
str
- property device: Device
The representation of the target device.
This gets the latest calibration data from the Braket service.
- Type:
sf.Device
- run(program: Program, *, compile_options=None, recompile=False, **kwargs) Result | None [source]
Runs a quantum task to completion and returns its result.
This is a blocking call that waits until the Braket quantum task is complete.
If the job completes successfully, the result is returned; if the job fails or is cancelled,
None
is returned.- Parameters:
program (strawberryfields.Program) – the quantum circuit
compile_options (None, Dict[str, Any]) – keyword arguments for
Program.compile()
recompile (bool) – Specifies if
program
should be recompiled usingcompile_options
, or if not provided, the default compilation options.
- Keyword Arguments:
shots (int, optional) – The number of shots for which to run the job. If this argument is not provided, the shots are derived from the given
program
.- Returns:
Optional[sf.Result] – The job result if successful, and
None
otherwise
- run_async(program: Program, *, compile_options=None, recompile=False, **kwargs) BraketJob [source]
Creates a Braket quantum task and returns a ``BraketJob` wrapping the task.
The user can check the status of the job or retrieve results, the latter of which is a blocking call.
- Parameters:
program (strawberryfields.Program) – the quantum circuit
compile_options (None, Dict[str, Any]) – keyword arguments for
Program.compile()
recompile (bool) – Specifies if
program
should be recompiled usingcompile_options
, or if not provided, the default compilation options.
- Keyword Arguments:
shots (Optional[int]) – The number of shots for which to run the job. If this argument is not provided, the shots are derived from the given
program
.- Returns:
BraketJob – The created Braket job