Skip to content

Add support for multiple qreg definitions in qasm2_to_ionq  #770

Open
@TheGupta2012

Description

Environment

  • qBraid version: 0.8.2
  • Python version: 3.12
  • Operating system: macOS 14.4

What happened?

For the following program -

from qbraid.transpiler.conversions.qasm2 import qasm2_to_ionq

qasm_str = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
x q[0];
y q[0];

qreg q2[2];
cx q2[0], q2[1];

"""

print(qasm2_to_ionq(qasm_str))

the output is -

{'qubits': 4, 'circuit': [{'gate': 'x', 'target': 0}, 
                        {'gate': 'y', 'target': 0},
                        {'gate': 'cnot', 'control': 0, 'target': 1}]}

The expected output for the program should be -

{'qubits': 4, 'circuit': [{'gate': 'x', 'target': 0},
                        {'gate': 'y', 'target': 0}, 
                        {'gate': 'cnot', 'control': 2, 'target': 3}]}

as cnot is applied on the 2nd and 3rd physical qubit (q2[0] and q2[1])

Suggestions (Optional)

There needs to be correct memory of the qregs being passed in the qasm2 program and mapping should be applied on the qubits when they are used in the converter.

Possibly this can benefit from the semantic analyser of qbraid-qir and can be taken up when it is available.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workingtranspiler 🚊Circuit conversions across program types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions