IEEE Transactions on Quantum Software uantumEngineering

Received March 24, 2020; revised July 29, 2020; accepted August 31, 2020; date of publication September 11, 2020; date of current version October 5, 2020.

Digital Object Identifier 10.1109/TQE.2020.3023419

Logical Clifford Synthesis for Stabilizer Codes

NARAYANAN RENGASWAMY1 (Student Member, IEEE), ROBERT CALDERBANK1 (Fellow, IEEE), SWANAND KADHE2 (Member, IEEE), AND HENRY D. PFISTER1 (Senior Member, IEEE) 1 Department of Electrical and Computer Engineering, Duke University, Durham, NC 27708 USA 2 Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, CA 94720 USA Corresponding author: Narayanan Rengaswamy (e-mail: [email protected]). Part of this work was presented at the 2018 IEEE International Symposium on Information Theory [1]. This work was supported by the National Science Foundation under Grants 1718494, 1908730, and 1910571.

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. In this article, 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 effciently 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 physi- cal 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 article, 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 The Clifford hierarchy of unitary operators was defned It is expected that universal fault-tolerant quantum com- to help demonstrate that universal quantum computation can putation will be achieved by employing Quantum Error- be realized via the teleportation protocol [9]. The frst level Correcting Codes (QECCs) to protect the information stored C(1) in the hierarchy is the Pauli group of unitary operators, in the quantum computer and to enable error-resilient com- and subsequent levels C(),≥ 2, are defned recursively as putation on that data. The frst QECC was discovered by those unitary operators that map the Pauli group into C(−1), Shor [2], and subsequently, a systematic framework was de- under conjugation. By this defnition, the second level is veloped by Calderbank, Shor and Steane [3], [4] to translate the normalizer of the Pauli group in the unitary group, and (pairs of) classical error-correcting codes into QECCs. Codes hence C(2) is the Clifford group [5]. It is well-known that produced using this framework are referred to as CSS codes. the levels C() do not form a group for  ≥ 3, but that the The general class of stabilizer codes includes CSS codes Clifford group along with any unitary in C(3) can be used to as a special case and was introduced by Calderbank, Rains, approximate an arbitrary unitary operator up to any desired Shor and Sloane [5], and by Gottesman [6]. These codes, precision. (Note that using a simple inductive argument it can and their variations [7], [8], still remain the preferred class be proven that each level in the hierarchy is closed under of codes for realizing error-resilient quantum computation in multiplication by Clifford group elements.) Therefore, the practice. standard strategy for realizing universal computation with

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see http://creativecommons.org/licenses/by/4.0/ VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

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

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

In light of such applications, our software currently allows one to determine only one physical realization in cases where the number of solutions is prohibitively large, specifcally for QECCs with large-dimension stabilizers (r = m − k  1). However, this single solution does not come with any explicit guarantees regarding depth or number of two-qubit gates or avoiding certain physical qubits. Therefore, even devel-

FIGURE 1. Two physical circuits that realize the CZ gate on the two oping heuristics to directly optimize for a “good enough” logical qubits of the [[4, 2, 2]] code. solution, instead of assembling all solutions and searching over them, will have a signifcant impact on the effciency of compilers. on the two logical qubits are shown in Fig. 1. The logi- cal Pauli operators in this case are X¯1 = X1X2, X¯2 = X1X3, B. QECCS FOR UNIVERSAL QUANTUM COMPUTATION Z¯1 = Z2Z4, Z¯2 = Z3Z4. Assuming that single-qubit gates do not contribute to com- Physical single-qubit rotation gates on trapped-ion qubits plexity (or diffculty of implementation), we observe that are natural, reliable and have a long history [39]. Re- both choices have the same number of two-qubit gates and cently, it has also been observed that small-angle Mølmer- θ = θ · − θ · depth. More interestingly, we see that the second choice Sørensen gates, i.e., XXij( ) cos 2 I4 ı sin 2 XiXj for θ completely avoids the frst physical qubit while realizing the small , are more reliable than the maximally-entangling XX π same logical CZ operation. Therefore, if either the frst qubit ij( 2 ) gate [40]. Since these are the primitive operations itself has poor fdelity or coupling to it does, then clearly the in trapped-ion systems [41], codes that support a transversal T = , ıπ second choice is more appropriate. Preliminary experiments diag(1 exp( 4 )) gate, such as the tri-orthogonal codes on the IBM system confrm this advantage when qubits are mentioned earlier, could be directly used for computation mapped appropriately. Note that even if we use a QECC that rather than being dedicated for expensive magic state distil- protects a single qubit but has a transversal CZ implemen- lation [10], [42]–[44]. However, it is well-known that there tation, i.e., the logical CZ is a CZ between corresponding exists no single QECC that supports a universal set of gates physical qubits in two separate code blocks, this incurs a where all of them have a transversal implementation at the larger overhead than the above scheme. We identifed this ex- logical level [45]–[47]. Therefore, there is a natural tradeoff ample by using our open-source implementation of our LCS between exploiting transversality for logical non-Clifford op- algorithm, which is available on github.3 In order to identify erations versus Clifford operations. (or construct) more interesting codes that exhibit a “rich” Indeed, this will be a realistic alternative only if the logical set of choices for each logical operator, one needs a better Clifford operations on these codes are “error-resilient”, by understanding of the geometry of the space of symplectic so- which we mean that for at least constant-depth circuits, the lutions. We believe this is an important open problem arising most likely errors remain correctable and do not propagate from this article. catastrophically through the Clifford sections of these logical For near-term Noisy Intermediate-Scale Quantum (NISQ) circuits. For this purpose, our LCS algorithm can be a sup- [32] era of quantum computers, a lot of current research portive tool to investigate properties of stabilizer QECCs that is focused on equipping compilers with routines that opti- guarantee error-resilience of their logical Clifford operators. mize circuits for depth and two-qubit gates, and the map- Note that constant-depth circuits have been shown to provide ping of qubits from the algorithm to the hardware, while all a quantum advantage over classical computation [48]. In fact, taking into account the specifc characteristics and noise in it has been shown that the advantage persists even if those the hardware [31], [33]–[36]. Although employing QECCs circuits are noisy [49], and the proof involves a QECC which is considered to be beyond the NISQ regime, exploiting admits constant-depth logical Cliffords. simple codes, such as the [[4, 2, 2]] code and using post- selection provides increased reliability than uncoded com- C. ORGANIZATION putation (as Harper and Flammia have demonstrated [37], The rest of this article is organized as follows. Section II [38]). Therefore, our effcient LCS algorithm might fnd an discusses the connection between quantum computation and application in such quantum compilers, where the utility is to the binary symplectic group, which forms the foundation for determine the best physical realization of a logical operator this article. Section III begins by outlining the process of with respect to current system characteristics. Specifcally, fnding logical Clifford gates through a demonstration for , , this allows dynamic compilation (i.e., during program ex- the [[6 4 2]] CSS code [27], [50]. Then the general case of ecution) that could provide signifcant reliability gains in stabilizer codes is discussed rigorously via four theorems practice. and our LCS algorithm. Finally, Section IV concludes this article. Appendix B discusses the proof of Theorem 1, and Appendix C provides the source code for Algorithm 2 with 3[Online]. Available: https://github.com/nrenga/symplectic-arxiv18a extensive comments.

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

2 II. PHYSICAL AND LOGICAL OPERATORS κ ∈ Z4  {0, 1, 2, 3}. The order is |HWN|=4N and the Quantum error-correcting codes (QECCs) protect qubits in- center of this group is ıIN={IN, ıIN, −IN, −ıIN}, where IN volved in quantum computation. In this section, we sum- is the N × N identity matrix. Since XZ =−ZX marize the mathematical framework introduced in [3], [5],   abT +baT   [6], and [50] and described in more detail in [16] and [51]. D(a, b)D(a , b ) = (−1) D(a , b )D(a, b)(3) Mathematically, an m-qubit system is treated as a Hilbert  T = − a b + , +  space with dimension N = 2m. Universal quantum compu- ( 1) D(a a b b )(4) T tation requires the ability to implement (within a specifed and D(a, b)T = (−1)ab D(a, b). The symplectic inner prod- tolerance) quantum operations represented by the group of uct in F 2m is defned as N × N unitary matrices acting on this space. In this article, 2    T  T   T we are primarily concerned with the unitary operators in the [a, b], [a , b ]s  a b + b a = [a, b]  [a , b ] (mod 2), Clifford group.   R C 0 I Notation: Let denote the feld of real numbers, de- where   m . (5) note the feld of complex numbers, and F2 denote the binary Im 0 feld. We will consider vectors over F to be row vectors and 2 Two operators D(a, b) and D(a, b) commute if and only if vectors over R or C to be column vectors. Vectors over CN [a, b], [a, b] = 0. The homomorphism γ : HW → F 2m with N = 2m will be indexed by elements of F m in the natural s N 2 2 γ κ ,  , κ ∈ Z binary order 00 ···00, 00 ···01,...,11 ···11 (rather than defned by (ı D(a b)) [a b] for all 4 has kernel   {1, 2,...,N}). Thus, for v ∈ F m,letev ∈ CN denote the ıIN , which allows us to represent elements of HWN (up to 2 = standard basis vector associated with index v, i.e., ev =|v multiplication by scalars) as binary vectors. Since Y ıXZ is all-zero except for a 1 in the entry indexed by v. is Hermitian but XZ is not, an additional factor of ı is required to make D(a, b) Hermitian for each i ∈{1,...,m} where = A. AND THE SYMPLECTIC aibi 1. Hence, the matrix T INNER PRODUCT E(a, b)  ıab mod 4D(a, b)(6) For a single qubit, we have m = 1 and a quantum pure state is 2 2 2 2 2 a vector in the N = 2 dimensional C . A pure is Hermitian and E(a, b) =IN, because X = Z = Y = I2. ∈ C2 , , ,  ∈ F 2m quantum stateu ˆ is a unit-length superposition of the Given [a b] [a b ] 2 , it can be shown that  , T ,  , T two states e0 [1 0] e1 [0 1] that form the computa-    T +  T   E(a, b)E(a , b ) = (−1)a b b a E(a , b )E(a, b)(7) tional basis. Thus,u ˆ = αe0 + βe1, where α,β ∈ C satisfy |α|2 +|β2|=1. The Pauli matrices for a single qubit system  T −  T   = ıa b b a E(a + a , b + b )(8) are the 2 × 2 identity matrix I2       where the exponent and the sums a + a, b + b are computed 01 10 0 −ı , X  , Z  , Y  ıXZ = . modulo 4 (see [52] for the extended defnition of E(a b)). 10 0 −1 ı 0 (1) B. STABILIZER CODES We use commutative subgroups of HW to defne resolutions We note that the Pauli matrices form a basis over C for all N of the identity. A stabilizer group is a commutative sub- 2 × 2 complex matrices. Thus, any single qubit unitary oper- group S of HW generated by commuting Hermitian matri- ator (such as an error) can be written as a linear combination N ces ±E(a, b), with the additional property that if E(a, b) ∈ S of Pauli matrices. One can also express any pure quantum then −E(a, b) ∈/ S. Recall that an operator is an orthogo- state asu ˆ = (α0I2 + α1X + ıα2Z + α3Y ) e0, where αi ∈ R. = m nal projection onto its range iff it is idempotent and Her- For an m-qubit system, we work in the N 2 dimen- , 2 = , ∈ F m N mitian. Since E(a b) IN for all a b 2 , the operator sional Hilbert space C and a pure quantum stateu ˆ is ± , IN E(a b) ± a unit-length vector in this space. The computational ba- 2 is an orthogonal projection onto the 1 eigenspace N m of E(a, b), respectively. Also, the eigenvalues of each E(a, b) sis vectors {ev ∈ C |(v1,...,vm) ∈ F } are defned by the 2 are ±1 with algebraic multiplicity N/2. Kronecker product ev  ev ⊗ ev ⊗···⊗ev . Thus a pure 1 2  m Since all elements of S are commuting Hermitian uni- can be written asu ˆ = v∈Fm αvev, where  2 tary matrices, they can be simultaneously diagonalized with 2 v∈Fm |αv| = 1. 2 respect to a common orthonormal basis. We refer to such  m , ∈ F m a basis as the common eigenbasis or simply the eigen- Let N 2 . Given row vectors a b 2 , defne the m- fold Kronecker product basis of the subgroup S. In addition, if the subgroup S is generated by E(ai, bi), i = 1,...,r, then the operator ,  a1 b1 ⊗···⊗ am bm ∈ U ,  D(a b) X Z X Z N (2) 1 r + , 2r i=1(IN E(ai bi)) is an orthogonal projection onto k where UN denotes the group of all N × N unitary opera- the 2 -dimensional subspace V (S) fxed pointwise by S, tors. The Heisenberg-Weyl group HWN (also called the m- i.e., the +1 eigenspace of S, where k  m − r. Mathemat- qubit Pauli group) consists of all operators ıκ D(a, b), where ically, V (S)  {|ψ∈CN | g|ψ=|ψ for all g ∈ S}.The

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

subspaceV (S) is called the [[m, k]] stabilizer code determined because (3) implies that elements in HWN either commute by S, where the notation [[m, k]]indicates that V (S) encodes k or anti-commute. The automorphism induced by an element logical qubits into m physical qubits. The extended notation g ∈ CliffN satisfes (see [51] for a proof) [[ m, k, d]]is used to denote that any undetectable error on the     code must act on at least d qubits, i.e., d is the (minimum) † Ag Bg gE (a, b)g =±E [a, b]Fg , where Fg = . distance of the stabilizer code. Cg Dg γ F 2m Let (S) denote the subspace of 2 formed by the binary (10) representations of the elements of S under the homomor- Since conjugation by g respects commutativity in HWN, phism γ . A generator matrix for γ (S)isGS  [ai, bi]i=1,...,r  T = × the matrix Fg preserves symplectic inner products: and we have GS GS 0r, where 0r is the r r all-     [a, b]Fg, [a , b ]Fgs =[a, b], [a , b ]s. This implies that Fg zero matrix (the subscript is often neglected). The condi- T T satisfes FgF = . We say that Fg is a binary symplectic tion GS  G = 0 encodes the fact that elements of S must g S  T =  pairwise commute. matrix, and express the symplectic property Fg Fg T = T , T = T , T + T = Given a stabilizer S with generators E(ai, bi), i = 1,...,r, as AgBg BgAg CgDg DgCg AgDg BgCg Im.Let r ··· , F × we can defne 2 subgroups S 1··· r where the index ( 1 r ) Sp(2m 2) denote the group of symplectic 2m 2m matri- , ∈{± } F φ → , F represents that S 1··· r is generated by iE(ai bi), i 1 . ces over 2. The homomorphism : CliffN Sp(2m 2) Note that defned by φ(g)  Fg is surjective with kernel HWN, U(1), and every Clifford operator maps down to a symplectic 1 r ···  (I + E(a , b )) (9) matrix Fg. Thus, HWN is a normal subgroup of CliffN and 1 r 2r N i i i / , U  =∼ , F i=1 CliffN HWN (1) Sp(2m 2). This implies that the | , F |= m2 m j − size is Sp(2m 2) 2 j=1(4 1) (also see [5]). is the orthogonal projector onto V (S ··· ) and the sum  1 r Table I lists elementary symplectic transformations Fg, that ,..., ∈{± }r ··· = IN defnes a resolution of the iden- ( 1 r ) 1 1 r generate the binary symplectic group Sp(2m, F2), and the tity. In , it is suffcient to correct corresponding unitary automorphisms g ∈ CliffN, which Pauli errors (i.e., elements in HWN) because general errors together with HWN generate CliffN (see [51, Appendix I]). can be approximated by linear combinations of them [53]. Some important circuit identities involving these operators Also, the elements of HWN, acting via conjugation, permute are listed in [51]. the subgroups S ··· . Given an [[m, k]] stabilizer code, it is 1 r In [55], Can has developed an algorithm that factors a possible to perform encoded quantum computation in any of 2m × 2m binary symplectic matrix into a product of at most the subspaces V (S ··· ) by synthesizing appropriate logical 1 r 6 elementary symplectic matrices of the type shown in operators. If we think of these subspaces as threads, then a Table I. The target symplectic matrix maps the dual basis computation starts in one thread and jumps to another when  { , ∈ F m},  { , ∈ F m} XN E(a 0) : a 2 ZN E(0 b):b 2 to a dual an error (from HWN) occurs. QECCs enable error control by  ,  basis XN ZN. Row and column operations by the elementary identifying the jump that the computation has made. Identi-  ,  , matrices return XN ZN to the original pair XN ZN. This de- fcation makes it possible to adjust future operations in the composition simplifes the translation of symplectic matrices computation instead of returning to the initial subspace and into circuits (see [51, Appendix I]), and so we use it in our restarting the computation. The idea of tracing these threads LCS algorithm. For completeness, we include the theorem is called Pauli frame tracking [54]. here. Theorem 1 ([55, Theorem 3.2.1]): Any binary symplectic C. THE CLIFFORD GROUP AND SYMPLECTIC MATRICES transformation F can be expressed as The Clifford group CliffN consists of all unitary matrices g ∈ N×N † F = A  T G T A C for which gD(a, b)g ∈ HWN for all D(a, b) ∈ HWN, Q1 R1 k R2 Q2 † where g is the conjugate transpose of g [16]. CliffN is the as per the notation used in Table I, where invertible matrices normalizer of HW in the unitary group U , so it con- N N Q1, Q2 and symmetric matrices R1, R2 are chosen appropri- tains HWN. Note that by defnition CliffN has an infnite ately. U  { ıθ ; θ ∈ R} center consisting of (1) e IN , but it can be Proof: The idea is to perform row and column operations /U made fnite by frst taking the quotient group CliffN (1) on the matrix F via left and right multiplication by ele- ıπ/4 and then including multiples of just the phase e , which mentary symplectic transformations from Table I, and bring contributes a factor 8 in its size [5], i.e., |Cliff |=8 ·  N the matrix F to the standard form  TR  (for details see m2+2m m j − 1 2 j=1(4 1). We regard operators in CliffN as phys- Appendix B).  ical operators acting on quantum states in CN,tobeim- A closely related algorithm was given earlier by Dehaene plemented by quantum circuits. Every operator g ∈ CliffN and De Moor [56]. The elementary symplectic matrices ap- induces an automorphism of HWN by conjugation. Note pearing in the product can be related to the Bruhat decompo- that the inner automorphisms induced by matrices in HWN sition of the symplectic group (see [20]). When the algorithm preserve every conjugacy class {±D(a, b)} and {±ıD(a, b)}, is run in reverse it produces a random Clifford matrix, which

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

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

serves as a “third-order” approximation to a random unitary The stabilizer group of the [[6, 4, 2]] CSS code is S = matrix since the Clifford group forms a unitary 3-design [57]. X⊗6, Z⊗6=E(1, 0), E(0, 1), where 1 = 111111, 0 = This is an instance of the subgroup algorithm [58] for gen- 000000. The logical Pauli operators can be calculated erating uniform random variables. The algorithm has com- directly [51, Section V], or using algorithms developed plexity O(m3) and uses O(m2) random bits, which is order by Gottesman [6] or Wilde [12]. These operators are , F ¯ = = + , , ¯ = = optimal given the order of the symplectic group Sp(2m 2) given by Xj X1Xj+1 E(e1 e j+1 0) Z j Z j+1Z6 , + , = , , , (cf. [59]). Our algorithm is similar to that developed by Jones E(0 e j+1 e6) j 1 2 3 4, where e j is the jth standard et al. [60] in that it alternates (partial) Hadamard matrices F 6 basis vector in 2 . We now fnd a six-qubit circuit CZ12 and diagonal matrices; the difference is that the unitary three- on the physical (code) qubits that (i) realizes the CZ12 gate design property of the Clifford group provides randomness on the logical qubits, i.e., CZ12 acts on X¯ j, Z¯ j analogous to guarantees. This also fnds application in machine learning how CZ12 acts on Xj, Z j as stated explicitly in (11), and (ii) (see [61] and references therein). preserves the code space. Note that satisfying the mathemat- ical condition in (i) does not already guarantee (ii). The frst III. SYNTHESIS OF LOGICAL CLIFFORD OPERATORS FOR condition is written as the constraints STABILIZER CODES ⎧ , ⎪ ¯ ¯ = , Quantum computation in the protected space of an [[m k]] ⎨⎪X1Z2 if j 1 quantum error-correcting code (QECC) requires the transla- † CZ X¯ jCZ = Z¯ X¯ if j = 2, tion of logical operators on the k encoded qubits into phys- 12 12 ⎪ 1 2 ⎩ ¯ = , , ical operators on the m code qubits. In this section, for an Xj if j 1 2 [[ m, k]] stabilizer code, we develop an algorithm that syn- ¯ † = ¯ = , , , . thesizes all physical Clifford realizations of a logical Clif- CZ12Z jCZ12 Z j for all j 1 2 3 4 (11) ford operator, up to equivalence classes defned by their action on input Pauli operators [which is encoded in their The symplectic representation of Clifford elements in (10) symplectic matrix representation, by (10)]. This algorithm transforms these conditions into the following linear con- makes it possible to optimize the choice of circuit with re- straints on the desired symplectic matrix F : CZ12 spect to a metric that is a function of the quantum hard- ware. We now outline the algorithm and illustrate the steps [e + e , 0]F = [e + e , e + e ], using an example where we synthesize a logical controlled- 1 2 CZ12 1 2 3 6 Z gate on the frst two logical qubits of the [[6, 4, 2]] + , = + , + , [e1 e3 0]FCZ [e1 e3 e2 e6] code [6], [27]. See [1] for discussions on other operators for 12 this code. [e + e + , 0]F = [e + e + , 0], j = 3, 4, 1 j 1 CZ12 1 j 1 Input: Target Clifford circuit g on the k logical qubits, [0, e + e ]F = [0, e + e ], stabilizers, and logical Paulis. 2 6 CZ12 2 6 Output: All Clifford circuitsg ¯ on the m physical qubits [0, e + e ]F = [0, e + e ], that preserve the code space and implement g on the k logical 3 6 CZ12 3 6 qubits. Step 1: Translate the input into linear constraints on [0, e + + e ]F = [0, e + + e ], j = 3, 4. (12) the symplectic matrix Fg¯ representingg ¯. j 1 6 CZ12 j 1 6

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

Constraint (ii) requires that the physical circuit must normal- Proof: There are two cases: x, ys = 1 or 0. First assume ize the stabilizer. We prove later that any such circuit can x, ys = 1. Defne h  x + y,so be transformed into one that commutes with each stabilizer element, while realizing the same logical operation (see The- xFh = Zh(x) = x +x, x + ys(x + y) orem 11). Note that the requirement is only to preserve the = x + (x, xs +x, ys) (x + y) code space, i.e., CZ12 must commute with the code projector, but this is equivalent to normalizing the stabilizer since we = x + (0 + 1)(x + y) = y. restrict CZ12 to be a physical Clifford operator. For non- Clifford physical operators, the general approach would be Next assume x, ys = 0. Defne h1  w + y, h2  x + w, w ∈ F 2m  , w =, w = similar to that considered for Z-rotations in [62]. Requiring where 2 is chosen such that x s y s 1. that the circuit centralize the stabilizer yields the constraints Then [111111, 000000]F = [111111, 000000], + ∗ = + , w +  w + CZ12 rCl x xFh1 Fh2 Zh2 (x x y s( y)) [000000, 111111]F = [000000, 111111]. (13) = + w + + + w + , + w CZ12 (x y) (x ) y x s Step 2: Find all symplectic solutions. × (x + w)  T =  The symplectic constraint FCZ F is non- 12 CZ12 = y. linear, and in the description of the generic LCS algorithm  that follows this example, we show how to use transvections We will use the above result to propose an algorithm r r+ / to fnd all 2 ( 1) 2 symplectic solutions. We then translate (Algorithm 1) which determines a symplectic matrix F that each solution into a physical Clifford circuit using the de- satisfes xiF = yi, i = 1, 2,...,t ≤ 2m, where xi are lin- composition of symplectic matrices as a product of the ele- early independent and satisfy xi, x js =yi, y js for all i, mentary matrices listed in Table I (see Appendix B or [51] j ∈{1,...,t}. for details). For the [[6, 4, 2]] code there are 8 symplectic solutions. The solution with smallest depth is the elementary B. DESCRIPTION OF THE GENERIC LOGICAL CLIFFORD symplectic matrix F = TB, where B23 = B32 = B26 = CZ12 SYNTHESIS (LCS) ALGORITHM B = B = B = 1 and B = 0 elsewhere. The corre- 62 36 63 ij The synthesis of logical Paulis by Gottesman [6] and by = vBvT sponding physical operator CZ12 diag(ı ) can be de- Wilde [12] exploits symplectic groups over the binary feld. composed into CZ23CZ26CZ36. Step 3: Identify any sign vi- Building on their work we have demonstrated, using the olations and fnd a Pauli matrix to fx the signs while leaving [[ 6 , 4, 2]] code as an example, that the binary symplectic the logical operation undisturbed. group provides a systematic framework for synthesizing The operator CZ23CZ26CZ36 commutes with the stabilizer physical implementations of any logical operator in the logi- E(0, 1) but not with the stabilizer E(1, 0). Adding the Pauli cal Clifford group Cliff2k for stabilizer codes. In other words, operator Z6 fxes the sign and leaves the logical operation the symplectic group provides a control plane where ef- undisturbed. So the fnal circuit is CZ23CZ26CZ36Z6. fects of Clifford operators can be analyzed effciently. For each logical Clifford operator, one can obtain all symplectic A. SYMPLECTIC TRANSVECTIONS solutions using the algorithm below. ∈ F 2m Defnition 2: Given row vector h 2 , a symplectic F 2m → F 2m transvection is a map Zh : 2 2 defned by 1) Collect all the linear constraints on F, obtained from the conjugation relations of the desired Clifford opera- Z (x)  x +x, h h = xF , where F  I + hT h h s h h 2m tor with the stabilizer generators and logical Paulis, to (14) obtain a system of equations UF = V. where Fh is its associated symplectic matrix [59]. A transvec- 2) Then vectorize both sides to get (I2m ⊗ U )vec(F) = tion does not correspond to a single elementary Clifford op- vec(V ). erator. 3) Perform Gaussian elimination on the augmented ma- Fact 3 ([63, Theorem 2.10]): The symplectic group trix [(I2m ⊗ U ), vec(V )]. If  is the number of non- Sp(2m, F2) is generated by the family of symplectic pivot variables in the row-reduced echelon form, then transvections. there are 2 solutions to the linear system. An important result that is involved in the proof of this 4) For each such solution, check if it satisfes FFT = . fact is the following theorem from [59] and [63], which we If it does, then it is a feasible symplectic solution forg ¯. F 2m restate here for 2 since we will build on this result to state and prove Theorem 5. Clearly, this algorithm is not very effcient since  could be , ∈ F 2m Theorem 4: Let x y 2 be two nonzero vectors. Then very large. Specifcally, for codes that do not encode many x can be mapped to y by a product of at most two symplectic logical qubits this number will be very large as the system transvections. UF = V will be very under-constrained. We now state and

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

prove two theorems that enable us to determine all symplec- Algorithm 1: Algorithm to Find F ∈ Sp(2m, F ) Satis- tic solutions for each logical Clifford operator much more 2 fying a Linear System of Equations, Using Theorem 5. effciently. 2m , ∈ F 2m Theorem 5: Let x , y ∈ F , i = 1, 2,...,t ≤ 2m be a Input: xi yi 2 s.t. i i 2  ,  = ,  ∀ , ∈{ ,..., } collection of (row) vectors such that x , x  =y , y  .As- xi x j s yi y j s i j 1 t . i j s i j s ∈ , F sume that the x are linearly independent. Then a solution Output: F Sp(2m 2) satisfying i = ∀ ∈{ ,..., } F ∈ Sp(2m, F ) to the system of equations x F = y can be xiF yi i 1 t 2 i i  ,  = obtained as the product of a sequence of at most 2t symplec- 1: if x1 y1 s 1 then  +  T ∈ F 2m 2: set h1  x1 + y1 and F1  Fh . tic transvections Fh I2m h h, where h 2 is a row 1 vector. 3: else  w + ,  + w Proof: We will prove this result by induction. For i = 1 4: h11 1 y1 h12 x1 1 and F  F F . we can simply use Theorem 4 to fnd F1 ∈ Sp(2m, F2)as 1 h11 h12  ,  =   + 5: end if follows. If x1 y1 s 1 then F1 Fh1 with h1 x1 y1,  ,  =   w + , 6: for i = 2,...,t do or if x1 y1 s 0 then F1 Fh11 Fh12 with h11 1 y1 7: Calculatex ˜i  xiFi−1 and x˜i, yis. h12  x1 + w1, where w1 is chosen such that x1, w1s = 8: if x˜i = yi then y1, w1s = 1. In any case F1 satisfes x1F1 = y1. Next con- 9: Set F  F − . Continue. sider i = 2. Letx ˜  x F so that x , x  =y , y  = i i 1 2 2 1 1 2 s 1 2 s 10: end if y , x˜  , since F is symplectic and hence preserves sym- 1 2 s 1 11: if x˜ , y  = 1 then plectic inner products. i i s 12: Set hi  x˜i + yi, Fi  Fi−1Fh . Similar to Theorem 4 we have two cases: x˜2, y2s = 1or i  + 13: else 0. For the former, we set h2 x˜2 y2 so that we clearly have w  , w  = , w  = = = 14: Find a i s.t. x˜i i s yi i s 1 and x˜2Fh2 Zh2 (˜x2) y2 (see Section III-A for the defnition of y j, wis =y j, yis ∀ j < i. Zh(·)). We also observe that 15: Set hi1  wi + yi, hi2  x˜i + wi, Fi  y F = Z (y ) = y +y , x˜ + y  (˜x + y ) 1 h2 h2 1 1 1 2 2 s 2 2 Fi−1Fhi1 Fhi2 . 16: end if = y1 + (y1, y2s +y1, y2s)(˜x2 + y2) 17: end for = . y1 18: return F  Ft . Hence, in this case, F  F F satisfes x F = y , x F = 2 1 h2 1 2 1 2 2 y , y  ∀ j < i. Then we defne h  w + y , h  x˜ + w y . For the case x˜ , y  = 0 we again fnd a w j i s i1 i i i2 i i 2 2 2 s 2 and observe that satisfes x˜2, w2s =y2, w2s = 1 and set h21  w2 +   ,  + w = y2 h22 x˜2 2. Then by Theorem 4 we clearly have y jFhi1 Fhi2 Zhi2 Zhi1 (y j ) x˜2Fh Fh = y2.Fory1 we observe that 21 22 = y j +y j, wi + yis(˜xi + yi) y1Fh21 Fh22 = , < .   y j for j i = Zh Zh (y1) = 22 21 Again, by Theorem 4, we clearly havex ˜iFhi1 Fhi2 yi. Hence = + , w +  w + we set Fi  Fi−1Fh Fh in this case. In both cases Fi satis- Zh22 (y1 y1 2 y2 s( 2 y2)) i1 i2 fes x F = y ∀ j = 1,...,i. Setting F  F completes the = + , w +  w + +  , + w  j i j t y1 y1 2 y2 s( 2 y2) ( y1 x˜2 2 s inductive proof and it is clear that F is the product of at most  +y1, w2 + y2sw2 + y2, x˜2 + w2s) (˜x2 + w2) 2t symplectic transvections. The algorithm defned implicitly by the above proof is (a) = y1 +y1, w2 + y2s(˜x2 + y2) stated explicitly in Algorithm 1. F 2m Defnition 6: A symplectic basis for 2 is a set of pairs = y1 if and only if y1, w2s =y1, y2s {(v1, w1), (v2, w2),...,(vm, wm)} such that vi, w js = δij v , v  =w , w  = δ = = where (a) follows from y1, x˜2s =y1, y2s, w2 + y2, x˜2 + and i j s i j s 0, where ij 1ifi j and 0 if = w2s = 1 + 0 + 0 + 1 = 0. Hence, we pick a w2 such i j. , F that x˜2, w2s =y2, w2s = 1 and y1, w2s =y1, y2s, and Note that the rows of any matrix in Sp(2m 2)forma  symplectic basis for F 2m. There exists a symplectic Gram- then set F2 F1Fh21 Fh22 . Again, for this case F2 satisfes 2 x1F2 = y1, x2F2 = y2 as well. Schmidt orthogonalization procedure that can produce a = F 2m By induction, assume Fi−1 satisfes x jFi−1 y j for all symplectic basis starting from the standard basis for 2 and = ,..., − ≥ v ∈ F 2m j 1 i 1, where i 3. Using the same idea as for an additional vector 2 (see [59]). i = 2 above, let xiFi−1 = x˜i.Ifx˜i, yis = 1, we simply set Now, we state our main theorem, which enables one to   +  ,  = Fi Fi−1Fhi , where hi x˜i yi.If x˜i yi s 0, we fnd determine all symplectic solutions for a system of linear a wi that satisfes x˜i, wis =yi, wis = 1 and y j, wis = equations.

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

{ , v , ∈{ ,..., }} v  , v  =  , v  = , v  = Theorem 7: Let (ua a) a 1 m be a col- u˜d and ˜d are that u˜d1 d s ud ˜d2 s u˜d1 ˜d2 s δ 2 1 lection of pairs of (row) vectors that form a symplec- d1d2 and all other pairs of vectors in the new basis set for F 2m , v ∈ F 2m ⊥ tic basis for 2 , where ua a 2 . Consider the sys- W be orthogonal to each other. In the dth symplectic pair = , v = v ∈ I ⊆ , v  , v , v tem of linear equations uiF ui jF j, where i —(˜ud d )or(ud ˜d )or(˜ud ˜d ) — of its new symplectic {1,...,m}, j ∈ J ⊆{1,...,m} and F ∈ Sp(2m, F2). As- basis there is at least one free vector —u ˜d orv ˜d or both,   sume that the given vectors satisfy u , u  u , u  = 0, respectively. For the frst of the α free vectors, there are i1 i2 s i1 i2 s v , v  =v , v  = ,  , v  = , v  =δ 2|I¯ ∪ J¯|−α symplectic inner product constraints (which j1 j2 s j j s 0 ui j s ui j s ij where 1 2 |I¯ ∪ J¯|−α i1, i2 ∈ I, j1, j2 ∈ J (since symplectic transformations F are linear constraints) imposed by the 2 con- α  |I¯|+  , v ⊥ must preserve symplectic inner products). Let strained vectors ud d. Since W has (binary) |J¯|, where I¯, J¯ denote the set complements of I, J in dimension 2|I¯ ∪ J¯| and each linearly independent constraint α {1,...,m}, respectively. Then there are 2α(α+1)/2 solutions decreases the dimension by 1, this leads to 2 possible F to the given linear system, and they can be enumerated choices for the frst free vector. For the second free vector, systematically. there are α − 1-degrees of freedom as it has an additional Proof: By the defnition of a symplectic basis (Defni- inner product constraint from the frst free vector. This leads α−1 tion 6), we have ua, vbs = δab and ua, ubs =va, vbs = to 2 possible choices for the second free vector, and so α  = 0, where a, b ∈{1,...,m}. The same defnition extends to on. Therefore, the given linear system has at least =1 2 F 2m α(α+1)/2 any (symplectic) subspace of 2 . The linear system un- 2 symplectic solutions. der consideration imposes constraints only on ui, i ∈ I and We will now argue that there cannot be more solutions. v , ∈ J F 2m j j .LetW be the subspace of 2 spanned by the The given system of equations can be represented compactly , v ∈ I ∩ J ⊥ = , ∈ F (2m−α)×2m symplectic pairs (uc c) where c and W be its as UF V, where U V 2 and F is symplectic. orthogonal complement under the symplectic inner product, Observe that for each valid choice of V the set of symplectic ⊥ i.e., W  {(uc, vc), c ∈ I ∩ J } and W  {(ud, vd ), d ∈ solutions is disjoint, and hence they form a partition of the I¯ ∪ J¯}, where I¯, J¯ denote the set complements of I, J in binary symplectic group Sp(2m, F2). Therefore, it is enough {1,...,m}, respectively. to show that the product of the number of such valid matrices α(α+1)/2 Using the result of Theorem 5, we frst compute one solu- V and 2 is equal to the size of Sp(2m, F2). By defn- tion F0 for the given system of equations. In the subspace W, ing k = m − α, the number of such valid matrices V is given , v →  , v ∈ I ∩ J F0 maps (uc c) (uc c) for all c and hence we by ={  , v , ∈ I ∩ J } now have W (uc c) c spanned by its new  , v ⊥ , v → − − basis pairs (uc c). However in W , F0 maps (ud d ) (22m − 1) · (22m 1 − 21) · (22m 2 − 22) ··· (u , v˜ )or(u , v ) → (˜u , v )or(u , v ) → (˜u , v˜ ) de- d d d d d d d d d d  pending on whether d ∈ I ∩ J¯ or d ∈ I¯ ∩ J or d ∈ I¯ ∩ J¯, m− m− m− respectively (d ∈/ I ∩ J by defnition of W ⊥). Note however (22 ( 1) − 2 1) ⊥  that the subspace W itself is fxed. We observe that suchu ˜   d andv ˜ are not specifed by the given linear system and hence − − + − + − d × 22m m · 22m (m 1) ···22m (m k 1) form only a particular choice for the new symplectic basis ⊥  of W . These can be mapped to arbitrary choicesu ˜d andv ˜d,   − − while fxing other u and v , as long as the new choices still = 20(22m − 1) · 21(22m 2 − 1) · 22(22m 4 − 1)··· d d ⊥ complete a symplectic basis for W . Hence, these form the  degrees of freedom for the solution set of the given system m−1 (m+1)−(m−1) − · m · m−1 ··· m−(k−1) of linear equations. The number of such “free” vectors is 2 (2 1) 2 2 2 exactly |I¯|+|J¯|=α. This can be verifed by observing that m ⊥ + −  the number of basis vectors for W is 2|I¯ ∪ J¯| and making m(m 1) +(k−1)m− k(k 1) j = 2 2 2 (4 − 1). the following calculation. j=1 ⊥ Number of constrained vectors in the new basis for W The counting in the frst line is as follows. First, we as- =|I \ J |+|J \ I| sume without loss of generality that the pairs of rows i and (m + i)ofV form a symplectic pair, for i = 1,...,k, and the =|I|−|I ∩ J |+| |−|I ∩ J | J rows k + 1,...,m are orthogonal to all rows of V under the = (m −|I¯|) + (m −|J¯|) − 2(m −|I¯ ∪ J¯|) symplectic inner product. More precisely, the inner products between pairs of rows ofV must be the same as those between = |I¯ ∪ J¯|− |I¯|+|J¯| 2 ( ) corresponding pairs of rows of U. But, we assume that we = 2|I¯ ∪ J¯|−α. can perform a symplectic Gram-Schmidt process on U so that the above assumption is valid. For the frst row of V, 2m Let d, d1, d2 ∈ I¯ ∪ J¯ be indices of some symplectic ba- we can choose any nonzero vector and there are (2 − 1) of sis vectors for W ⊥. Then, the constraints on free vectors them. For the second row, we need to restrict to vectors that

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

are orthogonal to the frst row, and we need to eliminate the Algorithm 2: Algorithm to Determine All subspace generated by the frst row. Similarly, for the third F ∈ Sp(2m, F ) Satisfying a Linear System of row until the mth row, we keep restricting to the subspace of 2 Equations, Using Theorem 7. vectors orthogonal to all previous rows and eliminate the sub- , v ∈ F 2m  , v  = δ space generated by all previous rows. For the (m + 1)th row, Input: ua b 2 s.t. ua b s ab and  ,  =v , v  = , ∈{ ,..., } it needs to be orthogonal to all rows starting from the second ua ub s a b s 0, where a b 1 m . , v ∈ F 2m to the mth, but it needs to have symplectic inner product 1 ui j 2 s.t. u , u  = 0, v , v  = 0, u, v  = δ , where with the frst row. Hence the dimension decreases by m from i1 i2 s j1 j2 s i j s ij 2m, but notice that the subspace generated by the frst m rows i, i1, i2 ∈ I, j, j1, j2 ∈ J , I, J ⊆{1,...,m}. cannot have any vector that has symplectic inner product Output: F ⊂ Sp(2m, F2) such that each F ∈ F =  ∀ ∈ I v = v ∀ ∈ J 1 with the frst row. Therefore, we need not subtract this satisfes uiF ui i , and jF j j . 2m−m subspace and this gives the count 2 for the (m + 1)th 1: Determine a particular symplectic solution F0 for row. A similar argument can be made for all remaining rows the linear system using Algorithm 1. and this completes the argument for counting. (It is easy to 2: Form the matrix A whose ath row is uaF0 and verify that by substituting k = m above we obtain the size (m + b)th row is vbF0, where a, b ∈{1,...,m}. −1 F of Sp(2m, F2) exactly.) Now we expand the exponent of 2 3: Compute the inverse of this matrix, A ,in 2. 1 2 + − 2 − + 4: Set F = φ and α  |I¯|+|J¯|, where I¯, J¯ denote above to obtain 2 (m 2mk k m k). the set complements of I, J in {1,...,m}, Recollect that the size of the symplectic group is m2 m j 2 = (4 − 1), and we need to check that the number respectively. j 1 α(α+1)/2 α(α+1)/2 5: for  = 1,...,2 do obtained by dividing this by 2 is equal to the above m 6: Form a matrix B = A. number, for α = m − k. Since the product (4 j − 1) j=1 7: For i ∈/ I and j ∈/ J replace the ith and matches with the expression in the count above, we only have (m + j)th rows of B with arbitrary vectors such to check that the exponents of 2 match. Here, the exponent T  that BB =  and B = B for 1 ≤  <. of 2 is given by  /∗ See proof of Theorem 7 for details or − − + ∗/ 2 (m k)(m k 1) Appendix C for example MATLAB code m −  − 2 8: Compute F = A 1B.     F 1 9: Add F F0F to . = 2m2 − (m2 − 2mk + k2 + m − k) 10: end for 2   11: return F 1 = m2 + 2mk − k2 − m + k , 2 which equals the exponent calculated above. This com- basis (u j, v j ), j = 1,...,m using the symplectic Gram- α α+ / pletes the proof that the given system has exactly 2 ( 1) 2 Schmidt orthogonalization procedure discussed in [59]. Then solutions. we transform the given system into an equivalent system of Finally, we show how to get each symplectic solution F for constraints on these basis vectors u j, v j and apply Theorem 7 the given linear system. First form the matrix A whose rows to obtain all symplectic solutions. F 2m are the new symplectic basis vectors for 2 obtained under The algorithm defned implicitly by the above proof is  ,  ,  the action of F0, i.e., the frst m rows are uc ud u˜d and the last stated explicitly in Algorithm 2. For a given system of linear v , v , v α = m rows are c d ˜d. Observe that this matrix is symplectic (independent) equations, if 0 then the symplectic matrix and invertible. Then form a matrix B = A and replace the F is fully constrained and there is a unique solution. Other- rows corresponding to free vectors with a particular choice wise, the system is partially constrained and we refer to a of free vectors, chosen to satisfy the conditions mentioned solution F as a partial symplectic matrix. above. Note that B and A differ in exactly α rows, and that B Example: As an application of this theorem, we discuss is also symplectic and invertible. Determine the symplectic the procedure to determine all symplectic solutions for the  = −1 matrix F A B which fxes all new basis vectors obtained logical controlled-Z gate CZ12 discussed at the beginning of ⊥ 12 forW andW under F0 except the free vectors in the basis for this section. First we defne a symplectic basis for F using ⊥  2 W . Then this yields a new solution F = F0F for the given the binary vector representation of the logical Pauli operators =  v = , , system of linear equations. Note that ifu ˜d u˜d and ˜d and stabilizer generators of the [[6 4 2]] code. v  , v ˜d for all free vectors, whereu ˜d ˜d were obtained under the ⊥  = action of F0 on W , then F I2m. Repeating this process u1  [110000, 000000], v1  [000000, 010001], for all 2α(α+1)/2 choices of free vectors enumerates all the  , , v  , , solutions for the linear system under consideration.  u2 [101000 000000] 2 [000000 001001] Remark 8: For any system of symplectic linear equa- u3  [100100, 000000], v3  [000000, 000101], tions xiF = yi, i = 1,...,t where the xi do not form a F 2m  , , v  , , symplectic basis for 2 , we frst calculate a symplectic u4 [100010 000000] 4 [000000 000011]

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

