CQCL / pytket-braket

pytket-braket, extensions for pytket quantum SDK
Apache License 2.0
2 stars 2 forks source link

IonQ's Aria-1 device is currently not supported #74

Closed yoshi-qc closed 1 year ago

yoshi-qc commented 1 year ago

I tried to access to IonQ's Aria-1 in AWS braket

import boto3
from braket.aws import AwsSession
boto_session = boto3.Session(
    aws_access_key_id= your aws_access_key_id,
    aws_secret_access_key= your aws_secret_access_key,
    region_name= 'us-east-1'
)
aws_session = AwsSession(boto_session=boto_session)
from pytket.extensions.braket import BraketBackend
aws_backend = BraketBackend(device='Aria-1', region = 'us-east-1', s3_bucket=s3_name , s3_folder = bucket_key, device_type = 'qpu', provider = 'ionq', aws_session=aws_session)

I got the error

ValueError: Unsupported device Aria-1

I checked device information of IonQ

device = aws_session.search_devices()
for dev in device:
    if dev["deviceStatus"]=='IonQ':
        print(dev)

and I got

{'deviceArn': 'arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1', 'deviceName': 'Aria 1', 'deviceStatus': 'ONLINE', 'deviceType': 'QPU', 'providerName': 'IonQ'}
{'deviceArn': 'arn:aws:braket:us-east-1::device/qpu/ionq/Harmony', 'deviceName': 'Harmony', 'deviceStatus': 'ONLINE', 'deviceType': 'QPU', 'providerName': 'IonQ'}

For Aria, the name of device in 'deviceArn' is 'Aria-1' but 'deviceName' is 'Aria 1'.
In pytket-braket, is the name of device in 'deviceArn' compared with 'deviceName' somewhere?

https://github.com/CQCL/pytket-braket/blob/fa8a33f496d92570329b720ecca525b7eb239ab1/pytket/extensions/braket/backends/braket.py#L363

cqc-alec commented 1 year ago

This doesn't look like an issue with the name: if it's coming from that line then it means that

device_info = props["action"][DeviceActionType.JAQCD]

raised a KeyError. This usually indicates that it's not a gate-model device, but this one appears to be, so I'm not sure what the reason is, would need to do some digging.

yoshi-qc commented 1 year ago

What is the line doing? Here, an error occurs. Thanks for the above explanation.

device_info = props["action"][DeviceActionType.JAQCD]

from braket.aws import AwsDevice
from braket.device_schema import DeviceActionType
device = AwsDevice(
                "arn:aws:braket:"
                + "us-east-1"
                + "::"
                + "/".join(
                    ["device", "qpu", "ionq", "Aria-1"],
                ),
                aws_session=aws_session,
            )
device.properties.dict()["action"][DeviceActionType.JAQCD] # Error occurs.
yoshi-qc commented 1 year ago

For Harmony,

device.properties.dict()["action"]

returns

{<DeviceActionType.JAQCD: 'braket.ir.jaqcd.program'>: {'version': ['1'],...}

For Aria-1,

device.properties.dict()["action"]

returns

{<DeviceActionType.OPENQASM: 'braket.ir.openqasm.program'>: {'version': ['1'],...}

So, device.properties.dict()["action"][DeviceActionType.OPENQASM] does not occur for Aria-1.

cqc-alec commented 1 year ago

Looks like we have to try both then. Will make a PR.