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

Shape error for tensor-like parameters in pauli arithmetic fixed (Addition to PR: #6562) #6587

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

ldi18
Copy link

@ldi18 ldi18 commented Nov 14, 2024

Context:
I added Pauli string decompositions for single qubit parametrized gates in PR: #6562. Pennylane exploits these Pauli string representations when, for example, computing

(qml.RX(1.11, wires=0) @ qml.RY(1.23, wires=0)).matrix()

The example above works as intended, but

(qml.RX([1.11, 2.11, 3.11], wires=0) @ qml.RY([1.23, 2.23, 3.23], wires=0)).matrix()     # shape error

or

(qml.RX(np.array([1.11, 2.11, 3.11]), wires=0) @ qml.RY(np.array([1.23, 2.23, 3.23]), wires=0)).matrix()     # shape error

returns a shape error. The code above should work since RXand RYsupport tensor-like (flattened) parameters as it can be seen from

qml.RX([1.11, 2.11, 3.11], wires=0).matrix()    # works!

Description of the Change:

I added an outer product in pauli_arithmetic.

Benefits:

  • Pauli representations can now be leveraged for the matrix conversion of products of ops.
  • A Pauli representation of the PhaseShift gate could be added - this was not possible before as the PCPhase gate used the pauli_arithmetic, which gave an error in the pytests.

Possible Drawbacks:
None

Related GitHub Issues:
#6243 and PR: #6562

Lasse Dierich and others added 21 commits November 10, 2024 00:47
Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: David Wierichs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant