Open
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 qreg
s 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