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

Raise RuntimeWarning if jax > 0.4.28 is installed #6864

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Jan 20, 2025

Jax is not compatible with pennylane for versions > 0.4.28 (confirmed by the test logs of this PR). This PR raises a RuntimeWarning if version > 0.4.28 is installed:

  • In QNode.__init__ if the specified interface resolves to JAX or JAX_JIT
  • In execute if the original interface was "auto" or None and the resolved interface is JAX or JAX_JIT. I don't raise a warning if the original interface was jax/jax-jit because if that is the case, QNode.__init__ should've already raised a warning.
  • This is done by adding a _validate_jax_version private kwarg to qml.math.get_canonical_interface_name, which is called by QNode.__init__, and qml.workflow.resolution._resolve_interface (used by qml.execute), so that both those entry points can raise warnings if appropriate.

Possible drawbacks:
None. The only annoying is that our CI uses supported versions of jax, so we can't get coverage for the runtime warning. I've added a # pragma: no cover to work around this, but I'm not particularly happy about it.

[sc-82570]

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 Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.51%. Comparing base (5910ef7) to head (256b673).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6864      +/-   ##
==========================================
- Coverage   99.59%   99.51%   -0.09%     
==========================================
  Files         478      479       +1     
  Lines       45294    45443     +149     
==========================================
+ Hits        45112    45222     +110     
- Misses        182      221      +39     

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

@mudit2812 mudit2812 requested a review from josh146 January 20, 2025 21:09
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.

So why are we not validating if someone specifies interface="jax"? Or am I missing something?

@mudit2812 mudit2812 requested a review from albi3ro January 21, 2025 19:26
@mudit2812 mudit2812 requested a review from andrijapau January 30, 2025 22:07
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.

3 participants