Skip to content

[BUG] Error in ECR gates processing in qml.from_qiskit method #614

@Tomev

Description

@Tomev

Describe the bug

When creating a pennylane circuit from a qiskit circuit using qml.from_qiskit method there's an error in the operation name processing in the converter.py file. The error parses ECR Gate operation name to Gate and states that Gate instruction is not supported by PennyLane. That's because Gate is not present in the QISKIT_OPERATION_MAP whereas ECR clearly is.

The ECR gates ends up ignored in the processed circuit.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a qiskit circuit with at least one ECR gate.
  2. Run qml.from_qiskit method on the circuit.
  3. See error.

Expected behavior
ECR gate is processed correctly and is included in the final circuit.

Error
<...>/pennylane_qiskit/converter.py:582: UserWarning: pennylane_qiskit.converter: The Gate instruction is not supported by PennyLane, and has not been added to the template.

Hotfix
A quick hotfix for this issue is to include:

if instruction.name == "ecr":
    instruction_name = "ECRGate"

after instruction_name = getattr(...) in line 502. However, I believe that this issue can be solved in a more general and elegant way.

Desktop (please complete the following information):

  • OS: Tested on Windows 10, Kali Linux and MacOS.
  • Version: pennylane-qiskit 0.40.0

Additional context
It's important, because all the publicly available IBM devices uses ECR Gate as their native two-qubit gate.

I believe I can take care of this issue, but I need some time to wrap up my other, work-related stuff first.

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