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

Unitary Synthesis of ChoiMixTableau for Diagonalisation #941

Merged
merged 69 commits into from
Nov 7, 2023

Conversation

willsimmons1465
Copy link
Contributor

I have copied this across from refactor/pauligraph where these changes are useful for making ChoiMixTableau a central representation for diagonalisation. This PR changes the following:

  • PauliGadget construction code largely moved into Diagonalisation folder (viewing the Clifford component as a trivial diagonalisation of one or two Pauli strings) or into PauliExpBoxes.cpp for building boxes.
  • cm_tableau_to_circuit now takes a second argument to switch between exact synthesis, which may use initialisations, discarding, collapses, etc. to exactly construct the channel corresponding to the ChoiMixTableau, or unitary synthesis, which synthesises a unitary channel whose stabilizer group contains at least all the rows of the input tableau (possibly supplemented with Zs on unused inputs intended to be initialised or unused outputs intended to be postselected).
  • Fixes a bug in ChoiMixTableau where terms on the input segment are inconsistently transposed.
  • Adds all remaining Clifford OpTypes into gate handling for SymplecticTableau and UnitaryTableau.
  • Better semantics tests for tableaus to ensure actual correctness instead of just internal consistency.

Making this a draft PR for now to look for some feedback on the changes to the code structure. Some of the code could really do with a strong tidying up because it is getting rather incomprehensible, and I suspect I will still need to bump coverage stats.

@willsimmons1465 willsimmons1465 marked this pull request as ready for review August 3, 2023 12:08
@willsimmons1465
Copy link
Contributor Author

I've made the synthesis code much cleaner and broken into simpler stages. The unitary synthesis of ChoiMixTableau does not currently get used in user-facing features, but will be useful in the upcoming PauliGraph refactor.

This PR also refactors the Pauli gadget synthesis code to always apply some diagonalisation method to reduce it completely to a single Rz gate. The only differences this should give in the end circuits occurs during pairwise synthesis: previously, the synthesis would only reduce the overlap to a single qubit and then would synthesise each gadget separately (and always using CXConfigType::Snake rather than the CXConfigType given to the method), which would mean Clifford gates occur between the core rotations, trapping them from being considered for peephole optimisation (relevant 2qb gates would not be able to commute through the core rotations). Now, the gadgets are completely reduced to either an Rz and Rx on the same qubit or simultaneous Rzs (using a consistent CXConfigType for the reductions). In theory, this uses the same number of 2qb gates for synthesis and more of them are exposed for peephole optimisation with the environment the gadgets appear in, so we would heuristically expect better performance, but the different arrangement of gates makes this inconsistent and hard to predict.

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.

Quite a tour de force! I've just left a few comments.

tket/include/tket/Utils/PauliStrings.hpp Outdated Show resolved Hide resolved
tket/src/Utils/PauliStrings.cpp Outdated Show resolved Hide resolved
tket/include/tket/Circuit/CircUtils.hpp Outdated Show resolved Hide resolved
tket/include/tket/Circuit/CircUtils.hpp Outdated Show resolved Hide resolved
tket/src/Diagonalisation/Diagonalisation.cpp Show resolved Hide resolved
tket/src/Converters/ChoiMixTableauConverters.cpp Outdated Show resolved Hide resolved
tket/src/Converters/ChoiMixTableauConverters.cpp Outdated Show resolved Hide resolved
tket/src/Converters/ChoiMixTableauConverters.cpp Outdated Show resolved Hide resolved
tket/src/Converters/ChoiMixTableauConverters.cpp Outdated Show resolved Hide resolved
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.

I think there was just one doxygen comment missed (which I've left unresolved); otherwise looks good!

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!

@willsimmons1465 willsimmons1465 merged commit ff68b3e into develop Nov 7, 2023
30 checks passed
@willsimmons1465 willsimmons1465 deleted the feature/choimix_unitary_synth branch November 7, 2023 10:43
cqc-alec added a commit that referenced this pull request Jan 8, 2024
This reverts commit ff68b3e.

Reverting because it caused significant regression in compilation
performance with
QuantinuumBackend.default_compilation_pass(optimisation_level=2) with
certain circuits composed of PauliExpBoxes.
cqc-alec added a commit that referenced this pull request Jan 8, 2024
Revert "Unitary Synthesis of ChoiMixTableau for Diagonalisation (#941)"
cqc-alec added a commit that referenced this pull request Jan 8, 2024
Revert "Unitary Synthesis of ChoiMixTableau for Diagonalisation (#941)"
cqc-alec added a commit that referenced this pull request Jan 17, 2024
* [infra] Fix determination of ccache path on Windows (#1192)

* Remove obsolete script. (#1179)

* Allow restriction of number of threads when building pytket using cmake. (#1180)

* Use PEP 600 manylinux containers to build pytket (#1194)

* [infra] Update versions of catch2 and rapidcheck. (#1190)

* Support python 3.12; drop python 3.9 (#1193)

* Only check pytket coverage for PRs to develop. (#1198)

* Revert "Unitary Synthesis of ChoiMixTableau for Diagonalisation (#941)"

This reverts commit ff68b3e.

Reverting because it caused significant regression in compilation
performance with
QuantinuumBackend.default_compilation_pass(optimisation_level=2) with
certain circuits composed of PauliExpBoxes.

* Bump tket version.

* Update changelog.

* Don't try to install ZX module with Python 3.12. (#1203)

* Bump tket version.

* Make the syntax of example commands more consistent between the READMEs. (#1188)

* [bugfix] Handle missing edge case in decomposition of `Rotation` (#1208)

* [feature] Accept `OpType.Phase` in circuits passed to `ZXGraphlikeOptimisation` (#1210)

* Update/copyright year (#1211)

* updtae copyright year

* update tket version

* update tket version II

* Don't build docs in release workflow. (#1212)

* Add missing `OpType.ConjugationBox` (#1209)

* Improve documentation of PassSelector. (#1214)

* Bump cachix/install-nix-action from 24 to 25 (#1216)

Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 24 to 25.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](cachix/install-nix-action@v24...v25)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alec Edgington <[email protected]>

* Update version and changelog.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: David Yonge-Mallo <[email protected]>
Co-authored-by: cqc-melf <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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