<<

Date of publication xxxx 00, 0000, date of current version xxxx 00, 0000.

Digital Object Identifier

Logical Clifford Synthesis for Stabilizer Codes

NARAYANAN RENGASWAMY1, (Member, IEEE), ROBERT CALDERBANK1, (Fellow, IEEE), SWANAND KADHE2, (Member, IEEE), and HENRY D. PFISTER1, (Senior Member, IEEE) 1Department of Electrical and Computer Engineering, , Durham, NC 27708 USA (e-mail: { narayanan.rengaswamy, robert.calderbank, henry.pfister }@duke.edu) 2Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, CA 94720 USA (e-mail: [email protected]) Corresponding author: Narayanan Rengaswamy (e-mail: [email protected]). Part of this work has been presented at the 2018 IEEE International Symposium on [1]. This work was supported in part by the National Science Foundation (NSF) under Grant Nos. 1718494, 1908730 and 1910571. Any opinions, findings, conclusions, and recommendations expressed in this material are those of the authors and do not necessarily reflect the views of these sponsors.

ABSTRACT Quantum error-correcting codes are used to protect involved in quantum computation. This process requires logical operators to be translated into physical operators acting on physical quantum states. We propose a mathematical framework for synthesizing physical circuits that implement logical Clifford operators for stabilizer codes. Circuit synthesis is enabled by representing the desired physical Clifford in CN×N as a 2m×2m binary symplectic , where N = 2m. We prove two theorems that use symplectic transvections to efficiently enumerate all binary symplectic matrices that satisfy a system of linear equations. As a corollary, we prove that for an [[m, k]] every logical Clifford operator has 2r(r+1)/2 symplectic solutions, where r = m − k, up to stabilizer degeneracy. The desired physical circuits are then obtained by decomposing each solution into a product of elementary symplectic matrices, that correspond to elementary circuits. This enumeration of all physical realizations enables optimization over the ensemble with respect to a suitable metric. Furthermore, we show that any circuit that normalizes the stabilizer can be transformed into a circuit that centralizes the stabilizer, while realizing the same logical operation. Our method of circuit synthesis can be applied to any stabilizer code, and this paper discusses a proof of concept synthesis for the [[6, 4, 2]] CSS code. Programs implementing the algorithms in this paper, which includes routines to solve for binary symplectic solutions of general linear systems and our overall LCS (logical circuit synthesis) algorithm, can be found at https://github.com/nrenga/symplectic-arxiv18a.

INDEX TERMS Clifford , Heisenberg-Weyl group, logical operators, stabilizer codes, binary symplectic group, transvections

