Skip to content

Error when using Control flow + QNode + Dynamic shapes #1607

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

Open
dime10 opened this issue Apr 3, 2025 · 0 comments
Open

Error when using Control flow + QNode + Dynamic shapes #1607

dime10 opened this issue Apr 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@dime10
Copy link
Contributor

dime10 commented Apr 3, 2025

The following program raises an error:

from catalyst import *
import jax.numpy as jnp
import pennylane as qml

@qml.qnode(qml.device('lightning.qubit', wires=1))
def circuit(n):
    a = jnp.zeros((n,), dtype=int)
    return a

@qjit
def main(n: int):

    def f():
        circuit(n)

    cond(n != 0)(f)()  # fails

    return circuit(n)  # succeeds

This occurs only when the three elements are used in tandem:

  • control flow calling a subroutine
  • the subroutine is a qnode
  • the qnode returns a dynamically-shaped array
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

No branches or pull requests

1 participant