[BUG] Incorrect order of adjoint operations in HilbertSchmidt
template
#6586
Labels
bug 🐛
Something isn't working
HilbertSchmidt
template
#6586
Expected behavior
In the current implementation of the HilbertSchmidt template, the adjoint of the operations in the function v_function is applied using the following code:
decomp_ops.extend(qml.adjoint(op_v, lazy=False) for op_v in v_tape.operations)
However, this might not be correct as the adjoint should be applied in reverse order. This was noticed in the following test case:
The output shows that since v_function involves RZ followed by RX, the adjoint should likely be applied in the opposite order. The fix would involve changing the line to:
decomp_ops.extend(qml.adjoint(op_v, lazy=False) for op_v in reversed(v_tape.operations))
Actual behavior
The adjoint operations are applied in the incorrect order, which may result in incorrect behavior for certain quantum circuits.
Additional information
No response
Source code
Tracebacks
No response
System information
Name: PennyLane Version: 0.39.0 Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network. Home-page: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /usr/local/lib/python3.10/dist-packages Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions Required-by: PennyLane_Lightning Platform info: Linux-6.1.85+-x86_64-with-glibc2.35 Python version: 3.10.12 Numpy version: 1.26.4 Scipy version: 1.13.1 Installed devices: - lightning.qubit (PennyLane_Lightning-0.39.0) - default.clifford (PennyLane-0.39.0) - default.gaussian (PennyLane-0.39.0) - default.mixed (PennyLane-0.39.0) - default.qubit (PennyLane-0.39.0) - default.qutrit (PennyLane-0.39.0) - default.qutrit.mixed (PennyLane-0.39.0) - default.tensor (PennyLane-0.39.0) - null.qubit (PennyLane-0.39.0) - reference.qubit (PennyLane-0.39.0)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: