diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index fd68e99648..e8e5540baa 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -83,6 +83,9 @@ ### Bug fixes +* Bug fix for `_pauli_word` of `QuantumScriptSerializer`. `_pauli_word` can process `PauliWord` object: `I`. + [(#919)](https://github.com/PennyLaneAI/pennylane-lightning/pull/919) + * Bug fix for analytic `probs` in the `lightning.tensor` C++ layer. [(#906)](https://github.com/PennyLaneAI/pennylane-lightning/pull/906) diff --git a/doc/lightning_tensor/device.rst b/doc/lightning_tensor/device.rst index 0d5b973d4b..cf125c07cc 100644 --- a/doc/lightning_tensor/device.rst +++ b/doc/lightning_tensor/device.rst @@ -22,7 +22,7 @@ and greater. This device supports both exact and finite shots measurements. Curr The ``lightning.tensor`` device is designed for expectation value calculations. Measurements of ``qml.probs()`` or ``qml.state()`` return dense vectors of dimension :math:`2^{n_\text{qubits}}`, so they should only be used for small systems. -.. note:: ``qml.Hermitian`` is currently only supported for single wires. You can use ``qml.pauli_decompose`` on smaller matrices to obtain a compatible Pauli decomposition in the meantime. As a result, it is advisable to disable ``new_opmath`` for the ``lightning.tensor`` device to prevent the implicit conversion of Pauli words to multi-wire Hermitian observables. This limitation will be addressed once multi-wires Hermitian observables can be supported with ``cutensornet``. +.. note:: ``qml.Hermitian`` is currently only supported for single wires. You can use ``qml.pauli_decompose`` on smaller matrices to obtain a compatible Pauli decomposition in the meantime. Users also have the flexibility to customize these parameters according to their specific needs with: diff --git a/pennylane_lightning/core/_serialize.py b/pennylane_lightning/core/_serialize.py index edc60b667c..9cd80c9550 100644 --- a/pennylane_lightning/core/_serialize.py +++ b/pennylane_lightning/core/_serialize.py @@ -285,6 +285,9 @@ def _pauli_word(self, observable, wires_map: dict = None): def map_wire(wire: int): return wires_map[wire] if wires_map else wire + if len(observable) == 0: + return self.named_obs(PAULI_NAME_MAP["I"], [0]) + if len(observable) == 1: wire, pauli = list(observable.items())[0] return self.named_obs(PAULI_NAME_MAP[pauli], [map_wire(wire)]) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 8fc72a7939..42a9e08d77 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.39.0-dev30" +__version__ = "0.39.0-dev31" diff --git a/tests/test_execute.py b/tests/test_execute.py index 4e2eb03327..505c705543 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -33,9 +33,6 @@ class TestQChem: def test_VQE_gradients(self, diff_method, tol): """Test if the VQE procedure returns the expected gradients.""" - if qml.operation.active_new_opmath() and device_name == "lightning.tensor": - pytest.skip("The new operation math is not yet fully supported for lightning.tensor") - symbols = ["H", "H"] geometry = np.array(