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

Issue with inverse of QubitStateVector #218

Open
trbromley opened this issue Jun 6, 2022 · 1 comment
Open

Issue with inverse of QubitStateVector #218

trbromley opened this issue Jun 6, 2022 · 1 comment

Comments

@trbromley
Copy link
Contributor

Describe the bug
An error is raised when using qml.QubitStateVector(...).inv() with any of the Qiskit devices.

The error is:

CircuitError: "Invalid param type <class 'complex'> for gate initialize_dg."

To Reproduce

import pennylane as qml
import numpy as np

dev = qml.device("qiskit.aer", wires=1)
state = np.array([1, 1]) / np.sqrt(2)

@qml.qnode(dev)
def f():
    qml.QubitStateVector(state, wires=0).inv()
    return qml.expval(qml.PauliZ(0))

f()

Expected behavior
The above error is not raised.

We could raise a different error because we don't want to support inverses of state preparations (see PennyLaneAI/pennylane#2666).

Additional context

The error itself is linked to the use of Qiskit's Initialize here, which does not support inverses.

This issue was found by @QFer when working on a separate plugin that inherits from the Qiskit plugin. The error occurs in this test in the device test suite when QubitStateVector is added as a supported operation.

@lillian542
Copy link
Contributor

The inv() issue is no longer relevant, and this code runs with qml.adjoint(qml.QubitStateVector(state, wires=0)) instead. Not sure if that resolves the linked issue in PennyLane, but that seems like a separate question. @trbromley , can we close this?

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

No branches or pull requests

2 participants