Should the braket.aws.AwsDevice.get_devices()
API return a non-empty list of AWS Braket systems for the us-east-2
region? (It does).
The reason for my question is that it does not look like us-east-2 is a supported service endpoint for the AWS Braket service, however when the following code is used to query the braket devices available in the us-east-2
region, a non-empty list of devices is returned:
from braket.aws import AwsDevice
import sys
import os
AWS_REGIONS = [ 'us-east-2' ]
for region in AWS_REGIONS:
os.environ['AWS_DEFAULT_REGION'] = region
try:
aws_braket_devices = AwsDevice.get_devices(order_by='provider_name')
except Exception as exception:
exc_type, value, traceback = sys.exc_info()
print(f'{exc_type.__name__} calling AwsDevice.get_devices()')
raise exception
print(f'AWS Braket devices in region {region}')
for aws_braket_device in aws_braket_devices:
print(f'{aws_braket_device.name:<20}{aws_braket_device.status:<10} {aws_braket_device.arn}')
When the code above is run, it prints a list of braket systems in the us-east-2
region which looks like this:
AWS Braket devices in region us-east-2
Advantage_system3.2 OFFLINE arn:aws:braket:::device/qpu/d-wave/Advantage_system3
Advantage_system4.1 ONLINE arn:aws:braket:::device/qpu/d-wave/Advantage_system4
Advantage_system1.1 RETIRED arn:aws:braket:::device/qpu/d-wave/Advantage_system1
DW_2000Q_6 ONLINE arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6
IonQ Device ONLINE arn:aws:braket:::device/qpu/ionq/ionQdevice
Aspen-10 RETIRED arn:aws:braket:::device/qpu/rigetti/Aspen-10
Aspen-8 RETIRED arn:aws:braket:::device/qpu/rigetti/Aspen-8
Aspen-9 RETIRED arn:aws:braket:::device/qpu/rigetti/Aspen-9
Aspen-11 ONLINE arn:aws:braket:::device/qpu/rigetti/Aspen-11
However, if a user tries to access any of the ONLINE systems via a us-east-2
endpoint, the API call will fail as shown in the following example:
from braket.aws import AwsDevice
import botocore
import sys
import os
AWS_REGIONS = [ 'us-east-2' ]
for region in AWS_REGIONS:
os.environ['AWS_DEFAULT_REGION'] = region
try:
aws_braket_devices = AwsDevice.get_devices(statuses=['ONLINE'], order_by='provider_name')
except Exception as exception:
exc_type, value, traceback = sys.exc_info()
print(f'{exc_type.__name__} calling AwsDevice.get_devices()')
raise exception
print(f'Creating device objects for AWS Braket ONLINE devices in region {region}')
for aws_braket_device in aws_braket_devices:
print(f'Creating device obj for {aws_braket_device.arn}...')
try:
aws_device = AwsDevice(aws_braket_device.arn)
except botocore.exceptions.EndpointConnectionError as exc:
print(exc)
except Exception as exc:
print(exc)
print(f'device created for {aws_braket_device.arn}')
Running this code produces the following output:
Creating device objects for AWS Braket ONLINE devices in region us-east-2
Creating device obj for arn:aws:braket:::device/qpu/d-wave/Advantage_system4...
Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fqpu%2Fd-wave%2FAdvantage_system4"
device created for arn:aws:braket:::device/qpu/d-wave/Advantage_system4
Creating device obj for arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6...
Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fqpu%2Fd-wave%2FDW_2000Q_6"
device created for arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6
Creating device obj for arn:aws:braket:::device/qpu/ionq/ionQdevice...
Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fqpu%2Fionq%2FionQdevice"
device created for arn:aws:braket:::device/qpu/ionq/ionQdevice
Creating device obj for arn:aws:braket:::device/qpu/rigetti/Aspen-11...
Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fqpu%2Frigetti%2FAspen-11"
device created for arn:aws:braket:::device/qpu/rigetti/Aspen-11
If the code above is modified to use a region which is a supported service endpoint for AWS Braket (such as us-east-1
), then the code works as expected.
(It is then possible to create device objects for all of the ARNs returned by the braket.aws.AwsDevice.get_devices()
API)
Since it appears that AWS Braket devices cannot be accessed via the us-east-2
region, it seems like the braket.aws.AwsDevice.get_devices()
API should be returning an empty list of AWS Braket systems for the us-east-2
region, and it is not. This API is returning a non-empty list of AWS Braket systems as if they can be reached through the us-east-2
region when in fact they cannot.
Additionally, QPUs (but not simulators) will redirect to their respective regions, so even though you're in us-east-2,
AwsDevice
will find and instantiate QPUs in the correct region.This is not quite the behavior that I am observing. I get different lists of devices returned by braket.aws.AwsDevice.get_devices() depending on the region I am making the request from. For the following regions: us-east-1, us-west-1, us-west-2: AwsDevice.get_devices() returns different lists of devices and I can successfully create a device object using braket.aws.aws_device.AwsDevice() for each device returned in those regions. For the us-east-2 region, AwsDevice.get_devices() returns yet another different list of devices and braket.aws.aws_device.AwsDevice() fails for all of them.
What version of the Braket SDK are you using?