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

AutoGraph errors if there are control/adjoint functions used on operator objects #1339

Open
josh146 opened this issue Nov 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@josh146
Copy link
Member

josh146 commented Nov 28, 2024

The following program fails with an AssertionError when using AutoGraph:

dev = qml.device("lightning.qubit", wires=2)

@qml.qjit(autograph=True)
@qml.qnode(dev)
def circuit():
    qml.ctrl(qml.PauliX(0), control=1)
    return qml.probs(wires=0)

However, it works fine when qml.ctrl is passed a callable instead:

@qml.qjit(autograph=True)
@qml.qnode(dev)
def circuit():
    qml.ctrl(qml.PauliX, control=1)(0)
    return qml.probs(wires=0)

>>> circuit()
Array([1., 0.], dtype=float64)

This is likely because the hotfix defined here,

# HOTFIX: pass through calls of known Catalyst wrapper functions
if fn in (
catalyst.adjoint,
qml.adjoint,
catalyst.ctrl,
qml.ctrl,
catalyst.grad,
catalyst.value_and_grad,
catalyst.jacobian,
catalyst.vjp,
catalyst.jvp,
catalyst.vmap,
catalyst.mitigate_with_zne,
):
assert args and callable(args[0])
wrapped_fn = args[0]

does not take this form of ctrl/adjoint into account.

@josh146 josh146 added the bug Something isn't working label Nov 28, 2024
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