diff --git a/frontend/catalyst/device/qjit_device.py b/frontend/catalyst/device/qjit_device.py index 24be391cdc..e25f478ef3 100644 --- a/frontend/catalyst/device/qjit_device.py +++ b/frontend/catalyst/device/qjit_device.py @@ -487,10 +487,16 @@ def validate_device_capabilities( if hasattr(device, "operations") and hasattr(device, "observables"): # For gates, we require strict match device_gates = filter_out_adjoint(set(device.operations)) + # Lightning-kokkis might support C(GlobalPhase) in Python, but not in C++. We remove this + # gate before calling the validation. + # See https://github.com/PennyLaneAI/pennylane-lightning/pull/642#discussion_r1535478642 + if device_name == "lightning.kokkos": + device_gates = device_gates - {"C(GlobalPhase)"} spec_gates = filter_out_adjoint(set.union(native, matrix, decomposable)) if device_gates != spec_gates: raise CompileError( - "Gates in qml.device.operations and specification file do not match.\n" + "Gates in qml.device.operations and specification file do not match for " + f'"{device_name}".\n' f"Gates that present only in the device: {device_gates - spec_gates}\n" f"Gates that present only in spec: {spec_gates - device_gates}\n" ) diff --git a/frontend/catalyst/utils/toml.py b/frontend/catalyst/utils/toml.py index 1806d23c2c..abe0204343 100644 --- a/frontend/catalyst/utils/toml.py +++ b/frontend/catalyst/utils/toml.py @@ -260,24 +260,10 @@ def get_operation_properties(config_props: dict) -> OperationProperties: def patch_schema1_collections( - config, device_name, native_gate_props, matrix_decomp_props, decomp_props, observable_props + config, _device_name, native_gate_props, matrix_decomp_props, decomp_props ): # pylint: disable=too-many-arguments, too-many-branches """For old schema1 config files we deduce some information which was not explicitly encoded.""" - # TODO: remove after PR #642 is merged in lightning - # NOTE: we mark GlobalPhase as controllables even if `quantum_control` flag is False. This - # is what actual device reports. - if device_name == "lightning.kokkos": # pragma: nocover - native_gate_props["GlobalPhase"] = OperationProperties( - invertible=False, controllable=True, differentiable=True - ) - - # TODO: remove after PR #642 is merged in lightning - if device_name == "lightning.kokkos": # pragma: nocover - observable_props["Projector"] = OperationProperties( - invertible=False, controllable=False, differentiable=False - ) - # The deduction logic is the following: # * Most of the gates have their `C(Gate)` controlled counterparts. # * Some gates have to be decomposed if controlled version is used. Typically these are @@ -414,7 +400,6 @@ def load_device_capabilities( native_gate_props, matrix_decomp_props, decomp_props, - observable_props, ) return DeviceCapabilities( diff --git a/frontend/test/pytest/test_custom_devices.py b/frontend/test/pytest/test_custom_devices.py index 74e47bde0a..54d9215dee 100644 --- a/frontend/test/pytest/test_custom_devices.py +++ b/frontend/test/pytest/test_custom_devices.py @@ -60,7 +60,6 @@ "PSWAP", "SISWAP", "SQISW", - "CPhase", "BasisState", "QubitStateVector", "StatePrep", diff --git a/runtime/lib/backend/dummy/dummy_device.toml b/runtime/lib/backend/dummy/dummy_device.toml index d9fa3eaddf..82bdc0d933 100644 --- a/runtime/lib/backend/dummy/dummy_device.toml +++ b/runtime/lib/backend/dummy/dummy_device.toml @@ -19,7 +19,6 @@ CY = { properties = [ "invertible", "differentiable" ] } CZ = { properties = [ "invertible", "differentiable" ] } PhaseShift = { properties = [ "controllable", "invertible", "differentiable" ] } ControlledPhaseShift = { properties = [ "invertible", "differentiable" ] } -CPhase = { properties = [ "invertible", "differentiable" ] } RX = { properties = [ "controllable", "invertible", "differentiable" ] } RY = { properties = [ "controllable", "invertible", "differentiable" ] } RZ = { properties = [ "controllable", "invertible", "differentiable" ] }