Main Content

quantum.backend.QuantumDeviceAWS Class

Namespace: quantum.backend

Quantum device available through AWS

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

A QuantumDeviceAWS object represents a specific quantum device that is available through Amazon® Web Services (AWS®). To work with remote devices and data using AWS, you must first set up access following the steps in Run Quantum Circuit on Hardware Using AWS.

The quantum.backend.QuantumDeviceAWS class is a handle class.

Creation

Description

dev = quantum.backend.QuantumDeviceAWS(deviceName) returns a representation of the specified quantum device. The deviceName input must uniquely define the device. This syntax sets the Name property to deviceName.

example

dev = quantum.backend.QuantumDeviceAWS(deviceARN) returns a representation of the device based on its ARN (Amazon Resource Name) identifier. If deviceARN exists in multiple regions, then the region in the AWS_DEFAULT_REGION environment variable determines which of the devices to represent. This syntax sets the DeviceARN property to deviceARN.

example

dev = quantum.backend.QuantumDeviceAWS(___,Name=Value) sets properties using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes.

  • You can specify the region of the device using quantum.backend.QuantumDeviceAWS(__,Region=region).

  • You can also specify a remote folder in an Amazon S3™ bucket to write and retrieve the results of running a quantum circuit using quantum.backend.QuantumDeviceAWS(__,S3Path=folderpath).

example

Note

Saving and loading QuantumDeviceAWS objects in MATLAB® are not supported.

Properties

expand all

Short name of the quantum device, returned as a string scalar.

The device name must be listed on Amazon Braket supported devices or on the Amazon Braket > Devices page when you are connected to the AWS Console. MATLAB currently supports most (but not all) of the listed devices. If a device is not supported, try connecting to another device with a different name.

Attributes:

GetAccess
public
SetAccess
private

ARN identifier of the device, returned as a string scalar. If the device ARN exists in multiple regions, then the region in the AWS_DEFAULT_REGION environment variable determines which of the devices to represent.

The device ARN must be listed on Amazon Braket supported devices or on the Amazon Braket > Devices page when you are connected to the AWS Console. MATLAB currently supports most (but not all) of the listed devices. If a device is not supported, try connecting to another device with a different ARN.

Attributes:

GetAccess
public
SetAccess
private

Region that the device is in, returned as a string scalar. If devices with the same name exist in multiple regions, this region determines which of the devices to use. By default, the AWS_DEFAULT_REGION environment variable determines the device region.

Attributes:

GetAccess
public
SetAccess
private

Path to remote storage of results, returned as a string scalar. This property specifies the AWS path to a folder in an Amazon S3 bucket. Your account must have access to this folder. MATLAB uses this folder to store and retrieve the results of running a quantum circuit.

In this path, the bucket name must start with "amazon-braket-" and the bucket must be accessible from the region in your AWS_DEFAULT_REGION environment variable if it is set. The default value of S3Path is "s3://amazon-braket-mathworks/default".

Attributes:

GetAccess
public
SetAccess
private

Methods

expand all

Examples

collapse all

Connect to a remote quantum device through AWS by specifying the device name as "Aspen-M-3".

dev = quantum.backend.QuantumDeviceAWS("Aspen-M-3")
dev = 

  QuantumDeviceAWS with properties:

         Name: "Aspen-M-3"
    DeviceARN: "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
       Region: "us-west-1"
       S3Path: "s3://amazon-braket-mathworks/default"

Create a task by running a quantum circuit on this device.

gates = [hGate(1); cxGate(1,2)];
c = quantumCircuit(gates);
task = run(c,dev)
task = 

  QuantumTaskAWS with properties:

    TaskARN: "arn:aws:braket:us-west-1:123456789012:quantum-task/12a34b5c-6a78-9a01-2ab3-4c56def7a890"
     Status: "finished"

Retrieve the measurement result of running the circuit.

m = fetchOutput(task)
m = 

  QuantumMeasurement with properties:

    MeasuredStates: [3×1 string]
            Counts: [3×1 double]
     Probabilities: [3×1 double]
         NumQubits: 2

Connect to a remote quantum device through AWS by specifying the device ARN as "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy".

devARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy";
dev = quantum.backend.QuantumDeviceAWS(devARN)
dev = 

  QuantumDeviceAWS with properties:

         Name: "Lucy"
    DeviceARN: "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
       Region: "eu-west-2"
       S3Path: "s3://amazon-braket-mathworks/default"

Retrieve details about the quantum device.

s = fetchDetails(dev)
s = 

  struct with fields:

             deviceArn: "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
    deviceCapabilities: "{"service": {"braketSchemaHeader": {"name"... "
            deviceName: "Lucy"
          deviceStatus: "ONLINE"
            deviceType: "QPU"
          providerName: "Oxford"

To parse the deviceCapabilities field in the returned structure, you can use the jsondecode function to convert the description string into another structure.

capabilities = jsondecode(s.deviceCapabilities)
capabilities = 

  struct with fields:

               service: [1×1 struct]
                action: [1×1 struct]
      deviceParameters: [1×1 struct]
    braketSchemaHeader: [1×1 struct]
              paradigm: [1×1 struct]
              provider: [1×1 struct]
          standardized: [1×1 struct]
                 pulse: [1×1 struct]

The structure returned by fetchDetails changes from device to device, and its content may also change over time as provided by the AWS quantum computing service.

Connect to a remote quantum device through AWS by specifying the device name as "SV1". Because devices with this name exist in multiple regions, specify the region of the device to connect to as "us-west-1". Also, specify the S3 path to store the results of running tasks on this device.

dev = quantum.backend.QuantumDeviceAWS("SV1",Region="us-west-1", ...
      S3Path="s3://amazon-braket-projectabc/examples")
dev = 

  QuantumDeviceAWS with properties:

         Name: "SV1"
    DeviceARN: "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
       Region: "us-west-1"
       S3Path: "s3://amazon-braket-projectabc/examples"

Tips

  • Amazon Braket provides a suite of quantum simulators, such as "SV1", "TN1", and "DM1", that emulate the behavior of quantum computers using classical hardware. You can use these simulators to validate complex quantum circuits before running them on QPU (quantum processing unit) devices. These simulators are also more readily available than QPU devices. For more information, see Amazon Braket supported devices.

Version History

Introduced in R2023a