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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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
Copy link
Contributor

github-actions bot commented Jan 8, 2025

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@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 (fa72766) to head (3d1f90a).
Report is 2 commits behind head on main.

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

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

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