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

OpenQASM 2.0 --> OpenQASM 3.0 conversion function #223

Closed
ryanhill1 opened this issue May 18, 2023 · 4 comments · Fixed by #243
Closed

OpenQASM 2.0 --> OpenQASM 3.0 conversion function #223

ryanhill1 opened this issue May 18, 2023 · 4 comments · Fixed by #243
Assignees
Labels
compatibility 🤝 Version or functionality agreement across packages interface 🔌 Features extended by individual package libs unitaryhack Dedicated issue for UF open-source hackathon

Comments

@ryanhill1
Copy link
Member

Write a function in qbraid.interface.qbraid_qasm.tools.py that converts an OpenQASM 2.0 program / string to an OpenQASM 3.0 program / string.

Resources:

Example usage:

>>> print(qasm_str)
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q[0] -> c[0];
measure q[1] -> c[1];
>>> print(convert_to_qasm3(qasm_str))
OPENQASM 3.0;
bit[2] b;
qubit[2] q;
h q[0];
cnot q[0], q[1];
b[0] = measure q[0];
b[1] = measure q[1];

One rough example of a way you could test for coverage:

from qbraid import circuit_wrapper
from qbraid.interface import random_circuit
from qbraid.interface.qbraid_qasm.tools import convert_to_qasm3

from braket.circuits.serialization import IRType

for _ in range(100):
    circuit = random_circuit("braket")
    qasm2_str = circuit_wrapper(circuit).transpile("qasm")
    qasm3_test = convert_to_qasm3(qasm2_str)
    qasm3_expected = circuit.to_ir(IRType.OPENQASM).source
    assert qasm3_test.strip() == qasm3_expected.strip()
@ryanhill1 ryanhill1 added compatibility 🤝 Version or functionality agreement across packages interface 🔌 Features extended by individual package libs labels May 18, 2023
@ryanhill1 ryanhill1 changed the title OpenQASM 2.0 $\rightarrow$ OpenQASM 3.0 conversion function OpenQASM 2.0 --> OpenQASM 3.0 conversion function May 18, 2023
@TheGupta2012
Copy link
Collaborator

Hi @ryanhill1, I was interested in taking up this issue!

@ryanhill1 ryanhill1 added the unitaryhack Dedicated issue for UF open-source hackathon label May 26, 2023
@ryanhill1
Copy link
Member Author

@TheGupta2012 all yours! Let me know if you have any questions!

@rryoung98
Copy link
Member

Good luck @TheGupta2012 💯

@TheGupta2012
Copy link
Collaborator

Thanks a lot for the help @ryanhill1 while solving this issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility 🤝 Version or functionality agreement across packages interface 🔌 Features extended by individual package libs unitaryhack Dedicated issue for UF open-source hackathon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants