2
$\begingroup$

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)    
$\endgroup$

1 Answer 1

3
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.