PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
131 stars 29 forks source link

[Frontend] The lack of a device specific decomposition logic #181

Open maliasadi opened 1 year ago

maliasadi commented 1 year ago

We currently serve all backend devices in a way that they all support an identical set of quantum gates. This design assumption would lead to the failure of decomposition rules for the OpenQasm3/Braket device. We may need to implement a device specific decomposition logic for every supported backend devices in the frontend to properly tackle this issue.

Check the test_unsupported_gate_braket test unit in test_aws_braket_devices.py for an example.

erick-xanadu commented 12 months ago

Possible implementation

    def __call__(self, *args, **kwargs):
        if isinstance(self, qml.QNode):
            if self.device.short_name not in QFunc.RUNTIME_DEVICES:
                raise CompileError(
                    f"The {self.device.short_name} device is not "
                    "supported for compilation at the moment."
                )
            ...
            # instead of generating the same QJITDevice with the same supported operations
            # we can easily pass the list of supported operations from the QNode.
            device = QJITDevice(
                self.device.shots, self.device.wires, self.device.short_name, backend_kwargs
                # we can easily access:
               , self.device.operations
               , self.device.observables
            )