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] Various Operator.pow methods with a batched exponent fail #5609

Open
1 task done
albi3ro opened this issue Apr 30, 2024 · 0 comments
Open
1 task done

[BUG] Various Operator.pow methods with a batched exponent fail #5609

albi3ro opened this issue Apr 30, 2024 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@albi3ro
Copy link
Contributor

albi3ro commented Apr 30, 2024

Expected behavior

I expect to get a decomposition with a batch dimension.

Actual behavior

Source code and traceback below

Additional information

We have a moderate amount of support for Pow operators with a batched exponent. For example:

(qml.X(0) ** np.array([0,1])).matrix()

Works as expected.

But many definitions of Operator.pow do not work when pow has a batch dimension.

Source code

qml.X(0).pow(np.array([0,1]))

Tracebacks

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 qml.X(0).pow(np.array([0,1]))

File ~/Prog/pennylane/pennylane/ops/qubit/non_parametric_ops.py:337, in PauliX.pow(self, z)
    335 def pow(self, z):
    336     z_mod2 = z % 2
--> 337     if abs(z_mod2 - 0.5) < 1e-6:
    338         return [SX(wires=self.wires)]
    339     return super().pow(z_mod2)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

System information

PL master.

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
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