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

Support standalone Vars in OQ3 exporter #12308

Merged
merged 4 commits into from May 2, 2024
Merged

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Apr 29, 2024

Summary

This adds the remaining support needed for the OpenQASM 3 exporter to support standalone variables. The way the circuit model handles closures over these variables makes it much easier to support these than it was to handle free-form control-flow operations.

This PR somewhat refactors small parts of the exporter to better isolate the "top-level program" statement construction and analysis from the "build a scoped set of instructions" logic, which makes it rather easier to handle things like declaring IO variables only in the global scope, but locally declared variables in all relevant scopes.

Details and comments

Close #10929

Depends on #12307 because of the need to decouple the visualisers more from OQ3.

@jakelishman jakelishman added Changelog: New Feature Include in the "Added" section of the changelog mod: qasm3 Related to OpenQASM 3 import or export labels Apr 29, 2024
@jakelishman jakelishman added this to the 1.1.0 milestone Apr 29, 2024
@jakelishman jakelishman requested review from nonhermitian and a team as code owners April 29, 2024 23:00
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

@jakelishman jakelishman added the on hold Can not fix yet label Apr 29, 2024
@coveralls
Copy link

coveralls commented Apr 29, 2024

Pull Request Test Coverage Report for Build 8916639862

Details

  • 67 of 69 (97.1%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.04%) to 89.567%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/qasm3/exporter.py 67 69 97.1%
Files with Coverage Reduction New Missed Lines %
qiskit/qasm3/exporter.py 1 95.87%
crates/qasm2/src/lex.rs 3 93.38%
Totals Coverage Status
Change from base Build 8916509583: 0.04%
Covered Lines: 61621
Relevant Lines: 68799

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the second commit while we wait for #12307 to merge. Overall it looks fine to me, but I'm also not super familiar with the internals of the oq3 exporter so I don't have the most critical eye while looking at this code. I just had some quick questions inline.

qiskit/qasm3/exporter.py Outdated Show resolved Hide resolved
qiskit/qasm3/exporter.py Outdated Show resolved Hide resolved
test/python/qasm3/test_export.py Show resolved Hide resolved
This adds the remaining support needed for the OpenQASM 3 exporter to
support standalone variables.  The way the circuit model handles
closures over these variables makes it much easier to support these than
it was to handle free-form control-flow operations.

This PR somewhat refactors small parts of the exporter to better isolate
the "top-level program" statement construction and analysis from the
"build a scoped set of instructions" logic, which makes it rather easier
to handle things like declaring IO variables only in the global scope,
but locally declared variables in _all_ relevant scopes.
@mtreinish mtreinish enabled auto-merge May 2, 2024 00:22
@jakelishman jakelishman removed the on hold Can not fix yet label May 2, 2024
@mtreinish mtreinish added this pull request to the merge queue May 2, 2024
Merged via the queue into Qiskit:main with commit 676a5ed May 2, 2024
15 checks passed
@jakelishman jakelishman deleted the var/qasm3 branch May 2, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: qasm3 Related to OpenQASM 3 import or export
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support manual variables in OpenQASM 3
4 participants