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 · 2 comments · May be fixed by #122
Open

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

ryanhill1 opened this issue Nov 5, 2024 · 2 comments · May be fixed by #122
Labels
enhancement New feature or request

Comments

@ryanhill1
Copy link
Member

ryanhill1 commented Nov 5, 2024

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 not 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
@arulandu
Copy link
Contributor

Do you mean should not depend on other quantum packages?

@arulandu
Copy link
Contributor

Working on this!

@arulandu arulandu linked a pull request Jan 11, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants