Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

March 24, 2019

Normalising Quantum Circuits

Posted by John Baez

guest post by Giovanni de Felice and Leo Lobski

This post marks the beginning of the second iteration of the Applied Category Theory School. The mentors this year are Miriam Backens, Tobias Fritz, Pieter Hofstra, Bartosz Milewski, Mehrnoosh Sadrzadeh, and David Spivak. Each mentor has provided two papers associated to their proposed project in the field of applied category theory. Our students read these papers, gaining the requisite background to engage the projects. As part of this process, they will write an article on each paper and post it here.

This first article is inspired by the paper A finite presentation of CNOT-dihedral operators by Matthew Amy, Jianxin Chen and Neil J. Ross. The result of the paper, existence and uniqueness of a normal form for a fragment of quantum computation, was obtained by the authors by observing an interesting interplay between two languages: the representation of unitary quantum gates as circuits in a symmetric monoidal groupoid, and their description in terms of ‘phase polynomials’.

In this blog post, we add a third language to the ones introduced in the paper, the ZX-calculus. This, inter alia, serves the purpose of putting the work done in the paper into a broader context. On the one hand, we use the ZX calculus to develop an intuition for the relations between unitary gates exposed in the paper, while on the other hand we discuss how the phase polynomial formalism can be imported into the ZX calculus to obtain rewrite strategies for circuit optimization.

Introduction

Quantum computer science studies how to use the properties of quantum mechanical systems for designing algorithms which outperform classical computers. To reason about quantum computation, it is useful to represent algorithms as circuit diagrams. These consist of two basic components. Each wire of the circuit diagram represents a qubit, whose states are (normalised) vectors in a two-dimensional complex Hilbert space, i.e. points on the Bloch sphere. Wires are connected to boxes, which represent operations that can be performed on qubits. These are unitary linear maps, i.e. reversible maps which send points on the Bloch sphere to points on the Bloch sphere, and they are referred to as gates by analogy with classical computation.

A commonly studied unitary fragment of quantum circuits is known as Clifford+T, and it is generated by the gates CNOTC N O T (controlled not), TT (rotation by π4\frac{\pi}{4} about the Z axis) and HH (the Hadamard gate, corresponding to the rotation which interchanges the Z and X axes on the Bloch sphere). What makes this gate set of particular interest is that while it is finitely generated, it is approximately universal for quantum computation, meaning that we can get arbitrarily close to any nn-qubit unitary using polynomially many Clifford+T gates (see the survey paper by Miller-Bakewell).

Since quantum circuits can be composed both 'horizontally' (do one process after another) and 'vertically' (do operations on multiple qubits at the same time), monoidal categories are a suitable algebraic framework for formalising this situation.

There have been two main approaches for developing an algebraic theory of quantum circuits. Relaxing the unitarity condition, we can consider arbitrary linear maps on qubits, which have been axiomatised in the ZX and ZW calculi, in terms of compact closed monoidal categories. These calculi are essentially graph-theoretic, which allows techniques from graph theory to be used for rewriting circuits (see e.g. the recent paper by Duncan et al.). The drawback of this approach is that it requires tools for unitary circuit extraction, because the instructions for a quantum computer are sequences of basic unitary operations.

A direct axiomatisation of unitary circuits, in the form of a symmetric monoidal groupoid, is a harder task because of the rigidity of such a representation. Moreover an axiomatisation of the full Clifford+T gate set with a finite number of relations is likely to be rather tricky, if possible at all, because of the inherent complexity of these circuits. For this reason, research has focused at axiomatising restricted fragments of the standard circuit model.

This was started in 2003 by Lafont, who provided a normal form for affine circuits generated by the CNOTC N O T and XX gates. In 2015, Selinger gave a finite presentation for the Clifford groupoid, generated by CNOTC N O T, XX, HH and T 2T^2. Clifford gates are known to be efficiently simulatable classically, although adding any non-Clifford gate to the set allows to recover universal quantum computation. Non-Clifford gates, such as the TT-gate, usually require a large number of resources to be implemented fault-tolerantly in a lab. For this reason a lot of current research has been looking for ways of reducing the TT-count, i.e. the number of TT-gates used in a circuit. To this end, Amy et al. (2013, 2016) introduced the formalism of phase polynomials for optimizing the TT-count within the {CNOT,T}\{C N O T, T\} -fragment.

Putting together the work of Lafont, the groupoid formalism of Selinger and the phase polynomials of Amy et al., the current paper provided a finite presentation of the CNOT-dihedral fragment, which is generated by CNOTC N O T, XX and TT.

Brief overview of the paper

The paper proves existence and uniqueness of a normal for the CNOT-dihedral operators, which are defined below [Amy, Chen and Ross. p.86].

In addition to the above operators, we also have access to the SWAPS W A P gate which corresponds to the linear map |00|00|00\rangle \mapsto |00 \rangle, |01|10|01\rangle \mapsto |10 \rangle, |10|01|10\rangle \mapsto |01\rangle, |11|11|11\rangle \mapsto |11\rangle (where |0|0\rangle and |1|1\rangle denote the standard basis vectors), interchanging the position of two qubits. These gates generate a symmetric monoidaḷ groupoid where the monoidal product is given by the tensor product of matrices, the symmetry is given by the SWAPS W A P gate and the invertibility of the generators can easily be checked.

An important step towards the normal form is the observation that the operators can be split into two classes: diagonal gates and affine gates. The diagonal gates have diagonal matrix representations, while the affine gates are affine transformations of the basis states. The gates XX, CNOTC N O T and SWAPS W A P are affine, while ω\omega, TT, UU and VV are diagonal. Those CNOT-dihedral circuits that only contain affine gates are called affine circuits, and correspondingly for diagonal circuits.

The CNOT-dihedral gates are subject to the following relations. [Amy, Chen and Ross. p.87].

One central point to notice here are the degree reduction rules R 1R_1, R 4R_4, R 7R_7, R 8R_8, R 9R_9 and R 10R_{10}, which yield an upper bound on the power of each gate in the normal form (the power of a gate is just the number of times the gate is composed with itself). In fact R 13R_{13} can also be seen as a degree reduction rule; it shows that if we try to generalise the construction of UU and VV gates to four qubits, then this composite gate has degree zero (and hence there is no need to generalise beyond three qubits). The degree reduction rules also have a direct interpretation in terms of phase polynomial equalities, which we will discuss in more detail in a later section.

The overall normal form of a CNOT-dihedral circuit is a combination of the normal forms for an affine circuit and for a diagonal circuit. In fact, existence and uniqueness of the normal form for affine circuits was already proved by Lafont. Thus, what is proved in the present paper is that

  • if an affine gate is to the left of a diagonal gate, the circuit can be rewritten in such a way that the affine gate is the rightmost gate and all the remaining gates are diagonal (i.e. affine gates ‘commute’ past the diagonal ones),

  • diagonal gates commute with diagonal gates,

  • any diagonal circuit has a unique normal form.

It then follows that any CNOT-dihedral circuit CC can be rearranged so that C=DAC = D A, where DD is a diagonal circuit and AA is an affine circuit. Then one can just apply the result of Lafont to AA and the last bullet point above to DD to get that CC has a unique normal form.

The diagonal normal form found in the paper is given by an ordering of the diagonal gates, together with bounds on the number of consecutive gates used, which come from their representation in terms of phase polynomials.

From ZX to CNOT-dihedral rules

In order to get an intuition for the presentation given in the paper, we make a short digression to introduce some of the ZX-calculus rules. This will allow us to understand the relations exposed in the paper as direct consequences of the underlying rules for linear maps modelled with the ZX-calculus. It will also highlight the rules which are not easily derivable from ZX, which we will see come from the phase polynomial formalism.

The ZX calculus is a diagrammatic language for complex linear maps based on (strongly) complementary bases, roughly meaning that measurements cannot be performed simultaneously in both bases. Generators in these bases are denoted by dots of different colour, traditionally red and green, decorated with a phase. The generators (known as spiders)

with nn inputs and mm outputs (the diagrams are read from left to right) correspond to linear maps

where |±=12(|0±|1)| \pm \rangle = \frac{1}{\sqrt 2}(|0\rangle \pm |1\rangle) and α(π,π]\alpha\in(-\pi,\pi] (see e.g. Backens or Miller-Bakewell for a proper definition). The spiders can be thought of as generalised rotations; indeed, for a single qubit (n=m=1) the green spider corresponds to a rotation of the Bloch sphere of degree α\alpha around the Z axis, whereas the red spider is a rotation of degree α\alpha around the X axis.

The rule governing the interaction between generators of the same colour is the spider fusion law (a consequence of the axioms of dagger special Frobenius algebras), which states that spiders of the same colour can fuse into each other and their phases add up (modulo 2π2\pi). This is in analogy with rotations: two consecutive rotations (around the same axis) correspond to one rotation by an angle which is just the sum of the two angles, and going a full turn gets you back to where you started. Be aware, however, that the analogy with rotations breaks down when we consider spiders with more than one input or output wire.

The basic rules encoding strong complementarity are the bialgebra and Hopf laws.

Note that we are using the scalarless version of the ZX calculus, i.e. the equalities between our ZX diagrams are only true up to a complex scalar. Even though the presentation given in the paper includes scalars (generated by ω\omega), these are not relevant for the operational intuition we want to convey with ZX diagrams.

The CNOT-dihedral fragment can be expressed in ZX, it is given by the following representations of the generators.

This can then be used to obtain the representations for the derived generators.

Given the interpretation of the ZX generators as rotations, the relations R 1R_1 and R 7R_7 now acquire a physical meaning; rotating by π\pi twice is the same as doing nothing, and likewise rotating by π4\frac{\pi}{4} eight times is the same as doing nothing.

Most of the relations R 1R_1 to R 13R_{13} can be derived using the spider fusion law, the Hopf law and the bialgebra law. Rules 9 and 13 are the least straightforward, in fact we don’t know of any direct derivation of rule 13 from the axioms, although by the recent completeness results for the ZX calculus such a derivation must exist (there has recently been a wealth of completeness results for ZX; see the survey by Miller-Bakewell). Those rules however have a direct interpretation in terms of their phase polynomial representation.

Diagonal gates and phase polynomials

The action of any diagonal gate from the CNOT-dihedral fragment can be described as follows: D|x=ω p D(x)|x,p D: 2 n 8, D |x\rangle = \omega^{p_D(x)}|x\rangle, \quad p_D: \mathbb{Z}_2^n \rightarrow \mathbb{Z}_8 , Where p Dp_D is a polynomial using mixed arithmetic: p D(x)= i=1 ka ig i(x) p_D(x) = \sum_{i=1}^k a_i g_i(x) where a i 8a_i \in \mathbb{Z}_8 and g i: 2 n 2g_i:\mathbb{Z}_2^n \rightarrow \mathbb{Z}_2 are linear terms on at most nn variables, i.e terms of the form x i 1x i kx_{i_1} \oplus \dots \oplus x_{i_k} for some knk \leq n (this was shown in Amy et al.). Representations for the generating diagonal gates are given by:

ω k|x=ω k|x \omega^k |x\rangle = \omega^k |x\rangle T k|x 1=ω kx 1|x 1 T^k |x_1\rangle = \omega^{kx_1}|x_1\rangle U k|x 1x 2=ω k(x 1x 2)|x 1x 2 U^k |x_1x_2\rangle = \omega^{k(x_1\oplus x_2)}|x_1x_2\rangle V k|x 1x 2x 3=ω k(x 1x 2x 3)|x 1x 2x 3 V^k |x_1x_2x_3\rangle = \omega^{k(x_1\oplus x_2 \oplus x_3)}|x_1x_2x_3\rangle

We can read off the phase polynomial of a circuit on nn qubits built from the diagonal generators by labelling each wire with an index i=1,2,,ni=1,2, \dots, n (from top to bottom say) and adding: a constant term 11 for each scalar ω\omega, a term x ix_i whenever TT is applied to qubit ii, a term x ix jx_i \oplus x_j whenever UU is applied to qubits ii and jj and a term x ix jx kx_i \oplus x_j \oplus x_k whenever VV is applied to qubits ii,jj and kk. Note that the order doesn’t matter as diagonal gates commute. So we obtain the following general form:

p D(x)=a 0+ ia ix i+ i<jb ij(x ix j)+ i<j<kc ijk(x ix jx k) p_D(x) = a_0 + \sum_i a_i x_i + \sum_{i \lt j} b_{i j} (x_i \oplus x_j) + \sum_{i \lt j \lt k}c_{i j k} (x_i \oplus x_j \oplus x_k)

The important thing to note is that from the degree-reduction rules discussed earlier, the coefficients in the expression above can be bounded: a i 8a_i \in \mathbb{Z}_8, b ij 4b_{i j} \in \mathbb{Z}_4, c ijk 2c_{i j k} \in \mathbb{Z}_2. For instance if four UU gates are applied on the same pair of qubits, we can use rule 8 to turn them into TT gates.

This leads directly to a definition of the diagonal normal form, given by ordering the gates as they appear on the phase polynomial representation. The existence of the normal form comes from the fact that diagonal gates commute and that they are generated by ω\omega, TT, UU and VV. The bounds on coefficients a i,b ija_i, b_{i j} and c ijkc_{i j k} are the main ingredient to prove uniqueness.

The proof of uniqueness for the diagonal normal form proceeds as follows. Suppose DD and DD' are distinct diagonal normal forms, we want to show that they differ on some input, that is, there is a y 2 ny \in \mathbb{Z}_2^n such that D|yD|yD|y\rangle \neq D'|y\rangle. By construction, p D(x)p D(x)p_D(x) \neq p_{D'}(x) as polynomials. However, because of the use of mixed arithmetic in the polynomial expression, this does not mean that there is a y 2 ny \in \mathbb{Z}_2^n such that p D(y)p D(y)p_D(y) \neq p_{D'}(y). The following is a counterexample: 4x 1+4x 2+4(x 1x 2)=04x_1 + 4x_2 + 4(x_1 \oplus x_2) = 0 mod 88 for any x 1,x 2 2x_1, x_2 \in \mathbb{Z}_2. However, because of the bounds on the coefficient a ia_i, b ijb_{i j} and c ijkc_{i j k}, it can be shown that this situation never occurs, and that in fact there is a y 2 ny \in \mathbb{Z}_2^n such that D|yD|yD|y\rangle \neq D' |y\rangle.

Towards TT-count optimization in ZX circuits.

We have seen that phase polynomials are a useful technique for normalising diagonal circuits and distinguishing between them. Degree reduction rules and rule 13 in the paper are directly imported from this formalism. We have seen that most of those rules can be derived straightforwardly from the ZX calculus, except for R 13R_{13}, for which no direct derivation is known. The content of this section is inspired by a discussion with Quanlong Wang, we analyse R 13R_{13} from a ZX perspective, and show how it can be used to reduce T-count in ZX circuits.

First note that R 13R_{13} has the following phase polynomial representation: x 1x 2x 3x 4= i5x i+ i<j3(x ix j)+ i<j<kx ix jx k. x_1 \oplus x_2 \oplus x_3 \oplus x_4 = \sum_i 5x_i + \sum_{i\lt j} 3(x_i \oplus x_j) + \sum_{i\lt j\lt k}x_i \oplus x_j \oplus x_k. Reasoning inductively from this equality we can see that whenever a phase polynomial has terms with more than four variables, it can be rewritten as a phase polynomial where each term has at most three variables. This explains why ω\omega, TT, UU and VV generate all diagonal gates. In normalising CNOT-dihedral gates, this rule is used ‘from left to right’, in order to commute the CNOT gate to the left of the diagonal gates.

Now note that R 13R_{13} corresponds to the following equality of ZX circuits:

From the representation above, we see that the right-hand side contains 14= i=1 3(4i)14= \sum_{i=1}^3{\binom{4}{i}} occurrences of (an odd multiple of) π4\frac{\pi}{4} rotations, whereas the left-hand side contains only one. As discussed in the introduction, π4\frac{\pi}{4} rotations (i.e. TT-gates) are hard to implement in a fault-tolerant way. In order to reduce the TT-count we want to use R 13R_{13} ‘from right to left’. To do this let us consider the fragment of diagonal ZXZX circuits, i.e. ZXZX diagrams with nn inputs and nn outputs generated by ω\omega, TT, UU and VV. Define the TT-count of a diagonal ZX circuit to be the number of (odd multiples of) π4\frac{\pi}{4} phases appearing in the diagram. Let us also call ‘phase gadget’ a diagram of the form:

As diagonal gates commute amongst themselves, we can think of any diagonal ZX circuit D:nnD:n \rightarrow n as a hypergraph with nn nodes and labelled hyperedges for each phase gadget. Then R 13R_{13} can be generalised roughly as follows: any diagonal ZX circuit on 44 qubits (seen as a hypergraph) is equivalent to the hypergraph where the connections have been complemented and an additional phase gadget is connected to all 4 nodes. The labels on the phase gadgets should also be modified appropriately, but we don’t go into detail here.

This yields the following rewrite procedure for reducing TT-count in diagonal ZX circuits. Given an arbitrary diagonal ZX circuit D:nnD: n \rightarrow n, choose any quadruple of input qubits and consider the sub-hypergraph of hyperedges connected only to those 4 nodes. If the TT-count of the sub-hypergraph is k>7k\gt 7, then we can use the generalised R 13R_{13} to complement all the connections and add a phase gadget connected to all 4 nodes. Then the TT-count of the sub-hypergraph has been reduced from kk to 14k+114-k+1, reducing the overall TT-count of DD by k8k-8.

Future directions

As the authors of the paper remark in the conclusion, their result does not provide an algorithm to rewrite an arbitrary CNOT-dihedral circuit, as the coherence axioms of a symmetric monoidal category are non-constructive. Thus the next natural question to ask is how to find such an algorithm.

By removing the XX gate from the gate set considered in the paper, one obtains a normal form for the gate set {CNOT,T}\{C N O T, T\}. Thus the only gate missing in order to turn this into the Clifford+T gate set is the Hadamard gate. Since the Clifford+T gate set is known to be approximately universal for quantum computation, it would be of great interest to know whether there is a normal form for this fragment as well. This is currently an open problem. However, the authors make a combinatorial argument showing that including the Hadamard gate increases the number of diagonal gates dramatically. This suggests that the solution, even if it exists, is not an easy generalisation of the results of the paper.

In the last section, we saw how the phase polynomial identity for R 13R_{13} can be used to simplify ZX-circuits. Amy et al. (2016) classified all phase polynomial equalities (analogous to R 13R_{13}) in terms of Reed-Muller codes, translating those identities to develop rewrite techniques for TT-count optimization in ZX circuits is a promising direction of future research.

Posted at March 24, 2019 7:51 PM UTC

TrackBack URL for this Entry:   https://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/3101

0 Comments & 0 Trackbacks

Post a New Comment