tket
tket copied to clipboard
Simplify circuit first before rebase
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.