Chapter 9
Measurement-based quantum computation

Up to this point, whenever we talked about a quantum computation, we were talking about the circuit model. In this model of computation we start with a simple state, usually |0⋯0⟩, which is then inserted into a quantum circuit, i.e. a collection of simple unitaries that combine to make something more complex. At the end we measure the qubits in some fixed basis, and the outcome of these measurements is the outcome of our computation. This model of quantum computation is inspired by classic logic circuits. It is a universal model, meaning that we can in fact present arbitrary quantum computations in this way. This however does not mean that this is always the best way to think of a quantum computation, or the one that matches the most closely to how a real-world quantum computer would function.

There are more ways to implement a computation on a quantum state than just by directly performing a unitary on it. If we have some entangled state, then measurement of one part of the state induces an action on the other part. Depending on the entanglement and the measurement this action could be unitary or non-unitary. Let’s take for example a slight modification of the teleportation example of Section 3.3.2 that we also saw in Section 6.5:

(9.1)

In this example of gate teleportation we have some maximally entangled state |ψ⟩, which we entangle with the qubit we want to do a computation on using a CNOT. By then measuring some qubits, the resulting state has a unitary U and a Pauli applied to it. The Pauli we apply however is determined by the measurement outcome. This is an inevitable feature of using measurements to do computations: measurement non-determinism. Since we don’t control which Pauli gets applied, and it is ‘stuck’ behind the U, this seems like it would prevent us to control which computations get executed. However, it turns out that for smart choices of measurements and smart choices of U, we can feed-forward the Pauli errors and reliably implement U, possibly up to performing some later corrections.

Hence, general models of quantum computation can do the bulk of the computation with either unitary gates, with careful choices of measurements, or with something in-between. At one end of the spectrum is the circuit model, where measurements are limited to fixed ONB measurements performed at the very end, and the “code” that implements an algorithm consists entirely of the choice of unitary gates. Moving a bit further along the spectrum we can decide to implement only certain types of gates using gate teleportation (like in Eq. (9.1)), or using its closely related cousin of state injection. Even further along the spectrum we can let all multi-qubit dynamics be taken care of by measurements, which is the case in lattice surgery (which we’ll meet in Chapter 12) or more exotic models like fusion-based computation. On the opposite end of this “gates-vs-measurements” spectrum from the circuit model is the one-way model, where essentially all of the computation is done by measurements. In the one-way model we start with a large fixed graph state, and then we perform single-qubit measurements in different rotated bases. The choice of which qubit to measure and in what basis it is measured is informed by the computation we want to do and what the previous measurement outcomes were, while the starting graph state (apart from its given size) usually doesn’t depend on the particular computation. In this model all computation is done by measurements. Such a computation might for instance look like the following:

(9.2)

Here we start with a four qubit graph state, and then we measure each of these in different bases. The Boolean variables a, b, c and d represent each of the measurement outcomes and are the output of this computation. In this example we have pre-determined measurement planes, i.e. whether the measurement takes place in a (rotated) Z or X basis, but some adaptive measurement angles. While the top qubit is always measured in a basis with angle π 2 , the third qubit has a measurement angle (−1)aπ 4 , meaning that whether we measure it in the angle π 4 or −π 4 depends on the measurement outcome of the qubit a. This means there is an order fixed on the measurements of these qubits, with qubit a having to be measured before qubit c.

Collectively, we call models of quantum computation using measurements measurement-based quantum computing (MBQC). While the circuit model is inspired by classical circuits, MBQC has no classical counterpart. There are various reasons why we might want to consider MBQC as opposed to quantum circuits:

In this chapter we will focus on a particular model of MBQC called the one-way model, which relies on performing single-qubit measurements on graph states and feeding forward Pauli corrections. Along the way we will see techniques that apply more generally to optimising quantum computations, including circuits, using the ZX-calculus.

Graph-like ZX-diagrams can naturally be understood as computations in this model, which are called measurement patterns (Section 9.2.1). Using this connection, we will see that one can indeed do universal quantum computation in the one-way model. We will also see more broadly how we can determine when a computation can be made deterministic. We do this by studying generalised flow, or gflow for short, which tells us precisely how to feed-forward Pauli corrections when we obtain the ‘wrong’ measurement outcome during a computation (Section 9.2.2). It turns out that any deterministic measurement pattern with gflow can be efficiently transformed back into a quantum circuit (Section 9.4). This gives us a triangle of translations, from quantum circuits, to ZX-diagrams, to measurement patterns, and back to quantum circuits. Because we can rewrite ZX-diagrams, this gives us a unified way to think about circuit optimisation and measurement-pattern optimisation.

9.1 Measurement patterns

If we were to formally specify what a computation in the quantum circuit model is, it would be something like: prepare n qubits in the |0⟩ state, apply a series of unitary gates G1,…,Gk, then measure all n qubits in the computational basis, giving some bit string x→, and finally post-process this with some output function p(x→) giving the final outcome.

In contrast, a computation in the one-way model consists of a graph state |G⟩, a choice of single-qubit measurements at each vertex of G (i.e. each qubit of |G⟩), and possibly some classical post-processing. Crucially, we allow each choice of single-qubit measurement to depend on previous measurement outcomes, which is called feed-forward. In this section, we will define a measurement pattern, which is a formal ‘program’ on the one-way model, playing an analogous role to a circuit in the circuit model.

Fixing a single-qubit measurement is the same as picking a single point (and its antipode) on the Bloch sphere. In the one-way model, we restrict to planar measurements, that is measurements which lie in one of the three perpindicular planes {XY,Y Z,XZ} of the Bloch sphere. For a fixed plane, we can specify the choice of measurement as a single angle α:

Notably, such measurements have the property that one can map between the two basis elements by applying a Pauli operator. This property will become important soon.

Normally, we assume the measurement plane is fixed, but the measurement angle αv at time step k depends on the outcomes of measurements at time steps 1,…,k − 1. In fact, this already gives us a universal model of computation even if we fixed XY plane measurements everywhere. However, we allow the other planes as a convenience. We will initially consider XY plane measurements whose measurement effects are representable by (phased) Z-spiders. Starting in Section 9.5 we will see how the other two planes play a role, e.g. in representing phase gadgets.

Another convenience is to allow computations in the one-way model to have some input and output qubits. Recall that a complete computation in the circuit model consists of state preparation and measurement. So, in some sense there is only classical input (the circuit) and classical output (the measurement outcomes). However, it is still nevertheless useful to consider smaller parts of circuits, ranging from individual gates to subroutines, which have some quantum inputs and outputs.

The situation in the one-way model is similar. A complete computation in the one-way model fully prepares a graph state and measures all of its qubits, but it is also useful to think of ‘fragments’ of a measurement-based computation that can be composed together to create more complicated computations. These fragments have inputs and outputs just like a quantum circuit would. For instance, a computation that implements a CNOT gate is given by the following diagram:

(9.3)

Here the top qubit is both an input and an output and hence isn’t measured. The third qubit is an input, but is not an output and hence is measured. The fourth qubit is an output and hence also isn’t measured. The second qubit is ‘internal’ and is hence prepared and measured as part of this fragment. The pattern (9.3) implements a CNOT gate up to a known Pauli error that depends on the measurement outcomes a and b. We can calculate this Pauli error by simplifying the diagram:

(9.4)

Hence we end up with the circuit (Zb ⊗ (ZbXa)) ∘CNOT. Since the error is a known Pauli, later measurements can be adapted to absorb these errors so that the overall effect of this measurement pattern is the application of a CNOT gate. This is why we allow feed-forward in the one-way model.

In order to account for inputs and outputs to a measurement pattern, we work with open graphs.

Definition 9.1.1. An open graph (G,I,O) is a graph G = (V,E) together with a list of inputs I and outputs O. These lists consists of vertices of G, where repetition of vertices is allowed, and the order is relevant.

We let an open graph with a specified measurement order and measurement-plane function correspond to a ZX-diagram as follows. For every vertex in V we add a Z-spider, and for every edge in E we add a Hadamard edge between them. Then we add an input wire on a spider if it is in I and an output wire if it is in O. This so far gives us a graph-like diagram and an open graph (where the graph-like diagram is phase-free). However, now we also add an additional output wire to every non-output spider, to get a diagram that looks something like this:

(9.5)

Now on each of those additional output wires, we are going to plug in a measurement effect, corresponding to the measurement plane and angle of that vertex:

(9.6)

Here the αk denotes the measurement angle of the pattern, and the bk is a Boolean variable denoting the outcome of the measurement. Note that αk is actually a function of the variables b1,…,bk−1 representing the outcomes of the previous measurements.

We see then that if in (9.5) we choose XY for the measurement-plane of both qubits and we simply set the measurement angles to 0 that we get precisely the implementation (9.3) of the CNOT gate.

We can also construct a measurement pattern that implements an arbitrary single-qubit unitary. Recall that we can use the Euler decomposition of such a unitary to write it as a sequence of a Z phase gate, and X phase gate, and then another Z phase gate: diagram euler-decomposition. Let’s try to write down a measurement pattern that implements this, by putting each of the phases α,β and γ into the measurement angle of a qubit:

(9.7)

This is not exactly correct. There are a couple of things we need to fix. For one thing, there is a Pauli error at the end: an X gate depending on b + d and a Z error depending on a + c. We will learn how to deal with such errors later. But there is also a problem with the phases. We want the phases to be α, β and γ, but we see that depending on the measurement outcomes we might have actually gotten − β or − γ. This is why we need to allow measurement angles to depend on previous measurement outcomes. To make this pattern do what we want it to do, we need to make use of feed-forward to account for previous measurement outcomes. We first measure the qubit labelled by the measurement outcome a. If a = 0, we measure the qubit b in the angle β, which gives what we want. Otherwise we measure it in the angle − β. Hence, the measurement angle is (−1)aβ. Rerunning the calculation (9.7) with β replaced by (−1)aβ, we see that we get the final phase of (−1)a(−1)aβ = β, so that now the final angle no longer depends on the measurement outcome! We can do the same with γ, letting the measurement angle instead be (−1)bγ. With these changes the measurement pattern becomes:

(9.8)

Apart from the Pauli error at the end that we still need to deal with, this implements the unitary we want. Note that in the pattern implementing the CNOT (9.3), the measurement angles didn’t depend on each other, so that the order of measuring the qubits wasn’t important. In (9.8) however, the measurement angles of some of the qubits depend on the measurement outcomes of other qubits, so that those qubits have to be measured first. This gives us a ‘direction of time’ on the pattern. It makes sense that we need to have some kind of adaptivity or dependency in our calculation. If we could do universal computation without such dependencies, then we could measure all qubits simultaneously. We could then do computations in constant time. While quantum computing is powerful, it is not that powerful!

So now we have a measurement pattern implementing a CNOT and another one implementing arbitrary single-qubit unitaries. Hence, if we can combine these then we can implement arbitrary unitaries. However, there is still the problem of the Pauli errors that need to be fed-forward. Let’s see what we can do with them.

