CQCL/pytket-extensions

Unable to instantiate BraketBackend for Lucy QPU Gate Type 'ecr' not supported

dhaycraft opened this issue · 2 comments

Hello,
I was trying to use pytket-braket to create a BraketBackend

import boto3
from braket.aws import AwsSession, AwsDevice
region = "eu-west-2"
braket_client = boto3.client('braket', region_name = region)
b = BraketBackend(device_type="qpu", provider="oqc", device="Lucy", region="eu-west-2", aws_session = sess)

Yields the below error:

KeyError Traceback (most recent call last)
Input In [163], in
----> 1 b = BraketBackend(device_type="qpu",
2 provider="oqc",
3 device='Lucy',
4 region="eu-west-2",
5 aws_session = sess)

File ~/repos/quoir/venv/lib/python3.8/site-packages/pytket/extensions/braket/backends/braket.py:329, in BraketBackend.init(self, local, device, region, s3_bucket, s3_folder, device_type, provider, aws_session)
326 self._variance_min_shots = rtminshots
327 self._variance_max_shots = rtmaxshots
--> 329 self._singleqs, self._multiqs = self._get_gate_set(
330 supported_ops, self._device_type
331 )
333 arch, self._all_qubits = self._get_arch_info(props, self._device_type)
334 self._characteristics: Optional[Dict] = None

File ~/repos/quoir/venv/lib/python3.8/site-packages/pytket/extensions/braket/backends/braket.py:386, in BraketBackend._get_gate_set(supported_ops, device_type)
384 raise NotImplementedError("Device must support cnot, rx, rz and x gates.")
385 for t in supported_ops:
--> 386 tkt = _gate_types[t]
387 if tkt is not None:
388 if t in _multiq_gate_types:

KeyError: 'ecr'

aws_devices = AwsDevice.get_devices(aws_session = sess, names = ["Lucy"])
lucy_ops = aws_devices[0].properties.dict()['action']['braket.ir.jaqcd.program']['supportedOperations']
lucy_ops

['ccnot',
'cnot',
'cphaseshift',
'cswap',
'cy',
'cz',
'h',
'i',
'phaseshift',
'rx',
'ry',
'rz',
's',
'si',
'swap',
't',
'ti',
'v',
'vi',
'x',
'y',
'z',
'ecr',
'start_verbatim_box',
'end_verbatim_box']

If you look at
https://github.com/CQCL/pytket-extensions/blob/develop/modules/pytket-braket/pytket/extensions/braket/backends/braket.py#L105-L141
You can see that it's not in the supported set of gate ops.

Did a little more research and found implementations in Qiskit:
https://qiskit.org/documentation/stubs/qiskit.circuit.library.ECRGate.html

ECR includes another gate which isn't in pytket base
https://qiskit.org/documentation/stubs/qiskit.circuit.library.RZXGate.html

Do you have any timeline on when these gates/Lucy will be reported in the future?
Did some digging in pytket-extensions but couldn't find anything.

Thank you all so much for developing and maintaining this package I know Lucy just came out so not expecting it to be ready yet :)

Relevant Package versions:

amazon-braket-schemas 1.7.3.dev0
amazon-braket-sdk 1.16.0
pytket 1.0.0rc14
pytket-braket 0.17.0

Python version: 3.8.8

Thanks for the report. Yes, this is an issue we come across occasionally when new devices come online. We will be working on a fix for this very soon. (Pytket does support the ECR gate so it should not be difficult to make this work.)

Fixed by #327 .