Skip to content

Commit

Permalink
Remove deprecated pennylane code (#1168)
Browse files Browse the repository at this point in the history
As name says. ~I've also temporarily added a warning filter to promote
`PennyLaneDeprecationWarning`s to errors. I'll remove it once CI passes
in this PR.~ Removed.
  • Loading branch information
mudit2812 authored Oct 2, 2024
1 parent 934726f commit a013f12
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enzyme=v0.0.149

# For a custom PL version, update the package version here and at
# 'doc/requirements.txt
pennylane=0.39.0.dev16
pennylane=0.39.0.dev26

# For a custom LQ/LK version, update the package version here and at
# 'doc/requirements.txt'. Also, update the 'LIGHTNING_GIT_TAG' at
Expand Down
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@

<h3>Internal changes</h3>

* Remove deprecated pennylane code across the frontend.
[(#1168)](https://github.com/PennyLaneAI/catalyst/pull/1168)

* Update Enzyme to version `v0.0.149`.
[(#1142)](https://github.com/PennyLaneAI/catalyst/pull/1142)

Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ lxml_html_clean
--extra-index-url https://test.pypi.org/simple/
pennylane-lightning-kokkos==0.38.0
pennylane-lightning==0.38.0
pennylane==0.39.0.dev16
pennylane==0.39.0.dev26
6 changes: 4 additions & 2 deletions frontend/catalyst/device/qjit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class BackendInfo:

# pylint: disable=too-many-branches
@debug_logger
def extract_backend_info(device: qml.QubitDevice, capabilities: DeviceCapabilities) -> BackendInfo:
def extract_backend_info(
device: qml.devices.QubitDevice, capabilities: DeviceCapabilities
) -> BackendInfo:
"""Extract the backend info from a quantum device. The device is expected to carry a reference
to a valid TOML config file."""

Expand Down Expand Up @@ -472,7 +474,7 @@ def get_device_toml_config(device) -> TOMLDocument:
# The expected case: device specifies its own config.
toml_file = device.config
else:
# TODO: Remove this section when `qml.Device`s are guaranteed to have their own config file
# TODO: Remove this section when `qml.devices.Device`s are guaranteed to have their own config file
# field.
device_lpath = pathlib.Path(get_lib_path("runtime", "RUNTIME_LIB_DIR"))

Expand Down
3 changes: 2 additions & 1 deletion frontend/catalyst/jax_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import jax
import jax.numpy as jnp
import pennylane as qml
from pennylane import QubitDevice, QubitUnitary, QueuingManager
from pennylane import QubitUnitary, QueuingManager
from pennylane.devices import QubitDevice
from pennylane.measurements import DensityMatrixMP, MeasurementProcess, StateMP
from pennylane.operation import AnyWires, Operation, Operator, Wires
from pennylane.ops import Adjoint, Controlled, ControlledOp
Expand Down
2 changes: 1 addition & 1 deletion frontend/catalyst/third_party/cuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def wrap_fn(fn):


# Do we need to reimplement apply for every child?
class BaseCudaInstructionSet(qml.QubitDevice):
class BaseCudaInstructionSet(qml.devices.QubitDevice):
"""Base instruction set for CUDA-Quantum devices"""

pennylane_requires = ">=0.34"
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/pytest/test_braket_local_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

try:
qml.device("braket.local.qubit", backend="default", wires=1)
except qml._device.DeviceError:
except qml.DeviceError:
pytest.skip(
"skipping Braket local tests because ``amazon-braket-pennylane-plugin`` is not installed",
allow_module_level=True,
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/pytest/test_config_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)


class DeviceToBeTested(qml.QubitDevice):
class DeviceToBeTested(qml.devices.QubitDevice):
"""Test device"""

name = "Dummy Device"
Expand Down
6 changes: 3 additions & 3 deletions frontend/test/pytest/test_custom_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
def test_custom_device_load():
"""Test that custom device can run using Catalyst."""

class DummyDevice(qml.QubitDevice):
class DummyDevice(qml.devices.QubitDevice):
"""Dummy Device"""

name = "Dummy Device"
Expand Down Expand Up @@ -184,7 +184,7 @@ def f():
def test_custom_device_bad_directory():
"""Test that custom device error."""

class DummyDevice(qml.QubitDevice):
class DummyDevice(qml.devices.QubitDevice):
"""Dummy Device"""

name = "Dummy Device"
Expand Down Expand Up @@ -224,7 +224,7 @@ def f():
def test_custom_device_no_c_interface():
"""Test that custom device error."""

class DummyDevice(qml.QubitDevice):
class DummyDevice(qml.devices.QubitDevice):
"""Dummy Device"""

name = "Dummy Device"
Expand Down
7 changes: 7 additions & 0 deletions frontend/test/pytest/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def basic_entangler_layers(weights):
assert np.allclose(interpreted_fn(params), jitted_fn(params))


@pytest.mark.filterwarnings("ignore::pennylane.PennyLaneDeprecationWarning")
def test_basis_state_preparation(backend):
"""Test basis state preparation."""

Expand Down Expand Up @@ -508,6 +509,7 @@ def flip_sign():
assert np.allclose(jitted_fn(), interpreted_fn())


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_single(backend):
"""Test broadcast single."""

Expand All @@ -522,6 +524,7 @@ def broadcast_single(pars):
assert np.allclose(jitted_fn(params), interpreted_fn(params))


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_double(backend):
"""Test broadcast double."""

Expand All @@ -536,6 +539,7 @@ def broadcast_double(pars):
assert np.allclose(jitted_fn(params), interpreted_fn(params))


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_chain(backend):
"""Test broadcast chain."""

Expand All @@ -550,6 +554,7 @@ def broadcast_chain(pars):
assert np.allclose(jitted_fn(params), interpreted_fn(params))


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_ring(backend):
"""Test broadcast ring."""

Expand All @@ -564,6 +569,7 @@ def broadcast_ring(pars):
assert np.allclose(jitted_fn(params), interpreted_fn(params))


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_pyramid(backend):
"""Test broadcast pyramid."""

Expand All @@ -578,6 +584,7 @@ def broadcast_pyramid(pars):
assert np.allclose(jitted_fn(params), interpreted_fn(params))


@pytest.mark.filterwarnings("ignore:qml.broadcast:pennylane.PennyLaneDeprecationWarning")
def test_broadcast_all_to_all(backend):
"""Test broadcast all to all."""

Expand Down

0 comments on commit a013f12

Please sign in to comment.