If a pattern with a Pauli error occurs at the end of our computation this is easy enough to deal with. At the end, we measure all the qubits in the computational basis anyway. This means that these errors just change how we should interpret the measurement outcomes:

So if we were feedforwarding an X error, i.e. x = 1 above, then this changes how we should interpret the measurement outcome we got. If we observe the measurement outcome a′ then this is actually a′ = a ⊕ x. So to get the ‘actual’ measurement outcome a, we just take a′⊕ x = a ⊕ x ⊕ x = a. A Z error (z = 1) doesn’t change the measurement outcome when we measure in the computational basis, so we can ignore those in this setting. A Y error, i.e. where both a Z error and an X error occurred, we can treat the same as an X error here.

In general though, the measurement pattern will happen somewhere in the middle of the computation so that the errors will not change the final measurement outcomes, but change how we should run the next patterns in the sequence. For instance, let’s see what would have happened if a Pauli error had happened on the input qubit prior to executing the measurement pattern (9.8):

(9.9)

We see that we can push these errors to the output of the pattern, at the cost of changing the angles in the unitary to potentially have minus signs, and additionally changing our output Pauli error. But these Pauli errors we have on the input arise from measurements we have done before, so we know what this error is. This means we can decide the measurement angle of our measured qubits based on this input Pauli error, in the same way we also change it based on the measurement outcomes of the qubits internal to the pattern. The full pattern that can also deal with incoming errors then becomes:

(9.10)

This still gives us a Pauli error at the end, but this is fine since we now know how to deal with this: it should either be pushed through the next pattern, or otherwise be updating the final measurements in the computation.

We then see that for a good definition of measurement pattern, we should allow measurements to not only depend on previous measurement outcomes, but also on Pauli errors being fed-forward into the pattern. Accounting for these errors gives us all the data we need, so we are now ready to give a formal definition of a measurement pattern.

Definition 9.1.2. A measurement pattern consists of

Note that we take it as part of the definition of a measurement pattern to specify what the output errors are. By specifying what we consider ‘errors’ we are at the same time specifying what our desired outcome is, and hence what the linear map we are trying to implement is. We also need this error information as it needs to be fed-forward into the patterns following it.

Example 9.1.3. Translating the diagram (9.10) into the language of Definition 9.1.2, we see that G is a chain of five vertices, let’s call them a,b,c,d,o to match with the variables in (9.10). Then I = {a} and O = {o}. We have m = 4, ni = no = 1. The measurement order t just goes down the chain: t(1) = a,t(2) = b,t(3) = c,t(4) = d (although actually qubit d can be measured whenever as nothing else in the pattern depends on this outcome). The measurement-plane λ is XY for every measured qubit. The measurement-angle functions are then

f1(z,x) = (−1)xα, f2(z,x,a) = (−1)a+zβ, f3(z,x,a,b) = (−1)b+xγ, f4(z,x,a,b,c) = 0

where here α, β and γ are pre-determined phases corresponding to the unitary we wish to implement. Finally, the Pauli error functions are fZ(z,x,a,b,c,d) = a + c + z and fX(z,x,a,b,c,d) = b + d + x.

Exercise 9.1. Do the same type of analysis of the Pauli errors as was done for (9.9), but for the CNOT measurement pattern (9.3). Do the measurement angles in this pattern have to depend on the incoming Pauli errors? What are the resulting Pauli errors on the output? Translate all this information into the form of a measurement pattern as in Definition 9.1.2.

Since our definition of a measurement pattern can specify how incoming Pauli errors should change the measurement angles, and how the resulting errors should be fed-forward, we can actually compose these patterns together. We will not formally define how to do so, as this is quite tedious, but one can visualise it as just connecting the associated ZX-diagrams together and pushing the internal Pauli errors to the end:

Here z→′ = fZ(z→,x→,a→) and x→′ = fX(z→,x→,a→) are the Z- and X-errors as fed-forward through the first pattern, while a→ and a→′ are the measurement outcomes of respectively the first and second pattern. The measurement angles of the second pattern now do not depend on z→ and x→, but on the fed-forward z→′ and x→′ instead.

Remark 9.1.4. The example patterns we have considered so far, (9.10) and (9.3), implement a linear map that is independent of the measurement outcomes in the pattern (up to a known Pauli error that is being fed-forward). We call such a pattern deterministic, because if we zoom out and consider the pattern as a single unit where we follow the description on how to feed-forward the errors, then ignoring this known error it just implements a fixed unitary. Our definition of measurement pattern doesn’t require the patterns to be deterministic, but in practice we will restrict ourselves to deterministic ones. To be clear: a pattern being deterministic does not mean that we know what measurement outcomes we will see in advance, but it does mean that regardless of the measurement outcomes we get, we will implement the same linear map if we correct the fed-forward errors. We will have a lot more to say about determinism in the one-way model in Section 9.2.

9.1.1 Universal resources

We have described a measurement pattern to implement a CNOT gate and one that can implement an arbitrary single-qubit unitary. As CNOT gates and single-qubit unitaries form a universal gate set, we see then that we can construct a measurement pattern for any unitary we would want to implement. Hurray! Note however that the resulting graph state we need will depend on the specific unitary we want to implement. There is then still some information about the computation that is present in the starting resource state. This then raises an interesting question: can we implement arbitrary unitaries using a measurement pattern that has a fixed graph state? We need to be a bit careful about how to formally state this question, because there are unitaries that are really hard to implement, and so we would expect them to require a large resource state to prepare. Put simply, if we only have k measurements, we only have k continuous degrees of freedom to pick out a specific unitary. However, the number of degrees of freedom in an arbitrary unitary grows exponentially with the number of qubits. We therefore shouldn’t consider a fixed resource, but rather a family of resource state that is allowed to scale with the cost of the unitary.

In order to get resource states whose cost scales in (approximately) the same way as quantum circuits, it is natural to ask if there exists a family of generic resource states G with increasing numbers of vertices such that for any n-qubit unitary U with m gates, we can find a measurement pattern implementing U which uses the open graph in G with O(poly(n,m)) vertices. Perhaps surprisingly, the answer to this is yes!

There exist universal resource states which allow you to implement arbitrary quantum computations up to some size. A particularly nice example of a family of universal resource states are the 2D cluster states:

Cluster states are just big rectangular grids. In order to see that they are universal, we can use measurements in the Y Z plane to strategically cut holes into the grid:

This allows us to shape the grid into whatever pattern we need it to be to perform the computation we want:

We can then use the patterns we have already seen to implement a universal set of gates on the remaining parts of the graph state. Using this strategy, we can see that the width of the initial cluster state we need is linear in the qubit count and the height is linear in the gate depth.

9.2 Determinism and gflow

We have now seen that we can do universal computation using the one-way model. An important part in getting there was knowing how to deal with the wrong measurement outcomes by finding ways to feed them forward. So far we have done this essentially by trial and error: we construct a simple pattern, observe that we get the wrong phases sometimes, and then change them to correct for this. In this section we will find a more systematic way to think about correcting errors and when we can see that a measurement pattern can be made deterministic.

But first, let’s look at the connection between measurement patterns and graph-like diagrams.

9.2.1 Graph-like ZX-diagrams as measurement patterns

It turns out that if we take the ZX representation of a measurement pattern, ignore the adaptivity needed to correct for ‘wrong’ measurement outcomes, and fuse some spiders, that we get a graph-like diagram. For instance, doing this for the pattern (9.7), we get:

(9.11)

This graph-like diagram is then a representation of the post-selected measurement pattern, where all the measurement outcomes are the ones we wanted to get.

It turns out the converse is also true: any graph-like diagram can be seen as a post-selected measurement pattern just by unfusing some phases and introducing some identities:

(9.12)

If we were to actually try to run this as a measurement pattern, we would of course usually get some of the ‘wrong’ measurement outcomes.

If we wanted to implement this graph-like diagram in the one-way model, we could simply repeat this computation many times until we got the outcomes we wanted. However, the probability of this happening gets exponentially small in the number of measurements, so what would be even better is to come up with a general purpose strategy for finding the corrections we need to implement a given diagram deterministically. Since any quantum circuit can be represented using a graph-like ZX-diagram, this would give us an easy way to implement computations in the circuit model (and more!) using measurement-based quantum computing.

It turns out that it is in general not possible to turn graph-like diagrams into deterministic measurement patterns. This is for the simple reason that we can write down ZX-diagrams that are not isometries. For instance, consider the following graph-like diagram:

(9.13)

By doing some colour changing and identity removals, we see that this is just a 2-input, 2-output Z-spider, which is a projection and is not unitary. If we could deterministically perform such a projection, we could do non-unitary quantum computation! Or even more simply, consider the graph-like diagram diagram bra-plus. If we could implement this ZX-diagram deterministically, we would be doing post-selection.

So it is not always possible to turn a graph-like diagram into a deterministic measurement pattern. But can we at least somehow determine when we can do so? As it turns out: yes. For a particularly strong type of deterministic measurement pattern there is a one-to-one correspondence to graph-like ZX-diagrams with a property called gflow.

9.2.2 The measurement correction game

To understand when we can implement a correction strategy for measurement errors on a graph-like ZX-diagram, let’s consider a small toy diagram to see what we can do:

(9.14)

This is of course not a realistic diagram that we would expect to encounter when doing MBQC, but it will serve to demonstrate the principle of correction. Here our goal is to get rid of the π phase. We can do this by changing the spider with the β phase:

(9.15)

Hence, as long as we measure the qubit with phase β after the one with α, an error at α can be corrected by changing the measurement angle of the β qubit to be − β. Here we could have also chosen to change γ in order to correct the error at α.

Finding the right correction was easy here, because the β spider was only connected to α and nothing else. Let’s consider a slightly more complicated diagram:

(9.16)

In this case, changing the phase of β does still remove the error at α, but it also changes the phases at the other spiders:

(9.17)

Now if we can run the pattern such that the qubits with the γ and δ phase can be measured after the α qubit, then this is fine, since we can still decide to measure them with a different phase to correct for the additional π phase they have. But if we suppose that we have already measured the qubit with the γ phase, then this would not be possible. In that case however, we see that we can apply the same ‘π-pushing’ trick with δ to turn γ + π back into γ:

(9.18)

This gave us an additional π phase at β as well, but that is fine as we are already considering changing the phase at β. Hence, to correct the error at α, we can decide to change the phase at β and δ, and this leaves the phase at γ invariant.

Let’s try to formalise what is happening here. We see that the trick of pushing out an X(π) phase affects the phases on all the neighbours of this vertex, and that if we affect the phase of a vertex twice, that this then cancels out the effect. The qubits will be measured in some fixed order, so we must make sure that the angles we change only affect measurements taking place after the error we are trying to correct.

We can capture this behaviour in a little game: you are given an open graph with vertices V where every vertex is labelled with either the presence or absence of an error (a 1 or 0). You are allowed to do the operation flipv for a vertex v ∈ V , which flips the value of the error on all the neighbours of v (but not at v itself). The goal is to move all the 1’s (the errors) to the output vertices. For example:

(9.19)

For some open graphs and configurations of errors, this task might be impossible. For example, there is no solution for the following graph:

We should expect to have no solution for the example above, because if we were to try to build a one-way model computation on this open graph, it would map two qubits to one qubit. There is no way we could do such a computation deterministically, so we don’t expect to find a deterministic strategy for implementing it in the one-way model.

The question then is, for which graphs can you always win this game, regardless of where the errors occur?

We can see that a winning strategy is the following: first, find an ordering ≺ of vertices which give a direction of ‘time’ going from inputs to outputs, and find for each non-output vertex u, a correction set g(u) ⊂ V of vertices in the future of u (with respect to the ordering  ≺) such that applying flipv for all v ∈ g(u) flips the bit on u, and potentially also flips some other bits, as long as those bits all belong to vertices that are in the future of u (again, with respect to ≺). Now, for any instance of the game we can apply the following strategy: find a minimal vertex u (w.r.t.  ≺) which has an error. Then apply flipv to all v ∈ g(u). This removes the error on u, and only introduces new errors on vertices in the future of u. Then find a new minimal vertex with an error and repeat until all the errors are moved all the way to the outputs.

This game describes the property of g(u) in terms of the flip operation, but we can actually make the description a bit simpler and more natural to graph-theory language. Namely, we see that a vertex w gets its bit flipped by applying flipv for all v ∈ g(u) precisely when it is connected to an odd number of vertices in g(u). This is because if it is connected an even number of times to vertices in g(u), then it gets its bit flipped an even number of times, so nothing happens. Let’s capture this in a definition.

For v ∈ G, let NG(v) denote its neighbourhood, i.e. its set of adjacent vertices or neighbours.

Definition 9.2.1. Let G = (V,E) be an (open) graph, and A ⊆ V some subset of its vertices. We define the odd neighbourhood of A in G as OddG(A) := {w ∈ V ||NG(w) ∩ A| mod 2 = 1}.

Using odd neighbourhoods we can rephrase the condition we needed on the correction sets g(u): we need u ∈OddG(g(u)) (applying flip for all vertices in g(u) results in a flip at u) and if v ∈OddG(g(u)) then u ≺ v (if v gets flipped by the corrections for u, then v needs to be in the future of u).

This is in fact exactly what we require, and allows us to give the definition of the central concept of this chapter: gflow.

Definition 9.2.2. Let G = (V,E,I,O) be an open graph. A gflow (≺,g) on G consists of a partial order ≺ on the vertices of G, and a correction set function g : V ∖O → ℘(V ∖I) that associates to every non-output vertex v ∈ V ∖O a subset of non-input vertices g(v) ⊆ V ∖I, such that:

1..

The inputs are minimal in the partial order ≺ (meaning that if v ≺ i for some input i, then v = i) and conversely the outputs are maximal;

2..

For every u ∈ V ∖O, we have that u ≺ v and u≠v for every v ∈ g(u), i.e. all the elements in the correction set are in the future of the vertex being corrected;

3..

For every u ∈ V ∖O we have u ∈OddG(g(u)), i.e. applying a correction at all the vertices in the correction set of u, results in a correction at u;

4..

For every u ∈ V ∖O, if v ∈OddG(g(u)), then u ≺ v. That is, if v is a vertex that ends up with a correction from the correction set of u, then v is in the future of u.

We say an open graph has gflow when at least one gflow can be defined on it.

By construction, whenever an open graph has gflow, it has a winning strategy for the error correction game we described above. Hence, it supports deterministic computation.

Remark 9.2.3. One might ask if the converse is true. That is, if a graph supports deterministic computation in the one-way model, does it necessarily have gflow? It turns out this is false: there are some deterministic measurement patterns on graphs that do not have gflow. For example, consider this measurement pattern with no inputs and one output with a Pauli Z correction:

This pattern produces a |+⟩ state with probability 1, but the associated open graph doesn’t have gflow. Hence, gflow is a sufficient, but not necessary criterion for determinism. However, there is a particularly well-behaved kind of determinism, called strong, stepwise, uniform determinism, which is equivalent to existence of gflow. See the References of this chapter for more.

A useful tool for doing gflow calculations is the symmetric difference A Δ B of sets. This is the set-theoretic equivalent of XOR: it consists of the set of elements in A or B, but not both. For example {1,2,3}Δ {2,3,4} = {1,4}. This operation is associative and commutative, so just like unions or intersections, we can write the symmetric difference of many sets using index notation. For I = {1,…,n},

Δ i∈IAi := A1 Δ A2 Δ … Δ An

We will perform many calculations with symmetric difference in the coming sections, so we’ll conclude this section with a little warm-up.

Exercise 9.2. In the definition above OddG(A) is defined by quantifying over all the vertices of G. However, there is another version of the definition that just refers to the neighbourhoods of the vertices in A, namely OddG(A) := Δ v∈ANG(v). Prove that this definition is equivalent to the one in Definition 9.2.1.

Exercise 9.3. Show that for any two sets of vertices A,B ⊆ V of G = (V,E) that OddG(A Δ B) = OddG(A) Δ Oddg(B).

9.2.3 Diagrams with gflow are deterministic measurement patterns

We can use gflow to describe how to transform a graph-like ZX-diagram into a deterministic measurement pattern.

Let’s assume we have a graph-like ZX-diagram D such that its corresponding open graph G has a gflow (≺,g). We saw in Definition 9.1.2 that a full description of a measurement pattern requires various pieces of data. The first pieces are easy enough to specify:

But now comes the more complicated part: we need to describe the measurement angles, and more importantly, how they are affected by the measurement outcomes. We have already done this informally when we discussed how to use gflow to win the measurement correction game from Section 9.2.2, but now we will formalise this.

We have a standard measurement angle α that comes from the angle we had in the ZX-diagram D. But then this α gains either gets negated if it appears in a correction set of some previous measurement that got the ‘wrong’ outcome, or it gets a π added to it if it appears in the odd neighbourhood of such a correction set.

Let’s write αu for the phase that the spider u has in the original diagram D and au for the measurement outcome when the spider u is measured. Hence, if all the measurement outcomes au are 0, then the measurement angles we want to measure every qubit in is just αu. We will change these αu to functions αu′ that may depend on the av of qubits v that have been measured before u.

Let’s first consider an input u ∈ I, which has to deal with a fed-forward Pauli X error, but no other corrections from inside the pattern:

We see that we should change our initial choice of measurement αu to a function αu′(z,x) = (−1)xα + zπ in order to account for the error being fed-forward into the spider. Note we only need to flip the αu term, because for angles π = −π.

This doesn’t fully capture the incoming Pauli error though, as we see that the X error has to be further fed-forward into the neighbours of u. All this does is change the measurement angle of that neighbour by xπ, so we will ignore this detail.

While this deals with the incoming Pauli error, it does not deal with the measurement error av that it produces itself. To correct this we need the gflow condition. This procedure is the same regardless of whether the spider is an input or not, so let’s just take u ∈ V ∖O to be any measured qubit now. We then have a set of correction qubits g(u) = {v1,…,vk} and a set of ‘corrected’ qubits OddG(g(u)) = {u,w1,…,wl}. We then see that by changing the measurement angles at the correction and corrected qubits, we can remove the measurement error at u:

Here for simplicity we have assumed that each vi and wj is not an output, as we will deal with that case later. We have given every qubit in this diagram an additional output wire to denote that it can also be connected to some other spiders. The last application of (π) does not affect these additional qubits, precisely because they are not in the odd neighbourhood of the correction set. So for every v ∈ g(u) we set αv′(au) = (−1)auαv and for every w ∈OddG(g(u)) with w≠u we set αw′(au) = αw + auπ.

In general, a spider could of course be part of multiple correction sets and odd neighbourhoods of correction sets. It will be useful to give these a name:

g∗(v) := {u ∈ V ∖O|v ∈ g(u)} Odd∗(v) := {u ∈ V ∖O|v ∈Odd G(g(u))∖{u}}

Then the actual measurement angle, as a function of the previous measurement outcomes, is

αv′({a u|u ≺ v}) = (−1)∑ u∈g∗(v)au αv + (∑ u∈Odd∗(v)au) π.

We are now almost done! The above tells us how to change measurement angles to correct errors when the correction sets g(u) and corrected sets OddG(g(u)) only contain non-outputs. When instead an output qubit o is in such a set, then we don’t change the measurement angle of o (which we can’t do since o is not measured), but we change the Pauli error that is being fed-forward. If o ∈ g(u), then we get a Pauli X error of auπ, and if o ∈OddG(g(u)), then we get a Pauli Z error auπ. In general then, the output Pauli that gets forwarded at output o is (z,x) = (∑ ⁡ u∈S2(o)au,∑ u∈S1(v)au).

We have now specified what all the measurement angles of the qubits should be, based on the fed-forward errors and the internal measurement outcomes, and we have specified what the outgoing fed-forward errors will be based on the measurement outcomes. This then indeed gives us a measurement pattern. By how we constructed the pattern, we see that it implements the ZX-diagram we started out with regardless of the internal measurement outcomes (up to the fed-forward Pauli error at the end). We have then proved the following result.

Theorem 9.2.4. Let D be a graph-like diagram, and G = (V,E,I,O) its corresponding open graph consisting of a vertex for every spider and edge for every Hadamard edge, and suppose that G has gflow. Then we can efficiently construct a deterministic measurement pattern from D and the gflow which has the same underlying open graph and implements the same linear map as D.

Remark 9.2.5. The trick we applied here, introducing Pauli X’s to cancel a Pauli Z at a different location, might have seemed a bit familiar. This is because it is actually based on the stabilisers of the underlying graph state (see Example 6.3.8). Applying the flipv operation is like introducing the graph-state stabiliser Sv consisting of an X at v and a Z at all its neighbours. The correction set g(u) then says that to correct the error at u, we need to introduce the stabiliser ∏ ⁡ v∈g(u)Sv.

9.2.4 From circuits to measurement patterns

We started out this section with the goal of understanding how we can systematically create measurement patterns that are deterministic. We have seen that we have one powerful tool for ensuring determinism: the existence of a gflow. What we have however not yet done is finding a good source of measurement patterns that have gflow.

As it turns out, if we take a unitary circuit consisting of Clifford and phase gates, and then turn it into a graph-like diagram by fusing all spiders and colour changing to Z-spiders as described in Proposition 5.1.8, the resulting diagram has gflow.

Proposition 9.2.6. Let D be the diagram of some quantum circuit, and D′ the graph-like diagram produced from D using Proposition 5.1.8. Then D′ has a gflow.

Proof. The idea will be to set g(u) = {v} where v is the spider directly to the right of u on the same qubit line, and for the partial order to encode ‘is that spider to the left of me?’

For every spider v of the circuit D we associate a number qv specifying on which ‘qubit-line’ it appears. We also associate a ‘column-number’ cv ≥ 0 specifying how ‘deep’ in the circuit it appears. Hence, each spider has ‘xy coordinates’ (cv,qv):

Suppose that v and w are connected in D, v ∼ w. If they are on the same qubit, so qv = qw, then necessarily rv≠rw, since they can’t share the same space. Conversely, if they are on different qubits, qv≠qw, then they must be part of a CZ or CNOT gate, and hence rv = rw.

In D′, every spider arises from fusing together adjacent spiders on the same qubit line from the original diagram (apart from the additional identity spiders introduced in the last step, which we will ignore for now):

For a spider v in D′ we can thus associate two numbers sv, and tv, where sv is the lowest column-number of a spider fused into v, and tv the highest. For instance, for the second spider on the second qubit, we have s = 3 and t = 5. Spider fusion in D only happens for spiders on the same qubit-line, and hence v also inherits a unique qv from all the spiders that got fused into it.

An identity spider v created by the last step of the translation, must be attached to either an input or an output. If it is attached to an input, we set sv = tv = 0. If it is attached to an output we set sv = tv = +∞ (or any value bigger than the largest value of tv in the diagram). For this proof we can treat these spiders the same way as the others.

We define a partial order on D′ as follows: v ≺ w if and only if v = w or tv < tw. It is straightforward to check that this is indeed a partial order. Now for any u in D′ that is not an output, set g(u) = {v} where v is the unique neighbour to the right of u on the same qubit-line. We claim (g,≺) is a gflow.

By construction u ∈Odd(g(u)) = N(v). We need u ≺ v. The spiders of D that got fused into the same spider in D′ must have all been adjacent. Hence, for the distinct spiders u and v in D′ on the same qubit we must have tv < sw, as they couldn’t have overlap in the spiders that got merged into them. Hence, tu < sv < tv so that u ≺ v. Suppose w ∈Odd(g(u)) = N(v) so that w ∼ v. We need to show that u ≺ w. If u = w this is trivial so suppose v≠w. First suppose that qw = qv (which is also equal to qu). We know v has a maximum of two neighbours on the same qubit-line (one to the left, and one to the right), and since the one to the left is u, w must be to the right, so u ≺ v ≺ w. If instead qv≠qw then their connection must have arisen from some CNOT or CZ gate in D, and hence the intervals [sv,tv] and [sw,tw] must have overlap, so that necessarily sw ≤ tv and sv ≤ tw. Since we also have tu < sv we get tu < sv ≤ tw so that indeed u ≺ w. □

Remark 9.2.7. A gflow like we get here, where each correction set only contains a single element, is known as a causal flow, or just a flow. This is the kind of flow that gflow is generalising.

There are also some simple modifications we can make to an open graph that preserve the existence of a gflow. Like adding new vertices after an output or adding and removing connections between output vertices.

Exercise 9.4. Let G = (V,E,I,O) be an open graph with a gflow (≺,g) and suppose that outputs oi,oj ∈ O are connected. Show then that (≺,g) is also a gflow for the open graph G′ = (V,E′,I,O) where E′ = E∖{(oi,oj)}, i.e. the graph where we removed an edge between two outputs. Similarly, show that adding an edge between two outputs also preserves gflow.

Exercise 9.5. Let G = (V,E,I,O) be an open graph with a gflow (≺,g) and let o ∈ O be some chosen output. Define G′ = (V ′,E′,I,O′) by V ′ = V ∪{u}, O′ = {u}∪ O∖{o} and E′ = E ∪{(o,u)}. That is: G′ is just G but with another vertex u after o that becomes the new output. Show that (≺′,g′) is a gflow for G′ where ≺′ is just the transitive closure of ≺ with the additional relation o ≺′u, and g′(o) = {u}, and g′(v) = v for every other vertex.

Note that these results only talk about creating a new pattern that also has a gflow. We are not defining an actual measurement pattern, and hence we are not saying anything about whether this new pattern implements the same linear map or not.

In Section 9.3 we will prove that some more elaborate ways in which we can change graphs also preserve the existence of a gflow.

9.2.5 Focussed gflow

The definition of a gflow allows the correction set g(u) to also induce corrections on other vertices, as long as those other vertices are in the future of u. That is, OddG(g(u)) can contain more than one vertex. It turns out that we can modify a gflow to just allow u to be corrected and no other measured vertex (this turns out to be useful later).

Definition 9.2.8. We say a gflow (≺,g) on an open graph G = (V,E,I,O) is focussed when for every u ∈ V ∖O, the set OddG(g(u)) consists only of u itself and output vertices. That is, OddG(g(u))∖O = {u}.

Intuitively we can focus a gflow because being in OddG(g(u)) means that a vertex v gains a Z(π) phase if u had the wrong measurement outcome. However, as v is measured in the XY-plane, gaining a Z(π) phase is also what happens when v itself gets the wrong measurement outcome:

Since we know that we can correct the wrong outcome of v, we can push the phase auπ at vertex v to the same correction set as we would’ve pushed avπ. Hence, if we add the correction set of v to that of u, we see that we no longer have Z(auπ) appearing at v, but instead only in the future of v. We then repeat this process until the Z(auπ) phase only appears at outputs.

Exercise 9.6. Let G = (V,E,I,O) be an open graph with a gflow (≺,g). Pick some vertex u ∈ V ∖O. Let A ⊆ V be some set of vertices such that for any v ∈ A and v ∈OddG(A) we have u ≺ v and u≠v. Show then that the function g′ defined by g′(u) = g(u) Δ A and g′(w) = g(w) for all w≠u also defines a gflow (≺,g′) on G.
Hint: Use Exercise 9.3.

Exercise* 9.7. Show that if an open graph has a gflow, then it also has a focussed gflow.
Hint: if you have some u for which OddG(g(u)) contains some vertex v it shouldn’t, then v has to be in the future of u. Argue that A = g(v) satisfies the conditions of the previous exercise. Proceed to modify g(u) with A. What has now changed about OddG(g′(u))?

9.3 Optimising deterministic measurement patterns

In the same way as we can think of optimising a circuit in terms of reducing the gate count or reducing the total depth by parallelising gates as much as possible, we can also think of optimising a measurement pattern by removing as many measured qubits as possible, or by reducing the total correction depth, the longest chain of measurements whose measurement angles depend on each other. Another consideration for measurement patterns is that we need to do these optimisations in a way that preserves determinism, and ideally the existence of gflow.

In this section we will show that qubits measured in a Clifford angle kπ 2 are particularly amenable to optimisation in measurement patterns. We will show first that all qubits with a Clifford measurement angle can be measured simultaneously so that the depth of the computation only depends on the number of non-Clifford angles. We will then show that we can in fact remove qubits with a Clifford measurement angle from the pattern all together. This will use the local complementation and pivoting rewrites from Chapter 5. These rewrites allowed us to remove internal spiders from a graph-like diagram and as we’ve seen in this chapter, we can view graph-like diagrams as measurement patterns, and then internal spiders become measured qubits. Hence, these rewrites now offer ways to optimise the number of qubits we need to measure in the pattern. We will show in this section that these rewrites preserve the existence of a gflow, and hence that the pattern remains deterministically realisable.

9.3.1 Parallelising Clifford measurements

We will show here that we can measure all qubits with a Clifford measurement angle simultaneously in a pattern with gflow. But first, since we said above that we can actually remove qubits measured in a Clifford angle from a pattern anyway: why bother? Those rewrites will change the structure of where we have Hadamard edges in the diagram. Hence, if we had carefully constructed our pattern to fit for instance in the cluster state shape of Section 9.1.1, then we would break this shape with these rewrites. The arguments we will use here however do not change anything about the shape of the pattern, and purely make the pattern take less time to execute by parallelising the number of measurements.

So suppose we have some measurement pattern with gflow (g,≺). Using the results of Section 9.2.5 we may assume this gflow is focussed, and hence no measured qubits are in the odd neighbourhood of a correction set. We wish to show that we can in fact ignore the order of measurement ≺ and instead measure each qubit v with αv = 0,π, π 2 ,−π 2 simultaneously.

The obstacle we need to overcome to make this work, is that a Clifford vertex v might be in the correction set g(u) of some other vertex u. We make a case distinction on the phase of v to see what that means for the linear map the pattern implements. Let’s first suppose αv = kπ:

We see that the needed correction for u is just absorbed in the kπ + avπ phase without changing anything. Hence, the way we measure v actually doesn’t depend on u, and so we are free to measure v before u instead of after. Note that the gflow conditions don’t ‘know’ about this possibility, since a measurement pattern has gflow regardless of the specific measurement angles we choose. In this particular case, when we know that the measurement angle is 0 or π, we see that it can absorb any correction, and hence that it doesn’t have to satisfy some of the gflow conditions.

Let’s now consider the other possibility for a Clifford phase: αv = ±π 2 :

The X(auπ) correction always toggles the measurement phase from αv to (−1)auαv. In this particular case, since the phase is ±π 2 , flipping it to ∓π 2 is the same thing as adding a π phase to it, so that we see that the needed X(auπ) correction is actually equivalent to a Z(auπ) here. Since this is precisely the correction needed to correct the measurement outcome avπ of v itself, we can push this phase to the correction set g(v). Hence, we don’t need v to correct u, we can instead use the correction set g(v). Note that this argument is very similar to the one we used when focussing gflow in Section 9.2.5, but now by making this change we might actually be breaking the gflow conditions. However, because we have just shown that we are preserving the linear map of the pattern, and because g(v) is in the future of v and hence of u, this is fine!

This shows that for a single Clifford qubit v we can ignore the dependency on ≺ and just measure it whenever we want. In order to do this for all Clifford qubits, we need to make these changes in order of ≺, starting with the earliest Clifford vertex and working our way to the end. This is because when the phase is αv = ±π 2 , we see that we must update each g(u) containing v to g(u)Δg(v)Δ{v} instead. Because this pushes corrections further into the future, we need to make sure we are not ‘undoing’ work we have done before.

Putting this all together we see that we have shown the following.

Proposition 9.3.1. Let D be a measurement pattern with gflow (g,≺). Then we can find a modified deterministic measurement pattern D′ that implements the same linear map, where all the qubits with measurement angle in the set αv = 0,π, π 2 ,−π 2 are measured simultaneously at the start. The remainder of the qubits are measured in the same relative order specified by ≺.

We showed this result only in the context of measurement patterns with XY -plane measurements. However, such a result also holds when we have measurements in the Y Z and XZ planes and 3-plane gflow, which we’ll introduce in Section 9.5, for similar reasons.

9.3.2 Removing Clifford vertices from measurement patterns

Instead of just parallelising all Clifford measurements, we can just remove the Clifford measurements entirely! We will show here that the spider-removing versions of local complementation and pivoting from Chapter 5 can also be thought of as modifications to an open graph in such a way that it preserves the existence of a gflow. Hence, these rewrites can be used to optimise measurement patterns with gflow and result in patterns with fewer measured qubits.

While we tried to present the proofs here in as simple a way as possible, it still requires some stamina to process all the odd-neighbourhood acrobatics. So perhaps on a first read-through you might want to just read the statements of Proposition 9.3.3 and 9.3.6 and then move on to the next section to see what we will use these results for.

Recall that for a graph G, we defined G ⋆ u to be the graph where we locally complemented about u. In this graph the neighbourhoods have been updated as follows for any v ∈ V :

NG⋆u(v) = { NG(v) Δ NG(u) Δ {v}if v ∈ NG(u) NG(v) otherwise
(9.20)

We will also need to know how the odd neighbourhood of a set changes when you apply a local complementation.

Lemma 9.3.2. Given a graph G = (V,E), A ⊆ V and u ∈ V ,

OddG⋆u(A) = { OddG(A) Δ (NG(u) ∩ A)if u∉OddG(A) OddG(A) Δ (NG(u) ∖ A) if u ∈OddG(A)

Proof. Using the fact that OddG(A) = Δ v∈ANG(v), we calculate:

OddG⋆u(A) = Δ v∈ANG⋆u(v) =(9.20) (Δ v∈A∩NG(u)NG(v) Δ NG(u) Δ {v})Δ (Δ v∈A∖NG(u)NG(v)) = (Δ v∈ANG(v)) Δ (Δ v∈A∩NG(u)NG(u)) Δ (Δ v∈A∩NG(u){v})

Here in the last step we simply regrouped the terms: we used the fact that the NG(v) term appears in both the terms above it so that we can combine them into Δ v∈ANG(v), and we separated out the other terms. We then see that the first term is precisely OddG(A), while the last term is just a union of all the {v} in A ∩ NG(u). This expression hence simplifies to

OddG⋆u(A) = OddG(A) Δ (Δ v∈A∩NG(u)NG(u)) Δ (A ∩ NG(u))

It remains to simplify the middle expression. This is just a symmetric difference of NG(u) with itself a number of times. This term hence only appears when |A ∩ NG(u)|≡ 1 mod 2. This is precisely the case when u ∈OddG(A). Hence, if u∉OddG(A), OddG⋆u(A) = OddG(A) Δ (A ∩ NG(u)). Otherwise, if u ∈OddG(A), we get OddG⋆u(A) = OddG(A) Δ NG(u) Δ (A ∩ NG(u)). We can simplify this expression by using the property B Δ (A ∩ B) = B ∖ A (convince yourself that this is true). The expression for OddG⋆u(A) then becomes exactly what we wanted to prove. □

Proposition 9.3.3. Let G = (V,E,I,O) be an open graph with a gflow (≺,g) and let u ∈ V ∖ (I ∪ O) be an internal vertex. Then G′ := (G ⋆ u) ∖{u}, the open graph we get by doing a local complementation about u and then removing u, also has gflow.

Proof. By Exercise 9.7 we may assume that the gflow g of G is focussed, i.e. that OddG(g(w)) only contains {w} and outputs of G for any w.

We then claim that the function g′ : V ∖ (O ∪{u}) → ℘(V ∖ (I ∪{u})) defined by

g′(w) := { g(w) if u∉g(w) g(w) Δ {u}Δ g(u)otherwise
(9.21)

gives a gflow (≺,g′) on (G ⋆ u) ∖{u}. We haven’t changed the partial order, so we just need to check the different conditions that g′ has to satisfy. First, note that it is well-defined: none of the g′(w) contain u. In the first case this is true by construction, and in the second case we know that u ∈ g(w), so that g(w) Δ {u} = g(w) ∖{u}.

Now we have to check three things:

1..

All the elements of g′(w) are in the future of w.

2..

All the elements of OddG⋆u(g′(w)), except for w itself are in the future of w.

3..

OddG⋆u(g′(w)) contains w.

For the first point, note that if u∉g(w), that then g′(w) = g(w), in which case all of g′(w) is definitely in the future of w (since we haven’t changed the partial order ≺). Otherwise u ∈ g(w), and hence w ≺ u, so that all the elements of g(u) are in the future of w. Hence g′(w) = g(w) Δ {u}Δ g(u) only contains elements in the future of w.

Then for the second and third point. Because g is focussed and u is not an output, we know that u∉OddG(g(w)) if w≠u. This means that when we use Lemma 9.3.2 to calculate OddG⋆u(g(w)) the first case applies and we get OddG(g(w)) Δ (NG(u) ∩ g(w)).

So now let’s again make the case distinction on whether u ∈ g(w). If this is not the case, then g′(w) = g(w), and hence

OddG⋆u(g′(w)) = Odd G⋆u(g(w)) = OddG(g(w)) Δ (NG(u) ∩ g(w)).

Both the elements of OddG(g(w)) and (NG(u) ∩ g(w)) ⊆ g(w) are certainly in the future of w, so that this odd neighbourhood lies in the future of w. Additionally, OddG(g(w)) contains w, while g(w) does not, so that w ∈OddG⋆u(g(w)). Hence, points 2 and 3 are satisfied for those w where u∉g(w).

It then remains to check OddG⋆u(g′(w)) for the w that satisfy u ∈ g(w). To calculate this set it will be useful to first calculate OddG⋆u(g(u)). As u ∈OddG(g(u)), the second case of Lemma 9.3.2 applies. We hence get

OddG⋆u(g(u)) = OddG(g(u)) Δ (NG(u) ∖ g(u)).

Then using the definition of g′(w) in Eq. (9.21) and the linearity property of odd neighbourhoods, OddG(A Δ B) = OddG(A) Δ OddG(B), we calculate:

OddG⋆u(g′(w)) = Odd G⋆u(g(w)) Δ OddG⋆u({u}) Δ OddG⋆u(g(u)) = OddG⋆u(g(w)) Δ NG(u) Δ OddG(g(u)) Δ (NG(u) ∖ g(u)) = OddG⋆u(g(w)) Δ OddG(g(u)) Δ (g(u) ∩ NG(u))

Here in the last step we used the property A Δ (A ∖ B) = B ∩ A where A = NG(u) and B = g(u). We have already seen that every element of OddG⋆u(g(w)) is in the future of w. Since we are assuming u ∈ g(w), we have w ≺ u, and hence both g(u) ∩ NG(u) ⊆ g(u) and OddG(g(u)) are in the future of w. It remains to verify that w ∈OddG⋆u(g′(w)), but this follows because w ∈OddG⋆u(g(w)).

We hence see that g′ is indeed a gflow. Note that while we started with a focussed gflow g, the new gflow g′ is not necessarily focussed. □

Proving that pivoting preserves gflow is done quite similarly. Just like how we needed a lemma that told us how odd neighbourhoods evolved under application of a local complementation, we need one that tells us what happens when a pivot happens. For this it will be helpful to introduce a little bit of extra notation.

Definition 9.3.4. We define the closed neighbourhood of a vertex u as NG[u] := NG(u) Δ {u} = NG(u) ∪{u}. Similarly we define the closed odd neighbourhood of a set A as OddG[A] := Δ u∈ANG[u] = OddG(A) Δ A.

Let u and v be some vertices of G, and write G ∧ uv for the graph where we pivoted along uv. Then for any w we have:

NG∧uv(w) = { NG(w) Δ NG[u] Δ NG[v]if w ∈ NG[u] ∩ NG[v] NG(w) Δ NG[v] if w ∈ NG[u] ∖ NG[v] NG(w) Δ NG[u] if w ∈ NG[v] ∖ NG[u] NG(w) otherwise
(9.22)

Exercise 9.8. Calculate using this equation, that when w = u we get NG∧uv(u) = (NG(v) ∪{v}) ∖{u} as we expect (since u and v essentially just swap places in the graph).

Lemma 9.3.5. Given a graph G = (V,E), A ⊆ V , u ∈ V , and v ∈ NG(u),

OddG∧uv(A) = { OddG(A) if u,v∉OddG[A] OddG(A) Δ NG[v] if u ∈OddG[A],v∉OddG[A] OddG(A) Δ NG[u] if u∉OddG[A],v ∈OddG[A] OddG(A) Δ NG[u] Δ NG[v]if u,v ∈OddG[A]
(9.23)

Exercise* 9.9. Prove Lemma 9.3.5.
Hint: You will need the same tricks that were used to prove Lemma 9.3.2.

Proposition 9.3.6. Let G = (V,E,I,O) be an open graph with a gflow (≺,g) and let u,v ∈ V ∖ (I ∪ O) be connected internal vertices. Then G′ := (G ∧ uv) ∖{u,v}, the open graph we get by doing a pivot along uv and then removing u and v, also has gflow.

Proof. Again we will assume that g is focussed. We then define a gflow g′ for G ∧ uv ∖{u,v} as follows: for every w ∈ V ∖ (O ∪{u,v}) set g′(w) := g(w) ∖{u,v}. Every condition needed for g′ to be a focused gflow then follows immediately except for checking that OddG∧uv∖{u,v}(g′(w)) contains w and lies in the future of w.

Note that OddG[g(w)] = OddG(g(w)) Δ g(w) ⊆{w}∪ O ∪ g(w) by the focussed property, so that u ∈OddG[g(w)]⟺u ∈ g(w) and similarly for v. Now, to look at the odd neighbourhoods of the correction sets we will make a case distinction on w based on whether u ∈ g(w) or v ∈ g(w).

□

We hence see that we can indeed do the spider-removing version of local complementation and pivoting while preserving the existence of gflow. You might at this point wonder whether we couldn’t just do the local complementation without removing the spider, and whether this preserves gflow. It in fact does not, but that is because we aren’t using the right notion of gflow for this: the spider-preserving version of local complementation (Lemma 5.2.4) introduces a X(π 2 ) phase on the spider being pivoted on. This makes it so that we can no longer interpret this spider as being measured in the XY plane. The solution to this is to treat it as a qubit measured in a different type of plane. We will see how to do this in Section 9.5.

Remark 9.3.7. Propositions 9.3.3 and 9.3.6 are results about open graphs, not measurement patterns. Hence, we can in general apply these to make new kinds of measurement patterns, which might not implement the same linear map as before. If we want to apply these in a way that preserves the linear map the pattern is implementing, we also need to consider the specific measurement angles the pattern must have and how these get updated by the rewrite. For this we would need to reference the ZX local complementation and pivot simplifications of Lemma 5.2.9 and 5.2.11.

9.4 From measurement patterns to circuits

Starting with a quantum circuit, we can transform it into a graph-like diagram which has gflow (Proposition 9.2.6), and hence we can turn this circuit into a deterministic measurement pattern. We have also seen several ways in which we can change a measurement pattern while preserving gflow. These patterns we get don’t necessarily look very circuit-like any more, so it is not obvious how the connections and measurements in this pattern correspond to unitaries acting on an input state.

In this section we will see that nevertheless we can transform an arbitrary deterministic measurement pattern with gflow back into a circuit that implements the same linear map. Since these patterns are deterministic, we can represent the linear map they implement as a single graph-like ZX-diagram, like we did in Section 9.2.1. The input of our algorithm will be a graph-like diagram whose underlying open graph has a gflow, and the output should be an equivalent quantum circuit. We call this process circuit extraction. The basic idea will be similar to the CNOT circuit extraction algorithm we saw way back in Chapter 4, but instead of doing one round of Gaussian elimination to get a circuit out, we will be doing ‘a little bit’ of row elimination in order to extract a single internal spider from the pattern. We repeat this until the diagram contains no more internal spiders. We then have a diagram looking very similar to the Clifford GSLC normal form of Section 5.3.3, which we know how to turn into a circuit.

Since our algorithm doesn’t work with measurement patterns directly, but with ZX-diagrams, we can let the input be any graph-like diagram whose underlying open graph has gflow. Such a diagram will then look something like this:

(9.24)

We put some phases on the spiders for concreteness, but as our only consideration is whether the diagram has gflow, the particular values of these phases won’t affect the steps we need to take to extract a circuit from a diagram.

So let’s start trying to make this diagram more circuit-like. As in Section 5.3.3, we first observe that the spiders on the boundary already directly correspond to quantum gates: either single-qubit gates or two-qubit CZ gates:

(9.25)

Here we mark the two parts of the diagram by ‘unextracted’ and ‘extracted’ to denote that we are done with the part on the right. This part already looks like a circuit now, so we don’t have to do anything with that anymore. We will refer to the spiders on the boundary of the extracted and unextracted part as the frontier. We will be applying operations to the frontier in such a way that we can move frontier spiders to the extracted part and internal spiders onto the frontier. The reason we start at the end of the diagram instead of at the beginning is because it will be easier to show that such operations preserve the existence of a gflow on the remaining diagram. The extraction algorithm is only guaranteed to work if the diagram has gflow, so it is important that all the steps change the diagram in ways which preserve the existence of a gflow. For instance, in Eq. (9.25) the underlying graph of the unextracted part only changed in having no more connections between the output vertices. This is exactly the transformation that we showed in Exercise 9.4 preserves gflow.

In the case of the GSLC normal form of Section 5.3.3, we realised that the internal connectivity of the diagram corresponds to a CNOT circuit. Here we can do something similar, but instead of rewriting the entire diagram to a CNOT circuit directly, we can ‘extract’ a single CNOT in order to change the connectivity of the diagram:

Proposition 9.4.1. For any graph-like diagram D, the following equation holds:

where M describes the biadjacency matrix of the relevant vertices, and M′ is the matrix produced by starting with M and then adding row 1 to row 2, taking sums modulo 2. Furthermore, if the diagram on the left has gflow, then the graph-like part on the right also has gflow.

Proof. For clarity we will not draw the entire diagram, but instead we focus on the relevant part. First of all we note that we can add CNOTs in the following way while preserving equality:

(9.26)

Now let A denote the set of vertices connected to the top vertex, but not to the vertex beneath it, B the set of vertices connected to both, and C the vertices connected only to the bottom one. Further restricting our view of the diagram to just these two lines, we see that we can apply a pivot:

Looking at the connectivity matrix, it is straightforward to see that the matrix M has now been changed in exactly the way described.

To see that these operations preserve the existence of a gflow, note first that we can view the rewrite of Eq. (9.26) as adding some identity spiders to the outputs of a diagram, and adding connections between these outputs. Hence, by Exercises 9.4 and 9.5 the resulting diagram still has gflow. We then do a pivot, which also preserves gflow by Proposition 9.3.6, and finally we consider the last CNOT as no longer being part of the graph-like diagram, which on the level of the underlying open graph looks like removing some output spiders, which can also be shown to preserve gflow. □

To demonstrate how we can use this, let us write down the biadjacency matrix from the frontier to the other spiders in our example diagram:

(9.27)

We see that if we add the fourth row to the third row that there will be only a single 1 on the third row. This means that the third frontier spider is only connected to a single internal spider, and hence corresponds to an identity spider that can be removed:

(9.28)

We now have one less spider in the unextracted part. We can again unfuse the phase of the frontier spider into the extracted part, and the same for the connections between the frontier spiders. We then rinse and repeat, extracting the spiders one by one. But why can we always do this? This is where gflow comes into play.

Using gflow we can show that the biadjacency matrix always has this property that we can reduce at least one of the rows to contain a single 1 using row operations: Suppose we have a graph-like diagram D and that its underlying open graph G has a gflow (≺,g). Pick the vertex u that is maximal according to the partial order ≺ in the set V ∖O. That is, u corresponds to the last measured qubit. Now we know that g(u) and OddG(g(u))∖{u} only contain vertices in the future of u. So in this case they must only contain outputs. So let o1,…,ok be the outputs that form g(u). Their sets of neighbours N(oj) then correspond to rows of the biadjacency matrix we wish to simplify. We are assuming we have already gotten rid of any connections between outputs, so that there are no outputs in the set N(oj). We know that OddG(g(u)) ⊆ O ∪{u} and furthermore OddG(g(u)) = N(o1) Δ ⋯ Δ N(ok) (Exercise 9.2). So in fact OddG(g(u)) = {u}.

Now here comes the kicker: taking the symmetric difference of sets follows exactly the logic of addition in 𝔽2! If we ‘add’ two sets A Δ B, then if there is an s with s ∈ A and s ∈ B, then s∉A Δ B, exactly how 1 ⊕ 1 = 0. All the other cases are checked similarly. So when we were adding together rows in the biadjacency matrix, what we were really doing was calculating the symmetric difference of the neighbourhoods. So since N(o1) Δ ⋯ Δ N(ok) = {u}, that means if we add together the rows of the biadjacency matrix corresponding to the outputs oj, then the resulting row has just a single 1, which corresponds to u. Hence, gflow tells us exactly which rows we can add together, and hence which CNOTs we need to place, in order to make progress. As we can do row operations on our biadjacency matrix using Proposition 9.4.1 and this preserves gflow, we will have after extracting a vertex still a diagram which has gflow. And hence when we repeat this procedure we will always be able to find some rows in the biadjacency matrix that combine together to form a row with a single 1, whose spider can then be extracted.

Note that this is a similar procedure to how we extracted a circuit from a CNOT+Phase diagram in Section 7.1.3: there we did column operations in order to reduce a column to contain just a single 1. Because we are extracting from the right here, we are doing row operations instead. At some point we will have removed all internal spiders, in which the case the remaining diagram is like the GSLC normal form of the previous chapter, except that the phases on the spiders can be arbitrary. This final bit can then also be transformed into a circuit using a variation on the procedure described in Section 5.3.3 and then we are done.

We can now conclude with the following theorem.

Theorem 9.4.2. Let D be a graph-like diagram whose underlying open graph has a gflow and which has the same number of inputs as outputs. Then we can efficiently extract a unitary circuit that implements the same linear map as D.

In Exercise 7.13 we saw that extracting a circuit from a ZX-diagram is in general a very hard problem. However, the existence of gflow gives a ZX-diagram enough extra structure to make this otherwise hard problem efficient.

Since any measurement pattern corresponds to a graph-like ZX-diagram with some additional information on how the measurement outcomes should be propagated, we can also use this result to conclude that any measurement pattern with gflow must be unitary.

Corollary 9.4.3. A deterministic measurement pattern with gflow and the same number of inputs as outputs implements a unitary.

9.5 Measurements in three planes

So far we have restricted all our thinking on determinism and gflow to measurements all occurring in the XY plane. With some small modifications, we can also make it work for measurement patterns where the measurements occur in all three planes. Before we see how that works, let’s answer an important question first: why bother? We’ve seen that we can do universal computation with measurement patterns where all measurements are in the XY plane, and that any circuit can be transformed into a single-plane measurement pattern. So why should we even talk about measurements in other planes.

There are a couple of reasons. First, in our discussion on universal resource states in Section 9.1.1 we saw that cluster states can be used to perform arbitrary computations. This however crucially depends on ‘carving out’ paths by doing strategic measurements in the Y Z plane. It is possible to do it without this feature, but the construction is much less intuitive. Second, in the previous chapter we saw how useful phase gadgets are. Phase gadgets are however not compatible with single-plane gflow. Consider the following simple diagram containing a phase gadget connected to just one spider:

(9.29)

This diagram is of course unitary, and if we were to simplify the gadget to a phase gate, the diagram would definitely have gflow. So what about the diagram itself? Consider the following two facts about gflow: (1) the phases of spiders are not important for having gflow or not, and (2) if you have gflow, the diagram must be unitary. Combining these facts we see that if the diagram (9.29) were to have gflow, then the following diagram would also have gflow, and hence would need to be unitary for all α and β:

(9.30)

But if we pick α = β = π 2 , we can show that the diagram disconnects, and so it is not unitary.

So what is the issue here? We see that the problem with unitarity arises when we put a non-zero phase on the ‘base’ of the gadget. Doing this stops it from being a phase gadget, and makes it just a stack of two spiders with some phases.

When translating a ZX-diagram into a measurement pattern, this is the wrong way to treat phase gadgets. Rather than treating the two spiders involved in the phase gadget as two XY -measured nodes in the graph state, we should treat the whole phase gadget as a single node measured in different plane.

The final reason for considering multiple measurement planes, closely related to allowing for phase gadgets, is that it allows us more freedom to optimise computations using the rules we have already seen without losing (3-plane) gflow.

So with all this in mind, let’s see how we should think about measurements happening in all three principal planes of the Bloch sphere. Recall first that these measurement bases have a nice representation in the ZX-calculus:

(9.31)

Here, as before, αk denotes the measurement angle of this specific effect, and the bk is a Boolean variable denoting the outcome of the measurement. The XY and Y Z plane measurements correspond to natural structures in a graph-like diagram: ‘regular’ internal spiders, and phase gadgets. We can view the ‘regular’ internal spiders of a graph-like diagram as qubits measured in the XY plane:

(9.32)

If we instead have a phase gadget, then we can view this as a qubit measured in the Y Z plane:

(9.33)

Measurements in the XZ plane don’t naturally occur in the graph-like diagrams we consider, because normally when we see a π 2 phase on an internal spider, we will immediately remove it with local complementation. Another reason we tend to keep XZ-plane measurements in the background is that measurement effects in the XY and Y Z planes correspond to Z and X spiders, respectively, but those for the XZ plane actually correspond to ‘Y -spiders’, which aren’t really a thing in the ZX-calculus.

Remark 9.5.1. It might be a bit confusing to remember that XY measurements correspond to Z spiders and so on for the other types of effects. The trick is to remember that the type of spider is the letter that does not appear in the name. So for XY , the corresponding spider is Z, and for Y Z it is X. The reason this happens is that spider of measurement effects for a given plane is defined using the basis (i.e. axis of the Bloch sphere) perpendicular to that plane.

We see then that to view a graph-like diagram as a measurement pattern, we need to interpret phase gadgets as qubits measured in the Y Z plane, while every other non-output spider is treated as a qubit measured in the XY plane.

Now, let’s consider what the corresponding notion of gflow should be for a 3-plane measurement pattern. To do so, let’s go back to the examples we looked at at the start of Section 9.2. There we considered an XY vertex that had an error:

We could then correct this by pushing out an X(π) phase from the XY vertex with phase β. When we push this X(π) phase, it becomes a Z(π) at the location we want it:

We captured the more general version of this idea with the gflow correction sets g(u). Here the set g(u) tells us where we have to extract out X(π) phases in order to get a Z(π) at the desired location. In particular, we get Z(π) phases at all the vertices in OddG(g(u)). The conditions on g(u) for u an XY vertex are hence that u ∈OddG(g(u)) and u∉g(u) (since we can’t extract out an X(π) phase from u itself). We see then that we interpret g(u) as the vertices where we need to push out an X(π) and OddG(g(u)) where we need to push out a Z(π). The properties of an XY -plane measured vertex u tell us what the relations to g(u) and OddG(g(u)) need to be.

Let’s now consider the same example, but with a Y Z vertex instead:

We see then that now we need to correct an X(π) error instead of a Z(π) error. Still treating g(u) as the ‘set of vertices where we push out an X(π)’ we see then that now we do need u ∈ g(u) to correct this error, as pushing out another X(π) from u corrects the error present. Analogously, we now do not want a Z(π) to appear at u, so we must have u∉OddG(g(u)).

Putting it succinctly: g(u) are the X-corrections, while OddG(g(u)) are the Z-corrections. The measurement plane of the vertex determines which correction its measurement outcome needs. Note that there is no restriction on what types of vertices can appear in g(u) or OddG(g(u)), as it is possible to extract both Z(π) phases and X(π) phases from a vertex used in a correction set, regardless of which measurement plane that vertex has.

In order to give a formal definition of a gflow on multiple measurement planes we need to work with a labelled open graph, where each non-output vertex u is labelled by its type λ(u). We take this type to be a set that is either {X,Y },{Y,Z} or {X,Z} (defining it as a set likes this makes the following definition nicer).

Definition 9.5.2. Let G = (V,E,I,O,λ) be a labelled open graph with labels given by a function λ : V ∖O →{{X,Y },{Y,Z},{X,Z}}. A 3-plane gflow (≺,g) on G consists of a partial order ≺ on the vertices of G, and a correction set function g : V ∖O → ℘(V ∖I) that associates to every non-output vertex u ∈ V ∖O a subset of non-input vertices g(u) ⊆ V ∖I, such that for every non-output vertex u the following conditions hold:

1..

The inputs are minimal in the partial order ≺ (meaning that if v ≺ i for some input i, then v = i) and conversely the outputs are maximal;

2..

We have u ≺ v for every v ∈ g(u) and v ∈OddG(g(u)), i.e. corrections lie in the future of u.

3..

u ∈OddG(g(u)) if and only if X ∈ λ(u),

4..

u ∈ g(u) if and only if Z ∈ λ(u).

We say an open graph has 3-plane gflow when at least one 3-plane gflow can be defined on it.

This definition is relatively compact, so it is worth checking that this gives the correct behaviour for all three types of measurement plane. If λ(u) = {X,Y }, then we see that condition 3 gives u ∈OddG(g(u)), while condition 4 gives u∉g(u). This is because condition 4 is an ‘if and only if’. Hence, as we do not have X ∈ λ(u), we also do not have u ∈ g(u). In the same way we can check that for λ(u) = {Y,Z} we get u∉OddG(g(u)) and u ∈ g(u) as we expect.

For the final type λ(u) = {X,Z} we see that we get the conditions u ∈OddG(g(u)) and u ∈ g(u). This means that to correct an error at u, we should get both an X(π) and a Z(π) there. We can check that this is indeed what is necessary:

(9.34)

We indeed see that the wrong measurement outcome in a XZ-plane measured vertex requires both a Pauli X and Z to correct it.

With this discussion we see then that 3-plane gflow allows us to correct the wrong measurement outcome in every measured vertex. We can then write down a 3-plane version of Theorem 9.2.4. As this gets a bit fiddly to describe the entire pattern explicitly, as we did in the XY -only case, we will give a more informal description.

Theorem 9.5.3. Let D be a graph-like ZX-diagram and let (G,I,O,λ) be its underlying labelled open graph, where λ is a choice of measurement planes compatible with D, i.e. the plane is XY for a regular spider and Y Z for a phase gadget. Then if its associated labelled open graph has a 3-plane gflow, we can efficiently construct a deterministic measurement pattern from D that implements the same linear map as D.

We can see something nice in Definition 9.5.2 that simplifies our life somewhat: each 3-plane gflow is compatible with exactly one choice of types. This is because conditions 3 and 4 are if-and-only-if. Just by inspecting whether u ∈OddG(g(u)) and u ∈ g(u) we can exactly determine which of the three types λ(u) is. Hence, if we are given an open graph with a 3-plane gflow, we don’t actually need to know the labels as we can recover them from the gflow itself. With slight abuse of notation we will hence just say that an (unlabelled) open graph has a 3-plane gflow, and that the label of a vertex is determined by the properties of its correction set.

9.5.1 Rewriting 3-plane gflow

Measurement patterns with 3-plane gflow allow some rewrites that have no counterpart in the single measurement-plane model. For instance, we can actually remove any vertex that is not measured in the XY plane.

Exercise 9.10. Let G be an open graph with 3-plane gflow (g,≺). Let u be a non-output, with u ∈ g(u), i.e. λ(u)≠{X,Y }. Show that then u can be removed from G while preserving the existence of a 3-plane gflow and that furthermore, this gflow can be chosen in such a way to preserve the measurement plane of all vertices. Hint: On the new graph with u removed, define a new gflow g′ as g′(v) = g(v) if u∉g(v) and g′(v) = g(v)Δg(u) otherwise.

While it might be surprising at first that we can just remove qubits while preserving gflow, remember that Y Z measurements correspond to phase gadgets. Since patterns with gflow must be deterministic for any choice of measurement angles, any Y Z measurement should be allowed to have an angle α = 0. But then, setting the angle of a phase gadget to 0 is the same as deleting it completely. The intuition is similar for XZ measurements, which behave a bit like phase gadgets in this respect.

In Proposition 9.3.3 we showed that we can do the spider-removing version of local complementation while preserving single-plane gflow. It turns out that we can split this up into two parts: local complementation and spider removing. The second part was covered by Exercise 9.10, which shows we can remove spiders in two of the measurement planes spider while preserving existence of gflow. The first part is the following proposition.

Proposition 9.5.4. Let (g,≺) be a 3-plane gflow for an open graph (G,I,O), and let u be an internal vertex. Then the local complementation of G about u, written G ⋆ u has a 3-plane gflow (g′,≺) where g′ is defined by

g′(u) := { g(u) if λ(u) = {Y,Z} g(u)Δ{u}else g′(v) := { g(v) if u∉OddG(g(v)) g(v)Δg′(u)Δ{u}if u ∈OddG(g(v))

where v is any non-output vertex not equal to u.

The proof of this proposition is similar to that of Proposition 9.3.3, though with more case distinctions for all the different measurement planes u and v can have. We leave the proof to the particularly motivated reader.

Exercise* 9.11. Prove Proposition 9.5.4.

In Proposition 9.5.4 we didn’t write out the measurement planes of the of the vertices in G ⋆ u. But it is important to keep in mind that these do change. Way back in Section 5.2.1 we saw that we can perform a local complementation on a graph state by adding some local Cliffords. In particular, on u we add an X(±π 2 ) phase, while all of its neighbours get a Z(∓π 2 ) phase. These π 2 phases change the measurement planes of u and its neighbours. For instance, suppose that λ(u) = {X,Y }. Then when its spider gains an X(−π 2 ) phase, we see that:

(9.35)

Hence, it becomes a spider measured in the XZ plane. This gives us a new perspective on the spider-removing version of local complementation: the local complementation changes the measurement plane from XY to XZ, and then Exercise 9.10 shows us that we can remove a spider measured in the XZ plane without losing the existence of gflow.

A pivot along the edge between vertices u and v is just a triple of local complementations on u, then v, and then u again. Hence, we see that a (regular, non-spider-removing) pivot also preserves gflow! As we saw in Section 5.2.2, the spiders being pivoted on gain (or lose) a Hadamard on their output wire:

In our setting of measurement planes, this again means that their measurement planes will change. In particular, the Z-spider of an XY measurement, becomes the X-spider of an Y Z measurement. This again allows us to decompose the preservation of gflow under the spider-removing pivot as a sequence of two operations: first we pivot to change the XY vertices into Y Z vertices, and then we remove these vertices while preserving gflow using Exercise 9.10.

This also immediately gets us the gflow preservation of variations on the pivot we’ve seen. In particular, the gadget pivot of Lemma 7.6.1 we can see as doing a regular pivot on a pair of XY vertices, where we then only remove the resulting Y Z vertex corresponding to the Pauli spider:

The new phase gadget we get is the second spider of the pivot, which transforms from XY to Y Z. As pivoting preserves gflow, we see that the gadget pivot (which we now see is just a regular pivot followed by a vertex removal) also preserves gflow. Hence, we can introduce phase gadgets while preserving the existence of a 3-plane gflow!

Exercise 9.12. Prove that local complementation and pivoting have the following effects on measurement planes:

Generalising to 3-plane gflow allows us to be more efficient in the number of qubits measured. In Section 7.6 we observed that local complementation and pivoting do not necessarily remove all internal Pauli spiders. In order to do so, we had to turn them into the base of a phase gadget. While this does not decrease the total number of spiders in the diagram, when viewing the diagram as a measurement pattern, the two spiders of a phase gadget correspond to a single qubit measured in the Y Z plane. If the phase gadget has a Clifford phase, we can remove it, so we observed that every internal spider either has a non-Clifford phase, or is part of a phase gadget with a non-Clifford phase. Phrasing this in terms of measurement patterns, we see that these rewrite rules allow us to remove all non-input qubits that are measured in a Clifford angle. Since all steps preserve gflow, the resulting compact pattern can still be deterministically implemented.

Theorem 9.5.5. For every 3-plane measurement pattern containing k non-Clifford non-input measured qubits, we can efficiently find an equivalent measurement pattern that contains at most k non-input measured qubits.

9.5.2 Circuit extraction with phase gadgets

We can also extract circuits from measurement patterns with 3-plane gflow. To do this we need to slightly modify the algorithm we described in Section 9.4.

First, let’s see how that algorithm will go wrong when we have measurements not in the XY plane. Consider the following example where we have a phase gadget (i.e. a Y Z plane measurement) connected to the frontier:

(9.36)

Looking at the connectivity matrix we see there is no way to do row operations to reduce any row to just have a single one. So our strategy for extracting spiders one-by-one fails here. But remember that we introduced phase gadgets into our diagrams by doing pivots (Lemmas 7.6.1 and 7.6.2). So if a pivot got us into this mess, perhaps another pivot can get us out of it:

(9.37)

Success! Looking at the connectivity matrix we see that a single row operation from qubit 2 to qubit 1 gives us the right connectivity to extract the spider with the α phase.

In general, the way we do circuit extraction is as follows. First, we need to make sure our pattern only contains XY and Y Z measurements, no XZ measurements allowed (we describe how to do this later). Then, as long as we have XY vertices we can extract, we extract them. When we get stuck, it must be because there are Y Z vertices in the way. We do a pivot on them to change them into XY vertices, and then we continue the process. Since all steps preserve gflow, this procedure works and allows us to extract the full diagram.

So how do we get rid of the XZ measurements? We can do this by doing a series of smart pivots and local complementations to change the measurement planes in useful ways (see Exercise 9.12). First, if a XZ is connected to a Y Z, we do a pivot on them. This transforms the Y Z to XY , but keeps the XZ as is. Once this is done to all XZ vertices, they are only connected to XY vertices and other XZ vertices. Then for each XZ vertex, we do a local complementation on them. This changes it into an XY vertex. Neighbouring XY vertices stay the same, but neighbouring XZ turn into Y Z. Hence, each application reduces the number of XZ vertices, so that we can get rid of all of them. All of these steps preserve gflow and don’t increase or decrease the number of measurements (although they do change the connectivity of the graph).

Theorem 9.5.6. We can efficiently turn a graph-like diagram with 3-plane gflow into an equivalent quantum circuit.

9.6 There and back again

Let’s summarise some of the things we have seen in this chapter. We introduced a new way to perform quantum computations using measurements. This led us to the notion of a measurement pattern, where we describe a set of inputs, outputs, measurements and corrections. This model is also universal for quantum computing, which we showed by demonstrating patterns for single-qubit unitaries and CNOT gates which can be combined directly as graphs or ‘cut out’ of a universal resource like a cluster state.

If we consider a single branch of a measurement pattern, where we fix all the measurement outcomes, this can be represented directly as a graph-like ZX-diagram. Conversely, a graph-like ZX-diagram can be easily understood as a branch of a measurement pattern. In this sense, graph-like diagrams and measurement patterns are ‘the same thing’. This misses an important detail though: determinism.

A measurement pattern is deterministic when we can perform the desired computation, regardless of the observed measurement outcomes, by applying the appropriate corrections. If our measurement pattern is not deterministic it is considerably less useful, as we may have to run it exponentially many times to get the result we want via post-selection. We introduced a useful tool for thinking of determinism: gflow. Gflow is not a property of a specific measurement pattern, but rather of the underlying graph structure, and is agnostic to the specific measurement angles in the pattern.

To specify a full deterministic measurement pattern we have to describe how all the measurement angles change depending on the observed measurement outcomes. If instead we know the pattern has gflow, then this is already sufficient, as this allows us to construct a correction strategy. Instead of deterministic measurement patterns we can hence consider the weaker notion of graph-like diagram with gflow: the graph-like diagram tells us what the map should be when we get the ideal outcomes, and the gflow tells us how to correct when we get the wrong outcomes. This notion is weaker, because there might also be other correction strategies that do not correspond to a gflow strategy, or even measurement patterns that do not have gflow but are still deterministic for ad-hoc reasons.

When we have such a graph-like diagram with gflow, we can efficiently convert this back into a measurement-free (i.e. ancilla-free) quantum circuit. Conversely, when we have a unitary quantum circuit, we can write this as a graph-like diagram with gflow.

By using ZX-diagrams as an intermediary, we can translate back-and-forth between representing a computation as a circuit vs a deterministic measurement pattern:

In Chapters 5 and 7 we saw strategies for optimising ZX-diagrams, and in particular to remove spiders from the diagram. In this chapter we have seen that these rewrites based on local complementation and pivoting preserve the existence of gflow on the underlying open graph. This allows us to think of these rewrites not just as spider-removing simplifications on ZX-diagrams, but as ‘qubit-removing’ (or ‘measurement-removing’) simplifications on deterministic measurement patterns. Essentially, these rewrites, even a variant like the gadget pivot, can be seen as ways to get rid of qubits measured in a Clifford angle. This is yet another way in which we can think of the Clifford operations as being ‘easy’: when we measure a qubit in a Clifford angle, we can find an equivalent pattern where that qubit wasn’t necessary in the first place.

9.7 Summary: What to remember

1..

In measurement-based quantum computing we use quantum measurements as an integral part of the computation, instead of just using them at the end to get the result out of the final computation.

2..

There are many different variants on measurement-based quantum computing, but one particularly well-studied model that lies on the extreme end of doing all computations via measurements is the one-way model.

3..

In the one-way model you start by preparing a graph state. Then single-qubit measurements are performed in one of three measurement planes at a specified angle α. Later measurement angles are allowed to depend on previous measurement outcomes.

4..

Just as a quantum circuit is built out of gates, we can view a one-way model computation as being built out of measurement patterns, which have inputs and outputs (Definition 9.1.2).

These patterns include both the choice of measurement angles as well as Pauli corrections that can depend on previous measurement outcomes.

5..

An important consideration for a measurement pattern is whether it is deterministic, meaning that regardless of all the intermediate measurement outcomes, the overall linear map that is performed is the same (up to a known Pauli error that is being propagated into the future).

6..

One particular strategy for ensuring a pattern is deterministic is for the underlying open graph to have a property called gflow (Definition 9.2.2, Theorem 9.2.4). We can understand the existence of gflow as giving a winning strategy to the ‘measurement correction game’ (Section 9.2.2).

7..

We can view measurement patterns as graph-like ZX-diagrams, and vice versa we can interpret a graph-like ZX-diagram as a measurement pattern without a specified order of measurement.

8..

There is an efficient strategy to translate a circuit into a measurement pattern with gflow (Proposition 9.2.6).

9..

There is an efficient strategy to translate a measurement pattern with gflow, or equivalently a ZX-diagram with gflow, back into a circuit (Theorem 9.4.2).

10..

While the one-way model with just measurements in the XY plane is already universal, allowing measurements in all three principal planes allows for more compact patterns. There is a notion of gflow that works for measurements in all three planes (Definition 9.5.2, Theorem 9.5.3), and the circuit extraction algorithm can be adapted to work for that (Theorem 9.5.6).

11..

The ZX rewrite strategy of Section 7.6 involving phase gadgets preserves the existence of 3-plane gflow.

9.8 References and further reading

The one-way model The one-way model was originally proposed by [204], where they also immediately showed how the cluster state can be used as a universal resource for quantum computation. The cluster state itself was introduced by the same authors in a paper earlier that year [40]. In a paper the following year they formalised the model underlying the one-way model more, and they showed that a Clifford computation can be performed in a single time-step [206]. These authors revisit computing on cluster states in more detail in [207] which also coins the term ‘measurement-based quantum computing. The authors together with several others review all the progress made on the one-way model some years later [39].

Measurement patterns The notion of a measurement pattern was formalised in [70], using a syntactic representation called the measurement calculus. This consisted of basic operations to prepare single qubit states in |+⟩, entangle via controlled-Z, perform single-qubit measurements, and perform Pauli corrections. They showed that these can be composed and put into a standard form where we first do all state preparations and only then do measurements in [71]. This standard form has a natural correspondence to the graph-based definition of measurement patterns we use, which is closely related to the description of the pattern as a ZX-diagram. The first description of the one-way model using the ZX-calculus was given by [93].

Flow and determinism The notion of causal flow was introduced by [69]. This was later extended to generalised flow, or gflow, by [43], where they show that certain graph states do not allow causal flow, but do allow gflow. This paper defined both the single-plane gflow and 3-plane gflow, though our presentation of 3-plane gflow is a bit simplified. Furthermore, [43] showed that a measurement pattern has a gflow if and only if the pattern is uniformly, strongly and stepwise deterministic. Uniformity means that the determinism holds for any choice of measurement angle. Strong determinism means that every measurement outcome happens with equal probability. The stepwise determinism means that we retrieve a deterministic pattern after every single measurement. Or in other words, that the necessary corrections depend only on a single previous outcome. Hence, while there are deterministic patterns that do not have gflow, when they are sufficiently ‘regular’ and the reason for their determinism ‘not too complex’, it will have a gflow. Finally, [43] also introduced Pauli flow, which can deal with patterns where some qubits are designated to be measured in a Clifford angle. Hence, the uniformity condition doesn’t apply to these qubits. Because measurements in a Clifford angle essentially belong to two principal planes of the Bloch sphere at the same time, they can be corrected, and be part of correction sets, in more ways than general measurements, so that their gflow conditions can be less strict (something we also saw in Section 9.3.1).

Circuit extraction A routine for translating measurement patterns with gflow into quantum circuits without introducing extra ancilla qubits was first introduced by [94]. In [90] the authors improved on this technique and applied it to circuit optimisation. This was then extended to work for 3-plane gflow in [23]. The procedure we show in this chapter is based on that article. An alternative approach for extracting a circuit without ancilla from a measurement pattern with single-plane gflow was given by [189]. This was based on finding a path-cover of the open graph, and then resolving ‘acausal’ CZ gates by pushing them through other gates until they were acting at the same point in time on the two qubits. While efficient circuit extraction routines exist, it is difficult to control the two-qubit gate count of the resulting circuit. Heuristics have been proposed for this e.g. by [226] and [135].

Rewriting measurement patterns How a local complementation changes a graph state was noted in [238], and specifically for pivots in [186]. That these operations preserve gflow was shown in [90], that they preserve 3-plane gflow in [23], and that they preserve Pauli flow in [223]. This chapter is based on [90] and [23].

Other measurement-based models The one-way model is not the only way to do measurement-based quantum computing. One can also do universal computation using AKLT states [248], a state based on phase gadgets [153], or generalisations of graph states known as hypergraph states, that are built using multi-qubit controlled-Z operations [188, 231]. For a ZX perspective on hypergraph states, see [171]. We can also view the lattice surgery operations we will explore in Chapter 12 as a measurement-based model, see [76].

Applications of MBQC There are several suggested applications of MBQC that don’t make sense when just talking about circuits. Representing a circuit by a measurement pattern allows you to parallelise more operations, creating a shallower, but wider computation [42], in some cases even being able to reduce a computation from linear to logarithmic depth. The notion of blind quantum computation [41] was also demonstrated using MBQC. In blind computation, a client that only has the ability to prepare single-qubit states and transmit them, can delegate a computation to a server in such a way that the server does not know what it is computing. Hence, in this way you can do quantum computations ‘on the cloud’ without needing to share your data or even the computation you wish to perform. MBQC is ideally suited for such a scheme, since it can be implemented using a universal resource state and measurement angles can be masked by encoding them as single-qubit quantum states that get plugged into the resource state, rather than sending them over classically. Finally, MBQC is also a natural framework for understanding computations with photons as the qubits. Photons are then non-deterministically entangled using ‘fusion’ operations (which are not the same as spider fusions, though they are related [76]), which results in a resource state which has some random structure. By analysing average case behaviour, deterministic computations can still be run on such a ballistic state [192, 114].