The circuit resulting from the following:
from sympy import Symbol
from pytket import Circuit, OpType
from pytket.passes import AutoRebase, AutoSquash, SquashRzPhasedX
original_circ = Circuit(2).Rz(Symbol("alpha"), 1).CX(0, 1)
AutoRebase(gateset={OpType.PhasedX, OpType.Rz, OpType.ZZPhase}).apply(original_circ)
AutoSquash(singleqs={OpType.PhasedX, OpType.Rz}).apply(original_circ)
includes Rx gates, which I think is surprising?
Additionally have reason to believe that the resulting circuit is incorrect.
For example, the following builds a simple circuit and composes it with its inverse:
from sympy import Symbol
from pytket import Circuit, OpType
from pytket.extensions.stim.backends.stim_backend import StimBackend
from pytket.passes import AutoRebase, SequencePass, AutoSquash, SquashRzPhasedX
symbol_dict = {Symbol("alpha"):0}
original_circ = Circuit(2)
original_circ.CX(0, 1)
original_circ.Rz(Symbol("alpha"), 1)
original_circ.CX(0, 1)
optimized_circ = original_circ.copy()
erroneous_pass = SequencePass(
pass_list=[
AutoRebase({OpType.PhasedX, OpType.Rz, OpType.ZZPhase}),
AutoSquash(singleqs={OpType.PhasedX, OpType.Rz}),
],
)
erroneous_pass.apply(optimized_circ)
original_circ.symbol_substitution(symbol_dict)
optimized_circ.symbol_substitution(symbol_dict)
reversed_circ = original_circ.dagger()
optimized_circ.append(reversed_circ)
optimized_circ.measure_all()
backend = StimBackend()
compiled_circuit = backend.get_compiled_circuit(optimized_circ, optimisation_level=0)
result = backend.run_circuit(compiled_circuit, n_shots=1)
result.get_counts()
This should produce the all zero outcome but does not.
Note that in both cases the behaviour of SquashRzPhasedX is different and I think correct.
The circuit resulting from the following:
includes Rx gates, which I think is surprising?
Additionally have reason to believe that the resulting circuit is incorrect.
For example, the following builds a simple circuit and composes it with its inverse:
This should produce the all zero outcome but does not.
Note that in both cases the behaviour of SquashRzPhasedX is different and I think correct.