I. INTRODUCTION arXiv:1907.00310v2 [quant-ph] 18 Aug 2021 realizing error-resilient quantum computation in practice. T is expected that universal fault-tolerant quantum com- The Clifford hierarchy of unitary operators was defined I putation will be achieved by employing quantum error- to help demonstrate that universal quantum computation can correcting codes (QECCs) to protect the information stored be realized via the teleportation protocol [9]. The first level in the quantum computer and to enable error-resilient com- C(1) in the hierarchy is the Pauli group of unitary operators, putation on that data. The first QECC was discovered by and subsequent levels C(`), ` ≥ 2, are defined recursively as Shor [2], and subsequently, a systematic framework was de- those unitary operators that map the Pauli group into C(`−1), veloped by Calderbank, Shor and Steane [3], [4] to translate under conjugation. By this definition, the second level is the (pairs of) classical error-correcting codes into QECCs. Codes normalizer of the Pauli group in the unitary group, and hence produced using this framework are referred to as CSS codes. C(2) is the Clifford group [5]. It is well-known that the levels The general class of stabilizer codes includes CSS codes as a C(`) do not form a group for ` ≥ 3, but that the Clifford group special case and was introduced by Calderbank, Rains, Shor along with any unitary in C(3) can be used to approximate an and Sloane [5], and by Gottesman [6]. These codes, and their arbitrary unitary operator up to any desired precision. (Note variations [7], [8], still remain the preferred class of codes for that using a simple inductive argument it can be proven that

VOLUME 4, 2016 1 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes each level in the hierarchy is closed under multiplication by The primary contributions of this paper are the four theo- Clifford group elements.) Therefore, the standard strategy rems that we state and prove in Section III-B, and the main for realizing universal computation with QECCs is to first LCS algorithm (Algorithm 3) which builds on the results of synthesize1 logical Paulis, then logical Cliffords, and finally these theorems. These results form part of a larger program some logical non-Clifford in the third level of the Clifford for fault-tolerant quantum computation, where the goal is hierarchy. In this paper, we will be primarily concerned to achieve reliability by using classical computers to track with logical Cliffords because specific QECCs, such as tri- and control physical quantum systems, and perform error orthogonal codes [10], can be used to distill magic states [11] correction only as needed. for a non-Clifford gate in C(3), and these states can then We note that there are several works that focus on exactly be “injected” into the computation via teleportation in order decomposing, or approximating, an arbitrary unitary operator to realize the action of that gate at the logical level [9]. as a sequence of operators from a fixed instruction set, such Hence, any circuit implemented on the computer equipped as Clifford + T [18]–[23]. However, these works do not with error-correction might be expected to consist only of consider the problem of circuit synthesis or optimization over , augmented with ancilla magic states, and Pauli different realizations of unitary operators on the encoded measurements. space. We also note that there exists several works in the For the task of synthesizing the logical Pauli operators for literature that study this problem for specific codes and oper- stabilizer codes, the first algorithm was introduced by Gottes- ations, e.g., see [6]–[8], [24]–[27]. However, we believe our man [6, Sec. 4] and subsequently, another algorithm based work is the first to propose a systematic framework to address on a symplectic Gram-Schmidt procedure was proposed by this problem for general stabilizer codes, and hence enable Wilde [12]. The latter is closely related to earlier work by automated circuit synthesis for encoded Clifford operators. Brun et al. [13], [14]. Since the logical Paulis are inputs to This procedure is more systematic in considering all degrees our algorithm that synthesizes logical Clifford operators for of freedom than conjugating the desired logical operator by stabilizer codes, we will consider the above two procedures the encoding circuit for the QECC. to be “preprocessors” for our algorithm. Recently, we have used the LCS algorithm to translate Given the logical Pauli operators for an [[m, k]] stabilizer the unitary 2-design we constructed from classical Kerdock QECC, that encodes k logical qubits into m physical qubits, codes into a logical unitary 2-design [28], and in general physical Clifford realizations of Clifford operators on the log- any design consisting of only Clifford elements can be trans- ical qubits can be represented by 2m×2m binary symplectic formed into a logical design using our algorithm. An imple- matrices, thereby reducing the complexity dramatically from mentation of the design is available at: https://github.com/ 22m complex variables to 4m2 binary variables (see [15], nrenga/symplectic-arxiv18a. This finds direct application in [16] and Section II). We exploit this fact to propose an the logical randomized benchmarking protocol proposed by algorithm that efficiently assembles all 2r(r+1)/2, where r = Combes et al. [29]. This protocol is a more robust pro- m − k, symplectic matrices representing physical Clifford cedure to estimate logical gate fidelities than extrapolating operators (circuits) that realize a given logical Clifford oper- results from randomized benchmarking performed on phys- ator on the protected qubits. We will refer to this procedure ical gates [30]. Now we discuss some more motivations and as the Logical Clifford Synthesis (LCS) algorithm. Here, potential applications for the LCS algorithm. each symplectic solution represents an equivalence class of Clifford circuits, all of which “propagate” input Pauli opera- A. NOISE VARIATION IN QUANTUM SYSTEMS tors through them in an identical fashion (see Section III). Although depth or the number of two- gates might Moreover, as we will discuss later in the context of the appear to be natural metrics for optimization, near-term quan- algorithm, the other degrees of freedom not captured by our tum computers can also benefit from more nuanced metrics algorithm are those provided by stabilizers (see Remark 12). depending upon the physical system. For example, it is now But, at the cost of some increased computational complexity, established that the noise in the IBM Q Experience computers the algorithm can easily be modified to account for these varies widely among qubits and also with time, and that stabilizer degrees of freedom. Hence, our work makes it circuit optimizations might have to be done in regular time possible to optimize the choice of circuit with respect to intervals in order to exploit the current noise characteristics a suitable metric, that might be a function of the quantum of the hardware [31]. In such a scenario, if we need to imple- hardware. Note that our approach here is to determine unitary ment a specific logical operator at the current time, and if it is physical operations to realize a specific logical (Clifford) the case that some specific qubits or qubit-links in the system operation, and this is distinct from operations such as lattice are particularly unreliable, then it might be better to sacrifice surgery [17] that are used to perform logical operations on depth and identify an equivalent logical operator that avoids topological codes. those qubits or qubit-links (if possible). As an example, for the well-known [[4, 2, 2]] code [6], [27], whose stabilizer group is generated as S = hX1X2X3X4,Z1Z2Z3Z4i, two 1By “synthesize” we mean determine the logical operator, i.e., a circuit on the physical qubits of the QECC, that realizes the action of the given unitary implementations of the logical controlled-Z (CZ12) oper- operator on the logical qubits of that QECC. ation on the two logical qubits are shown in Fig. 1. The

2 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

1 P 1 However, this single solution does not come with any explicit guarantees regarding depth or number of two-qubit gates or 2 P 2 avoiding certain physical qubits. Therefore, even developing ≡ heuristics to directly optimize for a “good enough” solution, 3 P 3 instead of assembling all solutions and searching over them, will have a significant impact on the efficiency of compilers. 4 P Z 4 Z

Figure 1: Two physical circuits that realize the CZ gate on the B. QECCS FOR UNIVERSAL QUANTUM COMPUTATION two logical qubits of the [[4, 2, 2]] code. Physical single-qubit rotation gates on trapped-ion qubits are natural, reliable and have a long history [39]. Recently, it has also been observed that small-angle Mølmer-Sørensen ¯ ¯ θ θ logical Pauli operators in this case are X1 = X1X2, X2 = gates, i.e., XXij(θ) = cos · I4 − ı sin · XiXj for ¯ ¯ 2 2 X1X3, Z1 = Z2Z4, Z2 = Z3Z4. small θ, are more reliable than the maximally-entangling Assuming that single-qubit gates do not contribute to π XXij( 2 ) gate [40]. Since these are the primitive operations complexity (or difficulty of implementation), we observe that in trapped-ion systems [41], codes that support a transversal both choices have the same number of two-qubit gates and ıπ T = diag(1, exp( 4 )) gate, such as the tri-orthogonal codes depth. More interestingly, we see that the second choice mentioned earlier, could be directly used for computation completely avoids the first physical qubit while realizing rather than being dedicated for expensive magic state distil- the same logical CZ operation. Therefore, if either the first lation [10], [42]–[44]. However, it is well-known that there qubit itself has poor fidelity or coupling to it does, then exists no single QECC that supports a universal set of gates clearly the second choice is more appropriate. Preliminary where all of them have a transversal implementation at the experiments on the IBM system confirm this advantage when logical level [45]–[47]. Therefore, there is a natural tradeoff qubits are mapped appropriately. Note that even if we use between exploiting transversality for logical non-Clifford a QECC that protects a single qubit but has a transversal operations versus Clifford operations. CZ implementation, i.e., the logical CZ is a CZ between Indeed, this will be a realistic alternative only if the logical corresponding physical qubits in two separate code blocks, Clifford operations on these codes are “error-resilient”, by this incurs a larger overhead than the above scheme. We which we mean that for at least constant-depth circuits, the identified this example by using our open-source implemen- most likely errors remain correctable and do not propagate tation of our LCS algorithm, that is available at: https:// catastrophically through the Clifford sections of these logical github.com/nrenga/symplectic-arxiv18a. In order to identify circuits. For this purpose, our LCS algorithm can be a sup- (or construct) more interesting codes that exhibit a “rich” portive tool to investigate properties of stabilizer QECCs that set of choices for each logical operator, one needs a better guarantee error-resilience of their logical Clifford operators. understanding of the geometry of the space of symplectic Note that constant-depth circuits have been shown to provide solutions. We believe this is an important open problem a quantum advantage over classical computation [48]. In fact, arising from our work. it has been shown that the advantage persists even if those For near-term NISQ (Noisy Intermediate-Scale Quan- circuits are noisy [49], and the proof involves a QECC which tum [32]) era of quantum computers, a lot of current research admits constant-depth logical Cliffords. is focused on equipping compilers with routines that optimize circuits for depth and two-qubit gates, and the mapping of C. ORGANIZATION qubits from the algorithm to the hardware, while all taking The paper is organized as follows. Section II discusses the into account the specific characteristics and noise in the connection between quantum computation and the binary hardware [31], [33]–[36]. Although employing QECCs is symplectic group, which forms the foundation for this work. considered to be beyond the NISQ regime, exploiting simple Section III begins by outlining the process of finding logical codes such as the [[4, 2, 2]] code and using post-selection Clifford gates through a demonstration for the [[6, 4, 2]] CSS provides increased reliability than uncoded computation (as code [27], [50]. Then the general case of stabilizer codes is Harper and Flammia have demonstrated [37], [38]). There- discussed rigorously via four theorems and our LCS algo- fore, our efficient LCS algorithm might find an application in rithm. Finally, Section IV concludes the paper. Appendix B such quantum compilers, where the utility is to determine the discusses the proof of Theorem 1, and Appendix C provides best physical realization of a logical operator with respect the source code for Algorithm 2 with extensive comments. to current system characteristics. Specifically, this allows dynamic compilation (i.e., during program execution) that II. PHYSICAL AND LOGICAL OPERATORS could provide significant reliability gains in practice. Quantum error-correcting codes (QECCs) protect qubits in- In light of such applications, our software currently allows volved in quantum computation. In this section, we sum- one to determine only one physical realization in cases where marize the mathematical framework introduced in [3], [5], the number of solutions is prohibitively large, specifically for [6], [50] and described in more detail in [16], [51]. Math- QECCs with large-dimension stabilizers (r = m − k  1). ematically, an m-qubit system is treated as a

VOLUME 4, 2016 3 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

T with dimension N = 2m. Universal quantum computation and D(a, b)T = (−1)ab D(a, b). The symplectic inner 2m requires the ability to implement (within a specified toler- product in F2 is defined as ance) quantum operations represented by the group of N ×N 0 0 0 T 0 T 0 0 T unitary matrices acting on this space. In this paper, we are h[a, b], [a , b ]is , a b + b a = [a, b]Ω[a , b ] (mod 2),   primarily concerned with the unitary operators in the Clifford 0 Im where Ω , . (5) group. Im 0 Notation: Let denote the field of real numbers, denote R C Two operators D(a, b) and D(a0, b0) commute if and only if the field of complex numbers, and denote the binary F2 h[a, b], [a0, b0]i = 0. The homomorphism γ : HW → 2m field. We will consider vectors over to be row vectors s N F2 F2 defined by γ(ıκD(a, b)) [a, b] for all κ ∈ has kernel and vectors over or to be column vectors. Vectors over , Z4 R C hıI i, which allows us to represent elements of HW (up N with N = 2m will be indexed by elements of m N N C F2 to multiplication by scalars) as binary vectors. Since Y = in the natural binary order 00 ··· 00, 00 ··· 01,..., 11 ··· 11 ıXZ is Hermitian but XZ is not, an additional factor of ı is (rather than {1, 2,...,N}). Thus, for v ∈ m, let e ∈ N F2 v C required to make D(a, b) Hermitian for each i ∈ {1, . . . , m} denote the standard basis vector associated with index v, i.e., where aibi = 1. Hence, the matrix ev = |vi is all-zero except for a 1 in the entry indexed by v. abT mod 4 E(a, b) , ı D(a, b) (6) A. AND THE SYMPLECTIC INNER 2 2 2 2 PRODUCT is Hermitian and E(a, b) = IN , because X = Z = Y = 0 0 2m For a single qubit, we have m = 1 and a quantum pure state I2. Given [a, b], [a , b ] ∈ F2 , it can be shown that 2 is a vector in the N = 2 dimensional Hilbert space C .A 0 0 a0bT +b0aT 0 0 2 E(a, b)E(a , b ) = (−1) E(a , b )E(a, b) (7) pure uˆ ∈ C is a unit-length superposition 0 T 0 T T T = ıa b −b a E(a + a0, b + b0), (8) of the two states e0 , [1, 0] , e1 , [0, 1] that form the computational basis. Thus, uˆ = αe + βe , where α, β ∈ 0 1 C where the exponent and the sums a + a0, b + b0 are computed satisfy |α|2 + |β2| = 1. The Pauli matrices for a single qubit modulo 4 (see [52] for the extended definition of E(a, b)). system are the 2 × 2 identity matrix I2, 0 1 1 0  0 −ı B. STABILIZER CODES X , ,Z , ,Y , ıXZ = . 1 0 0 −1 ı 0 We use commutative subgroups of HWN to define reso- (1) lutions of the identity. A stabilizer group is a commuta- tive subgroup S of HWN generated by commuting Hermi- We note that the Pauli matrices form a basis over C for all 2× tian matrices ±E(a, b), with the additional property that if 2 complex matrices. Thus, any single qubit unitary operator E(a, b) ∈ S then −E(a, b) ∈/ S. Recall that an operator is (such as an error) can be written as a linear combination of an orthogonal projection onto its range iff it is idempotent Pauli matrices. One can also express any pure quantum state 2 m and Hermitian. Since E(a, b) = IN for all a, b ∈ F2 , the uˆ = (α I + α X + ıα Z + α Y ) e , α ∈ I ±E(a,b) as 0 2 1 2 3 0 where i R. operator N is an orthogonal projection onto the ±1 For an m-qubit system, we work in the N = 2m di- 2 N eigenspace of E(a, b), respectively. Also, the eigenvalues of mensional Hilbert space C and a pure quantum state uˆ is each E(a, b) are ±1 with algebraic multiplicity N/2. a unit-length vector in this space. The computational basis N m Since all elements of S are commuting Hermitian uni- vectors {ev ∈ C |(v1, . . . , vm) ∈ F2 } are defined by the tary matrices, they can be simultaneously diagonalized with Kronecker product ev , ev1 ⊗ ev2 ⊗ · · · ⊗ evm . Thus a pure P respect to a common orthonormal basis. We refer to such quantum state can be written as uˆ = m αvev, where v∈F2 a basis as the common eigenbasis or simply the eigen- P 2 m |αv| = 1. v∈F2 basis of the subgroup S. In addition, if the subgroup S m m Let N , 2 . Given row vectors a, b ∈ F2 , define the is generated by E(ai, bi), i = 1, . . . , r, then the operator 1 Qr m-fold Kronecker product 2r i=1(IN + E(ai, bi)) is an orthogonal projection onto the 2k-dimensional subspace V (S) fixed pointwise by S, i.e., D(a, b) Xa1 Zb1 ⊗ · · · ⊗ Xam Zbm ∈ , (2) , UN the +1 eigenspace of S, where k , m − r. Mathematically, V (S) {|ψi ∈ N | g |ψi = |ψi for all g ∈ S}. The sub- where denotes the group of all N × N unitary operators. , C UN space V (S) is called the [[m, k]] stabilizer code determined by The Heisenberg-Weyl group HW (also called the m-qubit N S, where the notation [[m, k]] indicates that V (S) encodes k Pauli group) consists of all operators ıκD(a, b), where κ ∈ logical qubits into m physical qubits. The extended notation {0, 1, 2, 3}. The order is |HW | = 4N 2 and the center Z4 , N [[m, k, d]] is used to denote that any undetectable error on the of this group is hıI i = {I , ıI , −I , −ıI }, where I N N N N N N code must act on at least d qubits, i.e., d is the (minimum) is the N × N identity matrix. Since XZ = −ZX, distance of the stabilizer code. 0 T 0 T 2m D(a, b)D(a0, b0) = (−1)a b +b a D(a0, b0)D(a, b) (3) Let γ(S) denote the subspace of F2 formed by the binary 0 T representations of the elements of S under the homomor- = (−1)a b D(a + a0, b + b0), (4) phism γ. A generator matrix for γ(S) is GS , [ai, bi]i=1,...,r

4 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

T 0 0 0 0 and we have GS Ω GS = 0r, where 0r is the r × r all- h[a, b]Fg, [a , b ]Fgis = h[a, b], [a , b ]is. This implies that Fg T zero matrix (the subscript is often neglected). The condition satisfies FgΩFg = Ω. We say that Fg is a binary symplectic T T GS Ω GS = 0 encodes the fact that elements of S must matrix, and express the symplectic property FgΩFg = Ω as T T T T T T pairwise commute. AgBg = BgAg ,CgDg = DgCg ,AgDg + BgCg = Im. Given a stabilizer S with generators E(ai, bi), i = Let Sp(2m, F2) denote the group of symplectic 2m × r 1, . . . , r, we can define 2 subgroups S1···r where the index 2m matrices over F2. The homomorphism φ: CliffN → (1 ··· r) represents that S1···r is generated by iE(ai, bi), Sp(2m, F2) defined by φ(g) , Fg is surjective with kernel i ∈ {±1}. Note that hHWN , U(1)i, and every Clifford operator maps down to r a symplectic matrix Fg. Thus, HWN is a normal subgroup 1 Y of Cliff and Cliff /hHW , (1)i ∼ Sp(2m, ). This Π ··· (IN + iE(ai, bi)) (9) N N N U = F2 1 r , 2r m2 Qm j i=1 implies that the size is |Sp(2m, F2)| = 2 j=1(4 − 1) (also see [5]). Table 1 lists elementary symplectic trans- is the orthogonal projector onto V (S ··· ) and the sum P 1 r formations Fg, that generate the binary symplectic group r Π ··· = IN defines a resolution of the (1,...,r )∈{±1} 1 r Sp(2m, ), and the corresponding unitary automorphisms identity. In , it is sufficient to correct F2 g ∈ Cliff , which together with HW generate Cliff Pauli errors (i.e., elements in HW ) because general errors N N N N (see [51, Appendix I]). Some important circuit identities can be approximated by linear combinations of them [53]. involving these operators are listed in [51]. Also, the elements of HW , acting via conjugation, permute N In [55], Can has developed an algorithm that factors a the subgroups S . Given an [[m, k]] stabilizer code, it is 1···r 2m × 2m binary symplectic matrix into a product of at possible to perform encoded quantum computation in any of most 6 elementary symplectic matrices of the type shown in the subspaces V (S ) by synthesizing appropriate logical 1···r Table 1. The target symplectic matrix maps the dual basis operators. If we think of these subspaces as threads, then a X {E(a, 0): a ∈ m},Z {E(0, b): b ∈ m} computation starts in one thread and jumps to another when N , F2 N , F2 to a dual basis X0 ,Z0 . Row and column operations by an error (from HW ) occurs. QECCs enable error control N N N the elementary matrices return X0 ,Z0 to the original pair by identifying the jump that the computation has made. N N X ,Z . This decomposition simplifies the translation of Identification makes it possible to adjust future operations in N N symplectic matrices into circuits (see [51, Appendix I]), and the computation instead of returning to the initial subspace so we use it in our LCS algorithm. For completeness, we and restarting the computation. The idea of tracing these include the theorem here. threads is called as Pauli frame tracking [54]. Theorem 1 ([55, Theorem 3.2.1]): Any binary symplectic transformation F can be expressed as C. THE CLIFFORD GROUP AND SYMPLECTIC MATRICES F = AQ1 Ω TR1 GkTR2 AQ2 , The Clifford group CliffN consists of all unitary matrices N×N † g ∈ C for which gD(a, b)g ∈ HWN for all D(a, b) ∈ as per the notation used in Table 1, where invertible matrices † HWN , where g is the conjugate transpose of g [16]. CliffN Q1,Q2 and symmetric matrices R1,R2 are chosen appropri- is the normalizer of HWN in the unitary group UN , so it ately. contains HWN . Note that by definition CliffN has an infinite Proof: The idea is to perform row and column operations ıθ center consisting of U(1) , {e IN ; θ ∈ R}, but it can be on the matrix F via left and right multiplication by ele- made finite by first taking the quotient group CliffN /U(1) mentary symplectic transformations from Table 1, and bring and then including multiples of just the phase eıπ/4, which the matrix F to the standard form Ω TR1 Ω (for details see contributes a factor 8 in its size [5], i.e., |CliffN | = 8 · Appendix B). m2+2m Qm j 2 j=1(4 − 1). We regard operators in CliffN as A closely related algorithm was given earlier by Dehaene physical operators acting on quantum states in CN , to be and De Moor [56]. The elementary symplectic matrices implemented by quantum circuits. Every operator g ∈ CliffN appearing in the product can be related to the Bruhat de- induces an automorphism of HWN by conjugation. Note that composition of the symplectic group (see [20]). When the the inner automorphisms induced by matrices in HWN pre- algorithm is run in reverse it produces a random Clifford serve every conjugacy class {±D(a, b)} and {±ıD(a, b)}, matrix, which serves as a “third-order” approximation to because (3) implies that elements in HWN either commute a random unitary matrix since the Clifford group forms a or anti-commute. The automorphism induced by an element unitary 3-design [57]. This is an instance of the subgroup g ∈ CliffN satisfies (see [51] for a proof) algorithm [58] for generating uniform random variables. The algorithm has complexity O(m3) and uses O(m2) random A B  gE(a, b)g† = ±E ([a, b]F ) , where F = g g . bits, which is order optimal given the order of the symplectic g g C D g g group Sp(2m, ) (cf. [59]). Our algorithm is similar to that (10) F2 developed by Jones et al. [60] in that it alternates (partial) Since conjugation by g respects commutativity in HWN , Hadamard matrices and diagonal matrices; the difference the matrix Fg preserves symplectic inner products: is that the unitary 3-design property of the Clifford group

VOLUME 4, 2016 5 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Table 1: A universal set of logical operators for Sp(2m, F2) and their corresponding physical operators in CliffN (see Appendix A for a detailed discussion and circuits). The number of 1s in Q and R directly relates to the number of gates. t Here H2t denotes the Walsh-Hadamard matrix of size 2 , Ut = diag (It, 0m−t) and Lm−t = diag (0t,Im−t).

Logical Operator Fg Physical Operator g Circuit Element

   ⊗m 0 Im 1 1 ⊗m √1 Ω = HN = H = m Transversal Hadamard Im 0 ( 2) 1 −1   Q 0 P Controlled-NOT (CNOT) AQ = −T aQ : |vi 7→ |vQi , aQ = v∈ m |vQi hv| 0 Q F2 Qubit Permutation   Im R T  vRvT mod 4 P vRvT Controlled-Z (CZ) TR = ; R = R tR = diag ı = v∈ m ı |vi hv| 0 Im F2 Phase (P )   Lm−t Ut Gt = gt = H2t ⊗ I2m−t Partial Hadamards Ut Lm−t

provides randomness guarantees. This also finds application to how CZ12 acts on Xj,Zj as stated explicitly in (11), in machine learning (see [61] and references therein). and (ii) preserves the code space. Note that satisfying the mathematical condition in (i) does not already guarantee (ii). III. SYNTHESIS OF LOGICAL CLIFFORD OPERATORS The first condition is written as the constraints FOR STABILIZER CODES  Quantum computation in the protected space of an [[m, k]] X¯ Z¯ if j = 1,  1 2 ¯ † ¯ ¯ quantum error-correcting code (QECC) requires the transla- CZ12XjCZ12 = Z1X2 if j = 2, tion of logical operators on the k encoded qubits into physical  X¯j if j 6= 1, 2, operators on the m code qubits. In this section, for an [[m, k]] ¯ † ¯ stabilizer code, we develop an algorithm that synthesizes all CZ12ZjCZ12 = Zj for all j = 1, 2, 3, 4. (11) physical Clifford realizations of a logical Clifford operator, up to equivalence classes defined by their action on input The symplectic representation of Clifford elements in (10) Pauli operators (which is encoded in their symplectic matrix transforms these conditions into the following linear con- straints on the desired symplectic matrix F : representation, by (10)). This algorithm makes it possible to CZ12 optimize the choice of circuit with respect to a metric that [e + e , 0]F = [e + e , e + e ], is a function of the quantum hardware. We now outline the 1 2 CZ12 1 2 3 6 algorithm and illustrate the steps using an example where we [e1 + e3, 0]FCZ = [e1 + e3, e2 + e6], synthesize a logical controlled-Z gate on the first two logical 12 [e + e , 0]F = [e + e , 0], j = 3, 4, qubits of the [[6, 4, 2]] code [6], [27]. See [1] for discussions 1 j+1 CZ12 1 j+1 [0, e + e ]F = [0, e + e ], on other operators for this code. 2 6 CZ12 2 6 [0, e + e ]F = [0, e + e ], Input: Target Clifford circuit g on the k logical qubits, 3 6 CZ12 3 6 stabilizers, and logical Paulis. [0, e + e ]F = [0, e + e ], j = 3, 4. (12) j+1 6 CZ12 j+1 6 Output: All Clifford circuits g¯ on the m physical qubits that preserve the code space and implement g on the k logical Constraint (ii) requires that the physical circuit must normal- qubits. ize the stabilizer. We prove later that any such circuit can Step 1: Translate the input into linear constraints on the be transformed into one that commutes with each stabilizer element, while realizing the same logical operation (see The- symplectic matrix Fg¯ representing g¯. orem 11). Note that the requirement is only to preserve the The stabilizer group of the [[6, 4, 2]] CSS code is S = code space, i.e., CZ must commute with the code projector, hX⊗6,Z⊗6i = hE(1, 0),E(0, 1)i, where 1 = 111111, 0 = 12 but this is equivalent to normalizing the stabilizer since we 000000. The logical Pauli operators can be calculated di- restrict CZ to be a physical Clifford operator. For non- rectly [51, Section V], or using algorithms developed by 12 Clifford physical operators, the general approach would be Gottesman [6] or Wilde [12]. These operators are given by similar to that considered for Z-rotations in [62]. Requiring X¯ = X X = E(e + e , 0), Z¯ = Z Z = j 1 j+1 1 j+1 j j+1 6 that the circuit centralize the stabilizer yields the constraints E(0, ej+1 + e6), j = 1, 2, 3, 4, where ej is the j-th standard 6 basis vector in F2. We now find a 6-qubit circuit CZ12 on [111111, 000000]F = [111111, 000000], CZ12 the physical (code) qubits that (i) realizes the CZ12 gate ¯ ¯ [000000, 111111]F = [000000, 111111]. (13) on the logical qubits, i.e., CZ12 acts on Xj, Zj analogous CZ12

6 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Step 2: Find all symplectic solutions. We will use the above result to propose an algorithm (Al- The symplectic constraint F ΩF T = Ω is non- gorithm 1) which determines a symplectic matrix F that sat- CZ12 CZ12 linear, and in the description of the generic LCS algorithm isfies xiF = yi, i = 1, 2, . . . , t ≤ 2m, where xi are linearly that follows this example, we show how to use transvections independent and satisfy hxi, xjis = hyi, yjis for all i, j ∈ to find all 2r(r+1)/2 symplectic solutions. We then trans- {1, . . . , t}. late each solution into a physical Clifford circuit using the decomposition of symplectic matrices as a product of the B. DESCRIPTION OF THE GENERIC LOGICAL elementary matrices listed in Table 1 (see Appendix B or [51] CLIFFORD SYNTHESIS (LCS) ALGORITHM for details). For the [[6, 4, 2]] code there are 8 symplectic The synthesis of logical Paulis by Gottesman [6] and by solutions. The solution with smallest depth is the elementary Wilde [12] exploits symplectic groups over the binary field. symplectic matrix F = T , where B = B = B = Building on their work we have demonstrated, using the CZ12 B 23 32 26 B62 = B36 = B63 = 1 and Bij = 0 elsewhere. The [[6, 4, 2]] code as an example, that the binary symplectic group  vBvT  corresponding physical operator CZ12 = diag ı can provides a systematic framework for synthesizing physical implementations of any logical operator in the logical Clif- be decomposed into CZ23CZ26CZ36. ford group Cliff2k for stabilizer codes. In other words, the Step 3: Identify any sign violations and find a Pauli matrix to symplectic group provides a control plane where effects of fix the signs while leaving the logical operation undisturbed. Clifford operators can be analyzed efficiently. For each logi- The operator CZ23CZ26CZ36 commutes with the stabilizer cal Clifford operator, one can obtain all symplectic solutions E(0, 1) but not with the stabilizer E(1, 0). Adding the Pauli using the algorithm below. operator Z6 fixes the sign and leaves the logical operation 1) Collect all the linear constraints on F , obtained from undisturbed. So the final circuit is CZ23CZ26CZ36Z6. the conjugation relations of the desired Clifford opera- tor with the stabilizer generators and logical Paulis, to A. SYMPLECTIC TRANSVECTIONS obtain a system of equations UF = V . 2m Definition 2: Given row vector h ∈ F2 , a symplectic 2) Then vectorize both sides to get (I2m ⊗ U) vec(F ) = 2m 2m transvection is a map Zh : F2 → F2 defined by vec(V ). 3) Perform Gaussian elimination on the augmented ma- Z (x) x + hx, hi h = xF , where F I + ΩhT h, h , s h h , 2m trix [(I ⊗ U) , vec(V )]. If ` is the number of non- (14) 2m pivot variables in the row-reduced echelon form, then ` where Fh is its associated symplectic matrix [59]. A there are 2 solutions to the linear system. transvection does not correspond to a single elementary 4) For each such solution, check if it satisfies F ΩF T = Clifford operator. Ω. If it does, then it is a feasible symplectic solution for Fact 3 ([63, Theorem 2.10]): The symplectic group g¯. Sp(2m, F2) is generated by the family of symplectic Clearly, this algorithm is not very efficient since ` could transvections. be very large. Specifically, for codes that do not encode An important result that is involved in the proof of this fact many logical qubits this number will be very large as the is the following theorem from [59], [63], which we restate system UF = V will be very under-constrained. We now 2m here for F2 since we will build on this result to state and state and prove two theorems that enable us to determine all prove Theorem 5. symplectic solutions for each logical Clifford operator much 2m Theorem 4: Let x, y ∈ F2 be two non-zero vectors. Then x more efficiently. can be mapped to y by a product of at most two symplectic 2m Theorem 5: Let xi, yi ∈ F2 , i = 1, 2, . . . , t ≤ 2m be a transvections. collection of (row) vectors such that hxi, xjis = hyi, yjis. Proof: There are two cases: hx, yis = 1 or 0. First Assume that the xi are linearly independent. Then a solution assume hx, yis = 1. Define h , x + y, so F ∈ Sp(2m, F2) to the system of equations xiF = yi can be obtained as the product of a sequence of at most 2t xFh = Zh(x) = x + hx, x + yis(x + y) T 2m symplectic transvections Fh , I2m +Ωh h, where h ∈ F2 = x + (hx, xis + hx, yis)(x + y) is a row vector. = x + (0 + 1)(x + y) = y. Proof: We will prove this result by induction. For i = 1 we can simply use Theorem 4 to find F1 ∈ Sp(2m, F2) hx, yi = 0 h w + y, h x + w Next assume s . Define 1 , 2 , , as follows. If hx1, y1is = 1 then F1 Fh with h1 2m , 1 , where w ∈ 2 is chosen such that hx, wis = hy, wis = 1. F x1 + y1, or if hx1, y1is = 0 then F1 , Fh11 Fh12 with Then h11 , w1 + y1, h12 , x1 + w1, where w1 is chosen such that hx1, w1is = hy1, w1is = 1. In any case F1 satisfies xFh1 Fh2 = Zh2 (x + hx, w + yis(w + y)) x1F1 = y1. Next consider i = 2. Let x˜2 , x2F1 so that = (x + w + y) + h(x + w) + y, x + wi (x + w) s hx1, x2is = hy1, y2is = hy1, x˜2is, since F1 is symplectic and = y. hence preserves symplectic inner products.

VOLUME 4, 2016 7 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Similar to Theorem 4 we have two cases: hx˜2, y2is = 1 or Algorithm 1 Algorithm to find F ∈ Sp(2m, F2) satisfying a 0. For the former, we set h2 , x˜2 +y2 so that we clearly have linear system of equations, using Theorem 5 x˜2Fh = Zh (˜x2) = y2 (see Section III-A for the definition 2m 2 2 Input: xi, yi ∈ F2 s.t. hxi, xjis = hyi, yjis ∀ i, j ∈ of Zh(·)). We also observe that {1, . . . , t}. Output: F ∈ Sp(2m, ) satisfying x F = y ∀ i ∈ y1Fh = Zh (y1) = y1 + hy1, x˜2 + y2is(˜x2 + y2) F2 i i 2 2 {1, . . . , t} = y1 + (hy1, y2is + hy1, y2is)(˜x2 + y2) 1: if hx1, y1is = 1 then = y1. 2: set h1 , x1 + y1 and F1 , Fh1 . 3: else Hence in this case F2 , F1Fh2 satisfies x1F2 = y1, x2F2 = 4: h11 w1 + y1, h12 x1 + w1 and F1 Fh Fh . y2. For the case hx˜2, y2is = 0 we again find a w2 that satisfies , , , 11 12 5: end if hx˜2, w2is = hy2, w2is = 1 and set h21 , w2 + y2, h22 , 6: for i = 2, . . . , t do x˜2 + w2. Then by Theorem 4 we clearly have x˜2Fh21 Fh22 = 7: Calculate x˜i xiFi−1 and hx˜i, yiis. y2. For y1 we observe that , 8: if x˜i = yi then y F F 1 h21 h22 9: Set Fi , Fi−1. Continue. 10: end if = Zh22 (Zh21 (y1)) 11: if hx˜i, yiis = 1 then = Zh22 (y1 + hy1, w2 + y2is(w2 + y2)) 12: Set hi x˜i + yi,Fi Fi−1Fh . = y + hy , w + y i (w + y ) + hy , x˜ + w i , , i 1 1 2 2 s 2 2 1 2 2 s 13: else  + hy1, w2 + y2ishw2 + y2, x˜2 + w2is (˜x2 + w2) 14: Find a wi s.t. hx˜i, wiis = hyi, wiis = 1 and (a) hyj, wiis = hyj, yiis ∀ j < i. = y1 + hy1, w2 + y2is(˜x2 + y2) 15: Set hi1 , wi + yi, hi2 , x˜i + wi,Fi , = y1 if and only if hy1, w2is = hy1, y2is, Fi−1Fhi1 Fhi2 . 16: end if where (a) follows from hy1, x˜2is = hy1, y2is, hw2 + y2, x˜2 + 17: end for w2is = 1 + 0 + 0 + 1 = 0. Hence, we pick a w2 such that 18: return F F . hx˜2, w2is = hy2, w2is = 1 and hy1, w2is = hy1, y2is, and , t then set F2 , F1Fh21 Fh22 . Again, for this case F2 satisfies x1F2 = y1, x2F2 = y2 as well. By induction, assume Fi−1 satisfies xjFi−1 = yj for all Now we state our main theorem, which enables one to j = 1, . . . , i − 1, where i ≥ 3. Using the same idea as for determine all symplectic solutions for a system of linear i = 2 above, let xiFi−1 =x ˜i. If hx˜i, yiis = 1, we simply set equations. Fi Fi−1Fh , where hi x˜i + yi. If hx˜i, yiis = 0, we find , i , Theorem 7: Let {(ua, va), a ∈ {1, . . . , m}} be a col- a wi that satisfies hx˜i, wiis = hyi, wiis = 1 and hyj, wiis = lection of pairs of (row) vectors that form a symplec- hyj, yiis ∀ j < i. Then we define hi1 , wi+yi, hi2 , x˜i+wi 2m 2m tic basis for F2 , where ua, va ∈ F2 . Consider the and observe 0 0 system of linear equations uiF = ui, vjF = vj, where i ∈ I ⊆ {1, . . . , m}, j ∈ J ⊆ {1, . . . , m} and yjFhi1 Fhi2 = Zhi2 (Zhi1 (yj)) F ∈ (2m, ) = y + hy , w + y i (˜x + y ) Sp F2 . Assume that the given vectors satisfy j j i i s i i hu , u i = hu0 , u0 i = 0, hv , v i = hv0 , v0 i = i1 i2 s i1 i2 s j1 j2 s j1 j2 s = yj, for j < i. 0 0 0, hui, vjis = hui, vjis = δij, where i1, i2 ∈ I, j1, j2 ∈ J (since symplectic transformations F must preserve symplec- Again, by Theorem 4, we clearly have x˜iFhi1 Fhi2 = yi. tic inner products). Let α |I|¯ +|J¯ |, where I¯, J¯ denote the Hence we set Fi , Fi−1Fhi1 Fhi2 in this case. In both cases , Fi satisfies xjFi = yj ∀ j = 1, . . . , i. Setting F Ft set complements of I, J in {1, . . . , m}, respectively. Then , α(α+1)/2 completes the inductive proof and it is clear that F is the there are 2 solutions F to the given linear system, product of at most 2t symplectic transvections. and they can be enumerated systematically. The algorithm defined implicitly by the above proof is Proof: By the definition of a symplectic basis (Defini- stated explicitly in Algorithm 1. tion 6), we have hua, vbis = δab and hua, ubis = hva, vbis = 2m Definition 6: A symplectic basis for F2 is a set of pairs 0, where a, b ∈ {1, . . . , m}. The same definition extends 2m {(v1, w1), (v2, w2),..., (vm, wm)} such that hvi, wjis = δij to any (symplectic) subspace of F2 . The linear system and hvi, vjis = hwi, wjis = 0, where δij = 1 if i = j and 0 under consideration imposes constraints only on ui, i ∈ I 2m if i 6= j. and vj, j ∈ J . Let W be the subspace of F2 spanned Note that the rows of any matrix in Sp(2m, F2) form a by the symplectic pairs (uc, vc) where c ∈ I ∩ J and 2m ⊥ symplectic basis for F2 . There exists a symplectic Gram- W be its orthogonal complement under the symplectic Schmidt orthogonalization procedure that can produce a inner product, i.e., W , h{(uc, vc), c ∈ I ∩ J }i and 2m ⊥ ¯ ¯ ¯ ¯ symplectic basis starting from the standard basis for F2 and W , h{(ud, vd), d ∈ I ∪ J }i, where I, J denote the 2m an additional vector v ∈ F2 (see [59]). set complements of I, J in {1, . . . , m}, respectively.

8 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Using the result of Theorem 5, we first compute one defining k = m − α, the number of such valid matrices V solution F0 for the given system of equations. In the subspace is given by 0 0 W , F0 maps (uc, vc) 7→ (uc, vc) for all c ∈ I ∩ J  0 0 2m 2m−1 1 2m−2 2 and hence we now have W = h{(uc, vc), c ∈ I ∩ J }i (2 − 1) · (2 − 2 ) · (2 − 2 ) ··· 0 0 ⊥ spanned by its new basis pairs (uc, vc). However in W , 0 0 0 0  F0 maps (ud, vd) 7→ (ud, v˜d) or (ud, vd) 7→ (˜ud, vd) or (22m−(m−1) − 2m−1) 0 0 ¯ (ud, vd) 7→ (˜ud, v˜d) depending on whether d ∈ I ∩ J or d ∈ I¯ ∩ J or d ∈ I¯ ∩ J¯, respectively (d∈ / I ∩ J by   × 22m−m · 22m−(m+1) ··· 22m−(m+k−1) definition of W ⊥). Note however that the subspace W ⊥ itself is fixed. We observe that such u˜0 and v˜0 are not specified  d d 0 2m 1 2m−2 2 2m−4 by the given linear system and hence form only a particular = 2 (2 − 1) · 2 (2 − 1) · 2 (2 − 1) ··· ⊥ choice for the new symplectic basis of W . These can be  0 m−1 (m+1)−(m−1) m m−1 m−(k−1) mapped to arbitrary choices u˜d and v˜d, while fixing other ud 2 (2 − 1) · 2 · 2 ··· 2 0 and vd, as long as the new choices still complete a symplectic ⊥ m basis for W . Hence, these form the degrees of freedom for m(m+1) +(k−1)m− k(k−1) Y j = 2 2 2 (4 − 1). the solution set of the given system of linear equations. The j=1 number of such “free” vectors is exactly |I|¯ + |J¯ | = α. This can be verified by observing that the number of basis vectors The counting in the first line is as follows. First, we assume for W ⊥ is 2|I¯ ∪ J¯ | and making the following calculation. without loss of generality that the pairs of rows i and (m + i) of V form a symplectic pair, for i = 1, . . . , k, and the rows Number of constrained vectors in the new basis for W ⊥ k + 1, . . . , m are orthogonal to all rows of V under the symplectic inner product. More precisely, the inner products = |I \ J | + |J \ I| between pairs of rows of V must be the same as those = |I| − |I ∩ J | + |J| − |I ∩ J | between corresponding pairs of rows of U. But, we assume = (m − |I|¯ ) + (m − |J¯ |) − 2(m − |I¯ ∪ J¯ |) that we can perform a symplectic Gram-Schmidt process on = 2|I¯ ∪ J¯ | − (|I|¯ + |J¯ |) U so that the above assumption is valid. For the first row of V , we can choose any non-zero vector and there are (22m −1) of = 2|I¯ ∪ J¯ | − α. them. For the second row, we need to restrict to vectors that are orthogonal to the first row, and we need to eliminate the ¯ ¯ Let d, d1, d2 ∈ I ∪ J be indices of some symplectic basis subspace generated by the first row. Similarly, for the third ⊥ vectors for W . Then, the constraints on free vectors u˜d and row until the m-th row, we keep restricting to the subspace v˜ are that hu˜ , v0 i = hu0 , v˜ i = hu˜ , v˜ i = δ d d1 d2 s d1 d2 s d1 d2 s d1d2 of vectors orthogonal to all previous rows and eliminate the and all other pairs of vectors in the new basis set for W ⊥ subspace generated by all previous rows. For the (m + 1)- be orthogonal to each other. In the d-th symplectic pair — th row, it needs to be orthogonal to all rows starting from 0 0 (˜ud, vd) or (ud, v˜d) or (˜ud, v˜d) — of its new symplectic the second to the m-th, but it needs to have symplectic inner basis there is at least one free vector — u˜d or v˜d or both, product 1 with the first row. Hence the dimension decreases respectively. For the first of the α free vectors, there are by m from 2m, but notice that the subspace generated by the 2|I¯ ∪ J¯ | − α symplectic inner product constraints (which first m rows cannot have any vector that has symplectic inner are linear constraints) imposed by the 2|I¯ ∪ J¯ | − α con- product 1 with the first row. Therefore, we need not subtract 0 0 ⊥ 2m−m strained vectors ud, vd. Since W has (binary) this subspace and this gives the count 2 for the (m+1)- dimension 2|I¯ ∪ J¯ | and each linearly independent constraint th row. A similar argument can be made for all remaining decreases the dimension by 1, this leads to 2α possible rows and this completes the argument for counting. (It is easy choices for the first free vector. For the second free vector, to verify that by substituting k = m above we obtain the size there are α − 1 degrees of freedom as it has an additional of Sp(2m, F2) exactly.) Now we expand the exponent of 2 1 2 2 inner product constraint from the first free vector. This leads above to obtain 2 (m + 2mk − k − m + k). to 2α−1 possible choices for the second free vector, and so Recollect that the size of the symplectic group is Qα ` m2 Qm j on. Therefore, the given linear system has at least `=1 2 = 2 j=1(4 − 1), and we need to check that the number α(α+1)/2 2 symplectic solutions. obtained by dividing this by 2α(α+1)/2 is equal to the above Qm j We will now argue that there cannot be more solutions. The number, for α = m − k. Since the product j=1(4 − 1) given system of equations can be represented compactly as matches with the expression in the count above, we only have (2m−α)×2m UF = V , where U, V ∈ F2 and F is symplectic. to check that the exponents of 2 match. Here, the exponent of Observe that for each valid choice of V the set of symplectic 2 is given by solutions is disjoint, and hence they form a partition of the (m − k)(m − k + 1) binary symplectic group Sp(2m, ). Therefore, it is enough m2 − F2 2 to show that the product of the number of such valid matrices 1 2 2 2  V and 2α(α+1)/2 is equal to the size of Sp(2m, ). By = 2m − (m − 2mk + k + m − k) F2 2 VOLUME 4, 2016 9 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

1 = m2 + 2mk − k2 − m + k , Algorithm 2 Algorithm to determine all F ∈ Sp(2m, F2) 2 satisfying a linear system of equations, using Theorem 7 which equals the exponent calculated above. This completes 2m Input: ua, vb ∈ F2 s.t. hua, vbis = δab and hua, ubis = the proof that the given system has exactly 2α(α+1)/2 solu- hva, vbis = 0, where a, b ∈ {1, . . . , m}. tions. u0 , v0 ∈ 2m hu0 , u0 i = 0, hv0 , v0 i = i j F2 s.t. i1 i2 s j1 j2 s Finally, we show how to get each symplectic solution F 0 0 0, hui, vjis = δij, where i, i1, i2 ∈ I, j, j1, j2 ∈ for the given linear system. First form the matrix A whose J , I, J ⊆ {1, . . . , m}. 2m rows are the new symplectic basis vectors for F2 obtained Output: F ⊂ Sp(2m, ) such that each F ∈ F satisfies 0 0 0 F2 under the action of F0, i.e., the first m rows are uc, u , u˜ 0 0 d d uiF = ui ∀ i ∈ I, and vjF = vj ∀ j ∈ J . and the last m rows are v0 , v0 , v˜0 . Observe that this matrix c d d 1: Determine a particular symplectic solution F0 for the is symplectic and invertible. Then form a matrix B = A linear system using Algorithm 1. and replace the rows corresponding to free vectors with 2: Form the matrix A whose a-th row is uaF0 and (m + b)- a particular choice of free vectors, chosen to satisfy the th row is vbF0, where a, b ∈ {1, . . . , m}. conditions mentioned above. Note that B and A differ in −1 3: Compute the inverse of this matrix, A , in F2. exactly α rows, and that B is also symplectic and invertible. 4: Set F = φ and α |I|¯ + |J¯ |, where I¯, J¯ denote the set 0 −1 , Determine the symplectic matrix F = A B which fixes all complements of I, J in {1, . . . , m}, respectively. ⊥ new basis vectors obtained for W and W under F0 except 5: for ` = 1,..., 2α(α+1)/2 do ⊥ the free vectors in the basis for W . Then this yields a new 6: Form a matrix B = A. 0 ` solution F = F0F for the given system of linear equations. 7: For i∈ / I and j∈ / J replace the i-th and (m + j)- 0 0 Note that if u˜d =u ˜d and v˜d =v ˜d for all free vectors, where th rows of B with arbitrary vectors such that 0 0 ⊥ ` u˜ , v˜ were obtained under the action of F on W , then T 0 d d 0 B ΩB = Ω and B 6= B 0 for 1 ≤ ` < `. 0 α(α+1)/2 ` ` ` ` F = I2m. Repeating this process for all 2 choices /∗ See proof of Theorem 7 for details or Appendix C of free vectors enumerates all the solutions for the linear for example MATLAB® code ∗/ system under consideration. 8: Compute F 0 = A−1B. Remark 8: For any system of symplectic linear equations 0 9: Add F` , F0F to F. xiF = yi, i = 1, . . . , t where the xi do not form a 10: end for 2m symplectic basis for F2 , we first calculate a symplectic 11: return F basis (uj, vj), j = 1, . . . , m using the symplectic Gram- Schmidt orthogonalization procedure discussed in [59]. Then we transform the given system into an equivalent system of {1, 2, 3, 4, 6} and α = 1 + 1 = 2. As discussed ear- constraints on these basis vectors uj, vj and apply Theorem 7 lier, we impose constraints on all ui, vj except for i = 6 to obtain all symplectic solutions. and j = 5. Therefore, as per the notation in the above The algorithm defined implicitly by the above proof is ⊥ proof, we have W , h{(u1, v1),..., (u4, v4)}i and W , stated explicitly in Algorithm 2. For a given system of linear h{(u5, v5), (u6, v6)}i. Using Algorithm 1 we obtain a partic- (independent) equations, if α = 0 then the symplectic ular solution F0 = TB where B is given in the beginning of matrix F is fully constrained and there is a unique solution. Section III. Then we compute the action of F0 on the bases Otherwise, the system is partially constrained and we refer to for W and W ⊥ to get a solution F as a partial symplectic matrix. 0 0 Example: As an application of this theorem, we discuss uiF0 , ui, vjF0 , vj, i ∈ I, j ∈ J , and 0 the procedure to determine all symplectic solutions for the u6F0 = [100000, 000000] , u˜6, logical controlled-Z gate CZ12 discussed at the beginning of 0 12 v5F0 = [000000, 000001] , v˜5, (16) this section. First we define a symplectic basis for F2 using 0 0 the binary vector representation of the logical Pauli operators where ui, vj are the vectors obtained in (12), (13). Then we and stabilizer generators of the [[6, 4, 2]] code. identify v˜5 and u˜6 to be the free vectors and one particular 0 0 α solution is v˜5 =v ˜5, u˜6 =u ˜6. In this case we have 2 = u1 [110000, 000000] , v1 [000000, 010001], 2 0 , , 2 = 4 choices to pick v˜5, since we need hu5, v˜5is = 1, 0 u2 , [101000, 000000] , v2 , [000000, 001001], hui, v˜5is = 0 for i = 1, 2, 3, 4, and hvj, v˜5is = 0 for j = α−1 1, 2, 3, 4, 6. For each such choice of v˜5, we have 2 = 2 u3 , [100100, 000000] , v3 , [000000, 000101], choices for u˜6. Next we form the matrix A whose i-th row is u4 [100010, 000000] , v4 [000000, 000011], 0 0 , , ui and (6 + j)-th row is vj, where i ∈ I, j ∈ J . We set the 0 0 u5 , [111111, 000000] , v5 , [000000, 000001], 6th row to be u˜6 and the 11th row to be v˜5. Then we form a matrix B = A and replace rows 6 and 11 by one of the u6 , [100000, 000000] , v6 , [000000, 111111]. (15) 8 possible pair of choices for u˜6 and v˜5, respectively. This 0 −1 Note that v5 and u6 do not correspond to either a logical Pauli yields the matrix F = A B and the symplectic solution 0 operator or a stabilizer element but were added to complete a F = F0F . Looping through all the 8 choices we obtain the symplectic basis. Hence we have I = {1, 2, 3, 4, 5}, J = solutions listed in the appendices of [51].

10 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Theorem 9: For an [[m, k]] stabilizer code, the number of γ(Z¯) denote the matrices whose rows are γ(X¯i) and γ(Z¯i), solutions for each logical Clifford operator is 2r(r+1)/2, respectively, for i = 1, . . . , k, where γ is the map defined ignoring stabilizer degrees of freedom (Remark 12), where in Section II-A. Similarly, let γ(S) denote the matrix whose r = m − k. rows are the images of the stabilizer generators under the 2m Proof: Let ui, vi ∈ F2 represent the logical Pauli map γ. Then, by stacking these matrices as in the proof of operators X¯i, Z¯i, for i = 1, . . . , k, respectively, i.e., γ(X¯i) = Theorem 9, we observe that Fn is a solution of the linear ui, γ(Z¯i) = vi, where γ is the map defined in Section II-A. system ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ Since XiZi = −ZiXi and XiZj = ZjXi for all j 6= i, it is γ(X¯) γ(X¯ 0) clear that hui, vjis = δij for i, j ∈ {1, . . . , k} and hence they γ(S) F = γ(S0) , 2m   n   form a partial symplectic basis for F2 . Let uk+1, . . . , um γ(Z¯) γ(Z¯0) represent the stabilizer generators, i.e., γ(Sj) = uk+j where ¯ 0 ¯0 the stabilizer group is S = hS1,...,Sri. Since by definition where X , Z are defined by the conjugation relations of g¯ ¯ † ¯ 0 ¯ † ¯0 X¯i, Z¯i commute with all stabilizer elements, it is clear that with the logical Paulis, i.e., g¯Xig¯ = Xi, g¯Zig¯ = Zi, and S0 hui, ujis = hvi, ujis = 0 for i ∈ {1, . . . , k}, j ∈ {k + denotes the stabilizer group of the code generated by a 1, . . . , m}. To complete the symplectic basis we find vectors different set of generators than that of S. Note, however, that S0 = S F vk+1, . . . , vm s.t. hui, vjis = δij ∀ i, j ∈ {1, . . . , m}. Now as a group . The goal is to find a different solution c 0 we note that for any logical Clifford operator, the conjugation that centralizes the stabilizer, i.e. we replace γ(S ) with γ(S) relations with logical Paulis yield 2k constraints, on ui, vi above. for i ∈ {1, . . . , k}, and the normalization condition on the We first find a matrix K ∈ GL(m − k, F2) such that Kγ(S0) = γ(S) S0 stabilizer yields r constraints, on uk+1, . . . , um. Hence we , which always exists since generators of have I¯ = φ, J¯ = {k + 1, . . . , m}, as per the notation in span S as well. Then we determine a symplectic solution H Theorem 7, and thus α = |I|¯ + |J¯ | = m − k = r. for the linear system     Corollary 10: For any logical k-qubit Clifford operation on γ(X¯) γ(X¯) an [[m, k]] stabilizer code, there always exists a physical γ(S) H = Kγ(S) , m-qubit Clifford circuit that normalizes the stabilizer and γ(Z¯) γ(Z¯) realizes the given operation. Effectively, this identifies the so that H satisfies Kγ(S) = γ(S)H while fixing γ(X¯) and surjection Cliff ∩ N (S) → Cliff k whose kernel is N UN 2 γ(Z¯). Then since K is invertible we can write all the physical Cliffords that normalize the stabilizer but    ¯     ¯ 0  realize only the logical identity (see the proof of Theorem 11 Ik γ(X) Ik γ(X ) 0 for a method to identify them). Here, N (S) denotes the  K  γ(S) Fn =  K  γ(S ) UN I γ(Z¯) I γ(Z¯0) normalizer of S in the group UN of all m-qubit unitary k k operations. γ(X¯) γ(X¯ 0) Note that, for each symplectic solution, there are multi- ⇒ γ(S) HFn =  γ(S)  . ple decompositions into elementary forms (from Table 1) γ(Z¯) γ(Z¯0) possible; one possibility is given in Theorem 1. Although Hence, F HF is a centralizing solution for g¯. Note each decomposition yields a different circuit, all of them c , n that there are 2r(r+1)/2 solutions for H, as per the result of will act identically on X and Z under conjugation (see N N Theorem 9 with the operator being the identity operator on Section II-C for notation). Once a logical Clifford operator is the logical qubits, and these produce all centralizing solutions defined by its conjugation with the logical Pauli operators, a for g¯. physical realization of the operator could either normalize the Although any normalizing solution can be converted into stabilizer or centralize it, i.e., fix each element of the stabi- a centralizing solution, the optimal solution with respect to lizer group under conjugation. We note here that any obtained a suitable metric need not always centralize the stabilizer. normalizing solution can be converted into a centralizing However, we can always setup the problem of identify- solution. While we do not have a well-motivated application ing a symplectic matrix, representing the physical circuit, for this result yet, we believe this might be useful in Pauli by constraining it to centralize the stabilizer. The general frame tracking [54] and adapting future logical operations to procedure to determine all symplectic solutions, and their the current signs. circuits, for a logical Clifford operator for a stabilizer code Theorem 11: For an [[m, k]] stabilizer code with stabilizer S, is summarized in Algorithm 3. For the [[6, 4, 2]] CSS code, each physical realization of a given logical Clifford operator we employed Algorithm 3 to determine the solutions listed that normalizes S can be converted into a circuit that central- in the appendices of [51] for each of the standard generating izes S while realizing the same logical operation. operators for the Clifford group (see Table 1). Proof: Let the symplectic solution for a specific logical The MATLAB® programs for all algorithms in this paper are Clifford operator g¯ ∈ CliffN that normalizes the stabi- available at https://github.com/nrenga/symplectic-arxiv18a. lizer S be denoted by Fn. Define the logical Pauli groups We executed our programs on a laptop running the Windows ¯ ¯ ¯ ¯ ¯ ¯ ¯ ® ™ X , hX1,..., Xki and Z , hZ1,..., Zki. Let γ(X) and 10 operating system (64-bit) with an Intel Core i7-5500U

VOLUME 4, 2016 11 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Z Algorithm 3 LCS Algorithm to determine all logical Clifford where g = Z1Z2Z3Z4, instead of just Z¯2 7→ Z¯1Z¯2 as the operators (see Section II for the homomorphisms γ, φ) above algorithm would typically require. 1: Determine the target logical operator g¯ by specifying In principle, the LCS algorithm can be easily modified to † its action on logical Paulis X¯i, Z¯i [16]: g¯X¯ig¯ = consider these possibilities, but this significantly increases ¯ 0 ¯ † ¯0 Xi, g¯Zig¯ = Zi . the computational complexity of the algorithm. A better un- 2: Transform the above relations into linear equations on derstanding of the structure of logical Clifford operators for a F ∈ Sp(2m, F2) using the map γ and the result of (10), given general stabilizer code, or even heuristics developed to ¯ ¯ 0 ¯ ¯0 i.e., γ(Xi)F = γ(Xi), γ(Zi)F = γ(Zi). Add the con- identify which degrees of freedom are worth considering for ditions for normalizing the stabilizer S, i.e., γ(S)F = a given code, would greatly improve the quality of solutions γ(S0). produced by the overall algorithm. 3: Calculate the feasible symplectic solution set F using Algorithm 2 by mapping X¯i, S, Z¯i to ui, vi as in The- IV. CONCLUSION orem 9. In this work we have used the binary symplectic group to 4: Factor each F ∈ F into a product of elementary propose a systematic algorithm for synthesizing physical symplectic transformations listed in Table 1, possibly (Clifford) implementations of logical Clifford operators for using the algorithm given in [64] (which is restated in any stabilizer code. This algorithm provides as solutions Theorem 1 here), and compute the physical Clifford all symplectic matrices corresponding to the desired logical operator g¯. operator, each of which is subsequently transformed into 5: Check for conjugation of g¯ with the stabilizer generators a circuit by decomposing it into elementary forms. This and for the conditions derived in step 1. If some signs decomposition is not unique, and in future work we will are incorrect, post-multiply by an element from HWN address optimization of the synthesis algorithm with respect as necessary to satisfy all these conditions (apply [65, to circuit complexity, error-resilience, and also other nuanced ⊥ Prop. 10.4] for S = hS, X¯i, Z¯ii, using γ). Since HWN metrics discussed in the introduction. For such optimization is the kernel of the map φ, post-multiplication does not to be feasible, one might have to explore opportunities for change F . identifying and exploring the algebraic structure hidden in 6: Express g¯ as a sequence of physical Clifford gates corre- the algorithm, since combinatorially the matrix inversion sponding to the elementary symplectic matrices obtained involved in Algorithm 2 could itself form a bottleneck. from the factorization in step 4 (see Appendix A for the . circuits for these matrices). APPENDIX A ELEMENTARY SYMPLECTIC TRANSFORMATIONS AND THEIR CIRCUITS In this section we verify that the physical operators listed @ 2.40GHz processor and 8GB RAM. For the [[6, 4, 2]] CSS in Table 1 are associated with the corresponding symplectic code, it takes about 0.5 seconds to generate all 8 symplectic transformation [64]. Furthermore, we also provide circuits solutions and their circuits for one logical Clifford operator. that realize these physical operators (also see [56]). For the [[5, 1, 3]] perfect code, it takes about 20 seconds to Since each physical operator in Table 1 is a unitary Clifford generate all 1024 solutions and their circuits. Note that for operator, it is enough to consider their actions on elements of step 5 in Algorithm 3, we use 1-qubit and 2-qubit unitary m the Heisenberg-Weyl group HWN , where N = 2 . Let ev matrices (from Cliff 2 ) to calculate conjugations for the Pauli 2 be a standard basis (column) vector in CN indexed by the operator on each qubit, at each circuit element at each depth, m vector v ∈ F2 such that it has entry 1 in position v and 0 and then combine the results to compute the conjugation of g¯ elsewhere. More precisely, if v = [v1, v2, . . . , vm] then ev = with a stabilizer generator or logical Pauli operator. Owing 1 0 e ⊗ e ⊗ · · · e , where e = |0i , e = |1i. to our naive implementation, we observe that most of the v1 v2 vm 0 , 0 1 , 1 time is consumed in computing Kronecker products and not Hence, we can simply write ev = |vi = |v1i ⊗ · · · ⊗ |vmi. in calculating the symplectic solutions. ⊗m 1) HN = H : The single-qubit Hadamard operator Remark 12: Observe that, in our LCS algorithm, we are 1 1  H √1 satisfies HXH† = Z,HZH† = not taking into account the degrees of freedom provided , 2 1 −1 by stabilizers. That is, if the logical operator g¯ is required X. Hence, the action of HN on a HWN element ¯ ¯ 0 to map Xi 7→ Xi, then an equivalent condition is to map D(a, b) is given by ¯ ¯ 0 Xi 7→ Xi · s, where s ∈ S is any stabilizer element for † † ¯ ¯0 HN D(a, b)HN = HN D(a, 0)D(0, b)HN (17) the given code. A similar statement is true for Zi 7→ Zi. † An explicit example for this scenario is the CNOT1→2 for = (HN D(a, 0)HN ) the [[4, 2, 2]] code with the logical Paulis defined instead as † (HN D(0, b)H ) (18) X¯ = X X , X¯ = X X , Z¯ = Z Z , Z¯ = Z Z . N 1 1 2 2 2 4 1 1 3 2 3 4 = D(0, a)D(b, 0) (19) The operation CNOT1→2 can simply be defined as swapping Z abT qubits 2 and 4, but this maps Z¯2 7→ Z2Z3 = Z¯1Z¯2 · g , = (−1) D(b, a) (20)

