Skip to content

Issue with inverse of QubitStateVector #218

@trbromley

Description

@trbromley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions