diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 913bd6ead..5b421121d 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -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) diff --git a/pennylane_lightning/lightning_tensor/backends/quimb/_mps.py b/pennylane_lightning/lightning_tensor/backends/quimb/_mps.py index db4836691..e7677b4fe 100644 --- a/pennylane_lightning/lightning_tensor/backends/quimb/_mps.py +++ b/pennylane_lightning/lightning_tensor/backends/quimb/_mps.py @@ -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 @@ -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}") diff --git a/pennylane_lightning/lightning_tensor/lightning_tensor.py b/pennylane_lightning/lightning_tensor/lightning_tensor.py index 3d2a457e4..831625e09 100644 --- a/pennylane_lightning/lightning_tensor/lightning_tensor.py +++ b/pennylane_lightning/lightning_tensor/lightning_tensor.py @@ -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 @@ -103,7 +103,6 @@ def __init__( c_dtype=np.complex128, **kwargs, ): - if not accepted_backends(backend): raise ValueError(f"Unsupported backend: {backend}") @@ -111,7 +110,7 @@ def __init__( 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) @@ -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): @@ -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( @@ -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 @@ -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( @@ -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." ) diff --git a/setup.py b/setup.py index a84f8619a..d231306a9 100644 --- a/setup.py +++ b/setup.py @@ -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 diff --git a/tests/lightning_tensor/test_lightning_tensor.py b/tests/lightning_tensor/test_lightning_tensor.py index 0c9ec1d29..aacc94bad 100644 --- a/tests/lightning_tensor/test_lightning_tensor.py +++ b/tests/lightning_tensor/test_lightning_tensor.py @@ -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: @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)