From d1db2bc1b11dedfe69aac770d3ec1f6a16d414f9 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Fri, 20 Sep 2024 18:33:59 +0000 Subject: [PATCH 1/7] initial commit --- pennylane_lightning/core/_serialize.py | 3 +++ tests/test_execute.py | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pennylane_lightning/core/_serialize.py b/pennylane_lightning/core/_serialize.py index edc60b667c..7b6b1886a6 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"], [map_wire(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/tests/test_execute.py b/tests/test_execute.py index 4e2eb03327..b4db301581 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( @@ -71,6 +68,8 @@ def test_VQE_gradients(self, diff_method, tol): qml.expval(H) + # print(H) + num_params = len(excitations) tape.trainable_params = np.linspace(1, num_params, num_params, dtype=int).tolist() From 41c22b50ebaef38a63a01d83987ba8ca6bfce1b8 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Fri, 20 Sep 2024 18:35:20 +0000 Subject: [PATCH 2/7] Auto update version from '0.39.0-dev28' to '0.39.0-dev30' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 83c48476df..8fc72a7939 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-dev28" +__version__ = "0.39.0-dev30" From 3b5c2c590d15f893464bfb92ba828e7f0d6829b8 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Fri, 20 Sep 2024 18:40:41 +0000 Subject: [PATCH 3/7] add changelog --- .github/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 818522dbb5..60e8edfef5 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -80,6 +80,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) From 271c444825bb243102c4233888df74d6964a9488 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Fri, 20 Sep 2024 18:44:15 +0000 Subject: [PATCH 4/7] update docsting accordingly --- doc/lightning_tensor/device.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From c89525de20dd1b8961662984dec9d41fb18dfa07 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Fri, 20 Sep 2024 18:46:20 +0000 Subject: [PATCH 5/7] tidy up typos --- tests/test_execute.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_execute.py b/tests/test_execute.py index b4db301581..505c705543 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -68,8 +68,6 @@ def test_VQE_gradients(self, diff_method, tol): qml.expval(H) - # print(H) - num_params = len(excitations) tape.trainable_params = np.linspace(1, num_params, num_params, dtype=int).tolist() From 5378b6a34281af7f65f7baebacfa98cac97c5216 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Fri, 20 Sep 2024 18:52:41 +0000 Subject: [PATCH 6/7] Auto update version from '0.39.0-dev30' to '0.39.0-dev31' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 041cf1eaa9a13879d723279cb6b566701ef82909 Mon Sep 17 00:00:00 2001 From: Shuli Shu <31480676+multiphaseCFD@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:13:29 -0400 Subject: [PATCH 7/7] Update pennylane_lightning/core/_serialize.py Co-authored-by: Mudit Pandey --- pennylane_lightning/core/_serialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_serialize.py b/pennylane_lightning/core/_serialize.py index 7b6b1886a6..9cd80c9550 100644 --- a/pennylane_lightning/core/_serialize.py +++ b/pennylane_lightning/core/_serialize.py @@ -286,7 +286,7 @@ 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"], [map_wire(0)]) + return self.named_obs(PAULI_NAME_MAP["I"], [0]) if len(observable) == 1: wire, pauli = list(observable.items())[0]