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

Fix qnode_spectrum with interface="auto" #6622

Merged
merged 11 commits into from
Nov 22, 2024
Merged

Fix qnode_spectrum with interface="auto" #6622

merged 11 commits into from
Nov 22, 2024

Conversation

dwierichs
Copy link
Contributor

@dwierichs dwierichs commented Nov 21, 2024

Context:
An example from the docstring of qnode_spectrum is failing because the detection of trainable arguments fails when using Autograd via vanilla numpy inputs and interface="auto" (default).

Note that this problem is caused by a bug in qml.math.is_independent, but so far only surfaces in the specific context of qnode_spectrum, which uses this function to check a Jacobian to be constant.

Description of the Change:
Add a warning to the docs that pure numpy parameters are not supported.
Raise an error if pure numpy parameters are present.
Smaller updates relating to code quality/linting.

Benefits:
Fixes #6593

Possible Drawbacks:
N/A

Related GitHub Issues:
Closes #6593
[sc-78453]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md 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.

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.46%. Comparing base (9c1292d) to head (ffd908d).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6622   +/-   ##
=======================================
  Coverage   99.46%   99.46%           
=======================================
  Files         454      454           
  Lines       42644    42649    +5     
=======================================
+ Hits        42415    42420    +5     
  Misses        229      229           

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


🚨 Try these New Features:

@albi3ro albi3ro self-requested a review November 21, 2024 14:22
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Could we instead stop mapping "numpy" to "autograd" (by mapping "numpy" toNone) and raise an informative error if the interface is None`?

@dwierichs dwierichs requested a review from albi3ro November 21, 2024 21:17
doc/releases/changelog-dev.md Show resolved Hide resolved
pennylane/fourier/circuit_spectrum.py Show resolved Hide resolved
pennylane/fourier/qnode_spectrum.py Show resolved Hide resolved
pennylane/fourier/qnode_spectrum.py Show resolved Hide resolved
pennylane/fourier/qnode_spectrum.py Show resolved Hide resolved
pennylane/math/is_independent.py Show resolved Hide resolved
pennylane/math/is_independent.py Show resolved Hide resolved
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

👍

@JerryChen97 JerryChen97 self-requested a review November 22, 2024 16:00
@dwierichs dwierichs added the merge-ready ✔️ All tests pass and the PR is ready to be merged. label Nov 22, 2024
@dwierichs dwierichs enabled auto-merge (squash) November 22, 2024 17:04
@dwierichs dwierichs merged commit a48fbf5 into master Nov 22, 2024
45 checks passed
@dwierichs dwierichs deleted the fix-qnode-spectrum branch November 22, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-ready ✔️ All tests pass and the PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Documentation examples on pennylane.fourier.qnode_spectrum no longer work
3 participants