tket icon indicating copy to clipboard operation
tket copied to clipboard

Simplify circuit first before rebase

Open yao-cqc opened this issue 1 year ago • 3 comments

from pytket.circuit import Circuit
from pytket.passes import SynthesiseTK, CommuteThroughMultis, RemoveRedundancies
c = Circuit(2).Rz(0.3,0).CX(0,1).Rz(-0.3,0).CX(0,1)
SynthesiseTK().apply(c)
# [TK1(0.5, 0.5, 3.5) q[0]; TK1(0, 3, 3) q[1]; TK2(0.5, 0, 0) q[0], q[1]; TK2(0.5, 0, 0) q[0], q[1]; TK1(0.5, 0.5, 0.5) q[0]; TK1(0, 0, 1) q[1]; ]

But original c should be easily reduced to identity with:

CommuteThroughMultis().apply(c)
RemoveRedundancies().apply(c)

The problem is that SynthesiseTK (i.e. synthesise_tk) does the TK2 rebase first, which makes it harder for the subsequent optimisations to work. Same thing applies to synthesise_tket.

I think this behaviour might have a considerable impact on performance since these rebase passes are often ran first. For example, SynthesiseTK in FullPeepholeOptimise and the pytket-quantinuum level 1 pass.

yao-cqc avatar Aug 15 '23 12:08 yao-cqc