CQCL/pytket-docs

Best pass(es) for optimization?

khieta opened this issue · 2 comments

Hi, I'm working on an updated version of our paper on verified optimization of quantum circuits. I'd like to update tket's results on our benchmarks. What is the best pass (or passes) to use for evaluating optimization (without routing)? For an even comparison, I'd like the output gate set to be {u1, u2, u3, CX}.

For reference, my current script for running tket is here. It uses FullPeepholeOptimise.

Thanks!

Edit: I'm also interested in how to get tket to output circuits in the gate set {Rz, X, H, CX}. If I do a Rebase after optimization, will I end up losing benefits from optimization?

Hi,

Thank you for your question.

FullPeepholeOptimise applies a combination of passes which are mentioned in the Compilation section of the user manual under "predefined sequences"

You can also define passes of your own using SequencePass.
If you are not concerned about routing then perhaps a good sequence of passes to apply is the following.

seq_pass=SequencePass([FullPeepholeOptimise(), RemoveRedundancies(), my_Rebase])

Here my_Rebase can be a user defined rebase which you can define using RebaseCustom

Depending on the structure of your circuits you may also see improved results by including OptimisePhaseGadgets and PauliSimp at the beginning of your sequence. However these compilation passes are application specific and may not be the way to go if you want to define a generic optimisation pass.

After FullPeepholeOptimise is applied the circuit will be in the {TK1,CX} gate set. Performing a rebase after this optimisation will introduce new gates as the TK1 gates need to be decomposed into {Rz,X,H}.

If your Rebase is the last pass in your sequence it should be applied to the optimised circuit. The RebaseCustom pass itself should automatically apply some light optimisations post conversion to remove some redundant gates.

I hope this helps. If anything I said is unclear then please let me know.

Thanks!