Repository navigation
fix(unroll): keep nop when inverting a custom gate body - #485
Merged
Merged
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✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
map_qasm_inv_op_to_callable had no entry for nop, so inv @ on a custom gate whose body contains nop raised ValidationError. nop is its own inverse, so add it to SELF_INVERTING_ONE_QUBIT_OP_SET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
openqasm3 1.0.2 parses nop as a statement, which the visitor split per operand before reversing an inverted body. That put the nops of inv @ g in the opposite order from 1.0.1. Reverse first, then split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TheGupta2012
force-pushed
the
bugfix-477-inv-nop
branch
from
November 19, 2026 07:05
8837579 to
9f22e5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
unroll()raisedUnsupported / undeclared QASM operation: noponinv @ gwhen the body ofgcontainsnop. The inverse gate map had no entry fornop. Anopis its own inverse, so the inverted body should keep eachnop.What changed
nopjoinsSELF_INVERTING_ONE_QUBIT_OP_SET, soinv @maps it to itself.nop. With openqasm3 1.0.2 the split came first, so thenops came out in the opposite order from 1.0.1.Scope
nopinside custom gate bodies underinv @, andpow(-n) @, which uses the same path.ctrl @on a gate whose body hasnopstill raises, as onmain. A bareinv @ nop q;is a parse error with openqasm3 1.0.2, because its grammar treatsnopas a statement.Blast Radius
Only inputs that used to raise change. Every
ctrl,inv @ ctrland plain gate input gives the same output as onmain.Verification
test_nop_unrolls_per_operandfail onmainand pass here, with openqasm3 1.0.1 and 1.0.2.tox -e format-checkpasses.Closes #477