CQCL / tket

Source code for the TKET quantum compiler, Python bindings and utilities
https://docs.quantinuum.com/tket/
Apache License 2.0
257 stars 48 forks source link

Refactor greedy pauli simp #1611

Closed yao-cqc closed 3 weeks ago

yao-cqc commented 1 month ago

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

yao-cqc commented 1 month ago

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.