From 72c2584544f8614a4381ab42257c67f8aaa1d83d Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Mon, 12 Aug 2024 10:57:08 -0400 Subject: [PATCH 1/5] Use `decomposition` instead of `Operator.expand` --- 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 4f8a9ab567..1ec5e5ddd1 100644 --- a/pennylane_lightning/core/_serialize.py +++ b/pennylane_lightning/core/_serialize.py @@ -404,7 +404,7 @@ def get_wires(operation, single_op): uses_stateprep = True continue if isinstance(operation, Rot): - op_list = operation.expand().operations + op_list = operation.decomposition() else: op_list = [operation] From bd7cf38dd2525f02b43c4f1d106d3120cb6c1a14 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Mon, 12 Aug 2024 15:05:24 +0000 Subject: [PATCH 2/5] Auto update version from '0.38.0-dev28' to '0.38.0-dev29' --- 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 1e0e19350b..68d119cc24 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.38.0-dev28" +__version__ = "0.38.0-dev29" From 70f690ebf0a93e7a76272d62837886fcef2ad40a Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Mon, 12 Aug 2024 11:48:32 -0400 Subject: [PATCH 3/5] make codecov happy --- tests/test_serialize.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_serialize.py b/tests/test_serialize.py index 5de35aa659..6860c19410 100644 --- a/tests/test_serialize.py +++ b/tests/test_serialize.py @@ -740,6 +740,29 @@ def test_basic_circuit(self, wires_map): ) assert s == s_expected + @pytest.mark.parametrize("wires_map", [wires_dict, None]) + def test_Rot_in_circuit(self, wires_map): + """Test expected serialization for a circuit with Rot which should be decomposed""" + + with qml.queuing.AnnotatedQueue() as q: + qml.Rot(0.1, 0.2, 0.3, wires=0) + + tape = qml.tape.QuantumScript.from_queue(q) + s = QuantumScriptSerializer(device_name).serialize_ops(tape, wires_map) + s_expected = ( + ( + ["RZ", "RY", "RZ"], + [np.array([0.1]), np.array([0.2]), np.array([0.3])], + [[0], [0], [0]], + [False, False, False], + [[], [], []], + [[], [], []], + [[], [], []], + ), + False, + ) + assert s == s_expected + @pytest.mark.parametrize("wires_map", [wires_dict, None]) def test_basic_circuit_not_implemented_ctrl_ops(self, wires_map): """Test expected serialization for a simple circuit""" From 8cbde2bb0ade5232fbc8ecdc0d8fbb2722f6327a Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Mon, 12 Aug 2024 13:20:21 -0400 Subject: [PATCH 4/5] changelog entry --- .github/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index b4b4bfb004..0ce73eb371 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -70,6 +70,9 @@ * Move `setBasisState`, `setStateVector` and `resetStateVector` from `StateVectorLQubitManaged` to `StateVectorLQubit`. [(#841)](https://github.com/PennyLaneAI/pennylane-lightning/pull/841) +* Remove use of the deprecated `Operator.expand` in favour of `Operator.decomposition` + [(#846)](https://github.com/PennyLaneAI/pennylane-lightning/pull/846) + ### Documentation * Updated the README and added citation format for Lightning arxiv preprint. @@ -105,7 +108,7 @@ This release contains contributions from (in alphabetical order): -Ali Asadi, Amintor Dusko, Vincent Michaud-Rioux, Erick Ochoa Lopez, Lee J. O'Riordan, Mudit Pandey, Shuli Shu, Paul Haochen Wang +Ali Asadi, Astral Cai, Amintor Dusko, Vincent Michaud-Rioux, Erick Ochoa Lopez, Lee J. O'Riordan, Mudit Pandey, Shuli Shu, Paul Haochen Wang --- From c5e1dc26a1f72882727843c089947e7f9c0789a2 Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Mon, 12 Aug 2024 13:23:15 -0400 Subject: [PATCH 5/5] Update .github/CHANGELOG.md Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com> --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 0ce73eb371..45a716643d 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -70,7 +70,7 @@ * Move `setBasisState`, `setStateVector` and `resetStateVector` from `StateVectorLQubitManaged` to `StateVectorLQubit`. [(#841)](https://github.com/PennyLaneAI/pennylane-lightning/pull/841) -* Remove use of the deprecated `Operator.expand` in favour of `Operator.decomposition` +* Remove use of the deprecated `Operator.expand` in favour of `Operator.decomposition`. [(#846)](https://github.com/PennyLaneAI/pennylane-lightning/pull/846) ### Documentation