12 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

† abT ⇒ HN D(a, b)H = (−1) D ([a, b]Ω) . (21) and with a unitary operator tR that realizes the map N T e 7→ ıvRv e t The circuit for H is just H applied to each of the m v v. We now verify that conjugation by R N induces T . We calculate (t D(a, b)t† )e qubits. R R R v 2) GL(m, F2): Each non-singular m × m binary matrix −vRvT abT = ı tR(−1) D(0, b)D(a, 0)ev (31) Q is associated with a symplectic transformation AQ −vRvT abT (v+a)bT given by = ı (−1) tR(−1) ev+a (32) T T T T Q 0  = (−1)ab ı−vRv (−1)(v+a)b ı(v+a)R(v+a) e A = , (22) v+a Q 0 Q−T (33) −T T −1 −1 T abT aRaT vRaT +(v+a)bT where Q = (Q ) = (Q ) . The matrix Q = (−1) ı (−1) ev+a (34) is also associated with the unitary operator aQ which abT −aRaT (v+a)(b+aR)T = (−1) ı (−1) ev+a (35) realizes the mapping ev 7→ evQ. We verify this as abT −aRaT follows. Note that D(c, 0)ev = ev+c and D(0, d)ev = = (−1) ı D(0, b + aR)D(a, 0)ev (36) T (−1)vd e (a D(c, d)a† )e abT −aRaT a(b+aR)T v. We calculate Q Q v = (−1) ı (−1) D(a, b + aR)ev (37) = aQD(c, 0)D(0, d)evQ−1 (23) T T aRa cd = ı D ([a, b]TR) ev. (38) = aQ(−1) D(0, d)D(c, 0)evQ−1 (24) T −1 T cd (vQ +c)d abT = (−1) aQ(−1) evQ−1+c (25) Hence, for E(a, b) ı D(a, b), we have T T, cdT (v+cQ)Q−1dT t E(a, b)t† = ıab ıaRa D(a, b+aR) = E ([a, b]T ) = (−1) (−1) ev+cQ (26) R R R cdT −1 T as required. We derive the circuit for this unitary opera- = (−1) D(0, d(Q ) )D(cQ, 0)ev (27) tor by observing the action of TR on the standard basis −T 2m = D(cQ, dQ )ev (28) vectors [e1, 0],..., [em, 0], [0, e1],..., [0, em] of F2 , = D ([c, d]AQ) ev. (29) where i ∈ {1, . . . , m}, which captures the effect of tR on the (basis) elements X1,...,Xm, Z1,...,Zm Since the operator aQ realizes the map ev = |vi 7→ of HWN , respectively, under conjugation. |vQi, the circuit for the operator is equivalent to the binary circuit that realizes v 7→ vQ. Evidently, this Assume as the first special case that R has non-zero elementary transformation encompasses CNOT opera- entries only in its (main) diagonal. If Rii = 1 then tions and qubit permutations. For the latter, Q will be a we have [ei, 0]TR = [ei, ei]. This indicates that tR maps Xi 7→ XiZi ≈ Yi. Since we know that the permutation matrix. Note that if aQ preserves the code space of a CSS code then the respective permutation phase gate Pi on the i-th qubit performs exactly this must be in the automorphism group of the constituent map under conjugation, we conclude that the circuit classical code. This is the special case that is discussed for tR involves Pi. We proceed similarly for every in detail by Grassl and Roetteler in [25]. i ∈ {1, . . . , m} such that Rii = 1. For a general Q, one can use the LU decomposition Now consider the case where Rij = Rji = 1 (since R is symmetric). Then we have over F2 to obtain PπQ = LU, where Pπ is a per- mutation matrix, L is lower triangular and U is upper [ei, 0]TR = [ei, ej], [ej, 0]TR = [ej, ei]. (39) triangular. Note that Lii = Uii = 1 ∀ i ∈ {1, . . . , m}. T Then the circuit for Q first involves the permutation Pπ This indicates that tR maps Xi 7→ XiZj and Xj 7→ −1 (or π ), then CNOTs for L with control qubits in the ZiXj. Since we know that the controlled-Z gate CZij order 1, 2, . . . , m and then CNOTs for U with control on qubits (i, j) performs exactly this map under con- qubits in reverse order m, m − 1,..., 1. The order is jugation, we conclude that the circuit for tR involves important because an entry Lji = 1 implies a CNOT CZij. We proceed similarly for every pair (i, j) such gate with qubit j controlling qubit i (with j > i), i.e, that Rij = Rji = 1. CNOTj→i, and similarly Lkj = 1 implies the gate Finally, we note that the symplectic transformation CNOT (with k > j). Since the gate CNOT k→j j→i associated with the operator HN tRHN is Ω TR Ω = requires the value of qubit j before it is altered by I 0  m . CNOTk→j, it needs to be implemented first. A similar RIm reasoning applies to the reverse order of control qubits 4) gt = H2t ⊗ I2m−t : Since H2t is the t-fold Kronecker for U. product of H and since D(a, b) = Xa1 Zb1 ⊗ · · · ⊗  T  vRv am bm † 3) tR = diag ı : Each symmetric matrix R ∈ X Z , we have gtD(a, b)gt m×m is associated with a symplectic transformation F2 = Za1 Xb1 ⊗ · · · ⊗ Zat Xbt  TR given by at+1 bt+1 am bm    ⊗ X Z ⊗ · · · ⊗ X Z (40) Im R TR = , (30) a1b1 b1 a1 atbt bt at  0 Im = (−1) X Z ⊗ · · · ⊗ (−1) X Z

