Skip to content

AutoGraph does not transform the body of qml.prod #1911

@dime10

Description

@dime10

The following code fails to be converted by autograph, even with #1910. The reason is that prod is not explicitly listed in the transform call hotfix nor the transform object hotfix.

@qml.prod
def template(b):
    if b:
        qml.H(0)
        qml.X(0)

@qjit(autograph=True)
@qml.qnode(qml.device("null.qubit", wires=0))
def circuit(b: bool):
    qml.adjoint(template(b))
    return qml.state()
  File "test.py", line 12, in template
    if b:

jax.errors.TracerBoolConversionError: Attempted boolean conversion of traced array with shape bool[].
This concrete value was not available in Python because it depends on the value of the argument b.

Note that there are likely other decorators similar to qml.prod that we haven't explicitly enabled for passthrough. It might be useful to generalize the CatalystCallable strategy in PennyLane.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendPull requests that update the frontend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions