-
Notifications
You must be signed in to change notification settings - Fork 616
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
base: master
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6864 +/- ##
=======================================
Coverage 99.60% 99.60%
=======================================
Files 476 476
Lines 45182 45195 +13
=======================================
+ Hits 45002 45015 +13
Misses 180 180 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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?
@@ -551,7 +551,7 @@ def __init__( | |||
# input arguments | |||
self.func = func | |||
self.device = device | |||
self._interface = get_canonical_interface_name(interface) | |||
self._interface = get_canonical_interface_name(interface, _validate_jax_version=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be less invasive to do something like,
self._interface = get_canonical_interface_name(interface, _validate_jax_version=True) | |
self._interface = get_canonical_interface_name(interface) | |
if "jax" in self.interface: | |
_validate_jax_version() |
and not have to modify anything downstream. For example, _resolve_interface
is called in qml.execute
which (with the new changes coming) will only be configurable purely from the QNode
with no other entry point. That way I see us only having to verify the version here.
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:QNode.__init__
if the specified interface resolves toJAX
orJAX_JIT
execute
if the original interface was"auto"
orNone
and the resolved interface isJAX
orJAX_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._validate_jax_version
private kwarg toqml.math.get_canonical_interface_name
, which is called byQNode.__init__
, andqml.workflow.resolution._resolve_interface
(used byqml.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]