PennyLaneAI / pennylane

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.
https://pennylane.ai
Apache License 2.0
2.27k stars 585 forks source link

[BUG] Operations in `has_unitary_generator` do not really have unitary generators #4055

Closed dwierichs closed 1 year ago

dwierichs commented 1 year ago

Expected behavior

The name of an object in qml.ops.qubit.attributes can be understood easily without causing confusion and uses standard terminology.

Actual behavior

The attribute has_unitary_generator is confusing and does not adhere to the standard notion of "unitary" in physics/math. It contains the following two sets of operations:

Additional information

The cause of this mismatch likely is in the discrepancy between the naming of the attribute collection and its use case in the codebase. However, the docstring is very clear about considering PhaseShift as non-unitarily generated operation because of the $0$ eigenvalue of its generator, which means that the second set of operations mentioned above definitely should not be in there, or both the docstring and the naming need to be changed.

has_unitary_generator is used in the following two places:

Source code

No response

Tracebacks

No response

System information

pl dev

Existing GitHub issues

trbromley commented 1 year ago

This bug should be fixed by carrying out the following changes:

ejthomas commented 1 year ago

Hi, I'd like to work on this issue please 🙂

trbromley commented 1 year ago

Hi @ejthomas! That's awesome, you can check out our development guide or just post here if you have any questions. Good luck!

ejthomas commented 1 year ago

Hi all, I've opened a PR for this fix here (#4183). Interested to hear your thoughts - I hope I've understood correctly what was intended but happy to make any changes needed. Thanks!

ejthomas commented 1 year ago

Hi, thanks for assigning me on this issue. I noticed that the issue has been reopened - is there anything else I need to do? It seems that to be counted on UnitaryHack before today's deadline the issue needs to be closed.

trbromley commented 1 year ago

Hi @ejthomas! Congrats on getting this merged and thank you for being a contributor to PennyLane! :rocket:

As part of our 0.31 release, we're planning to promote UnitaryHack contributions to PennyLane on social media. This is completely optional, but would you like to be mentioned in our social media posts? Specifically, we'd need either your Twitter profile, your LinkedIn profile, or your name.

ejthomas commented 1 year ago

Thanks! That's great, I'm totally happy to be mentioned - my LinkedIn is https://www.linkedin.com/in/edward-thomas-902b17a4 (Edward Thomas)