VOLUME 4, 2016 13 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

 0  at+1 bt+1 am bm  I 0 R E ⊗ X Z ⊗ · · · ⊗ X Z . (41) = k k . 0 0 0 Im−k ˆ¯ We write (a, b) = (ˆaa,¯ bb), where aˆ , a1 ··· at, a¯ , ˆ ¯ Now we observe that we can apply row operations to this at+1 ··· am, b , b1 ··· bt, b , bt+1 ··· bm. Then 0 −1 matrix and transform E to 0. We left multiply by Q13 , † aˆˆbT  0  g D(ˆaa,¯ ˆb¯b)g = (−1) D(ˆba,¯ aˆ¯b) (42) Ik E t t : aˆˆbT  ˆ¯  0 Im−k = (−1) D [ˆaa,¯ bb]Gt , (43)  −1     −1 −1 −1 −1 −1 −1  Q2 0 0 0 It 0 Q13 Q12 Q11 AQ13 Q12 Q11 B T 0 Q2  0 Im−t 0 0  where Gt =   . (44)  I 0 R 0  It 0 0 0  = k k . 0 0 0 I 0 0 0 Im−t m−k     R 0 It 0 0 0 R k Defining Ut , ,Lm−t , , we Since the matrix 2 , is symmetric, we apply the 0 0 0 Im−t 0 0   elementary transformation T from the right to obtain Lm−t Ut R2 then write Gt = . Similar to part 1   Ut Lm−t Ik 0 Rk 0 above, the circuit for gt is simply H applied to each of   Ik 0 Rk 0  0 Im−k 0 0  the first t qubits. Although this is a special case where   0 0 0 Im−k  0 0 Ik 0  the Hadamard operator was applied to consecutive 0 0 0 Im−k qubits, we note that the symplectic transformation for  I 0 0 0  Hadamards applied to arbitrary non-consecutive qubits = k . 0 0 0 I can be derived in a similar fashion. m−k Hence, we have demonstrated the elementary symplectic Finally, we apply the elementary transformation GkΩ =  U L  transformations in Sp(2m, F2) that are associated with arbi- k m−k to obtain trary Hadamard, Phase, Controlled-Z and Controlled-NOT Lm−k Uk gates. Since we know that these gates, along with HWN ,   Ik 0 0 0 generate the full Clifford group [16], these elementary sym-   Ik 0 0 0  0 0 0 Im−k  plectic transformations form a universal set corresponding to   0 0 0 Im−k  0 0 Ik 0  physical operators in the Clifford group. 0 Im−k 0 0   APPENDIX B PROOF OF THEOREM 1 Ik 0 0 0     = = Im 0 . AB T 0 I 0 0 Let F = so that AB Ω AB = 0 and m−k CD Hence we have transformed F to the form Ω TR Ω =    T T   1 CD Ω CD = 0 since F ΩF = Ω. We will Im 0 −1 −1 −1 −1 , i.e., if we define Q1 , Q13 Q12 Q11 then we perform a sequence of row and column operations to trans- R1 Im form F into the form Ω TR1 Ω for some symmetric R1. If have −1 rank(A) = k then there exists a row transformation Q11 −1 −1 −1 −1 −1 A FA TR2 GkΩ = Ω TR1 Ω. and a column transformation Q such that Q AQ = Q1 Q2   2 11 2 Ik 0 −1 −1 . Using the notation for elementary symplectic trans- Rearranging terms and noting that A = AQ−1 , Ω = 0 0 Q Ω,G−1 = G ,T −1 = T we obtain F = −1 k k R2 R2 formations discussed above, we apply Q11 and AQ−1 to 2 AQ Ω TR GkTR AQ . AB and obtain 1 1 2 2  −1   0  APPENDIX C MATLAB® CODE FOR ALGORITHM 2  −1 −1  Q2 0 Ik 0 Rk E Q11 AQ11 B T = 0 Q2 0 0 EBm−k function F_all = find_all_symp_mat(U,V,I,J)  0 0 , A B , I = I(:)’; where Bm−k is an (m − k) × (m − k) matrix. Since the J = J(:)’; above result is again the top half of a symplectic matrix, Ibar = setdiff(1:m,I); T we have A0 B0 Ω A0 B0 = 0 which implies R Jbar = setdiff(1:m,J); k alpha = length(Ibar) + length(Jbar); is symmetric, E = 0 and hence rank(B ) = m − k. m−k tot = 2^(alpha*(alpha+1)/2); Therefore we determine an invertible matrix Qm−k which F_all = cell(tot,1); transforms B to I under row operations. Then we m−k m−k −1 Ik 0 % Find one solution using symplectic apply Q12 , : transvections(Algorithm 1) 0 Qm−k F0 = find_symp_mat(U([I, m+J], :), V);  −1   −1 −1 −1 −1  Q2 0 Q12 Q11 AQ12 Q11 B T A = mod(U F0, 2); 0 Q2 *

