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

Improve error message for invalid measurement in adjoint() region #1425

Merged
merged 9 commits into from
Jan 13, 2025

Conversation

sengthai
Copy link
Contributor

@sengthai sengthai commented Jan 8, 2025

Context:
Improve the error message when using measure within an adjoin() region.

Example

import pennylane as qml
from pennylane import qjit
from catalyst import measure

dev = qml.device("lightning.qubit", wires=1)

@qjit
@qml.qnode(dev)
def circuit():
    def foo():
        measure(wires=0)
    qml.adjoint(foo)()
    return qml.expval(qml.PauliZ(0))

print(circuit())

Description of the Change:
Write and insert an error message "Measurements are not invertible and cannot be used within an adjoint() region."

Related GitHub Issues:
#1188

@sengthai sengthai requested a review from dime10 January 8, 2025 21:02
@dime10
Copy link
Contributor

dime10 commented Jan 9, 2025

@sengthai Have a look at the failing CI, it looks like you need to update the corresponding tests with the new error message :)

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (d05392b) to head (0e786f7).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1425      +/-   ##
==========================================
- Coverage   96.67%   96.67%   -0.01%     
==========================================
  Files          75       75              
  Lines        8230     8229       -1     
  Branches      859      859              
==========================================
- Hits         7956     7955       -1     
  Misses        221      221              
  Partials       53       53              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sengthai sengthai requested a review from dime10 January 10, 2025 19:42
Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

sengthai and others added 2 commits January 10, 2025 18:26
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
@sengthai
Copy link
Contributor Author

I appreciate your suggestion, @dime10. 🚀

@sengthai sengthai merged commit 55d424b into main Jan 13, 2025
26 checks passed
@sengthai sengthai deleted the improve-adjoint-error-msg branch January 13, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants