Skip to content

Commit

Permalink
Merge branch 'master' into update/kokkos_version
Browse files Browse the repository at this point in the history
  • Loading branch information
mlxd committed May 15, 2024
2 parents 37aa9eb + 628d47e commit 61605de
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

### Breaking changes

* Changed the name of `default.tensor` to `lightning.tensor` with the `quimb` backend.
[(#730)](https://github.com/PennyLaneAI/pennylane-lightning/pull/730)

* `dynamic_one_shot` uses shot-vectors in the auxiliary tape to tell the device how many times to repeat the tape. Lightning-Qubit is updated accordingly.
[(#724)](https://github.com/PennyLaneAI/pennylane-lightning/pull/724)

Expand Down
5 changes: 2 additions & 3 deletions pennylane_lightning/lightning_tensor/backends/quimb/_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@


def stopping_condition(op: qml.operation.Operator) -> bool:
"""A function that determines if an operation is supported by ``default.tensor`` for this interface."""
"""A function that determines if an operation is supported by ``lightning.tensor`` for this interface."""
return op.name in _operations # pragma: no cover


def accepted_observables(obs: qml.operation.Operator) -> bool:
"""A function that determines if an observable is supported by ``default.tensor`` for this interface."""
"""A function that determines if an observable is supported by ``lightning.tensor`` for this interface."""
return obs.name in _observables # pragma: no cover


Expand All @@ -138,7 +138,6 @@ class QuimbMPS:
"""

def __init__(self, num_wires, interf_opts, dtype=np.complex128):

if dtype not in [np.complex64, np.complex128]: # pragma: no cover
raise TypeError(f"Unsupported complex type: {dtype}")

Expand Down
19 changes: 9 additions & 10 deletions pennylane_lightning/lightning_tensor/lightning_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@


def accepted_backends(backend: str) -> bool:
"""A function that determines whether or not a backend is supported by ``default.tensor``."""
"""A function that determines whether or not a backend is supported by ``lightning.tensor``."""
return backend in _backends


def accepted_methods(method: str) -> bool:
"""A function that determines whether or not a method is supported by ``default.tensor``."""
"""A function that determines whether or not a method is supported by ``lightning.tensor``."""
return method in _methods


Expand Down Expand Up @@ -103,15 +103,14 @@ def __init__(
c_dtype=np.complex128,
**kwargs,
):

if not accepted_backends(backend):
raise ValueError(f"Unsupported backend: {backend}")

if not accepted_methods(method):
raise ValueError(f"Unsupported method: {method}")

if shots is not None:
raise ValueError("default.tensor does not support finite shots.")
raise ValueError("lightning.tensor does not support finite shots.")

super().__init__(wires=wires, shots=shots)

Expand Down Expand Up @@ -143,13 +142,13 @@ def __init__(
for arg in kwargs:
if arg not in self._device_options:
raise TypeError(
f"Unexpected argument: {arg} during initialization of the default.tensor device."
f"Unexpected argument: {arg} during initialization of the lightning.tensor device."
)

@property
def name(self):
"""The name of the device."""
return "default.tensor"
return "lightning.tensor"

@property
def num_wires(self):
Expand Down Expand Up @@ -266,7 +265,7 @@ def compute_derivatives(
Tuple: The Jacobian for each trainable parameter.
"""
raise NotImplementedError(
"The computation of derivatives has yet to be implemented for the default.tensor device."
"The computation of derivatives has yet to be implemented for the lightning.tensor device."
)

def execute_and_compute_derivatives(
Expand All @@ -284,7 +283,7 @@ def execute_and_compute_derivatives(
tuple: A numeric result of the computation and the gradient.
"""
raise NotImplementedError(
"The computation of derivatives has yet to be implemented for the default.tensor device."
"The computation of derivatives has yet to be implemented for the lightning.tensor device."
)

# pylint: disable=unused-argument
Expand Down Expand Up @@ -323,7 +322,7 @@ def compute_vjp(
tensor-like: A numeric result of computing the vector-Jacobian product.
"""
raise NotImplementedError(
"The computation of vector-Jacobian product has yet to be implemented for the default.tensor device."
"The computation of vector-Jacobian product has yet to be implemented for the lightning.tensor device."
)

def execute_and_compute_vjp(
Expand All @@ -344,5 +343,5 @@ def execute_and_compute_vjp(
Tuple, Tuple: the result of executing the scripts and the numeric result of computing the vector-Jacobian product
"""
raise NotImplementedError(
"The computation of vector-Jacobian product has yet to be implemented for the default.tensor device."
"The computation of vector-Jacobian product has yet to be implemented for the lightning.tensor device."
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def build_extension(self, ext: CMakeExtension):
pennylane_plugins = [device_name + " = pennylane_lightning." + backend + ":Lightning" + suffix]
if suffix == "Qubit":
pennylane_plugins.append(
"default.tensor = pennylane_lightning.lightning_tensor:LightningTensor"
"lightning.tensor = pennylane_lightning.lightning_tensor:LightningTensor"
)

pkg_suffix = "" if suffix == "Qubit" else "_" + suffix
Expand Down
16 changes: 8 additions & 8 deletions tests/lightning_tensor/test_lightning_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_device_name_and_init(num_wires, c_dtype):
"""Test the class initialization and returned properties."""
wires = Wires(range(num_wires)) if num_wires else None
dev = LightningTensor(wires=wires, c_dtype=c_dtype)
assert dev.name == "default.tensor"
assert dev.name == "lightning.tensor"
assert dev.c_dtype == c_dtype
assert dev.wires == wires
if num_wires is None:
Expand All @@ -48,7 +48,7 @@ def test_device_name_and_init(num_wires, c_dtype):

def test_device_available_as_plugin():
"""Test that the device can be instantiated using ``qml.device``."""
dev = qml.device("default.tensor", wires=2)
dev = qml.device("lightning.tensor", wires=2)
assert isinstance(dev, LightningTensor)


Expand All @@ -70,14 +70,14 @@ def test_invalid_keyword_arg():
"""Test an invalid keyword argument."""
with pytest.raises(
TypeError,
match=f"Unexpected argument: fake_arg during initialization of the default.tensor device.",
match=f"Unexpected argument: fake_arg during initialization of the lightning.tensor device.",
):
LightningTensor(fake_arg=None)


def test_invalid_shots():
"""Test that an error is raised if finite number of shots are requestd."""
with pytest.raises(ValueError, match="default.tensor does not support finite shots."):
with pytest.raises(ValueError, match="lightning.tensor does not support finite shots."):
LightningTensor(shots=5)


Expand All @@ -92,7 +92,7 @@ def test_compute_derivatives():
dev = LightningTensor()
with pytest.raises(
NotImplementedError,
match="The computation of derivatives has yet to be implemented for the default.tensor device.",
match="The computation of derivatives has yet to be implemented for the lightning.tensor device.",
):
dev.compute_derivatives(circuits=None)

Expand All @@ -102,7 +102,7 @@ def test_execute_and_compute_derivatives():
dev = LightningTensor()
with pytest.raises(
NotImplementedError,
match="The computation of derivatives has yet to be implemented for the default.tensor device.",
match="The computation of derivatives has yet to be implemented for the lightning.tensor device.",
):
dev.execute_and_compute_derivatives(circuits=None)

Expand All @@ -118,7 +118,7 @@ def test_compute_vjp():
dev = LightningTensor()
with pytest.raises(
NotImplementedError,
match="The computation of vector-Jacobian product has yet to be implemented for the default.tensor device.",
match="The computation of vector-Jacobian product has yet to be implemented for the lightning.tensor device.",
):
dev.compute_vjp(circuits=None, cotangents=None)

Expand All @@ -128,6 +128,6 @@ def test_execute_and_compute_vjp():
dev = LightningTensor()
with pytest.raises(
NotImplementedError,
match="The computation of vector-Jacobian product has yet to be implemented for the default.tensor device.",
match="The computation of vector-Jacobian product has yet to be implemented for the lightning.tensor device.",
):
dev.execute_and_compute_vjp(circuits=None, cotangents=None)

0 comments on commit 61605de

Please sign in to comment.