Repository navigation
fix: support openqasm3 1.0.2 alongside 1.0.1 - #475
Conversation
Argus reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Changes requested
The openqasm3 1.0.2 fixes work, and the suite passes on both 1.0.1 and 1.0.2. Three items remain before merge.
Findings
All findings are posted inline on the relevant lines. Checklist:
- M1 — Drop commit 8dee03a and its CHANGELOG line; the change now lives in #479
- M2 — CI runs only openqasm3 1.0.2, so nothing guards the 1.0.1 branches
- M3 —
pyqasm[pulse]on openqasm3 1.0.2 leaks a rawAttributeErrorfrom cal blocks
How it was tested
- Two Python 3.12 venvs with
pip install -e ".[test,pulse,cli,visualization]", openqasm3 pinned to 1.0.1 or 1.0.2, openpulse 1.0.1 in both. - PR head
725e2ffwith openqasm3 1.0.1:pytest testsgives 1054 passed, 6 skipped. - PR head with openqasm3 1.0.2: 1053 passed, 3 skipped, 4 xfailed.
- Base
d8680f7with openqasm3 1.0.2: 126 failed, 921 passed. Base with 1.0.1: 1047 passed. - black, isort and pylint (10.00/10) pass. mypy passes under both versions.
- Probes under both versions gave the same output wherever both parse: QASM 2 load, 3.2 and 4.0 rejection, syntax, EOF and lexer error messages,
nopinbox/for/if/def/gate bodies,nop $0, measurement calls, anddepth(),remove_idle_qubits()andreverse_qubit_order()on a program withnop.
Next steps
Drop 8dee03a now and rebase on main after #479 merges (M1). Address M2 and M3 before merge.
f31697b to
3baf28d
Compare
|
Thanks for the thorough review! I dropped the runner commit, added a test run on openqasm3 1.0.1 and the cal block case now gives a proper ValidationError that explains the version mismatch. I used a hash-locked requirements file for the 1.0.1 install so Scorecard stays happy, but happy to switch to a plain pin if you prefer. I'll rebase once #479 is in. |
Pass ignore_version when parse() accepts it so OpenQASM 2 loads again, find the syntax error token behind 1.0.2's "parse failed", unroll the new nop statement as before and reject measurement calls. Fixes qBraid#472. Suggested-by: Ryan Hill <ryanjh88@gmail.com> Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
The coverage job resolves openqasm3 1.0.2, so nothing ran the 1.0.1 code paths. The new step installs 1.0.1 from a hash-locked file, like the other workflow tools, and runs the suite again. Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
openpulse 1.0.1 with openqasm3 1.0.2 raised a raw AttributeError for any assignment in a cal or defcal block. Both parse calls now raise a ValidationError that names the version mismatch. Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
|
Hi @HVSharma12 , can you rebase? The PR #479 just merged and with your change, CI should pass now |
3baf28d to
57453d1
Compare
|
Rebased on main now that #479 is in. I ran the full CI on my fork with this exact commit and everything passes, including the new 1.0.1 step on macos-15. |
There was a problem hiding this comment.
I made some more comments @HVSharma12 , could you please take a look and change accordingly? I think we should be good to merge post this.
I have also added #481 as a follow up once the openpulse change merges so that we can cleanly upgrade the version and remove the openqasm3==1.0.1 backward compatibility code.
nop_as_gate_calls and expand_nop_statements read no visitor state, so they are static methods of Qasm3Transformer now. The visitor keeps _visit_nop and calls them. Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
The message is written at the two raise sites instead of in a module constant. Signed-off-by: HVSharma12 <harshvardhan.sharma@suse.com>
|
Done, both nop helpers are now static methods on Qasm3Transformer and the openpulse message is written inline where it is raised. Thanks for opening #481 as the follow up. |
TheGupta2012
left a comment
There was a problem hiding this comment.
Thanks @HVSharma12 for working on this, lgtm!
Correct the #462 broadcast example, which showed the old output as the new one. List cphaseshift and cv under the #459 inverse fix, link #481 from the #475 known issue, say drawer instead of printer in the #458 entry, and put each period after its PR link. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary of changes
openqasm3 1.0.2 broke
loads()in a few ways. This makes pyqasm work with it, and 1.0.1 keeps working. Fixes #472.loads()passesignore_version=Truewhenopenqasm3.parseaccepts it, as Ryan Hill suggested in loads() fails on every OpenQASM 2 program with openqasm3 1.0.2 #472, and pyqasm still checks the version itself. I check the signature instead of raising the minimum to 1.0.2. With 1.0.2, openpulse 1.0.1 cannot parse assignments incalblocks, and qbraid-runtime-api pins 1.0.1 for now. A floor can follow once a fixed openpulse is out.QASM3ParsingError("parse failed"), sodescribe_parse_errornow looks for the ANTLR token first. The test that built the error without a message now passes one.nopis its own statement in 1.0.2. pyqasm unrolls it to onenopper operand qubit through the same gate path as before, so the output is unchanged, also inside gate definitions, andnop;with no operands unrolls to nothing.measure_iq q[0]. pyqasm raises aValidationErrorfor it instead of anAttributeError.calordefcalblock now raises aValidationErrorthat names the version mismatch instead of a rawAttributeErrorfrom inside openqasm3.code-coveragejob runs the suite a second time on openqasm3 1.0.1, installed from a hash-locked file in.github/requirements/, so the 1.0.1 code paths stay tested until pyqasm requires 1.0.2.Four OpenPulse tests fail with 1.0.2 because openpulse 1.0.1 bundles an older copy of the qasm3 grammar (openqasm/openpulse-python#42). They are marked xfail only while the installed openpulse cannot parse an assignment in a
calblock, so they run again as soon as a fixed openpulse is installed. I sent the grammar update to openpulse in openqasm/openpulse-python#44.On a fresh install with openqasm3 1.0.2,
tox -e format-checkpasses and the suite has 1055 passed, 3 skipped and 4 xfailed. With 1.0.1, 1056 pass and 6 skip.