feat: integrate compute_output_permutation into _optimize_unitary#64
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Integrates PyZX’s up_to_perm=True extraction into _optimize_unitary to avoid SWAP decomposition clutter during basic_optimization, then explicitly reintroduces the extracted output permutation as SWAP gate objects for fairer gate-count comparisons.
Changes:
- Added
_permutation_to_swapshelper to convert an output permutation into a SWAP prefix. - Updated
_optimize_unitaryto extract withup_to_perm=True, runbasic_optimization, then prepend SWAP gates for the computed permutation. - Extended tests to cover permutation-to-SWAP conversion and (partially) pipeline behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
zxpass/zxpass.py |
Extract up to permutation, compute output permutation, and prepend it as SWAP gate objects before gate-count fallback. |
test/test_zxpass.py |
Adds tests for swap-prefix integration and permutation-to-swaps correctness; updates equivalence test set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
defff56 to
44482b6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract with `up_to_perm=True` so that basic_optimization runs on a SWAP-free circuit, then prepend the output permutation as SWAP gate objects (1 gate each instead of 3 CNOTs).
44482b6 to
a65ad04
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.
Extract with
up_to_perm=Trueso that basic_optimization runs on a SWAP-free circuit, then prepend the output permutation as SWAP gate objects (1 gate each instead of 3 CNOTs).Relates to #18.