Skip to content

Qasm refactor#295

Draft
Mayank447 wants to merge 5 commits intoqutip:masterfrom
Mayank447:qasm-refactor
Draft

Qasm refactor#295
Mayank447 wants to merge 5 commits intoqutip:masterfrom
Mayank447:qasm-refactor

Conversation

@Mayank447
Copy link
Copy Markdown
Member

@Mayank447 Mayank447 commented Dec 20, 2025

Pending qasm-refactor from #290. There are couple lots of pre-existing error in the qasm_processor.py file. Couple of variables are undefined e.g. curr_gate, reg_num and some are unused e.g. prev_token, gate_added (not sure whether some logic is missing or they are simply not needed).

@BoxiLi I haven't looked at the conversion logic properly as my first aim was to refactor the 1200 line single qasm.py file. I believe instead of fixing these errors as per OpenQASM 2.0 circuit conversion, we can directly upgrade to OpenQASM 3.0 (in accordance with #292) in this or another PR. Since OpenQASM 3.0 supports a lot of new features like loops, extern etc. the conversion logic would change anyways.

@BoxiLi
Copy link
Copy Markdown
Member

BoxiLi commented Dec 29, 2025

Yes I agree there are some qutie complicated logic in qasm.py and many potential bugs. Basically we implemented our own parser for a qasm file. I think there should be a smarter way of doing it.

I am surley happy to upgrade to qasm 3.0, also not against completely rewrite it if you find it a better approach. Would be good to keep the support of 2.0 if possible, because some platforms still only supports that. But this is open for discussion.

@Mayank447
Copy link
Copy Markdown
Member Author

Cool, I will work on resolving the bugs in openqasm 2. Unfortunately there is no parser for qasm 2 which converts .inc to an AST, so we will need to maintain a custom parser.

For qasm3 openqasm provides a python package for parsing, so that should make it easier to implement.

@Mayank447 Mayank447 marked this pull request as draft January 1, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants