How to print the stabilizers for a given circuit using Cirq (just like in Qiskit)?

For example, if I have the following cluster state and make a circuit using Cirq. I give the circuit as input, and I should have the output as: {+XZII, +ZXZI, +IZXZ, +IIZX}

4 node cluster state


1 Answer 1


This should work, though there might be some better UX on top of it that I'm not aware of.

a,b,c,d = cirq.LineQubit.range(4)

circuit = cirq.Circuit(cirq.H.on_each([a,b,c,d]),
t = cirq.CliffordTableau(4)
state = cirq.CliffordTableauSimulationState(t, qubits=[a,b,c,d])
for op in circuit.all_operations():
  cirq.act_on(op, state)

  • $\begingroup$ Thanks for the help. It is really working with any given circuit $\endgroup$ Commented Oct 15, 2022 at 14:17

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.