2

For the following sample circuit I want to reduce the number of gates in pytket: pytket circuit before

for example, I know:

  • Adjacent Rx gates can be merged
  • CZ is self-inverse and cancels itself out because any Hermitian gate is "self-canceling"
  • A zero-angle rotation does nothing and the corresponding gate can be removed
  • The effect of RZ is eliminated by measurement because we are just rotating around the z-axis which does not change the measurement in the z-basis.

from pytket import Circuit, OpType

circ = Circuit(3)
circ.Rx(0.92, 0).CX(1, 2).Rx(-0.18, 0)   
circ.CZ(0, 1).Ry(0.11, 2).CZ(0, 1)       
circ.add_gate(OpType.XXPhase, 0.6, [0, 1])
circ.add_gate(OpType.YYPhase, 0, [0, 1])     
circ.add_gate(OpType.ZZPhase, -0.84, [0, 1])
circ.Rx(0.03, 0).Rz(-0.9, 1).Ry(0.13, 2)    
Egretta.Thula
  • 11,986
  • 1
  • 13
  • 34
mapper
  • 35
  • 3

1 Answers1

3

Yes, you can use the pytket RemoveRedundancies pass: pytket manual

RemoveRedundancies().apply(circ.measure_all())

This should give a total of five reductions in your case! Very nice.

circuit after

KSp
  • 106
  • 3