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

[BUG] Gradient verification fails if there is a Prod operation somewhere in the circuit #976

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

Comments

@josh146
Copy link
Member

josh146 commented Jul 30, 2024

For the following circuit, gradient verification fails:

@qml.qjit
def f(params, x):

    @qml.qnode(dev, diff_method="parameter-shift")
    def circuit(params, x):
        qml.IQPEmbedding(x, wires=range(3), n_repeats=1)
        qml.StronglyEntanglingLayers(params["weights"], wires=range(3), imprimitive=qml.CZ)
        return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))

    return catalyst.grad(circuit)(params, x)
>>> x = jnp.array([0.1, 0.2, 0.3])
>>> params = {"weights": jnp.ones([3, 3, 3])}
>>> f(params, x)
File catalyst/device/verification.py:238, in validate_observables_parameter_shift.<locals>._obs_checker(obs)
    237 def _obs_checker(obs):
--> 238     if obs and obs.grad_method not in {"A", None}:
    239         raise DifferentiableCompileError(
    240             f"{obs.name} does not support analytic differentiation"
    241         )

AttributeError: 'Prod' object has no attribute 'grad_method'
@josh146 josh146 added the bug Something isn't working label Jul 30, 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