pyzx
pyzx copied to clipboard
Unable reach the diagram of depth 6 for Cliffords
As stated in Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus, a Clifford circuit can always be transformed in a graph-like diagram corresponding with a sub-diagram occurring in the middle and performing parity-checks -- see equation (11) of the above paper.
However I can't reach this form but only a similar one. And I struggle to understand what are the steps to reach this form.
I posted such issue also at the link below.
https://quantumcomputing.stackexchange.com/questions/27162/pyzx-optimisation-steps-for-clifford-circuits?noredirect=1#comment35564_27162
To get to the form on the right you unfuse the CZ gates and phases and colour change the right-most layer of spiders to X-spiders by pushing out Hadamards. I think this is also the way it is explained in the paper right? Is there a particular step that is unclear?
It is clear in theory, especially by reading the paper. However, when using the built-in methods, I can't obtain the CZ layers.
Below the steps I do:
random.seed(10)
g = zx.generate.cliffordT(qubits=6, depth=6, p_t=None, p_s=0.2, p_hsh=0.2, p_cnot=0.6)
zx.simplify.interior_clifford_simp(g)
g.normalize()
zx.simplify.to_rg(g, select = lambda v: set(g.neighbors(v)).intersection(g.outputs()))
Ah yeah, I don't think there currently is a built-in way to do that, apart from what is implemented in the extract_circuit
method. It shouldn't be too hard to implement it yourself though: find all the spiders connected to an input, and then for every Hadamard connection between these spiders, unfuse a spider into a CZ (this is essentially what extract_circuit
does, but then immediately unto a Circuit
, while I think you are wanting to keep it in the form of a Graph
?).
Yes, I'd like to reach that Graph
and then implement my own extract_circuit
method.
Sorry but the extract circuit also makes some changes on the final circuit, because I can see that the normal form is not preserved. Am I right?
For example extracting a circuit starting from the following generation:
g = zx.generate.cliffordT(qubits = 4, depth = 16, p_s=0.2, p_hsh=0.2, p_cnot=0.6)
In alternative I tried to use the extract_simple method. But I get the error:
Algorithm failed: Graph is not fully reduced
So the problem I think is that the extract_circuit
method does it in such a way that it generates both CNOTs and CZs during extraction. You can probably get it back to the correct form by pushing some Hadamards through CZs to turn them into CNOTs. But this is all not implemented in a method. I might get around to implementing a method that given a Clifford normal form, spits out a circuit of the form described in the paper, but this is currently not high on my todo list.
Is there a specific project or thing you need it for?
My paper on https://arxiv.org/abs/2112.14139 will be soon published on ACM Transactions on Quantum Computing.
I perform a distributed compilation over Clifford in normal forms. In such a paper I just give a numerical evaluation starting from random normal forms.
In order to use the library pyzx I need it to be able to give in output a Clifford circuit in normal form.
The case in the picture doesn't look to me like something that I can bring back to the normal form.

Yeah I don't exactly see how that corresponds to a normal form either, weird. Okay, I'll look into making a dedicated function for this, because it would be a nice thing to have.
Great! Thanks a lot. Looking forward to use it!
Greetings, Is there any news? Thank you!
Sorry, I got distracted with other things. The function I just added should do what you asked. Now that I am at it I also want to add a function that also immediately converts it to a Circuit
.
Great, thank you!
And now also implemented a new function zx.extract.extract_clifford_normal_form
that immediately gives you a circuit out.
Can I close this issue?
I already closed it.
Daniele
On 8 Jun 2023, at 15:34, John van de Wetering @.***> wrote:
Can I close this issue?
— Reply to this email directly, view it on GitHub https://github.com/Quantomatic/pyzx/issues/94#issuecomment-1582591640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBFE5O3PFDWFPXSMVZW2Y3XKHIHVANCNFSM522MNG6Q. You are receiving this because you modified the open/close state.