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

[Frontend] Fix AutoGraph not converting functions wrapped by 'adjoint', 'grad', etc. #336

Merged
merged 6 commits into from
Oct 26, 2023

Conversation

dime10
Copy link
Contributor

@dime10 dime10 commented Oct 25, 2023

The following example would fail before the fix:

 def inner(n):
    for i in range(n):
      qml.T(i)

  @qjit(autograph=True)
  @qml.qnode(qml.device("lightning.qubit", wires=5))
  def f(n: int):
      adjoint(inner)(n)
      return qml.state()

[sc-48511]

@dime10 dime10 added the bug Something isn't working label Oct 25, 2023
Also reorgonaize & format recent entries.
Copy link
Contributor

@erick-xanadu erick-xanadu left a comment

Choose a reason for hiding this comment

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

I am not an expert in autograph yet. The tests look good. I have noticed that some tests use the variable backend while others are hard coded to be lightning. I think it is best if we always use backend.

frontend/catalyst/ag_primitives.py Outdated Show resolved Hide resolved
frontend/catalyst/ag_primitives.py Outdated Show resolved Hide resolved
@dime10
Copy link
Contributor Author

dime10 commented Oct 26, 2023

The tests look good. I have noticed that some tests use the variable backend while others are hard coded to be lightning. I think it is best if we always use backend.

I deliberately didn't use it here because I'm only testing frontend functionality. I just had to use a QNode to use adjoint, otherwise I wouldn't have. I agree that most tests should use backend, unless they are not testing execution functionality.

Co-authored-by: erick-xanadu <110487834+erick-xanadu@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b729a19) 99.56% compared to head (2f79f1b) 99.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #336   +/-   ##
=======================================
  Coverage   99.56%   99.56%           
=======================================
  Files          42       42           
  Lines        7404     7410    +6     
  Branches      432      433    +1     
=======================================
+ Hits         7372     7378    +6     
  Misses         16       16           
  Partials       16       16           
Files Coverage Δ
frontend/catalyst/ag_primitives.py 97.92% <100.00%> (+0.06%) ⬆️

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

@dime10 dime10 merged commit 0849e07 into main Oct 26, 2023
18 checks passed
@dime10 dime10 deleted the ag_hotfix branch October 26, 2023 18:54
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 this pull request may close these issues.

2 participants