,..., I¯ = φ,J¯ ={ + ,..., } u5  [111111, 000000], v5  [000000, 000001], uk+1 um. Hence we have k 1 m , as per the notation in Theorem 7, and thus, α =|I¯|+|J¯|  , , v  , . u6 [100000 000000] 6 [000000 111111] = m − k = r.  (15) Corollary 10: For any logical k-qubit Clifford operation on an [[m, k]] stabilizer code, there always exists a phys- Note that v5 and u6 do not correspond to either a logi- cal Pauli operator or a stabilizer element but were added ical m-qubit Clifford circuit that normalizes the stabilizer to complete a symplectic basis. Hence we have I = and realizes the given operation. Effectively, this identifes the surjection Cliff ∩ NU (S) → Cliff k whose kernel is {1, 2, 3, 4, 5}, J ={1, 2, 3, 4, 6} and α = 1 + 1 = 2. As N N 2 all the physical Cliffords that normalize the stabilizer but discussed earlier, we impose constraints on all ui, v j ex- cept for i = 6 and j = 5. Therefore, as per the notation in realize only the logical identity (see the proof of Theorem 11 for a method to identify them). Here, NU (S) denotes the the above proof, we have W  {(u1, v1),...,(u4, v4)} and N ⊥ normalizer of S in the group UN of all m-qubit unitary W  {(u5, v5), (u6, v6)}. Using Algorithm 1 we obtain a operations. particular solution F0 = TB where B is given in the beginning Note that, for each symplectic solution, there are multiple of Section III. Then we compute the action of F0 on the bases for W and W ⊥ to get decompositions into elementary forms (from Table I) pos- sible; one possibility is given in Theorem 1. Although each  , v  v , ∈ I, ∈ J , uiF0 ui jF0 j i j and decomposition yields a different circuit, all of them will act identically on X and Z under conjugation (see Section II-C = ,   , N N u6F0 [100000 000000] u˜6 for notation). Once a logical Clifford operator is defned by  its conjugation with the logical Pauli operators, a physical v5F0 = [000000, 000001]  v˜ , (16) 5 realization of the operator could either normalize the stabi- , v where ui j are the vectors obtained in (12), (13). Then we lizer or centralize it, i.e., fx each element of the stabilizer identifyv ˜5 andu ˜6 to be the free vectors and one particular group under conjugation. We note here that any obtained v = v , =  α = 2 = solution is ˜5 ˜5 u˜6 u˜6. In this case we have 2 2 normalizing solution can be converted into a centralizing v   , v  =  , v  = 4 choices to pick ˜5, since we need u5 ˜5 s 1, ui ˜5 s solution. While we do not have a well-motivated application 0fori = 1, 2, 3, 4, and v j, v˜5s = 0for j = 1, 2, 3, 4, 6. For for this result yet, we believe this might be useful in Pauli α−1 each such choice ofv ˜5,wehave2 = 2 choices foru ˜6. frame tracking [54] and adapting future logical operations to  + Next we form the matrix A whose ith row is ui and (6 j)th the current signs. v ∈ I, ∈ J  , row is j, where i j .Wesetthe6throwtobe˜u6 Theorem 11: For an [[m k]] stabilizer code with stabilizer v = S, each physical realization of a given logical Clifford op- and the 11th row to be ˜5. Then we form a matrix B A and replace rows 6 and 11 by one of the eight possible pair erator that normalizes S can be converted into a circuit that of choices foru ˜6 andv ˜5, respectively. This yields the matrix centralizes S while realizing the same logical operation.  −1  F = A B and the symplectic solution F = F0F . Looping Proof: Let the symplectic solution for a specifc logi- through all the eight choices we obtain the solutions listed in cal Clifford operatorg ¯ ∈ CliffN that normalizes the stabi- the appendices of [51]. lizer S be denoted by Fn. Defne the logical Pauli groups Theorem 9: For an [[m, k]] stabilizer code, the number X¯  X¯1,...,X¯k and Z¯  Z¯1,...,Z¯k.Letγ (X¯ ) and γ (Z¯) + / of solutions for each logical Clifford operator is 2r(r 1) 2, denote the matrices whose rows are γ (X¯i) and γ (Z¯i), re- ignoring stabilizer degrees of freedom (Remark 12), where spectively, for i = 1,...,k, where γ is the map defned in r = m − k. Section II-A. Similarly, let γ (S) denote the matrix whose 2m Proof: Let ui, vi ∈ F represent the logical Pauli op- rows are the images of the stabilizer generators under the 2 γ erators X¯i, Z¯i,fori = 1,...,k, respectively, i.e., γ (X¯i) = map . Then, by stacking these matrices as in the proof of ui,γ(Z¯i) = vi, where γ is the map defned in Section II- Theorem 9, we observe that Fn is a solution of the linear A. Since X¯iZ¯i =−Z¯iX¯i and X¯iZ¯ j = Z¯ jX¯i for all j = i,itis system  , v  = δ , ∈{ ,..., } ⎡ ⎤ ⎡ ⎤ clear that ui j s ij for i j 1 k and hence they  F 2m ,..., γ (X¯ ) γ (X¯ ) form a partial symplectic basis for 2 .Letuk+1 um ⎢ ⎥ ⎢ ⎥ γ = γ  , represent the stabilizer generators, i.e., γ (S j ) = uk+ j where ⎣ (S)⎦ Fn ⎣ (S )⎦  the stabilizer group is S =S1,...,Sr. Since by def- γ (Z¯) γ (Z¯ ) nition X¯i, Z¯i commute with all stabilizer elements, it is   clear that ui, u js =vi, u js = 0fori ∈{1,...,k}, j ∈ where X¯ , Z¯ are defned by the conjugation relations ofg ¯ { + ,..., } ¯ † = ¯ , ¯ † = ¯  k 1 m . To complete the symplectic basis we fnd with the logical Paulis, i.e.,g ¯Xig¯ Xi g¯Zig¯ Zi, and S vectors vk+1,...,vm s.t. ui, v js = δij ∀ i, j ∈{1,...,m}. denotes the stabilizer group of the code generated by a dif- Now we note that for any logical Clifford operator, the ferent set of generators than that of S. Note, however, that  conjugation relations with logical Paulis yield 2k con- as a group S = S. The goal is to fnd a different solution Fc  straints, on ui, vi for i ∈{1,...,k}, and the normaliza- that centralizes the stabilizer, i.e. we replace γ (S ) with γ (S) tion condition on the stabilizer yields r constraints, on above.

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

We frst fnd a matrix K ∈ GL(m − k, F ) such that 2 Algorithm 3: LCS Algorithm to Determine All Kγ (S) = γ (S), which always exists since generators of S Logical Clifford Operators (See Section II for the span S as well. Then we determine a symplectic solution H Homomorphisms γ,φ). for the linear system ⎡ ⎤ ⎡ ⎤ 1: Determine the target logical operatorg ¯ by γ (X¯ ) γ (X¯ ) specifying its action on logical Paulis X¯i, Z¯i [16]: ⎢ ⎥ ⎢ ⎥ ¯ † = ¯ , ¯ † = ¯ ⎣γ (S)⎦ H = ⎣Kγ (S)⎦ , g¯Xig¯ Xi g¯Zig¯ Zi . 2: Transform the above relations into linear equations γ (Z¯) γ (Z¯) on F ∈ Sp(2m, F2) using the map γ and the result γ ¯ = γ ¯  ,γ ¯ = γ ¯ so that H satisfes Kγ (S) = γ (S)H while fxing γ (X¯ ) and of (10), i.e., (Xi)F (Xi ) (Zi)F (Zi ). γ (Z¯). Then since K is invertible we can write Add the conditions for normalizing the stabilizer S, ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ i.e., γ (S)F = γ (S).  Ik γ (X¯ ) Ik γ (X¯ ) 3: Calculate the feasible symplectic solution set F ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢  ⎥ ⎣ K ⎦ ⎣γ (S)⎦ Fn = ⎣ K ⎦ ⎣γ (S )⎦ using Algorithm 2 by mapping X¯i, S, Z¯i to ui, vi as  in Theorem 9. Ik γ (Z¯) Ik γ (Z¯ ) ⎡ ⎤ ⎡ ⎤ 4: Factor each F ∈ F into a product of elementary γ (X¯ ) γ (X¯ ) symplectic transformations listed in Table I, ⎢ ⎥ ⎢ ⎥ ⇒ ⎣γ (S)⎦ HFn = ⎣ γ (S) ⎦ . possibly using the algorithm given in [64] (which  is restated in Theorem 1 here), and compute the γ (Z¯) γ (Z¯ ) physical Clifford operatorg ¯. g Hence, Fc  HFn is a centralizing solution forg ¯. Note that 5: Check for conjugation of ¯ with the stabilizer there are 2r(r+1)/2 solutions for H, as per the result of The- generators and for the conditions derived in step 1. orem 9 with the operator being the identity operator on the If some signs are incorrect, post-multiply by an logical qubits, and these produce all centralizing solutions element from HWN as necessary to satisfy all these forg ¯.  conditions (apply [65, Prop. 10.4] for ⊥ = , ¯ , ¯  γ Although any normalizing solution can be converted into S S Xi Zi ,using ). Since HWN is the kernel φ a centralizing solution, the optimal solution with respect to of the map , post-multiplication does not change a suitable metric need not always centralize the stabilizer. F. However, we can always setup the problem of identifying a 6: Expressg ¯ as a sequence of physical Clifford gates symplectic matrix, representing the physical circuit, by con- corresponding to the elementary symplectic straining it to centralize the stabilizer. The general procedure matrices obtained from the factorization in step 4 to determine all symplectic solutions, and their circuits, for a (see Appendix A for the circuits for these logical Clifford operator for a stabilizer code is summarized matrices). in Algorithm 3. For the [[6, 4, 2]]CSS code, we employed Al- gorithm 3 to determine the solutions listed in the appendices of [51] for each of the standard generating operators for the Clifford group (see Table I). Remark 12: Observe that, in our LCS algorithm, we are The MATLAB programs for all algorithms in this paper are not taking into account the degrees of freedom provided by 4 available at. We executed our programs on a laptop running stabilizers. That is, if the logical operatorg ¯ is required to map the Windows 10 operating system (64-bit) with an Intel Core ¯ → ¯  ¯ → ¯  · Xi Xi , then an equivalent condition is to map Xi Xi s, i7-5500U @ 2.40GHz processor and 8GB RAM. For the where s ∈ S is any stabilizer element for the given code. A [[ 6 , 4, 2]]CSS code, it takes about 0.5 seconds to generate all  similar statement is true for Z¯i → Z¯ . An explicit example 8 symplectic solutions and their circuits for one logical Clif- i for this scenario is the CNOT → for the [[4, 2, 2]] code ford operator. For the [[5, 1, 3]]perfect code, it takes about 20 1 2 with the logical Paulis defned instead as X¯1 = X1X2, seconds to generate all 1024 solutions and their circuits. Note X¯ = X X , Z¯ = Z Z , Z¯ = Z Z . The operation that for step 5 in Algorithm 3, we use 1-qubit and 2-qubit 2 2 4 1 1 3 2 3 4 CNOT1→2 can simply be defned as swapping qubits unitary matrices (from Cliff 2 ) to calculate conjugations for Z 2 2 and 4, but this maps Z¯2 → Z2Z3 = Z¯1Z¯2 · g , where the Pauli operator on each qubit, at each circuit element at Z g = Z1Z2Z3Z4, instead of just Z¯2 → Z¯1Z¯2 as the above each depth, and then combine the results to compute the algorithm would typically require. conjugation ofg ¯ with a stabilizer generator or logical Pauli In principle, the LCS algorithm can be easily modifed to operator. Owing to our naive implementation, we observe consider these possibilities, but this signifcantly increases that most of the time is consumed in computing Kronecker the computational complexity of the algorithm. A better un- products and not in calculating the symplectic solutions. derstanding of the structure of logical Clifford operators for a given general stabilizer code, or even heuristics developed to 4[Online]. Available: https://github.com/nrenga/symplectic-arxiv18a identify which degrees of freedom are worth considering for

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

a given code, would greatly improve the quality of solutions The circuit for HN is just H applied to each of the m produced by the overall algorithm. qubits. 2) GL(m, F2) : Each nonsingular m × m binary matrix Q is associated with a symplectic transformation A IV. CONCLUSION Q given by In this article, we have used the binary symplectic group   to propose a systematic algorithm for synthesizing physi- Q 0 cal (Clifford) implementations of logical Clifford operators = , AQ −T (22) for any stabilizer code. This algorithm provides as solutions 0 Q all symplectic matrices corresponding to the desired logical − − − operator, each of which is subsequently transformed into a where Q T = (QT ) 1 = (Q 1)T . The matrix Q is also circuit by decomposing it into elementary forms. This de- associated with the unitary operator aQ which realizes composition is not unique, and in future work we will ad- the mapping ev → evQ. We verify this as follows. Note vdT dress optimization of the synthesis algorithm with respect to that D(c, 0)ev = ev+c and D(0, d)ev = (−1) ev.We , † circuit complexity, error-resilience, and also other nuanced calculate (aQD(c d)aQ)ev metrics discussed in the introduction. For such optimization to be feasible, one might have to explore opportunities for = , , aQD(c 0)D(0 d)evQ−1 (23) identifying and exploring the algebraic structure hidden in = − cdT , , the algorithm, since combinatorially the matrix inversion in- aQ( 1) D(0 d)D(c 0)evQ−1 (24) volved in Algorithm 2 could itself form a bottleneck. = − cdT − (vQ−1+c)dT ( 1) aQ( 1) evQ−1+c (25)

cdT (v+cQ)Q−1dT APPENDIX A: ELEMENTARY SYMPLECTIC = (−1) (−1) ev+cQ (26) TRANSFORMATIONS AND THEIR CIRCUITS cdT −1 T In this section, we verify that the physical operators listed = (−1) D(0, d(Q ) )D(cQ, 0)ev (27) in Table I are associated with the corresponding symplectic −T = D(cQ, dQ )ev (28) transformation [64]. Furthermore, we also provide circuits   that realize these physical operators (also see [56]). = D [c, d]AQ ev. (29) Since each physical operator in Table I is a unitary Clif- ford operator, it is enough to consider their actions on ele- Since the operator aQ realizes the map ev =|v → m ments of the Heisenberg-Weyl group HWN, where N = 2 . |vQ, the circuit for the operator is equivalent to the Let ev be a standard basis (column) vector in CN indexed binary circuit that realizes v → vQ. Evidently, this el- v ∈ F m by the vector 2 such that it has entry 1 in position ementary transformation encompasses CNOT opera- v and 0 elsewhere. More precisely, if v =[v1, v2,...,vm] tions and qubit permutations. For the latter, Q will be a 1 permutation matrix. Note that if aQ preserves the code then ev = ev ⊗ ev ⊗···ev , where e0  =|0, e1  1 2 m 0 space of a CSS code then the respective permutation   must be in the automorphism group of the constituent 0 =|1. Hence, we can simply write ev =|v=|v1⊗ classical code. This is the special case that is discussed 1 in detail by Grassl and Roetteler in [25]. ···⊗|vm. For a general Q, one can use the LU decomposition over F2 to obtain Pπ Q = LU , where Pπ is a permu- ⊗m 1) HN = H  : The single-qubit Hadamard operator tation matrix, L is lower triangular and U is upper 11 triangular. Note that L = U = 1 ∀ i ∈{1,...,m}. H  √1 satisfes HXH† = Z, HZH† = X. ii ii 2 1 −1 Then the circuit for Q frst involves the permutation T π −1 Hence, the action of H on a HW element D(a, b)is Pπ (or ), then CNOTs for L with control qubits N N , ,..., given by in the order 1 2 m and then CNOTs for U with control qubits in reverse order m, m − 1,...,1. The † † order is important because an entry L = 1 implies a HND(a, b)H = HND(a, 0)D(0, b)H (17) ji N N CNOT gate with qubit j controlling qubit i (with j > = , † = (HND(a 0)HN ) i), i.e, CNOT j→i, and similarly Lkj 1 implies the gate CNOTk→ j (with k > j). Since the gate CNOT j→i H D , b H† ( N (0 ) N ) (18) requires the value of qubit j before it is altered by = D(0, a)D(b, 0) (19) CNOTk→ j, it needs to be implemented frst. A similar reasoning applies to the reverse order of control qubits T = (−1)ab D(b, a) (20) for U. vRvT m×m T 3) tR = diag(ı ) : Each symmetric matrix R ∈ F ⇒ H D(a, b)H† = (−1)ab D ([a, b]) . (21) 2 N N is associated with a symplectic transformation TR given

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

