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

Refactor greedy pauli simp #1611

Merged
merged 63 commits into from
Oct 24, 2024
Merged

Refactor greedy pauli simp #1611

merged 63 commits into from
Oct 24, 2024

Conversation

yao-cqc
Copy link
Contributor

@yao-cqc yao-cqc commented Oct 8, 2024

Description

A modified version of the existing Pauli graph is needed for this feature.

New features:

Supports mid-circuit measurements, resets, conditionals and classical gates.

New parameters max_lookahead and max_tqe_candidates to limit the search space.

New parameter seed to support random sampling and tie breaking.

New parameter allow_zzphase allows the algorithm to implement 2-qubit rotations
using ZZPhase gates when deemed optimal.

Related issues

Please mention any github issues addressed by this PR.

Implements #1622 #1621

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@yao-cqc
Copy link
Contributor Author

yao-cqc commented Oct 16, 2024

Several changes since the last review:

Conditionals are now added as conditional blocks of PauliRotations, and any two blocks can be merged if they are adjacent and have the same conditions. Each block will be synthesised recursively using GreedyPauliSimp when it's ready to be added to the output circuit.

Randomised tie breaking when selecting TQEs

max_tqe_candidates controls the maximum number of TQE gates to be evaluated at each step. If more TQEs than this number then a set of size max_tqe_candidates will be randomly sampled.

max_lookahead controls the number of nodes to be costed when evaluating a TQE.

If allow_zzphase is true, then ZZPhase gates and TQE gates will all be considered when selecting an action. A ZZPhase will reduce the tqe cost of one 2-q rotation node by 1 and has no affect on other nodes.

@yao-cqc yao-cqc marked this pull request as ready for review October 16, 2024 13:49
@yao-cqc yao-cqc requested a review from sjdilkes October 16, 2024 13:49
sjdilkes
sjdilkes previously approved these changes Oct 23, 2024
Copy link
Contributor

@sjdilkes sjdilkes left a comment

Choose a reason for hiding this comment

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

Works for me, nice!

@yao-cqc yao-cqc merged commit 94de5fa into main Oct 24, 2024
32 checks passed
@yao-cqc yao-cqc deleted the refactor-greedy-pauli-simp branch October 24, 2024 12:00
CalMacCQ added a commit that referenced this pull request Oct 24, 2024
* Bump cachix/install-nix-action from 29 to 30 (#1606)

Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 29 to 30.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](cachix/install-nix-action@v29...v30)

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

