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

Update auto_rebase_pass to take optional allow_swaps argument #947

Merged
merged 32 commits into from
Aug 3, 2023

Conversation

sjdilkes
Copy link
Contributor

If allow_swaps is true, then when targeting CX or ZZMax gates, auto_rebase_pass will decompose TK2 gates with wire swaps added if it will reduce the number of CX/ZZMax gates in the decomposition.

To do this I've added two new methods to CircPool.hpp and the library.cpp binders: TK2_using_CX_and_SWAP and TK2_using_ZZMax_and_SWAP.

These methods construct circuits via a new method in CircPool.cpp TK2_Swap_replacement, which finds cases where wire swaps improve gate count.

To cleanup remaining single qubit gates, I've also updated standard_rebase_via_tk2 to move the TK2 gate decomposition into the for loop that replaces all gates with TK2 operations. This makes it easier apply single qubit cleanup to just the gates as part of that decomposition, shouldn't effect performance of the overall method, and seemed to be necessary to make gates such as SWAP return only a wire swap and not any further single qubit gates.

@sjdilkes sjdilkes requested a review from cqc-alec July 26, 2023 13:06
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

Nice, just a few comments.

pytket/binders/circuit/library.cpp Outdated Show resolved Hide resolved
pytket/pytket/passes/auto_rebase.py Outdated Show resolved Hide resolved
pytket/pytket/passes/auto_rebase.py Outdated Show resolved Hide resolved
tket/src/Transformations/Rebase.cpp Outdated Show resolved Hide resolved
tket/src/Transformations/Rebase.cpp Outdated Show resolved Hide resolved
tket/src/Transformations/Rebase.cpp Outdated Show resolved Hide resolved
tket/test/src/test_CompilerPass.cpp Show resolved Hide resolved
@sjdilkes sjdilkes requested a review from cqc-alec August 1, 2023 15:49
pytket/binders/circuit/library.cpp Outdated Show resolved Hide resolved
pytket/binders/circuit/library.cpp Outdated Show resolved Hide resolved
pytket/binders/circuit/library.cpp Outdated Show resolved Hide resolved
pytket/pytket/passes/auto_rebase.py Outdated Show resolved Hide resolved
pytket/pytket/passes/auto_rebase.py Show resolved Hide resolved
tket/include/tket/Circuit/CircPool.hpp Show resolved Hide resolved
tket/src/Circuit/CircPool.cpp Outdated Show resolved Hide resolved
tket/src/Circuit/CircPool.cpp Outdated Show resolved Hide resolved
tket/src/Circuit/CircPool.cpp Outdated Show resolved Hide resolved
@sjdilkes sjdilkes requested a review from cqc-alec August 3, 2023 12:09
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

A couple of pytket tests failing?

@sjdilkes
Copy link
Contributor Author

sjdilkes commented Aug 3, 2023

A couple of pytket tests failing?

I forgot to update the n_gates value for Sycamore for ZZPhase and ZZMax, have fixed now

@cqc-alec
Copy link
Collaborator

cqc-alec commented Aug 3, 2023

A couple of pytket tests failing?

I forgot to update the n_gates value for Sycamore for ZZPhase and ZZMax, have fixed now

Just the one still failing...

@sjdilkes sjdilkes requested a review from cqc-alec August 3, 2023 15:00
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

thanks!

@sjdilkes sjdilkes merged commit 16048f4 into develop Aug 3, 2023
33 checks passed
@sjdilkes sjdilkes deleted the allow-swap-in-auto-rebase branch August 3, 2023 16:56
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