Skip to content

feat: integrate compute_output_permutation into _optimize_unitary#64

Merged
dlyongemallo merged 1 commit into
mainfrom
integrate_permutation_into_optimize_unitary
Apr 21, 2026
Merged

feat: integrate compute_output_permutation into _optimize_unitary#64
dlyongemallo merged 1 commit into
mainfrom
integrate_permutation_into_optimize_unitary

Conversation

@dlyongemallo

@dlyongemallo dlyongemallo commented Apr 21, 2026

Copy link
Copy Markdown
Owner

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).

Relates to #18.

Copilot AI review requested due to automatic review settings April 21, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_swaps helper to convert an output permutation into a SWAP prefix.
  • Updated _optimize_unitary to extract with up_to_perm=True, run basic_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.

Comment thread test/test_zxpass.py Outdated
Comment thread zxpass/zxpass.py
@dlyongemallo dlyongemallo force-pushed the integrate_permutation_into_optimize_unitary branch from defff56 to 44482b6 Compare April 21, 2026 09:24
@dlyongemallo dlyongemallo requested a review from Copilot April 21, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread test/test_zxpass.py
Comment thread test/test_zxpass.py
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).
@dlyongemallo dlyongemallo force-pushed the integrate_permutation_into_optimize_unitary branch from 44482b6 to a65ad04 Compare April 21, 2026 09:57
@dlyongemallo dlyongemallo merged commit 02ad766 into main Apr 21, 2026
4 checks passed
@dlyongemallo dlyongemallo deleted the integrate_permutation_into_optimize_unitary branch April 21, 2026 10:02
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