* Fix initialization of subcircuit in `GuidedPauliSimp` implementation (#1607)

* Update docs and changelog for 1.33.1 release. (#1612)

* fix: update wasm functions to accept `WasmModuleHandler` (#1613)

* Update macos CI runners (#1616)

* Fix default value of wire_comments. (#1618)

* docs: use theming submodule, update docs build and linking (#1609)

* remove quantinuum-sphinx

* add pytket-docs-theming submodule

* delete _static and conf.py

* ignore jupyter cache

* use myst-nb for code cells

* use latest theming commit

* ignore any generated .ipynb files

* add myst_nb dependency

* remove jupyter sphinx and autodoc annotations dependencies

* add build docs script

* fix formatting of display.md

* update docs build in build and test workflow

* remove pypi pytket installation

* Hardcode pytket version in flake.nix, as there is no longer a place in the source code that it's written down.

* ignore jupyter execute

* use latest pytket-docs-theming submodule

* update extensions links

* update sidebar heading for extensions

* update pypi page links

* update README links

* replace remaining docs links

* use latest theming commit

* use package-mode=false for poetry

* install a develop wheel of pytket

* try to fix poetry issue

* use poetry without .venv in C.I.

* run docs build from correct directory

* use latest docs theming update

* fix up some extensions links

* fix some broken links found by checker

* link to H-Series docs

* fix two more links

* fix typo

* latest theming (again)

* fix artifact path

* use extensions.html

* use original README link

* remove backends sentance

* use >= for poetry

---------

Co-authored-by: Jake Arkinstall <[email protected]>

* Support Python 3.13 (#1620)

* Bugfix/circuit renderer (#1614)

* add default min width/height to circuit renderer config

* update docs

* changelog

* Don't try to install pytket[ZX] with Python 3.13. (#1627)

* `ClExprOp` and friends (#1628)

* Set MacOS deployment target to 12 for x86. (#1633)

* Drop support for MacOS 12 (#1634)

* Updated nixpkgs. Added custom mypy build. (#1636)

* Updated nixpkgs. Added custom mypy build (required version isn't in nixpkgs)

* Used overrideAttrs on nixpkgs' mypy rather than a new derivation as per @johnchildren's suggestion

* Refactor greedy pauli simp (#1611)

* Initial refactor

* Refactor node types

* Move nodes definition into a new file

* Refactor synthesis

* Cleanup

* More refactoring

* Refactor pauli graph converters

* Initial implementation of GPGraph

* Migrate to GPGraph

* Ignore global phase

* Add supports for conditional gates

* Add support for classical ops

* flatten_registers should only rename qubits and bits

* Replace unsigned with Bit

* Revert "Replace unsigned with Bit"

This reverts commit 9e9a2fd.

* Manually check if qubits and bits can be flattened since ``is_simple()`` doesn't work with wasm

* Consistent enum names

* Add support for mid-circuit measurement

* Rename variables

* Add support for resets

* Update docstrings

* Update pass predicate

* Add more tests

* bump tket version

* Add changelog entry

* Fix docs errors

* bump tket version

* Remove unused headers

* bump tket version in pytket

* uncomment lines

* remove consts in SQ_CLIFF_DAGGER

* Merging conditionals

* Revert "Merging conditionals"

This reverts commit f5138f1.

* Optimise conditional handling

* remove ConditionalPauliRotation

* Remove clifford reduction and pass parameters when synthesis conditionals

* Seeded tie breaking

* Add limits to the search space

* Allowing ZZPhase gates

* update binder and serialisation

* Add test for ops handling in python

* add note for AC node cost

* bump tket version

* update changelog

* fix changelog format

* add missing prams in docstrings

* cast size_t to unsigned

* remove nondeterminism from test

* Remove more nondeterminism

* regen stubs

* Add debug info

* Revert "Add debug info"

This reverts commit e5030e2.

* Replace implicit wire swaps in optimised conditional circuits

* re-organise changelog

* Bump tket version

* fix bug in sign correction

* Add more tests

* Bump version and update changelog for 1.34.0 release (#1637)

---------

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]>
Co-authored-by: Kartik Singhal <[email protected]>
Co-authored-by: Jake Arkinstall <[email protected]>
Co-authored-by: Tiffany Duneau <[email protected]>
Co-authored-by: yao-cqc <[email protected]>
yao-cqc added a commit that referenced this pull request Oct 28, 2024
* Initial refactor

* Refactor node types

* Move nodes definition into a new file

* Refactor synthesis

* Cleanup

* More refactoring

* Refactor pauli graph converters

* Initial implementation of GPGraph

* Migrate to GPGraph

* Ignore global phase

* Add supports for conditional gates

* Add support for classical ops

* flatten_registers should only rename qubits and bits

* Replace unsigned with Bit

* Revert "Replace unsigned with Bit"

This reverts commit 9e9a2fd.

* Manually check if qubits and bits can be flattened since ``is_simple()`` doesn't work with wasm

* Consistent enum names

* Add support for mid-circuit measurement

* Rename variables

* Add support for resets

* Update docstrings

* Update pass predicate

* Add more tests

* bump tket version

* Add changelog entry

* Fix docs errors

* bump tket version

* Remove unused headers

* bump tket version in pytket

* uncomment lines

* remove consts in SQ_CLIFF_DAGGER

* Merging conditionals

* Revert "Merging conditionals"

This reverts commit f5138f1.

* Optimise conditional handling

* remove ConditionalPauliRotation

* Remove clifford reduction and pass parameters when synthesis conditionals

* Seeded tie breaking

* Add limits to the search space

* Allowing ZZPhase gates

* update binder and serialisation

* Add test for ops handling in python

* add note for AC node cost

* bump tket version

* update changelog

* fix changelog format

* add missing prams in docstrings

* cast size_t to unsigned

* remove nondeterminism from test

* Remove more nondeterminism

* regen stubs

* Add debug info

* Revert "Add debug info"

This reverts commit e5030e2.

* Replace implicit wire swaps in optimised conditional circuits

* re-organise changelog

* Bump tket version

* fix bug in sign correction

* Add more tests
yao-cqc added a commit that referenced this pull request Oct 28, 2024
* Add failing test

* Preserve opgroups when sub symbols

* bump tket version

* Add entry to changelog

* bump tket version

* Drop support for MacOS 12 (#1634)

* Updated nixpkgs. Added custom mypy build. (#1636)

* Updated nixpkgs. Added custom mypy build (required version isn't in nixpkgs)

* Used overrideAttrs on nixpkgs' mypy rather than a new derivation as per @johnchildren's suggestion

* Refactor greedy pauli simp (#1611)

* Initial refactor

* Refactor node types

* Move nodes definition into a new file

* Refactor synthesis

* Cleanup

* More refactoring

* Refactor pauli graph converters

* Initial implementation of GPGraph

* Migrate to GPGraph

* Ignore global phase

* Add supports for conditional gates

* Add support for classical ops

* flatten_registers should only rename qubits and bits

* Replace unsigned with Bit

* Revert "Replace unsigned with Bit"

This reverts commit 9e9a2fd.

* Manually check if qubits and bits can be flattened since ``is_simple()`` doesn't work with wasm

* Consistent enum names

* Add support for mid-circuit measurement

* Rename variables

* Add support for resets

* Update docstrings

* Update pass predicate

* Add more tests

* bump tket version

* Add changelog entry

* Fix docs errors

* bump tket version

* Remove unused headers

* bump tket version in pytket

* uncomment lines

* remove consts in SQ_CLIFF_DAGGER

* Merging conditionals

* Revert "Merging conditionals"

This reverts commit f5138f1.

* Optimise conditional handling

* remove ConditionalPauliRotation

* Remove clifford reduction and pass parameters when synthesis conditionals

* Seeded tie breaking

* Add limits to the search space

* Allowing ZZPhase gates

* update binder and serialisation

* Add test for ops handling in python

* add note for AC node cost

* bump tket version

* update changelog

* fix changelog format

* add missing prams in docstrings

* cast size_t to unsigned

* remove nondeterminism from test

* Remove more nondeterminism

* regen stubs

* Add debug info

* Revert "Add debug info"

This reverts commit e5030e2.

* Replace implicit wire swaps in optimised conditional circuits

* re-organise changelog

* Bump tket version

* fix bug in sign correction

* Add more tests

* Bump version and update changelog for 1.34.0 release (#1637)

* Update README.md (#1625)

* nump tket version

* update changelog

* bump tket version

* Update changelog

---------

Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Jake Arkinstall <[email protected]>
Co-authored-by: Callum Macpherson <[email protected]>
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