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

[FEATURE] Add QasmModule.draw() method #61

Open
ryanhill1 opened this issue Nov 5, 2024 · 0 comments
Open

[FEATURE] Add QasmModule.draw() method #61

ryanhill1 opened this issue Nov 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ryanhill1
Copy link
Member

We would like to add a QasmModule.draw() method that generates a circuit diagram from a parsed OpenQASM program (i.e. an openqasm3.ast.Program object). This method can either generate either a raw ASCII string or leverage external visualization tools like pylatex, but should depend on any other quantum packages outside of the openqasm3.

Because of the large number of gates and operations supported by OpenQASM, we will restrict this first implementation to a smaller gate-set to make it a little more approachable. For this, you can use the following code to generate random qasm strings to use as the test data/files for the circuit drawer. Once the circuit drawer is reliably working for any circuits generated by this function, then we will consider this issue closed, and open a new issue that expands the scope.

pip install qbraid
pip install qiskit
pip install qiskit-qasm3-import --no-deps
import random

from pyqasm import load

from qbraid import random_circuit, transpile

qiskit_circuit = random_circuit("qiskit", measure=random.choice([True, False]))

qasm_str = transpile(qiskit_circuit, random.choice(["qasm2", "qasm3"]))

pyqasm_module = load(qasm_str)

pyqasm_module.draw()
@ryanhill1 ryanhill1 added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant