zxcalc/pyzx

Error in full_optimize

Closed this issue · 2 comments

Dear All,

I tried full_optimize for a circuit. Before doing this, when we check for circuit stats this way:

print(pyzx_circ.stats())

we get:

Circuit EvolvedOps-2842 on 10 qubits with 450 gates.
30 is the T-count
420 Cliffords among which
274 2-qubit gates (274 CNOT, 0 other) and
0 Hadamard gates.

But upon doing a full_reduce followed by full_optimize this way:

g = pyzx_circ.to_graph()
zx.full_reduce(g, quiet=False) 
g.normalize()
c_opt = zx.extract_circuit(g.copy(),optimize_czs=True, optimize_cnots=3, up_to_perm=False, quiet=True)
zx.full_optimize(c_opt.to_basic_gates(), quiet=True)

I run into this error:

TypeError: This method only works on Clifford+T circuits. This circuit contains a ZPhase(4,phase=940347/1909922)

Can someone please help resolve this issue? Thanks in advance! :-)

It means your circuit contains phase gates that are not a multiple of pi/4, and hence not supported by full_optimize. You can use basic_optimize instead.

Thank you very much for the clarification!