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

[BUG] qml.Adjoint and qml.Pow do not commute when exponent is fractional #5812

Closed
1 task done
EmilianoG-byte opened this issue Jun 6, 2024 · 1 comment · Fixed by #5835
Closed
1 task done

[BUG] qml.Adjoint and qml.Pow do not commute when exponent is fractional #5812

EmilianoG-byte opened this issue Jun 6, 2024 · 1 comment · Fixed by #5835
Assignees
Labels
bug 🐛 Something isn't working

Comments

@EmilianoG-byte
Copy link
Collaborator

Expected behavior

Taking the qml.adjoint() of a powered-operator, i.e. an operator resulting from qml.pow, returns the same result whether we use lazy=True or lazy=False in qml.adjoint().

Actual behavior

Setting the flag lazy=False when using a fractional power (z) in qml.pow produces a matrix with the imaginary component having the opposite sign as with lazy=True. The correct matrix is the one with lazy=True

Additional information

No response

Source code

import pennylane as qml 

power = 0.5
op = qml.Hadamard(0)
powered_op = qml.pow(op, power, lazy=True)

powered_op_adj_true = qml.adjoint(powered_op, lazy=True)
matrix_true = qml.matrix(powered_op_adj_true)

powered_op_adj_false = qml.adjoint(powered_op, lazy=False)
matrix_false = qml.matrix(powered_op_adj_false)

np.allclose(matrix_true, matrix_false)
>> False

Tracebacks

No response

System information

Name: PennyLane
Version: 0.36.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: /Users/emiliano.godinez/Documents/software_development/pennylane-iqm/venv/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: pennylane_iqm, PennyLane_Lightning

Platform info:           macOS-14.5-arm64-arm-64bit
Python version:          3.9.19
Numpy version:           1.26.4
Scipy version:           1.13.1
Installed devices:
- iqm.remote (pennylane-iqm-0.0.1)
- default.clifford (PennyLane-0.36.0)
- default.gaussian (PennyLane-0.36.0)
- default.mixed (PennyLane-0.36.0)
- default.qubit (PennyLane-0.36.0)
- default.qubit.autograd (PennyLane-0.36.0)
- default.qubit.jax (PennyLane-0.36.0)
- default.qubit.legacy (PennyLane-0.36.0)
- default.qubit.tf (PennyLane-0.36.0)
- default.qubit.torch (PennyLane-0.36.0)
- default.qutrit (PennyLane-0.36.0)
- default.qutrit.mixed (PennyLane-0.36.0)
- null.qubit (PennyLane-0.36.0)
- lightning.qubit (PennyLane-Lightning-0.36.0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@EmilianoG-byte EmilianoG-byte added the bug 🐛 Something isn't working label Jun 6, 2024
@dwierichs
Copy link
Contributor

I'm not sure we have a well-defined behaviour for non-integer powers, because the power function has branch cuts in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants