Global Quantum Circuit Optimization

Global Quantum Circuit Optimization

R. Dias da Silva The first two authors have contributed equally to this work. Instituto de Física, Universidade Federal Fluminense, Av. Gal. Milton Tavares de Souza s/n, Gragoatá, Niterói, RJ, 24210-340, Brazil E. Pius School of Informatics, University of Edinburgh, 10 Crichton Street, Edinburgh EH8 9AB, UK E. Kashefi School of Informatics, University of Edinburgh, 10 Crichton Street, Edinburgh EH8 9AB, UK
Abstract

One of the main goals in quantum circuit optimisation is to reduce the number of ancillary qubits and the depth of computation, to obtain robust computation. However, most of known techniques, based on local rewriting rules, for parallelising quantum circuits will require the addition of ancilla qubits, leading to an undesired space-time tradeoff. Recently several novel approaches based on measurement-based quantum computation (MBQC) techniques attempted to resolve this problem. The key element is to explore the global structure of a given circuit, defined via translation into a corresponding MBQC pattern. It is known that the parallel power of MBQC is superior to the quantum circuit model, and hence in these approaches one could apply the MBQC depth optimisation techniques to achieve a lower depth. However, currently, once the obtained parallel pattern is translated back to a quantum circuit, one should either increase the depth or add ancilla qubits. In this paper we characterise those computations where both optimisation could be achieved together. In doing so we present a new connection between two MBQC depth optimisation procedures, known as the maximally delayed generalised flow and signal shifting. This structural link will allow us to apply an MBQC qubit optimisation procedure known as compactification to a large class of pattern including all those obtained from any arbitrary quantum circuit. We also present a more efficient algorithm (compared to the existing one) for finding the maximally delayed generalised flow for graph states with flow.

1 Introduction and background material

We are slowly reaching the classical limit of current technology in decreasing the size of computer chips. Hence to avoid quantum effect and also to reduce heat generation parallel computing has become the dominant paradigm in computer architecture. On the other hand in the quantum domain reducing the depth would be essential for keeping the computation coherent to avoid classical effect. In both scenarios designing parallel circuit remains a challenging task. Hence one attempts to rewrite locally a given circuit to reduce the depth of the computation. Usually such an approach will add ancilla registers to achieve the parallelisation, this being an undesired effect in the quantum setting as addition of ancilla qubits could increase the decoherence, breaching the initial purpose of parallelisaiton. In this paper we present a general optimisation techniques for quantum circuit that exploits the global structure of a given computation to achieve parallelisation with no ancilla addition.

Our technique is based on the translation of a given quantum circuit [1, 2] into a measurement-based quantum computation (MBQC) [3, 4]. These two models utilise remarkably different information processing tools: while the former is based on unitary evolution of an initially non-entangled set of qubits, the latter needs an initial highly-entangled multi-qubit state, where the information processing is driven by measurements only. Naturally since the two aforementioned models use different information processing tools, hence each model has its own optimisation techniques. In the MBQC model, for instance, most of the optimization techniques are based on the identification of a more efficient correction structure that is directly linked to the geometry of the underlying global entanglement structure. Examples of these techniques are the signal shifting [4] and the generalised flow [5], both discussed in following sections. The so-called standardisation procedure [4] can also reduce the number of computational steps by rearranging the MBQC operations into a normal form. Moreover, all Pauli measurements in this model can be performed in the beginning of the computation [6], which is a surprising difference from the quantum circuit model.

On the other hand, most optimization techniques for quantum circuits are based on template identification and substitution. For instance in [7], some circuit identities are used to modify the teleportation and dense coding protocols, with the purpose of giving a more intuitive understanding of those protocols. Similarly in [8] and [9] a set of circuit identities for reducing the number of gates in the circuit for size optimization was given. In contrast to that, in [10] a useful set of techniques for circuit parallelisation was provided, where the number of computational steps is reduced by using additional resources. However, as noted in [8], all the aforementioned circuit optimization techniques are basically exchanging a sequence of gates for a different one without any consideration on the structure of the complete circuit being optimised. The translation into MBQC would allow us to explore the global structure of a given circuit.

The first such a scheme by back and forth translation between the two models was presented in [11]. However the backward translation into the circuit required the addition of many ancilla qubits. On the other hand several recent works presented an optimised translation scheme from MBQC into the circuit where all the non-input qubits are removed, referred hereinafter as compact translation [4, 12, 13, 28]. The price for doing that happened to be the loss of the optimal depth of the original MBQC. The key result of our paper is a new scheme for the parallelisation where the obtained MBQC pattern could be translated compactly. Our scheme is based on a new theoretical connection between two MBQC depth optimisation procedures, known as the maximally delayed generalised flow [14] and signal shifting, which could lead to other interesting observation about MBQC, beyond the purpose of this paper as we discuss later. Also our result highlights the fundamental role of the MBQC Pauli optimisation in obtaining MBQC parallel structure beyond anything obtainable in the quantum circuit model, described later. We prove how our proposed scheme is more optimal in both depth and space compare to the scheme in [11]. We conclude with a new algorithm for finding the maximally delayed generalised flow for graphs with flow with steps compared to the exciting algorithm in [14], where is the number of the nodes in the graph.

1.1 The MBQC Model

We review the basic ideas behind the measurement-based quantum computation, with special attention to its description in terms of the formal language known as Measurement Calculus [4], and the flow theorems [15, 5].

In 1999 Chuang and Gottesman described how one could apply arbitrary quantum gates using an adaptation of the quantum teleportation model [16]. This approach was further developed by other researchers [17, 18, 19, 20], enabling one in principle to perform arbitrary computations given a few primitives: preparation of maximally entangled systems of fixed, small dimension; multi-qubit measurements on arbitrary set of qubits; and the possibility of adapting the measurement bases depending on earlier measurement outcomes.

These models of computation draw on measurements to implement the dynamics, and as such named collectively the measurement-based model of quantum computation (MBQC), for an overview see the paper by Jozsa [21]. An MBQC model using only single qubit measurements was proposed by Raussendorf and Briegel in 2001, which became known as the one-way model [6]. The one-way model achieves universality through the preparation of a special type of entangled states, the so-called cluster states [22]. These states are created with the CZ gate acting on qubits prepared in the state arranged in a regular lattice, usually the two-dimensional ones. This can be relaxed to create more general states with the same interaction over general graphs, creating the so-called graph states [23]. Both cluster and graph states can be represented graphically, using vertices denoting the qubits and edges for the two-qubit entangling gate CZ. Therefore, the entangled resource for the one-way model can be fully represented as graphs. Although two-dimensional cluster states can be used as resource for universal quantum computation in the one-way model, arbitrary graph states may, or may not, serve for the same purpose; investigating which kinds of entangled states are useful resources for MBQC is an active area of research [24, 25, 26, 27].

A formal language to describe in a compact way the operations needed for the one-way model was proposed in [4]. The language could be easily adapted to any other type of measurement-based model hence in the rest of this paper we refer to the general MBQC term instead of the specific one-way model as our scheme could be applicable to any MBQC models. In this framework every MBQC algorithm (usually referred to as an MBQC pattern) involves a sequence of operations such as entangling gates, measurements and feed-forwarding of outcome results to determine further measurement bases. A measurement pattern, or simply a pattern, is defined by a choice of a set of working qubits , a subset of input qubits (), another subset of output qubits (), and a finite sequence of commands acting on qubits in . Therefore, we consider patterns associated to the so-called open graphs:

Definition 1 (open graph).

An open graph is a triplet , where is a undirected graph, and are respectively called input and output vertices.

An example of an open graph is shown in Figure 3. There are four types of commands, the first is the qubit initialisation command that prepares qubit in the state . The input qubits are already given as a prepared state. The entangling command corresponds to the gate between qubits and , where

 ∧Z≡⎛⎜ ⎜ ⎜⎝100001000010000−1⎞⎟ ⎟ ⎟⎠.

The single-qubit measurement command corresponds to a measurement of qubit in the basis , with outcome associated with , and outcome with . The measurement outcomes are usually referred as signals. Finally, the corrections may be of two types, either Pauli or Pauli , and they may depend on any prior measurement results, denoted by ( or and the summation is done modulo two). This dependency can be summarised as correction commands: and denoting a Pauli and corrections on qubit which must be applied only when the parity of the measurement outcomes on qubits equals one (as ). A characteristic of the MBQC model is that the choice of measurement bases may depend on earlier measurement outcomes. These dependent measurements can be conveniently written as , where

 t[Mθi]s≡MθiXsiZti=M(−1)sθ+tπi, (1)

where it is understood that the operations are performed in the order from right to left in the sequence. The left () and right () dependencies of the measurement are called its and dependencies, respectively.

A pattern is runnable, that is, corresponds to a physically sound sequence of operations, if it satisfies the following requirements: (R0) no command depends on outcomes not yet measured; (R1) no command acts on a qubit already measured or not yet prepared, with the obvious exception of the preparation commands; (R2) a qubit undergoes measurement (preparation) iff it is not an output (input) qubit.

As an example, take the pattern consisting of the choices and the sequence of commands:

 Xs12M−θ1E12N02. (2)

This sequence of operations does the following: first it initialises the output qubit 2 in the state ; then it applies on qubits 1 and 2; followed by a measurement of input qubit 1 onto the basis . If the result is the latter vector then the one-bit outcome is and there is a correction on the second qubit (), otherwise no correction is necessary. A simple calculation shows that this pattern implements the unitary on the state prepared in qubit 1, outputting the result on qubit 2, where

 Jθ≡1√2(1eiθ1−eiθ). (3)

The simple sequence above is a convenient building block of more complicated computations in the MBQC model. This is because the set of single qubit () together with CZ on arbitrary pairs of qubits can be shown to be a universal set of gates for quantum computation [2].

The following rewrite rules ([4]) put the command sequence in the standard form, where preparation is done first followed by the entanglement, measurements and corrections:

 EijXsi ⇒ XsiZsjEij (4) EijZsi ⇒ ZsiEij (5) t[Mθi]sXri ⇒ t[Mθi]s+r (6) t[Mθi]sZri ⇒ r+t[Mθi]s (7)

This procedure is called standardisation and can directly change the dependencies structure commands, possibly reducing the computational depth, without breaking the causality ordering [11].

1.2 Determinism in MBQC

Due to the probabilistic nature of quantum measurement, not every measurement pattern implements a deterministic computation – a completely positive, trace-preserving (cptp) map that sends pure states to pure states. We will refer to the collection of possible measurement outcomes as a branch of the computation. In this paper, we consider deterministic patterns which satisfies three conditions: (1) the probability of obtaining each branch is the same, called strong determinism; (2) for any measurement angle we have determinism, called uniform determinism; and (3) which are deterministic after each single measurement, called stepwise determinism. We will call those patterns simply deterministic patterns. Here since we are only working with quantum circuits we don’t need to be concerned with other stronger notions of determinism defined for MBQC pattern such as in [29].

In [15] conditions over a graph (knows as flow) are presented in order to identify a dependency structure for the measurement sequence associated to open graph to obtain determinism. In what follows, we call non-input vertices as (complement of in the graph) and non-output vertices as (complement of in the graph).

Definition 2 (Flow[15]).

We say that an open graph has flow iff there exists a map and a strict partial order over all vertices in the graph such that for all

• (F1) ;

• (F2) if , then or , where is the neighbourhood of ;

• (F3) ;

Efficient algorithms for finding flow (if it exist) can be found in [31, 14]. The flow function is a one-to-one function. The proof is trivial, but as this property is extensively used in this work we will present the proof in this paper.

Lemma 1.

Let be a flow on an open graph . The function is an injective function, i.e. for every , is unique.

Proof.

Let us assume that for some , is not unique, i.e. there exists such that but . Then according to the flow definition:

 j∈N(f(i))⇒i≺fj, i∈N(f(j))⇒j≺fi,

and we arrive to a contradiction because and cannot be true at the same time. Hence has to be unique. ∎

In the case where , the flow function induces a circuit-like structure in a graph, in the sense that for each input qubit , there exists a number such that and the vertex sequence

 {i,f(i),f[f(i)],f[f[f(i)]]},...,fn(i)}, (8)

can be translated to a single wire in the circuit model. A simple example can be seen in Figure 1. This circuit-like structure is an interesting feature of the flow function, since it allows a very simple translation procedure called star decomposition introduced in [15].

Flow provides only a sufficient condition for determinism but one can generalise the above definition to obtain a condition that is both necessary and sufficient. This generalisation allows correcting sets with more than one element. In those cases, we say that the graph has generalised flow (or simply gflow). In what follows we define to be the set of vertices where each element is connected with the set by an odd number of edges.

Definition 3 (Generalised flow[5]).

We say has generalised flow if there exists a map (the set of all subsets of non-input qubits) and a partial order over all vertices in the graph such that for all ,

• (G1) if then ;

• (G2) if then or ;

• (G3) ;

The set is often referred to as the correcting set for qubit . It is important to note that flow is a special case of gflow, where contains only one element. This is a key difference regarding the translation of measurement patterns to quantum circuits. An example of a graph with gflow (but no flow) is shown in Figure 1.

The gflow partial oder leads to an arrangement of the vertices into layers (see below), in which all the corresponding measurements can be performed simultaneously. The number of layers corresponds to the number of parallel steps in which a computation could be finished, known as the depth of the pattern.

Definition 4 (Depth of a gflow[14]).

For a given open graph and a gflow of , let

 V≺gk={max≺g(V(G)) if % k=0max≺g(V(G)∖(∪i0

where is the set of maximal elements of according to . The depth of the gflow is the smallest such that , is a partition of into layers.

We define the layering function of a gflow based on the above distribution of vertices into layers.

Definition 5 (Layering function).

Given a gflow on an open graph we define its layering function to be the natural number such that .

There is another useful way to understand the depth of a gflow. A gflow can be represented as a directed graph on top of an open graph as shown in Figure 1. The longest path from inputs to outputs over those directed edges corresponds to the depth of the gflow. In [14] it was shown, that a special type of gflow, called a maximally delayed gflow, has minimal depth.

Definition 6 (Maximally delayed gflow[14]).

For a given open graph and two given gflows and of , is more delayed than if , and there exists a such that the inequality is strict. A gflow is maximally delayed if there exists no gflow of the same graph that is more delayed.

We will simply refer to the maximally delayed gflow as the optimal gflow. Note that in [14] it was proven that the layering of the vertices imposed by an optimal gflow is always unique, however the gflow itself might not be unique. This is an important property together with the following lemmas that we will exploit later for our main result on linking gflow to other known structures for MBQC.

Lemma 2 (Lemma 1 from [14]).

If is a maximally delayed gflow of then .

Lemma 3 (Lemma 2 from [14]).

If is a maximally delayed gflow of then is a maximally delayed gflow of where is the restriction of to and .

2 Depth optimisation tools for MBQC

Th parallel power of MBQC is proven to be equivalent to quantum circuit augmented with free unbounded fanout [30]. This motivates to use MBQC as an automated tool for circuit parallelisation as it was first presented in [11]. Another way to obtain parallel MBQC structure is to extract the entanglement graph of the pattern and obtain the optimal gflow of the graph [14]. Then one performs the required corrections according to this structure. Our first main result is to show the equivalence between these two seemingly very different technique for the patterns obtained from a quantum circuit, that is those with flow. More precisely we show how the effect of performing signal shifting optimisation (that is the core idea in [11]) result in a maximally delayed gflow. This structural link shed further lights on the complicated structure of maximally delayed gflow and permit us to find a new efficient algorithm for finding it for the large class of patterns obtained form a circuit.

2.1 Signal shifted flow

We proceed with reviewing the rules for signal shifting defined in [4]:

 t[Mαi]s ⇒Sti[Mαi]s (9) XsjSti ⇒StiXs[(t+si)/si]j (10) ZsjSti ⇒StiZs[(t+si)/si]j (11)

where is the signal shifting command (adding to ) and denotes the substitution of with in . Signal shifting, can be utilised to parallelise MBQC patterns and quantum circuits [11]. The rest of this section is focused on various structural properties of the signal shifting.

As can be seen from the above rules, signal shifting rewrites the - and -corrections of a measurement pattern in a well defined manner. In particular, it will move all the -corrections to the end of the pattern, thereby introducing new -corrections when Rule 10 is applied. It is proven in [11] that signal shifting will never increase the depth of an MBQC pattern, although it can decrease it. In the case when the depth decreases, it is the consequence of the removal of the -corrections on the measured qubits by applying Rule 9.

The Rules 9 - 11 can be interpreted in the following way. Signal shifting takes a signal from a -correction on a measured qubit (Rule 9) and adds it to the corrections that depend on the outcome of the measurement of (Rules 10 - 11). When the signal moves to an -correction command, then it won’t propagate any further. If the signal was added to another -correction of a measured vertex, then signal shifting can be applied again until no -corrections are left on non-output vertices. Therefore signals move along a path created by the -corrections. The propagation of signals in an MBQC pattern can be described by a -path as defined below.

Definition 7.

Let be a measurement pattern on an open graph . Then we define a directed acyclic graph, called , on the vertices of such that there exists a directed edge from to iff there exists a correction command in . A path in between two vertices and is called a -path.

The above definition allows us to state a simple observation about connectivity of a graph with flow.

Lemma 4.

If is a flow on an open graph , and there exists a -path from vertex to vertex , then the vertices and cannot be connected.

Proof.

The existence of a -path from to implies that . The Z dependency graph is an acyclic graph, thus . If would be connected to , then according to the flow property (F2):

 i∈N(f(j))∧i≠j⇒j≺fi

Now we have two contradicting strict partial order relations and . Therefore cannot be connected to . ∎

Recall that the addition of signals is done modulo 2, therefore, if an even number of signals from a measured vertex is added to a correction command on vertex , the signals will cancel out (since ). Furthermore, it is evident from the rewrite Rules of 9 - 11 that after signal shifting, the measurement result of vertex will create a new -correction over vertex if there exist an odd number of -paths from to a vertex that is -dependent on directly before signal shifting. Similarly a new -correction from to will be created if there exists an odd number of -paths from to . Either way, the number of -paths from a vertex to another vertex , denoted as , can be used to determine if the signal from should be added to a correction. We define to be 1 to simplify further calculations and definitions in this paper. The importance of the number of -paths will manifest itself in the next subsection, when the relation between signal shifting and gflows is studied.

We define a new structure called the signal shifted flow (SSF), and show that it satisfies the three gflow properties in Definition 3. Before constructing the SSF, some definitions and lemmas are needed to justify our definition. Note that if an open graph has a flow , then we can write the MBQC pattern of a deterministic computations on this open graph as [15]:

 P=≺f∏i∈OC(Xsif(i)ZsiN(f(i))∖{i}Mαii)EGNIC (12)

where the product follows the strict partial order of the flow . From Equation 12 we see that a -correction on a vertex depending on the measurement outcome of another vertex appears only if is a neighbour of . This is formally stated in the next corollary as we will refer to it several times.

Corollary 1.

If is an open graph with a flow , then there exists a -correction from vertex to another vertex iff .

We define -dependency neighbourhood of a vertex to be the set of vertices from which is receiving a -correction from. This set has an explicit form given as , this is due to the following facts: for all vertices , from flow definition exists also since hence cannot be equal to and moreover since therefore according to Corollary 1 there exists a -correction from to . It is easy to see, that can be written as:

 ζi(j)=∑k∈NZ(j)ζi(k) (13)

There exists a -correction from every to . These -corrections can be used to extend every such -path to to reach . If is in the sum, then because the correct number of -paths is obtained with Equation 13.

We now present the complete algorithm (Algorithm 1) for signal shifting a flow pattern shown in Equation 12. We keep in mind that the order in which we apply the signal shifting rules does not matter [15].

Proposition 1.

Given the measurement pattern of a flow as defined in Equation 12 as input to Algorithm 1, the output will be the signal shifted measurement pattern of .

Proof.

We will prove this proposition by showing that:

• Algorithm 1 terminates.

• Every step in Algorithm 1 that modifies the pattern is a valid application of a signal shifting rewrite rule.

• The output of Algorithm 1, the pattern , is signal shifted.

We begin by showing that Algorithm 1 will terminate. The first “while” loop will obviously terminate, as we decrease the number of elements on each loop iteration and never add anything to the set . The second “while” loop will not terminate only if some command will be added to the pattern an infinite number of times. As the underlying graph is finite and a command represents a directed edge in the -correction graph, this implies the existence of a cycle in the graph, however this is impossible according to the flow definition. The “for” loop in the algorithm terminates because the graph itself is finite, hence Algorithm 1 has to terminate.

For Algorithm 1 to actually perform the signal shifting, its operations have to be either trivial commuting rules or the three signal shifting Rules 9 - 10. As can be easily seen from the algorithm, the operations done are indeed the signal shifting rewrite Rules 9 - 10. We still need to prove, that these rules can be applied in the order shown in the algorithm. Obviously we can use Rule 9 on line 8 to create the signal command due to the fact that and that every non-output qubit is measured. Hence we have the measurement required for the creation of the signal command in the pattern. We know that has to be in the pattern after the command and before . The entanglement and creation commands are the first commands in the pattern and we do not need to move the command past them. Hence we only need to move past measurement commands on qubits that are not and and other correction commands. These can be done trivially and hence we can always move the command next to to apply Rule 9.

Next we want to move the newly created command to the end of the measurement pattern. To do that we need to commute it past the commands that appear after it. The only commands commutes non-trivially with are the ones that depend on the measurement of qubit as can be seen from Rules 9 - 11. Those are the - and -corrections depending on the measurement outcome of qubit . According to Equation 12 there is exactly one such -correction in the pattern , namely . Also the previous steps of the algorithm could not have created any dependencies from qubit . The -correction commands have only been created depending on vertices that we already moved from . Therefore we need to create exactly one new -correction command using Rule 10. We also look at the -corrections depending on and from Equation 12 we see that in the original pattern these are on vertices from the set . As for the -corrections we also have not created any new -corrections from in the previous steps of the algorithm. Hence this is exactly the set of corrections we need to commute with and apply Rule 11. We are only left with commands after in the pattern that commute trivially with . We can move the command at the end of the pattern. The signal command at the end of the pattern does not influence the computation and we will not add any new commands to the end of the pattern. Hence we can remove the command from the pattern.

Finally we show that no more signal shifting rules can be applied after the completion of Algorithm 1, i.e. the pattern is signal shifted. We eliminate all -corrections acting on a non-output qubit depending on a vertex after removing it from the set and will afterwards never create any new -corrections depending on that vertex. At the end of the algorithm the set is empty, hence there cannot exist any non-output qubit that has a -correction acting on it and Rule 9 cannot be applied anymore. Moreover, since every signal command is at the end of the pattern, we cannot apply the Rules 10 and 11 neither, that completes the proof. ∎

We consider any trivial commutation of a pattern commands resulting to an equivalent pattern. Therefore the above algorithm defines the unique pattern obtained after signal shifting. Note that Algorithm 1 works almost like a directed graph traversal, where there is a directed edge from vertex to iff there exists the command in the measurement pattern. The only difference from a classical directed graph traversal is that we allow visiting of a vertex more than only once. Hence we will traverse through every different path in the graph however we do that exactly once.

As mentioned before, the evenness of the number of -paths can be used to determine if a signal is added to a correction command. Let be the function that determines the oddness or evenness of the integer , i.e. . Then if an open graph has a flow, the oddness of can be found as described in the following lemma.

Lemma 5.

For every two vertices and in an open graph with flow

 parity(ζi(j))=|k∈{NZ(j)|parity(ζi(k))=1}|mod2

i.e. depends only on the number of vertices in the -dependency neighbourhood which have odd number of -paths from .

Proof.

The oddness of can be written as

 parity(ζi(j)) =⎛⎝∑k∈NZ(j)ζi(k)⎞⎠mod2= =∑k∈NZ(j)(ζi(k)mod2)mod2= =∑{k∈NZ(j)|1=ζi(k)mod2}(ζi(k)mod2)mod2= =|{k∈NZ(j)|1=ζi(k)mod2}|mod2= =|{k∈NZ(j)|parity(ζi(k))=1}|mod2

All these notions will allow us to define the structure of the pattern after signal shifting is being performed.

Proposition 2.

Given a flow on an open graph , let be a function from such that iff . Also define to be a layering function from into a natural number:

 Ls(i) =0 ∀i∈O Ls(i) =maxj∈s(i)(Ls(j)+1) ∀i∉O

Define the strict partial order with:

 i≺sj⇔Ls(i)>Ls(j)

Then, the application of signal shifting Rules 9 - 11 over an MBQC pattern with flow will lead to the following pattern:

 P=∏j∈O,i∈ICZsi.parity(ζi(j))j≺s∏i∈OC(Xsis(i)Mαii)EGNIC (14)
Proof.

The proof is divided into three parts. First we will show that signal shifting creates exactly the pattern commands shown in Equation 14. We proceed by showing, that the layering function is defined for every . Lastly, we need to prove that using the partial order derived from for ordering the commands as in Equation 14 gives a valid measurement pattern.

Note that the preparation commands (), entanglement commands () and measurement commands () are the same for Equations 12 and 14. Because signal shifting would not change these commands (Rules 9 - 11) these are as required for a signal shifted pattern. Hence we need only to consider the correction commands.

We will look at the correction commands that would appear in a signal shifted pattern. We do this by examining the signal shifting algorithm (Algorithm 1). As mentioned before, the algorithm works as a directed graph traversal, in a way that every distinct path is traversed o. As seen in the algorithm every correction acting on a non-output qubit is removed from the pattern. This is in accordance with the proposed pattern in Equation 14. Let us examine which new corrections are created.

The number of newly created depends on the number of times we enter the first loop with command . As the algorithm is a directed graph traversal algorithm, this happens as many times as there are different paths over the -dependency graph from to . Because the same two corrections cancel each other, hence a new -correction appears in a signal shifted pattern only if . We also note that no new correction is created since there exist no -path between and . On the other hand Algorithm 1 leaves the already existed corrections unchanged and moreover since we have defined therefore . This implies that the set does indeed contain all the vertices that have an -correction depending on after signal shifting is performed.

The number of newly created -corrections on an output vertex depending on a vertex appearing in the signal shifted pattern is equal to the number of different paths from to . The difference with non-output qubits is that these will not be removed through the process of signal shifting. As with -corrections, two -correction commands on the same qubit will cancel each other out and hence the existence of a in the final pattern depends on the parity of the number of paths from to . This can be written in short as:

 Zsi⋅parity(ζi(j))j

Hence the measurement pattern in Equation 14 has exactly the same commands as the signal shifted pattern in Equation 12.

Another thing we need to proof is that the layering function is defined for every . As proven above, the -corrections depending on the measurement of qubit correspond to the set . Hence we can interpret the definition of as finding the maximum value of for every vertex that has an -correction from and adding to it. The recursive definition of is well defined, if for every non-output qubit we can find a path over -corrections ending at an output qubit. We know that signal shifting of a valid pattern creates another valid pattern. This implies that the -corrections cannot create a cyclic dependency structure and hence every path over the -corrections has an endpoint. Moreover such a path cannot end on a non-output qubit since and one could always extend that path with . Therefore is well defined.

Finally, it is easy to show that the partial order as used in Equation 14 gives a valid ordering of the commands. Every vertex that has an -correction depending on the measurement of qubit has a smaller number and hence . This way no -correction command acts on an already measured qubit and because the -corrections are applied only on output qubits, the correction ordering is valid. Every other command is applied before the measurement command and hence the pattern in Equation 14 is a valid measurement pattern. ∎

Given an open graph with a flow, we refer to the construction of the above proposition as its corresponding signal shifted flow (SSF). The main theorem of this section states that every SSF is actually a special case of a gflow.

Corollary 2.

If is an open graph with flow and SSF then for every vertex and such that , we can find another vertex , such that .

Proof.

If , then from the Proposition 2 of SSF we can conclude that . We know that from the assumptions. Lemma 5 says, that there must exist at least one other vertex from which has a -correction, such that . The flow definition says that must therefore be a neighbour of . Definition 2 of SSF states that must therefore be in , hence . ∎

Theorem 1.

Given any open graph with flow , the corresponding signal shifted flow is a gflow.

The proof is based on the following lemmas, demonstrating that is a gflow by satisfying all the properties of Definition 3. The first property of gflow (property G1) is satisfied by SFF implicitly from Definition 2, i.e. for every it holds that if . Consider the second gflow property (G2), i.e. if then or . We will show that every vertex with odd many connections to has to be either itself or an output qubit. This is a stronger condition than is needed to show G2, but as shown in Section 3, necessary for creating compact circuits from SSF.

Lemma 6.

If is an SSF then every non-output vertex connected to has an even number of connections to , i.e.,

 ∀v∈N(s(i))∖O∧v≠i⇒v∉Odd(s(i))
Proof.

Let be a vertex connected to , we show the following two sets have the same number of elements.

 {k∈NZ(v)|parity(ζi(k))=1} and s(i)∩N(v)∖{f(v)}

For every , we prove is the unique element in

 {k∈NZ(v)|parity(ζi(k))=1}

Because from Proposition 2 there must exist . Also since therefore . Moreover since , Corollary 1 implies the existence of a -correction from to , i.e. . Proposition 2 says that because , it must hold that . Therefore .

On the other hand, for every vertex , as then from Proposition 2 we have. Also because of Corollary 1 and finally, because cannot have a -correction from itself, i.e. . Hence it holds that . Therefore

 |s(i)∩N(v)∖{f(v)}|=|{k∈NZ(v)|parity(ζi(k))=1}|

According to Lemma 5 . If then must have an even number of elements. Proposition 2 says that cannot be in and therefore can have only even number of connections to . If then we know that must have an odd number of elements. If exists it must be in because of Proposition 2. In the case of , we can conclude that and has even many connections to . On the other hand if does not exist, has to be an output qubit because the flow function is defined for every non-output vertex. The only possibility of having odd many connections to is therefore if is an output vertex, which proves the lemma. ∎

The next lemma directly proves that an SSF also satisfies the last gflow property (G3) which states that .

Lemma 7.

If is an SSF, then for every it holds that .

Proof.

First we show that, performing signal shifting creates new -corrections only between unconnected vertices. Recall that signal shifting creates a new -correction between vertices and iff there exists a -path from to and an correction from to therefore from the Flow definition we have:

 i≺ff−1(j)≺fj

Let us assume that there exists an edge between and . According to the Flow definition we have that

 i∈N(j)j=f(f−1(j))}⇒i∈N(f(f−1(j)))⇒f−1(j)≺fi

This contradicts the partial order of the Flow and therefore there cannot be an edge between vertices and .

Next we claim that there is exactly one edge between and . According to Definition 2 of SSF, the set consists only of the vertex and the vertices to which signal shifting created a new X dependency from . We showed that signal shifting does not create dependencies between connected edges. Hence, is the only vertex in that can be connected to , and there must be an edge between and because of the flow property (F3) (). ∎

Proof.

Now to obtain the proof of Theorem 1, we note that the definition of SSF implies the gflow property (1.). Lemma 6 implies that every SSF satisfies the gflow condition (2.). As the third and last gflow condition is satisfied by SSF according to Lemma 7, SSF is indeed a gflow and Theorem 1 holds. ∎

The above theorem for the first time presents an structural link between two seemingly different approach for parallelisation, gflow and signal shifting, for those patterns having already flow. As mentioned in the introduction this is the key step in obtaining our simultaneous depth and space optimisation. The next section explores further the link with gflow, showing optimality of SSF in parallelisation.

2.2 Influencing paths

The notions of influencing walks and partial influencing walks on open graphs with flow was introduced in [11] to describe the set of all vertices that a measurement depends on. An influencing walk starts with an input and ends with an output vertex, a partial influencing walk starts with an input vertex but can end with a non-output vertex. We will use a modified definition of influencing walks that can start from any non-output vertex and end at any vertex and call it a stepwise influencing path. This will allow us to conveniently explore the dependency structure of a pattern with SSF.

Definition 8.

Let be an SSF that is obtained from a flow of an open graph and vertices and in such that . We say that a path between vertices and is an stepwise influencing path, noted as , iff

• The path is over the edges of .

• The first two elements on the path are and .

• Every even-placed vertex on the path , starting from , is in .

• Every odd-placed vertex on the path is the unique vertex of some such that is the next vertex on the path .

It is easy to see that every second edge, in particular the edges between and , in the stepwise influencing path is a flow edge. Hence the path contains no consecutive non-flow edges. If we restrict the first vertices of the stepwise influencing path to be input vertices, the stepwise influencing path would be a partial influencing path, but not vice versa. Stepwise influencing paths are useful because of their appearance in the SSF as proven by the following lemma.

Lemma 8.

Let be an SSF obtained from a flow of an open graph and vertices and in such that . Then there always exists a stepwise influencing path .

Proof.

We start by constructing such a path backward from to . We select and as the last two vertices on the path and apply Corollary 2 to find the vertices on the path, until we reach . The formation of cycles is impossible, as this would imply a cyclic dependency structure, impossible for a flow. We have to reach as the set of vertices we choose from is finite. ∎

The above lemma will be used in Section 3 to obtain compact circuits from SSF. Note that there might be more than one stepwise influencing path from to . We conclude the section about influencing paths with the following two lemmas which will be used to prove the optimality of SSF. First, the structure of stepwise influencing paths imposes a strict restriction on the way a vertex on the stepwise influencing path can be connected.

Lemma 9.

Let be a stepwise influencing path from to in an open graph with flow and corresponding SSF . Then is the only odd-placed vertex in that is connected to.

Proof.

According to the definition of stepwise influencing path, for every three consecutive vertices , , in such that and are odd-placed we have that and . According to Corollary 1 there must exist a -correction from to . Therefore the odd-placed vertices in are on a -path from to and obviously from every odd-placed vertex in there exists a -path to . Lemma 4 says that cannot be connected to any of the odd-placed vertices in . ∎

The previous lemma shows, that the stepwise influencing paths can be used to describe some properties of the connectivity in open graphs with SSF. The next lemma (illustrated in Figure 3) will explain how a stepwise influencing path can be extended.

Lemma 10.

Let be an open graph with flow and corresponding SSF and let and be two non-output vertices of the open graph such that . If then every stepwise influencing path can be extended by the vertices and to create another stepwise influencing path .

Proof.

Adding and to satisfies the conditions for stepwise influencing paths. There exists an edge between vertices and and vertices and , hence it is a valid path. Moreover, would be an even-placed vertex on the extended path, and would be the unique oddly-placed vertex with . ∎

2.3 Optimality of signal shifting

Given an MBQC pattern with gflow, finding the maximally delayed gflow of its underlying graph could potentially further reduce the depth of the computation [14]. A natural question that arises is how SSF is linked with the optimal gflow. In this section, we prove that if the input and output sizes of the pattern are equal, then SSF is indeed the optimal gflow. Hence we can conclude the most optimal parallelisation that one could obtain via translation of a quantum circuit into an MBQC pattern is achieved by the simple rewriting rules of SSF. This will also lead to a more efficient algorithm than the one presented in [14] for finding the maximally delayed gflow of a graph as we discuss later.

Theorem 2.

Let be an open graph with flow such that . Let be the SSF obtained from . Then is the optimal gflow of .

The proof of the theorem is rather long, an outline is presented below. A general reader could omit the next subsections, however various novel constructions has been introduced in the proof that could be explored for other MBQC results and hence could be valuable for an MBQC expert. In Section 2.3.1 we show that the penultimate layers of an optimal gflow and an SSF of an open graph where , are equal. Next we introduce the concept of a reduced open graph in Section 2.3.2. We prove two key properties of the optimal gflow and SSF of the reduced open graph. This highlights the recursive structures of the gflow and SSF leading to the possibility of extending these notions to new domains 111For example, the authors are currently exploring this structure to define the concept of partial flow, for patterns with no deterministic computation.. In Section 2.3.3 we put the pieces together, by showing that the previous properties imply that reduced gflow (implicitly also optimal gflow and SSF) layers are equal to the original gflow layers from layer 1 onward. This allows us to construct a recursive proof for Theorem 2, which we present in Section 2.3.4.

2.3.1 The last two layers

The equality of the last layers of an SSF and optimal gflow follows from Lemma 2 and Proposition 2 – the last layer of an optimal gflow and an SSF is always the set of output vertices. What is left to prove is that the penultimate layers are also equal, for doing so we need the following properties of open graphs with SSF. An illustration of the property proven in the first of the two lemmas is shown in Figure 3.

Lemma 11.

Let ) be an open graph with flow and corresponding SSF . If then for every strict subset of containing there must exist a non-output vertex that is oddly connected to such that , i.e.

 ∀i∈OC∀S⊂s(i)s.t.f(i)∈S∃v∈Odd(S)s.t.f(v)∈s(i)∖S
Proof.

If the lemma holds trivially, as there does not exist any nonempty strict subsets of . Consider the case where contains more than one element and is a strict subset of . Then we select any vertex from and look at the stepwise influencing paths from to . Note that there might be more than one such path. We move backwards from towards over the stepwise influencing paths in the following way:

1. Move by two vertices

1.1 If possible, choose any stepwise influencing path where the previous even-placed element is not in and move to that element.

1.2 If the previous even-placed elements in all the stepwise influencing paths from to are in , then stop.

2. Repeat step 1.

Let be the vertex to where we moved using the above process, has to exist because of the way we initially selected . There are a couple of other observations that we can make about . First, , because of the selection of and the way we moved on the paths. Second, cannot be the first even placed vertex on a stepwise influencing path from to because the first element is (according to Definition 8). Third, for every stepwise influencing path ending in , the previous even-placed vertex has to be in as otherwise we could have moved one more step towards .

Considering the previous three observations we can show that the vertex must be oddly connected to . We begin by noting that cannot be connected to any vertex . Otherwise, according to Lemma 10, we could extend any stepwise influencing path ending at with and . Hence would then be an even-placed vertex on a stepwise influencing path from to . In particular, would be the second to last even-placed vertex on a stepwise influencing path from to Every such vertex, except itself, is in as mentioned before. Because, according to Lemma 6, has to be evenly connected to , it has to be oddly connected to and Lemma 11 holds. ∎

Next we need to show that every non-input vertex has a corresponding unique vertex , this is only true for those graphs with .

Lemma 12.

If is a flow on an open graph (G,I,O), then iff for every there exists .

Proof.

First, if then also . The flow definition uniquely defines for every and therefore is uniquely defined for some, but not necessarily for all, vertices . The number of vertices for which is defined must equal the number of vertices for which is defined and because , must be defined for every element in .

Second, Let us consider the case when for every there exists . The number of elements for which is defined equals the number of elements is defined for. is by Definition 2 defined for every element in . Hence