question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Infinite run with JAX-JIT and `qml.expval`

See original GitHub issue

Expected behavior

This code should terminate with a result:

dev = qml.device('default.qubit.jax', wires=2, shots=10)

@jax.jit
@qml.qnode(dev, interface='jax')
def circ(x):
    qml.PauliZ(wires=0)
    qml.RY(x, wires=0)
    return qml.expval(qml.PauliZ(0))

print(circ(1))

Actual behavior

Code does not terminate

Additional information

Code terminates when not using jit:

dev = qml.device('default.qubit.jax', wires=2, shots=10)

@qml.qnode(dev, interface='jax')
def circ(x):
    qml.PauliZ(wires=0)
    qml.RY(x, wires=0)
    return qml.expval(qml.PauliZ(0))

print(circ(1))
>>> 0.4

Source code

No response

Tracebacks

No response

System information

Name: PennyLane
Version: 0.22.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-qiskit
Platform info:           Linux-5.13.0-39-generic-x86_64-with-glibc2.31
Python version:          3.9.7
Numpy version:           1.22.3
Scipy version:           1.8.0
Installed devices:
- default.gaussian (PennyLane-0.22.1)
- default.mixed (PennyLane-0.22.1)
- default.qubit (PennyLane-0.22.1)
- default.qubit.autograd (PennyLane-0.22.1)
- default.qubit.jax (PennyLane-0.22.1)
- default.qubit.tf (PennyLane-0.22.1)
- default.qubit.torch (PennyLane-0.22.1)
- qiskit.aer (PennyLane-qiskit-0.20.0)
- qiskit.basicaer (PennyLane-qiskit-0.20.0)
- qiskit.ibmq (PennyLane-qiskit-0.20.0)
- lightning.qubit (PennyLane-Lightning-0.22.0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ankit27khcommented, Apr 11, 2022

Hey @puzzleshark, this was just something I encountered. Not blocking my work.

0reactions
puzzlesharkcommented, Apr 11, 2022

Hi @ankit27kh thanks for the additional information. We are able to reproduce the bug with cuda enabled jaxlib, and will work on a solution. Just wondering issue is this a blocker for you currently? Trying to determine priority for the fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

How is noise implemented in `default.mixed` device?
When I use a noise gate like qml.DepolarizingChannel , what is being implemented in terms of gates on the circuit? The documentation refers...
Read more >
arXiv:2202.13414v1 [quant-ph] 27 Feb 2022
We can run the same circuit, but now compile using the qml.transforms.single qubit fusion transform, which will merge all adjacent single-qubit ...
Read more >
Animation QML Type | Qt Quick 6.4.1
Infinite, the animation will continuously repeat until it is explicitly stopped - either by setting the running property to false, or by calling...
Read more >
pennylane - bytemeta
Define custom positon for `qml.transforms.insert` ... [BUG] Infinite run with JAX-JIT and `qml.expval` ... More measurments supported with JAX-JIT. jackaraz.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found