# Depth circuit optimization for 6-qubits GHZ state

Standard implementation of the generalized GHZ circuit has a depth that grows linearly with the number of qubits.

I am looking for an optimized version in the case of 6 qubits.

Is there any?

• For really big GHZ states you can use parity measurements to prepare them, but you need access to midcircuit measurements and then either support for classical feedback or else the rest of the circuit needs to allow you to apply Pauli corrections in postprocessing (e.g. you can do this with Clifford circuits). A 6 qubit state is probably too small for this to be the right technique, though. May 4 at 17:21
• Thank you. I'd like to read more about this technique! May 5 at 11:02
• @DanieleCuomo I added an answer where the depth is constant (5), I'm not sure if it's what Craig had in mind, but it also uses midcircuit measurements. Jun 1 at 16:02

If you have nearest neighbor ("grid") connectivity, you can prepare an $$n$$-qubit GHZ with depth $$O(\log(n))$$ (with the best savings when $$n$$ is a power of $$2$$): For your case you throw away two of the CNOT's in the final layer and so this doesn't give any depth savings. However it is shallower than either linear method for all $$n>6$$. It has depth of 4 instead of 6

• looks like a logarithmic overhead! Great! May 4 at 15:27
• For large number of qubits, depth is still grows linearly. But it reduces its value to the half. May 4 at 15:31

If you can do adaptive measurements inside your circuit (i.e. measure a qubit and apply a correction to other qubits depending on the outcome of the measurement like in Measurement Based Quantum Computing), then you can easily create large GHZ on an arbitrary number $$n$$ of qubits with constant depth (5 if you start from $$|0\rangle$$). For instance, the circuit is examplified on a GHZ of size 6 as follows (you can trivially extend this pattern for more states): More precisely:

1. First, prepare $$2n-1$$ qubits in $$|0\rangle$$
2. Apply Hadamard on odd qubits (starting from 1)
3. Then, apply CNOT where control qubits are odd and the targets are the qubits right after the control
4. Then, apply CNOT where control qubits are even and the targets are the qubits right before the control
5. Measure in computational basis the even qubits
6. Apply for the remaining qubits an $$X$$ correction if the XOR (i.e. sum modulo 2) of the outcomes of the measurements above the current wire is $$1$$.

# Proof

The proof of correctness is easy to obtain using ZX-calculus (I let you do the math if you prefer the usual matrix formalism): for those that are not familiar with the ZX-calculus (I highly recommend the great introduction ZX-calculus for the working quantum computer scientist):

In ZX, we describe a quantum circuit/state using a graph made of red and green "spiders" that are decorated with an angle (if no angle is present, the angle is implicitly 0). We give a "semantic" (i.e. a corresponding matrix) to every graph made of these connected spiders using the definition: But the exact definition is not really important here: we just need to know that we describe (up to a non-important scalar) a CNOT as: (if you are disturbed by this vertical line that is neither an input nor an output, you can also shift the nodes to the right or left, but one can show that only "connectivity matters" in these graphs)

Then measuring an outcome $$a \in \{0,1\}$$ is , a $$|0\rangle$$ is , the $$X^a$$ gate is , and a $$|+\rangle = H |0\rangle$$ is represented with .

Therefore, the above circuit (I stopped after 4 qubits, the generalization to an arbitrary number of qubits is quite easy) is translated in ZX-calculus as: Then, in ZX-calculus, you can rewrite the graph without changing the state associated to the graph. In particular, you can merge all spiders with the same colors by summing their angles modulo $$2\pi$$ (this is known as the "spider fusion rule") and move the spiders as long as you don't change their connectivity (note that any rule is still valid if you exchange the colors). Therefore, the above graph is equivalent to this one: Now, you have another rule that tells you that a node (say a red node) with a label $$a\pi$$ can move through a node of the other color (say a green node) with an angle 0: in that case the original (here red node) is copied on all the other wires of the spider. For instance: Therefore, the above graph can be rewritten as: But using the spider fusion rule, the fact that $$a\pi + a\pi = 0 \bmod 2\pi$$, that $$a\pi + b\pi = (a \oplus b)\pi \bmod 2\pi$$ and the fact that , we obtain this equivalent graph: Then, we can do again the same operation to push the spider containing $$(a \oplus b)\pi$$: Finally, we repeat this one more time for the last qubit, which gives us this equivalent graph: Now, using the spider fusion one more time, we get this equivalent graph: And if you check the definition of the green spider, this is exactly a GHZ state (we omitted the normalization scalars for simplicity)! Therefore: which concludes our proof!

# A small note on the depth

Here, the quantum circuit has constant depth, but it is interesting to note that in order to compute the corrections (like $$a \oplus b \oplus c \oplus d \oplus e$$), we need a /classical/ circuit. However, the depth of this circuit can be made logarithmic (by basically computing recursively in a tree-like shape $$x = a \oplus b$$, $$y = c \oplus d$$, then $$x \oplus y$$…), at least if we consider that we can copy one value on $$n$$ wires in a single gate (this is required as the value $$a$$ is used to compute all the subsequent values).