Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix TrotterProduct differentiability with parameter-shift bug #6432

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@

<h3>Bug fixes 🐛</h3>

* Fixes incorrect differentiation of `TrotterProduct` when using `diff_method="parameter-shift"`.
[(#6432)](https://github.com/PennyLaneAI/pennylane/pull/6432)

* Patches the `math` module to function with autoray 0.7.0.
[(#6429)](https://github.com/PennyLaneAI/pennylane/pull/6429)

Expand Down
1 change: 1 addition & 0 deletions pennylane/ops/op_math/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class Exp(ScalarSymbolicOp, Operation):

"""

grad_method = None
control_wires = Wires([])
_name = "Exp"

Expand Down
2 changes: 2 additions & 0 deletions pennylane/templates/subroutines/trotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def my_circ(c1, c2, time):
(tensor(0.00961064, requires_grad=True), tensor(-0.12338274, requires_grad=True), tensor(-5.43401259, requires_grad=True))
"""

grad_method = None

@classmethod
def _primitive_bind_call(cls, *args, **kwargs):
# accepts no wires, so bypasses the wire processing.
Expand Down
2 changes: 1 addition & 1 deletion tests/ops/functions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
(qml.s_prod(1.1, qml.RX(1.1, 0)), {}),
(qml.prod(qml.PauliX(0), qml.PauliY(1), qml.PauliZ(0)), {}),
(qml.ctrl(qml.RX(1.1, 0), 1), {}),
(qml.exp(qml.PauliX(0), 1.1), {}),
(qml.exp(qml.PauliX(0), 1.1), {"skip_differentiation": True}),
andrijapau marked this conversation as resolved.
Show resolved Hide resolved
(qml.pow(qml.IsingXX(1.1, [0, 1]), 2.5), {}),
(qml.ops.Evolution(qml.PauliX(0), 5.2), {}),
(qml.QutritBasisState([1, 2, 0], wires=[0, 1, 2]), {"skip_differentiation": True}),
Expand Down
1 change: 0 additions & 1 deletion tests/templates/test_subroutines/test_trotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def test_copy(self, hamiltonian, time, n, order):
assert op.hyperparameters == new_op.hyperparameters
assert op is not new_op

@pytest.mark.xfail(reason="https://github.com/PennyLaneAI/pennylane/issues/6333", strict=False)
@pytest.mark.parametrize("hamiltonian", test_hamiltonians)
def test_standard_validity(self, hamiltonian):
"""Test standard validity criteria using assert_valid."""
Expand Down
Loading