a b † by X m Z m ,wehavegt D(a, b)g    t  = a1 b1 ⊗···⊗ at bt Im R Z X Z X TR = , (30)   0 Im ⊗ Xat+1 Zbt+1 ⊗···⊗Xam Zbm (40)   and with a unitary operator tR that realizes the map = (−1)a1b1 Xb1 Za1 ⊗···⊗(−1)at bt Xbt Zat vRvT ev → ı ev. We now verify that conjugation by tR   , † ⊗ Xat+1 Zbt+1 ⊗···⊗Xam Zbm . (41) induces TR. We calculate (tRD(a b)tR)ev , = , ˆ ¯  ··· ,  −vRvT abT We write (a b) (ˆaa¯ bb), wherea ˆ a1 at a¯ = ı tR(−1) D(0, b)D(a, 0)ev (31) at+1 ···am, bˆ  b1 ···bt , b¯  bt+1 ···bm. Then T T T −vRv ab (v+a)b T = ı (−1) tR(−1) ev+a (32) , ˆ ¯ † = − aˆbˆ ˆ , ¯ gt D(ˆaa¯ bb)gt ( 1) D(ba¯ aˆb) (42) abT −vRvT (v+a)bT (v+a)R(v+a)T   = (−1) ı (−1) ı ev+ (33) aˆbˆT a = (−1) D [ˆaa¯, bˆb¯]Gt , (43) abT aRaT vRaT +(v+a)bT ⎡ ⎤ = − − v+ ( 1) ı ( 1) e a (34) 00It 0 ⎢ ⎥ abT −aRaT (v+a)(b+aR)T ⎢ − ⎥ = − − v+ 0 Im t 00 ( 1) ı ( 1) e a (35) where Gt = ⎢ ⎥ . (44) ⎣It 000⎦ abT −aRaT = (−1) ı D(0, b + aR)D(a, 0)ev (36) 000Im−t     abT −aRaT a(b+aR)T = (−1) ı (−1) D(a, b + aR)ev (37) It 0 00 Defning Ut  , Lm−t  , we then write   00 0 Im−t T aRa L − U = ı D ([a, b]TR) ev. (38) G = m t t . Similar to part 1 above, the circuit t Ut Lm−t T for g is simply H applied to each of the frst t qubits. E a, b  ıab D a, b t Hence, for ( ) ( ), we have Although this is a special case where the Hadamard op- , † = abT aRaT , + = , tRE(a b)tR ı ı D(a b aR) E([a b]TR) erator was applied to consecutive qubits, we note that as required. We derive the circuit for this unitary the symplectic transformation for Hadamards applied operator by observing the action of TR on the standard to arbitrary nonconsecutive qubits can be derived in a , ,..., , , ,..., , basis vectors [e1 0] [em 0], [0 e1] [0 em] similar fashion. F 2m ∈{ ,..., } of 2 , where i 1 m , which captures the effect of tR on the (basis) elements X1,...,Xm, Hence, we have demonstrated the elementary symplectic , F Z1,...,Zm of HWN, respectively, under conjugation. transformations in Sp(2m 2) that are associated with arbi- Assume as the frst special case that R has nonzero trary Hadamard, Phase, Controlled-Z and Controlled-NOT entries only in its (main) diagonal. If Rii = 1 then we gates. Since we know that these gates, along with HWN, , = , generate the full Clifford group [16], these elementary sym- have [ei 0]TR [ei ei]. This indicates that tR maps Xi → XiZi ≈ Yi. Since we know that the phase gate plectic transformations form a universal set corresponding to Pi on the ith qubit performs exactly this map under physical operators in the Clifford group. conjugation, we conclude that the circuit for tR involves Pi. We proceed similarly for every i ∈{1,...,m} such APPENDIX B: PROOF OF THEOREM 1 AB that R = 1. Let F = [ ] so that [ AB]  [ AB]T = 0 and ii CD Now consider the case where R = R = 1 (since R is   ij ji  T =  T =  symmetric). Then, we have [ CD] CD 0 since F F . We will perform a sequence of row and column operations to transform F into , = , , , = , .   = [ei 0]TR [ei e j] [e j 0]TR [e j ei] (39) the form TR1 for some symmetric R1. If rank(A) k −1 → → then there exists a row transformation Q11 and a column This indicates that tR maps Xi XiZ j and Xj ZiXj. − − − 1 1 1 = Ik 0 Since we know that the controlled-Z gate CZij on transformation Q2 such that Q11 AQ2 00 .Using qubits (i, j) performs exactly this map under conjuga- the notation for elementary symplectic transformations −1 − AB tion, we conclude that the circuit for tR involves CZij. discussed above, we apply Q11 and AQ 1 to [ ] and obtain We proceed similarly for every pair (i, j) such that   2   −  R = R = 1. Q 1 0 I 0 R E ij ji Q−1AQ−1B 2 = k k Finally, we note that the symplectic transformation 11 11 T 00EB− 0 Q2 m k associated with the operator HNtRHN is  TR  =     I  , m 0 . [A B ] RIm = ⊗ − × − 4) gt H2t I2m−t : Since H2t is the t-fold Kronecker where Bm−k is an (m k) (m k) matrix. Since the above product of H and since D(a, b) = Xa1 Zb1 ⊗···⊗ result is again the top half of a symplectic matrix, we have

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

    T [ A B ]  [ A B ] = 0 which implies Rk is symmetric, E = 0 APPENDIX C: MATLAB CODE FOR ALGORITHM 2 and hence rank(Bm−k ) = m − k. Therefore we determine an invertible matrix Qm−k which transformsBm−k to Im−k under − row operations. Then, we apply Q 1  Ik 0 12 0 Qm−k     −1 −1 −1 −1 −1 Q2 0 Q12 Q11 AQ12 Q11 B T 0 Q2   = Ik 0 Rk E . 00 0 Im−k

Now, we observe that we can apply row operations to this  −1  matrix and transform E to 0. We left multiply by Q13 I E k : 0 Im−k     −1 −1 −1 −1 −1 −1 −1 Q2 0 Q13 Q12 Q11 AQ13 Q12 Q11 B T 0 Q2  = Ik 0 Rk 0 . 00 0 Im−k   Rk 0 Since the matrix R2  is symmetric, we apply the 00 elementary transformation TR2 from the right to obtain ⎡ ⎤  Ik 0 Rk 0  ⎢ ⎥ Ik 0 Rk 0 ⎢ 0 Im−k 00⎥ Ik 0 00 ⎣ ⎦ = . 00 0 Im−k 00Ik 0 000 Im−k 00 0 Im−k

Finally, we apply the elementary transformation Gk = U L − k m k to obtain Lm−k Uk ⎡ ⎤  Ik 0 00  ⎢ ⎥ Ik 0 00 ⎢ 000 Im−k ⎥ Ik 0 00 ⎣ ⎦ = 000 Im−k 00Ik 0 0 Im−k 00 0 Im−k 00   = Im 0 .

  = Hence we have transformed F to the form TR1 Im 0 −1  −1 −1 −1 , i.e., if we defne Q1 Q13 Q12 Q11 then we R1 Im have

− −  =  . A 1 FA 1 TR2 Gk TR1 Q1 Q2

−1 = , Rearranging terms and noting that AQ AQ−1 −1 = , −1 = , −1 = =  Gk Gk TR TR2 we obtain F AQ1 TR1 2  GkTR2 AQ2 .

VOLUME 1, 2020 2501217 IEEE Transactions on uantumEngineering Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES

for highlighting that the proof of Theorem 7 is incomplete without the counting argument. S. Kadhe would like to thank Robert Calderbank for his hospitality during S. Kadhe’s visit to Duke University. Any opinions, fndings, conclusions, and recommendations expressed in this material are those of the authors and do not necessarily refect the views of the sponsors.

REFERENCES [1] N. Rengaswamy, R. Calderbank, S. Kadhe, and H. D. Pfster, “Synthesis of logical Clifford operators via symplectic geometry,” in Proc. IEEE Int. Symp. Inf. Theory. 2018, pp. 791–795, doi: 10.1109/ISIT.2018.8437652. [2] P. W. Shor, “Scheme for reducing decoherence in quantum com- puter memory,” Phys. Rev. A, vol. 52, no. 4, pp. R2493–R2496, 1995, doi: 10.1088/0256-307X/14/7/003. [3] A. R. Calderbank and P. W. Shor, “Good quantum error-correcting codes exist,” Phys. Rev. A, vol. 54, pp. 1098–1105, Aug. 1996, doi: 10.1103/PhysRevA.54.1098. [4] A. M. Steane, “Simple quantum error-correcting codes,” Phys.Rev.A, vol. 54, no. 6, pp. 4741–4751, 1996, doi: 10.1103/PhysRevA.54.4741. [5] R. Calderbank, E. Rains, P. Shor, and N. Sloane, “Quantum error cor- rection via codes over GF(4),” IEEE Trans. Inf. Theory, vol. 44, no. 4, pp. 1369–1387, Jul. 1998, doi: 10.1109/18.681315. [6] D. Gottesman, “Stabilizer codes and quantum error correction,” Ph.D. dissertation, Dept. Phys., California Inst. Technol., Pasadena, CA, USA, 1997. [Online]. Available: https://arxiv.org/abs/quant-ph/9705052 [7] D. Bacon, “Operator quantum error-correcting subsystems for self- correcting quantum memories,” Phys. Rev. A, vol. 73, 2006, Art. no. 012340, doi: 10.1103/PhysRevA.73.012340. [8] T. J. Yoder, “Universal fault-tolerant quantum computation with Bacon- Shor codes,” 2017. [Online]. Available: https://arxiv.org/pdf/1705.01686 [9] D. Gottesman and I. L. Chuang, “Demonstrating the viability of universal quantum computation using teleportation and single-qubit operations,” Nature, vol. 402, no. 6760, pp. 390–393, 1999, doi: 10.1038/46503. [10] S. Bravyi and J. Haah, “Magic-state distillation with low overhead,” Phys. Rev. A, vol. 86, no. 5, 2012, Art. no. 052329, doi: 10.1103/PhysRevA.86.052329. [11] S. Bravyi and A. Kitaev, “Universal quantum computation with ideal Clif- ford gates and noisy ancillas,” Phys. Rev. A, vol. 71, no. 2, 2005, Art. no. 022316, doi: 10.1103/PhysRevA.71.022316. [12] M. M. Wilde, “Logical operators of quantum codes,” Phys. Rev. A, vol. 79, no. 6, 2009, Art. no. 062322, doi: 10.1103/PhysRevA.79.062322. [13] T. Brun, I. Devetak, and M.-H. Hsieh, “Correcting quantum errors with entanglement,” Science, vol. 314, no. 5798, pp. 436–439, 2006, doi: 10.1126/science.1131563. [14] T. A. Brun, I. Devetak, and M.-H. Hsieh, “Catalytic quantum error correc- tion,” IEEE Trans. Inf. Theory, vol. 60, no. 6, pp. 3073–3089, Jun. 2014, doi: 10.1109/TIT.2014.2313559. [15] A. R. Calderbank, E. M. Rains, P. W. Shor, and N. J. A. Sloane, “Quantum error correction and orthogonal geometry,” Phys.Rev.Lett., vol. 78, no. 3, pp. 405–408, 1997, doi: 10.1103/PhysRevLett.78.405. [16] D. Gottesman, “An introduction to quantum error correction and fault- tolerant quantum computation,” 2009. [Online]. Available: http://arxiv. ACKNOWLEDGMENT org/abs/0904.2557 The authors would like to thank Jungsang Kim for point- [17] D. Litinski, “A game of surface codes: Large-scale ing them to the work of Chao and Reichardt, and Jianfeng with lattice surgery,” Quantum, vol. 3, p. 128, Mar. 2019, doi: 10.22331/q- Lu for helpful discussions regarding Theorem 7. They are 2019-03-05-128. [18] V. Kliuchnikov, D. Maslov, and M. Mosca, “Asymptotically optimal ap- also very thankful to the anonymous reviewers (including proximation of single qubit unitaries by Clifford and T circuits using a at conferences where this article was presented as a poster) constant number of ancillary qubits,” Phys.Rev.Lett., vol. 110, no. 19, who provided helpful feedback to improve the presentation May 2013, Art. no. 190502, doi: 10.1103/PhysRevLett.110.190502. [19] M. Amy, D. Maslov, M. Mosca, and M. Roetteler, “A meet-in-the-middle and keep the article as self-contained as possible. In par- algorithm for fast synthesis of depth-optimal quantum circuits,” IEEE ticular, they would like to thank one reviewer who pointed Trans. Comput. Des. Integr. Circuits Syst., vol. 32, no. 6, pp. 818–830, out the example in Remark 12 and suggested us to specif- Jun. 2013, doi: 10.1109/TCAD.2013.2244643. [20] D. Maslov and M. Roetteler, “Shorter stabilizer circuits via Bruhat decom- cally mention that they are ignoring the stabilizer degrees of position and transformations,” IEEE Trans. Inf. Theory, freedom. They would also like to thank Jean-Pierre Tillich vol. 64, no. 7, pp. 4729–4738, Jul. 2018, doi: 10.1109/TIT.2018.2825602.

2501217 VOLUME 1, 2020 IEEE Transactions on Rengaswamy et al.: LOGICAL CLIFFORD SYNTHESIS FOR STABILIZER CODES uantumEngineering

[21] A. Fagan and R. Duncan, “Optimising Clifford circuits with quan- [43] J. Haah and M. B. Hastings, “Codes and protocols for distilling tomatic,” . Proc. Theor. Comput. Sci., vol. 287, pp. 85–105, 2019, T, controlled-S, and Toffoli gates,” Quantum, vol. 2, p. 71, 2017, doi: 10.4204/EPTCS.287.5. doi: 10.22331/q-2018-06-07-71. [22] R. Iten, O. Reardon-Smith, L. Mondada, E. Redmond, R. S. Kohli, and R. [44] C. Gidney and A. G. Fowler, “Effcient magic state factories with a cat- Colbeck, “Introduction to UniversalQCompiler,” 2019. [Online]. Avail- alyzed |CCZ> to 2|T> transformation,” Quantum, vol. 3, p. 135, 2018, able: http://arxiv.org/abs/1904.01072 doi: 10.22331/q-2019-04-30-135. [23] R. Duncan, A. Kissinger, S. Pedrix, and J. van de Wetering, “Graph- [45] B. Zeng, A. Cross, and I. L. Chuang, “Transversality versus universality theoretic simplifcation of quantum circuits with the ZX-calculus,” Quan- for additive quantum codes,” IEEE Trans. Inf. Theory, vol. 57, no. 9, tum, vol. 4, p. 279, 2020, doi: 10.22331/q-2020-06-04-279. pp. 6272–6284, Sep. 2011, doi: 10.1109/TIT.2011.2161917. [24] A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, “Sur- [46] B. Eastin and E. Knill, “Restrictions on transversal encoded quantum face codes: Towards practical large-scale quantum computation,” Phys. gate sets,” Phys.Rev.Lett., vol. 102, no. 11, 2009, Art. no. 110502, Rev. A, vol. 86, no. 3, 2012, Art. no. 032324, doi: 10.1103/PhysRevA.86. doi: 10.1103/PhysRevLett.102.110502. 032324. [47] M. Newman and Y. Shi, “Limitations on transversal computation through [25] M. Grassl and M. Roetteler, “Leveraging automorphisms of quantum quantum homomorphic encryption,” Quantum Inf. Comput., vol. 18, codes for fault-tolerant quantum computation,” in Proc. IEEE Int. Symp. nos. 11/12, pp. 0927–0948, Apr. 2018, doi: 10.5555/3370220.3370223. Inf. Theory. Jul. 2013, pp. 534–538, doi: 10.1109/ISIT.2013.6620283. [48] S. Bravyi, D. Gosset, and R. König, “Quantum advantage with [26] A. Kubica and M. E. Beverland, “Universal transversal gates with color shallow circuits.” Sci., vol. 362, no. 6412, pp. 308–311, 2018, codes: A simplifed approach,” Phys. Rev. A, vol. 91, no. 3, 2015, Art. no. doi: 10.1126/science.aar3106. 032330, doi: 10.1103/PhysRevA.91.032330. [49] S. Bravyi, D. Gosset, R. Koenig, and M. Tomamichel, “Quantum ad- [27] R. Chao and B. W. Reichardt, “Fault-tolerant quantum computation vantage with noisy shallow circuits,” Nat. Phys., 2020, to be published, with few qubits,” npj Quantum Inf., vol. 4, no. 1, 2018, Art. no. 42, doi: 10.1038/s41567-020-0948-z. doi: 10.1038/s41534-018-0085-z. [50] D. Gottesman, “Theory of fault-tolerant quantum computation,” Phys. Rev. [28] T. Can, N. Rengaswamy, R. Calderbank, and H. D. Pfster, “Kerdock codes A, vol. 57, no. 1, pp. 127–137, Jan 1998, doi: 10.1103/PhysRevA.57.127. determine unitary 2-designs,” IEEE Trans. Inf. Theory, vol. 66, no. 10, [51] N. Rengaswamy, R. Calderbank, S. Kadhe, and H. D. Pfster, “Synthesis pp. 6104–6120, Oct. 2020, doi: 10.1109/TIT.2020.3015683. of Logical Clifford Operators via Symplectic Geometry,” 2018. [Online]. [29] J. Combes, C. Granade, C. Ferrie, and S. T. Flammia, “Logical random- Available: http://arxiv.org/abs/1803.06987v1 ized benchmarking,” 2017. [Online]. Available: http://arxiv.org/abs/1702. [52] N. Rengaswamy, R. Calderbank, and H. D. Pfster, “Unifying the Clifford 03688 hierarchy via symmetric matrices over rings,” Phys. Rev. A, vol. 100, no. [30] E. Magesan, J. M. Gambetta, and J. Emerson, “Characterizing quantum 2, 2019, Art. no. 022304, doi: 10.1103/PhysRevA.100.022304. gates via randomized benchmarking,” Phys.Rev.A, vol. 85, no. 4 2012, [53] A. Ekert and C. Macchiavello, “Quantum error correction for commu- Art. no. 042311, doi: 10.1103/PhysRevA.85.042311. nication,” Phys. Rev. Lett., vol. 77, no. 12, pp. 2585–2588, Sep. 1996, [31] P. Murali, J. M. Baker, A. J. Abhari, F. T. Chong, and M. Martonosi, doi: 10.1103/PhysRevLett.77.2585. “Noise-adaptive compiler mappings for noisy intermediate-scale quantum [54] C. Chamberland, P. Iyer, and D. Poulin, “Fault-tolerant quantum comput- computers,” in Proc. 24th Int. Conf. Archit. Support Program. Lang. Oper. ing in the Pauli or Clifford frame with slow error diagnostics,” Quantum, Syst., 2019, pp. 1015–1029, doi: 10.1145/3297858.3304075. vol. 2, p. 43, 2018, doi: 10.22331/q-2018-01-04-43. [32] J. Preskill, “Quantum Computing in the NISQ era and beyond,” 2018. [55] T. Can, “The Heisenberg-Weyl group, fnite symplectic geometry, and [Online]. Available: https://arxiv.org/abs/1801.00862 their applications,” Senior thesis, Dept. Mathematics, Duke Univ., [33] A. Paler, “On the infuence of initial qubit placement during NISQ cir- Durham, NC, USA, May 2018. cuit compilation,” in Quantum Technol. and Optimization Problems,S. [56] J. Dehaene and B. De Moor, “Clifford group, stabilizer states, and lin- Feld and C. Linnhoff-Popien, Eds. Berlin, Germany: Springer, 2019, ear and quadratic operations over GF(2),” Phys. Rev. A, vol. 68, no. 4, pp. 207–217, doi: 10.1007/978-3-030-14082-3_18. Oct. 2003, Art. no. 042318, doi: 10.1103/PhysRevA.68.042318. [34] Y.Shi, N. Leung, P. Gokhale, Z. Rossi, D. I. Schuster, H. Hoffmann, and F. [57] Z. Webb, “The Clifford group forms a unitary 3-design,” Quan- T. Chong, “Optimized compilation of aggregated instructions for realistic tum Inf. Comput., vol. 16, nos. 15/16, pp. 1379–1400, 2016. quantum computers,” in Proc. 24th Int. Conf. Archit. Support Program. doi: 10.5555/3179439.3179447. Lang. Oper. Syst., 2019, pp. 1031–1044, doi: 10.1145/3297858.3304018. [58] P. Diaconis and M. Shahshahani, “The subgroup algorithm for generating [35] P. Murali, A. Javadi-Abhari, F. T. Chong, and M. Martonosi, “For- uniform random variables,” Prob. Eng. Inf. Sci., vol. 1, no. 1, pp. 15–32, mal constraint-based compilation for noisy intermediate-scale quan- 1987, doi: 10.1017/S0269964800000255. tum systems,” Microprocess. Microsyst., vol. 66, pp. 102–112, 2019, [59] R. Koenig and J. A. Smolin, “How to effciently select an arbitrary Clifford doi: 10.1016/j.micpro.2019.02.005. group element,” J. Math. Phys., vol. 55, no. 12, Dec. 2014, Art. no. 122202, [36] B. Nash, V. Gheorghiu, and M. Mosca, “Quantum circuit optimizations doi: 10.1063/1.4903507. for NISQ architectures,” Quantum Sci. Technol., vol. 5, no. 2, 2020, Art. [60] P. W. Jones, A. Osipov, and V. Rokhlin, “A randomized approximate no. 025010, doi: 10.1088/2058-9565/ab79b1. nearest neighbors algorithm,” Appl. Comput. Harmon. Anal., vol. 34, no. 3, [37] R. Harper and S. T. Flammia, “Fault-tolerant logical gates in the IBM pp. 415–444, 2013, doi: 10.1016/j.acha.2012.07.003. quantum experience,” Phys. Rev. Lett., vol. 122, no. 8, 2019, Art. no. [61] K. Choromanski, F. Fagan, C. Gouy-Pailler, A. Morvan, T. Sarlos, and J. 080504, doi: 10.1103/PhysRevLett.122.080504. Atif, “TripleSpin - a generic compact paradigm for fast machine learn- [38] N. M. Linke et al., “Fault-tolerant quantum error detection,” Sci. Adv.,vol. ing computations,” 2016. [Online]. Available: http://arxiv.org/abs/1605. 3, no. 10, Oct. 2017, Art. no. e1701074, doi: 10.1126/sciadv.1701074. 09046. [39] R. Ozeri, “The trapped-ion qubit tool box,” Contemp. Phys., vol. 52, no. [62] N. Rengaswamy, R. Calderbank, M. Newman, and H. D. Pfster, “On 6, pp. 531–550, 2011, doi: 10.1080/00107514.2011.603578. optimality of CSS codes for transversal T,” IEEE J. Sel. Areas Inf. Theory, [40] Y. Nam et al., “Ground-state energy estimation of the water molecule on to be published. [Online]. Available: http://arxiv.org/abs/1910.09333 a trapped-ion quantum computer,” npj Quantum Inf., vol. 6, no. 1, p. 33, [63] A. Salam, E. Al-Aidarous, and A. E. Farouk, “Optimal symplectic house- 2020, doi: 10.1038/s41534-020-0259-3. holder transformations for SR decomposition,” Lin. Algebra Its Appl., [41] N. M. Linke et al., “Experimental comparison of two quantum computing vol. 429, pp. 1334–1353, 2008, doi: 10.1016/j.laa.2008.02.029. architectures,” Proc. Nat. Acad. Sci., vol. 114, no. 13, pp. 3305–3310, [64] T. Can, “An Algorithm to Generate a Unitary Transformation from Log- 2017, doi: 10.1073/pnas.1618020114. arithmically Many Random Bits,” Research Independent Study, Dept. [42] J. Haah, M. B. Hastings, D. Poulin, and D. Wecker, “Magic state dis- Mathematics, Duke Univ., Durham, NC, USA, 2017. tillation with low space overhead and optimal asymptotic input count,” [65] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Quantum, vol. 1, p. 31, 2017, doi: 10.22331/q-2017-10-03-31. Information. Cambridge, U.K.: Cambridge Univ. Press, 2010.

VOLUME 1, 2020 2501217