14 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

Ainv = gf2matinv(A); + (1:(alpha-(i-1)))),’left-msb’) + IbJb = union(Ibar,Jbar); 1; Basis = A([IbJb, m+IbJb],:);% these rows Innprods = mod(Choices{i,1} * span the subspaceW^{\perp} in Theorem7 fftshift(W,2)’, 2); Subspace = % Impose symplectic inner product of mod(de2bi((0:2^(2*length(IbJb))-1)’, 0 with chosen free vectors 2*length(IbJb)) * Basis, 2); h = zeros(1,alpha); % Handle case when Basis containsa % Collect indices of free vectors in the symplectic pair of free vectors top and bottom halves of Basis if (i > length(Ibar)) % Note: these are now row indices of Basis, h(Basis_free == Basis_free(i) - not row indices ofA!! length(IbJb)) = 1; [~, Basis_fixed_I, ~] = intersect(IbJb,I); end % intersect(IbJb,I)= intersect(I,Jbar) % Check the necessary and sufficient [~, Basis_fixed_J, ~] = intersect(IbJb,J); conditions on the symplectic inner % intersect(IbJb,J)= intersect(Ibar,J) products Basis_fixed = [Basis_fixed_I, length(IbJb) Ch_i = Choices{i,1}(bi2de(Innprods) + Basis_fixed_J]; == bi2de(h), :); Basis_free = setdiff(1:2*length(IbJb), W(i,:) = Ch_i(vi_ind,:);% use the Basis_fixed); vi_ind-th valid choice for the i-th free vector Choices = cell(alpha,1); end Bl([Ibar, m+Jbar], :) = W;% replace % Calculate all choices for each free rows of free vectors with current vector using just conditions imposed choices % by the fixed vectors in Basis(or F = mod(Ainv * Bl, 2);% this is the equivalently inA) matrixF’ in Theorem7 for i = 1:alpha F_all{l+1,1} = mod(F0 * F, 2); ind = Basis_free(i); end h = zeros(1,length(Basis_fixed)); % Impose symplectic inner product of1 end with the"fixed" symplectic pair if (i <= length(Ibar)) h(Basis_fixed == length(IbJb) + ind) = 1; ACKNOWLEDGMENT else We would like to thank Jungsang Kim for pointing us to the h(Basis_fixed == ind - length(IbJb)) work of Chao and Reichardt, and Jianfeng Lu for helpful = 1; discussions regarding Theorem 7. We are also very thank- end % Check the necessary conditions on the ful to the anonymous reviewers (including at conferences symplectic inner products where this work was presented as a poster) who provided Innpdts = mod(Subspace * helpful feedback to improve the presentation and keep the fftshift(Basis(Basis_fixed,:), 2)’, paper as self-contained as possible. In particular, we would 2); like to thank one reviewer who pointed out the example in Choices{i,1} = Subspace(bi2de(Innpdts) == bi2de(h), :); Remark 12 and suggested us to specifically mention that we end are ignoring the stabilizer degrees of freedom. We would also like to thank Jean-Pierre Tillich for highlighting that % First free vector has 2^(alpha) choices, the proof of Theorem 7 is incomplete without the counting second has 2^(alpha-1) choices and so on argument. S. Kadhe would like to thank Robert Calderbank for l = 0:(tot - 1) Bl = A; for his hospitality during S. Kadhe’s visit to Duke University. W = zeros(alpha,2*m);% Rows are choices made for free vectors References %W(i,:) corresponds to [1] N. Rengaswamy, R. Calderbank, S. Kadhe, and H. D. Pfister, “Synthesis Basis(Basis_free(i),:) of logical Clifford operators via symplectic geometry,” in Proc. IEEE Int. lbin = Symp. Inform. Theory. IEEE, 2018, pp. 791–795. [Online]. Available: de2bi(l,alpha*(alpha+1)/2,’left-msb’); http://arxiv.org/abs/1803.06987 v1_ind = [2] P. W. Shor, “Scheme for reducing decoherence in quantum computer bi2de(lbin(1,1:alpha),’left-msb’) + 1; memory,” Phys. Rev. A, vol. 52, no. 4, pp. R2493–R2496, 1995. W(1,:) = Choices{1,1}(v1_ind,:); [3] A. R. Calderbank and P. W. Shor, “Good quantum error-correcting codes for i = 2:alpha exist,” Phys. Rev. A, vol. 54, pp. 1098–1105, Aug 1996. % vi_ind loops through the [4] A. M. Steane, “Simple quantum error-correcting codes,” Phys. Rev. A, vol. 54, no. 6, pp. 4741–4751, 1996. 2^(alpha-(i-1)) valid choices for [5] R. Calderbank, E. Rains, P. Shor, and N. Sloane, “Quantum error thei-th free vector correction via codes over GF(4),” IEEE Trans. Inform. Theory, vi_ind = vol. 44, no. 4, pp. 1369–1387, Jul 1998. [Online]. Available: https: bi2de(lbin(1,sum(alpha:-1:alpha-(i-2)) //.org/abs/quant-ph/9608006

VOLUME 4, 2016 15 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

[6] D. Gottesman, “Stabilizer codes and quantum error correction,” Ph.D. [28] T. Can, N. Rengaswamy, R. Calderbank, and H. D. Pfister, “Kerdock dissertation, California Institute of Technology, 1997. [Online]. Available: Codes Determine Unitary 2-Designs,” Accepted to IEEE Trans. Inf. https://arxiv.org/abs/quant-ph/9705052 Theory, arXiv preprint arXiv:1904.07842, 2019, [Online]. Available: [7] D. Bacon, “Operator quantum error-correcting subsystems for self- http://arxiv.org/abs/1904.07842. correcting quantum memories,” Phys. Rev. A, vol. 73, no. 012340, 2006. [29] J. Combes, C. Granade, C. Ferrie, and S. T. Flammia, “Logical [Online]. Available: https://arxiv.org/abs/quant-ph/0506023 Randomized Benchmarking,” arXiv preprint arXiv:1702.03688, 2017. [8] T. J. Yoder, “Universal fault-tolerant quantum computation with Bacon- [Online]. Available: http://arxiv.org/abs/1702.03688 Shor codes,” arXiv preprint arXiv:1705.01686, 2017. [Online]. Available: [30] E. Magesan, J. M. Gambetta, and J. Emerson, “Characterizing quantum https://arxiv.org/pdf/1705.01686 gates via randomized benchmarking,” Phys. Rev. A, vol. 85, no. 4, [9] D. Gottesman and I. L. Chuang, “Demonstrating the viability of universal p. 042311, 2012. [Online]. Available: https://link.aps.org/doi/10.1103/ quantum computation using teleportation and single-qubit operations,” PhysRevA.85.042311 Nature, vol. 402, no. 6760, pp. 390–393, 1999. [Online]. Available: [31] P. Murali, J. M. Baker, A. J. Abhari, F. T. Chong, and M. Martonosi, http://www.nature.com/articles/46503 “Noise-Adaptive Compiler Mappings for Noisy Intermediate-Scale [10] S. Bravyi and J. Haah, “Magic-state distillation with low overhead,” Quantum Computers,” in Proc. Twenty-Fourth Int. Conf. Archit. Support Phys. Rev. A, vol. 86, no. 5, p. 052329, 2012. [Online]. Available: Program. Lang. Oper. Syst. ACM, 2019, pp. 1015–1029. [Online]. http://arxiv.org/abs/1209.2426 Available: http://arxiv.org/abs/1901.11054 [11] S. Bravyi and A. Kitaev, “Universal quantum computation with ideal [32] J. Preskill, “ in the NISQ era and beyond,” Clifford gates and noisy ancillas,” Phys. Rev. A, vol. 71, no. 2, p. 022316, arXiv preprint arXiv:1801.00862, 2018. [Online]. Available: https: 2005. [Online]. Available: https://arxiv.org/abs/quant-ph/0403025 //arxiv.org/abs/1801.00862 [12] M. M. Wilde, “Logical operators of quantum codes,” Phys. Rev. [33] A. Paler, “On the Influence of Initial Qubit Placement During A, vol. 79, no. 6, p. 062322, 2009. [Online]. Available: https: NISQ Circuit Compilation,” in Quantum Technology and Optimization //arxiv.org/abs/0903.5256 Problems, S. Feld and C. Linnhoff-Popien, Eds., 2019, pp. 207–217. [13] T. Brun, I. Devetak, and M.-H. Hsieh, “Correcting quantum errors with [Online]. Available: http://arxiv.org/abs/1811.08985 entanglement,” Science, vol. 314, no. 5798, pp. 436–439, 2006. [Online]. [34] Y. Shi, N. Leung, P. Gokhale, Z. Rossi, D. I. Schuster, H. Hoffmann, Available: http://science.sciencemag.org/content/314/5798/436 and F. T. Chong, “Optimized Compilation of Aggregated Instructions for [14] T. A. Brun, I. Devetak, and M.-H. Hsieh, “Catalytic quantum error Realistic Quantum Computers,” in Proc. Twenty-Fourth Int. Conf. Archit. correction,” IEEE Trans. Inform. Theory, vol. 60, no. 6, pp. 3073–3089, Support Program. Lang. Oper. Syst. - ASPLOS ’19, 2019, pp. 1031–1044. 2014. [Online]. Available: https://arxiv.org/abs/quant-ph/0608027 [Online]. Available: http://arxiv.org/abs/1902.01474 [15] A. R. Calderbank, E. M. Rains, P. W. Shor, and N. J. A. Sloane, [35] P. Murali, A. Javadi-Abhari, F. T. Chong, and M. Martonosi, “Formal “Quantum Error Correction and Orthogonal Geometry,” Phys. Rev. constraint-based compilation for noisy intermediate-scale quantum Lett., vol. 78, no. 3, pp. 405–408, 1997. [Online]. Available: https: systems,” Microprocess. Microsyst., vol. 66, pp. 102–112, 2019. [Online]. //arxiv.org/abs/quant-ph/9605005 Available: http://arxiv.org/abs/1903.03276 [16] D. Gottesman, “An Introduction to Quantum Error Correction and [36] B. Nash, V. Gheorghiu, and M. Mosca, “ optimizations Fault-Tolerant Quantum Computation,” arXiv preprint arXiv:0904.2557, for NISQ architectures,” Quantum Sci. Technol., vol. 5, no. 2, p. 025010, 2009. [Online]. Available: http://arxiv.org/abs/0904.2557 2020. [Online]. Available: http://arxiv.org/abs/1904.01972 [17] D. Litinski, “A game of surface codes: Large-scale quantum computing [37] R. Harper and S. T. Flammia, “Fault-Tolerant Logical Gates in the IBM with lattice surgery,” Quantum, vol. 3, p. 128, Mar 2019. [Online]. Quantum Experience,” Phys. Rev. Lett., vol. 122, no. 8, p. 080504, 2019. Available: http://arxiv.org/abs/1808.02892 [Online]. Available: https://arxiv.org/abs/1806.02359 [18] V. Kliuchnikov, D. Maslov, and M. Mosca, “Asymptotically Optimal [38] N. M. Linke, M. Gutierrez, K. A. Landsman, C. Figgatt, S. Debnath, Approximation of Single Qubit Unitaries by Clifford and T Circuits Using K. R. Brown, and C. Monroe, “Fault-tolerant quantum error detection,” a Constant Number of Ancillary Qubits,” Phys. Rev. Lett., vol. 110, no. 19, Sci. Adv., vol. 3, no. 10, p. e1701074, Oct. 2017. [Online]. Available: p. 190502, May 2013. https://arxiv.org/abs/1611.06946 [19] M. Amy, D. Maslov, M. Mosca, and M. Roetteler, “A Meet-in-the-Middle [39] R. Ozeri, “The trapped-ion qubit tool box,” Contemp. Phys., vol. 52, no. 6, Algorithm for Fast Synthesis of Depth-Optimal Quantum Circuits,” IEEE pp. 531–550, 2011. [Online]. Available: http://arxiv.org/abs/1106.1190 Trans. Comput. Des. Integr. Circuits Syst., vol. 32, no. 6, pp. 818–830, Jun [40] Y. Nam, J.-S. Chen, N. C. Pisenti, K. Wright, C. Delaney, D. Maslov, 2013. K. R. Brown, S. Allen, J. M. Amini, J. Apisdorf, K. M. Beck, A. Blinov, [20] D. Maslov and M. Roetteler, “Shorter Stabilizer Circuits via Bruhat De- V. Chaplin, M. Chmielewski, C. Collins, S. Debnath, K. M. Hudek, composition and Quantum Circuit Transformations,” IEEE Trans. Inform. A. M. Ducore, M. Keesan, S. M. Kreikemeier, J. Mizrahi, P. Solomon, Theory, vol. 64, no. 7, pp. 4729–4738, 2018. M. Williams, J. D. Wong-Campos, D. Moehring, C. Monroe, and J. Kim, [21] A. Fagan and R. Duncan, “Optimising Clifford Circuits with “Ground-state energy estimation of the water molecule on a trapped-ion Quantomatic,” . Proc. Theor. Comput. Sci., vol. 287, pp. quantum computer,” npj Quantum Inf., vol. 6, no. 1, p. 33, 2020. [Online]. 85–105, 2019. [Online]. Available: http://arxiv.org/abs/1901.10114 Available: http://arxiv.org/abs/1902.10171 [22] R. Iten, O. Reardon-Smith, L. Mondada, E. Redmond, R. S. Kohli, [41] N. M. Linke, D. Maslov, M. Roetteler, S. Debnath, C. Figgatt, K. A. and R. Colbeck, “Introduction to UniversalQCompiler,” arXiv preprint Landsman, K. Wright, and C. Monroe, “Experimental comparison of two arXiv:1904.01072, 2019. [Online]. Available: http://arxiv.org/abs/1904. quantum computing architectures,” Proceedings of the National Academy 01072 of Sciences, vol. 114, no. 13, pp. 3305–3310, 2017. [Online]. Available: [23] R. Duncan, A. Kissinger, S. Pedrix, and J. van de Wetering, https://www.pnas.org/content/114/13/3305/ “Graph-theoretic Simplification of Quantum Circuits with the ZX- [42] J. Haah, M. B. Hastings, D. Poulin, and D. Wecker, “Magic calculus,” Quantum, vol. 4, p. 279, 2020. [Online]. Available: http: state distillation with low space overhead and optimal asymptotic //arxiv.org/abs/1902.03178 input count,” Quantum, vol. 1, p. 31, 2017. [Online]. Available: [24] A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, http://arxiv.org/abs/1703.07847 “Surface codes: Towards practical large-scale quantum computation,” [43] J. Haah and M. B. Hastings, “Codes and Protocols for Distilling $T$, Phys. Rev. A, vol. 86, no. 3, p. 032324, 2012. [Online]. Available: controlled-$S$, and Toffoli Gates,” Quantum, vol. 2, p. 71, 2017. [Online]. http://arxiv.org/abs/1208.0928 Available: https://arxiv.org/abs/1709.02832 [25] M. Grassl and M. Roetteler, “Leveraging automorphisms of quantum [44] C. Gidney and A. G. Fowler, “Efficient magic state factories with a codes for fault-tolerant quantum computation,” in Proc. IEEE Int. Symp. catalyzed |CCZ> to 2|T> transformation,” Quantum, vol. 3, p. 135, 2018. Inform. Theory. IEEE, Jul 2013, pp. 534–538. [Online]. Available: http://arxiv.org/abs/1812.01238 [26] A. Kubica and M. E. Beverland, “Universal transversal gates with color [45] B. Zeng, A. Cross, and I. L. Chuang, “Transversality Versus Universality codes: A simplified approach,” Phys. Rev. A, vol. 91, no. 3, p. 032330, for Additive Quantum Codes,” IEEE Trans. Inform. Theory, vol. 57, no. 9, 2015. [Online]. Available: https://arxiv.org/abs/1410.0069 pp. 6272–6284, 2011. [Online]. Available: https://arxiv.org/abs/0706.1382 [27] R. Chao and B. W. Reichardt, “Fault-tolerant quantum computation with [46] B. Eastin and E. Knill, “Restrictions on Transversal Encoded Quantum few qubits,” npj Quantum Inf., vol. 4, no. 1, p. 42, 2018. [Online]. Gate Sets,” Phys. Rev. Lett., vol. 102, no. 11, p. 110502, 2009. [Online]. Available: https://arxiv.org/abs/1705.05365 Available: http://arxiv.org/abs/0811.4262

16 VOLUME 4, 2016 N. Rengaswamy et al.: Logical Clifford Synthesis for Stabilizer Codes

[47] M. Newman and Y. Shi, “Limitations on Transversal Computation [56] J. Dehaene and B. De Moor, “Clifford group, stabilizer states, and linear through Quantum Homomorphic Encryption,” Quantum Inf. Comput., and quadratic operations over GF(2),” Phys. Rev. A, vol. 68, no. 4, p. vol. 18, no. 11&12, pp. 0927–0948, Apr. 2018. [Online]. Available: 042318, Oct 2003. http://arxiv.org/abs/1704.07798 [57] Z. Webb, “The Clifford group forms a unitary 3-design,” Quantum Inf. [48] S. Bravyi, D. Gosset, and R. König, “Quantum advantage with shallow Comput., vol. 16, no. 15-16, pp. 1379—-1400, 2016, [Online]. Available: circuits.” Science, vol. 362, no. 6412, pp. 308–311, 2018. [Online]. https://arxiv.org/pdf/1510.02769.pdf. Available: http://www.ncbi.nlm.nih.gov/pubmed/30337404 [58] P. Diaconis and M. Shahshahani, “The subgroup algorithm for generating [49] S. Bravyi, D. Gosset, R. Koenig, and M. Tomamichel, “Quantum uniform random variables,” Prob. Eng. Inf. Sci., vol. 1, no. 1, pp. 15–32, advantage with noisy shallow circuits,” Nat. Phys., 2020. [Online]. 1987. Available: http://arxiv.org/abs/1904.01502 [59] R. Koenig and J. A. Smolin, “How to efficiently select an arbitrary Clifford [50] D. Gottesman, “Theory of fault-tolerant quantum computation,” Phys. group element,” J. Math. Phys., vol. 55, no. 12, p. 122202, Dec 2014. Rev. A, vol. 57, no. 1, pp. 127–137, Jan 1998. [Online]. Available: [60] P. W. Jones, A. Osipov, and V. Rokhlin, “A randomized approximate https://arxiv.org/abs/quant-ph/9702029 nearest neighbors algorithm,” Appl. Comput. Harmon. Anal., vol. 34, no. 3, [51] N. Rengaswamy, R. Calderbank, S. Kadhe, and H. D. Pfister, pp. 415–444, 2013. “Synthesis of Logical Clifford Operators via Symplectic Geometry,” [61] K. Choromanski, F. Fagan, C. Gouy-Pailler, A. Morvan, T. Sarlos, and arXiv preprint arXiv:1803.06987, 2018. [Online]. Available: http: J. Atif, “TripleSpin - a generic compact paradigm for fast machine learning //arxiv.org/abs/1803.06987v1 computations,” arXiv preprint arXiv:1605.09046, 2016, [Online]. Avail- [52] N. Rengaswamy, R. Calderbank, and H. D. Pfister, “Unifying the Clifford able: http://arxiv.org/abs/1605.09046. hierarchy via symmetric matrices over rings,” Phys. Rev. A, vol. 100, no. 2, [62] N. Rengaswamy, R. Calderbank, M. Newman, and H. D. Pfister, “On p. 022304, 2019. [Online]. Available: http://arxiv.org/abs/1902.04022 optimality of CSS codes for transversal T ,” IEEE J. Sel. Areas in Inf. [53] A. Ekert and C. Macchiavello, “Quantum Error Correction for Communi- Theory, 2019. [Online]. Available: http://arxiv.org/abs/1910.09333 cation,” Phys. Rev. Lett., vol. 77, no. 12, pp. 2585–2588, Sep 1996. [63] A. Salam, E. Al-Aidarous, and A. E. Farouk, “Optimal symplectic House- [54] C. Chamberland, P. Iyer, and D. Poulin, “Fault-tolerant quantum holder transformations for SR decomposition,” Lin. Algebra and its Appl., computing in the Pauli or Clifford frame with slow error diagnostics,” vol. 429, pp. 1334–1353, 2008. Quantum, vol. 2, p. 43, 2018. [Online]. Available: https://arxiv.org/abs/ [64] T. Can, “An Algorithm to Generate a Unitary Transformation from Log- 1704.06662 arithmically Many Random Bits,” 2017, Research Independent Study, [55] T. Can, “The Heisenberg-Weyl group, finite symplectic geometry, and Preprint. their applications,” Senior Thesis, Duke University, May 2018. [65] M. A. Nielsen and I. L. Chuang, Quantum Computation and . Cambridge University Press, 2010.

VOLUME 4, 2016 17