Transversal diagonal logical operators for stabiliser codes

Storing quantum information in a quantum error correction code can protect it from errors, but the ability to transform the stored quantum information in a fault tolerant way is equally important. Logical Pauli group operators can be implemented on Calderbank-Shor-Steane (CSS) codes, a commonly-studied category of codes, by applying a series of physical Pauli X and Z gates. Logical operators of this form are fault-tolerant because each qubit is acted upon by at most one gate, limiting the spread of errors, and are referred to as transversal logical operators. Identifying transversal logical operators outside the Pauli group is less well understood. Pauli operators are the first level of the Clifford hierarchy which is deeply connected to fault-tolerance and universality. In this work, we study transversal logical operators composed of single- and multi-qubit diagonal Clifford hierarchy gates. We demonstrate algorithms for identifying all transversal diagonal logical operators on a CSS code that are more general or have lower computational complexity than previous methods. We also show a method for constructing CSS codes that have a desired diagonal logical Clifford hierarchy operator implemented using single qubit phase gates. Our methods rely on representing operators composed of diagonal Clifford hierarchy gates as diagonal XP operators and this technique may have broader applications.


Overview
Quantum error correction has become a very active area of research because of its potential to mitigate noise in complex quantum devices.Recent experimental results have validated the storage of quantum information in the codespace of a quantum error correction code as a practical way of protecting it from noise (see [1], [2] and [3]).Many of these initial demonstrations have made use of CSS codes [4], a well-studied class of quantum error correction codes that are relatively simple to analyse and implement.
To implement algorithms on quantum computers, we also need to transform the stored quantum information in a fault-tolerant way.One method of implementing fault-tolerant logical operations on CSS codes is to use transversal logical operators.Transversal logical operators have depth-one circuit implementations involving single or multi-qubit gates.Such implementations are considered fault-tolerant because an error on one physical qubit can only spread to a limited number of other qubits when applying the logical operator.Whilst the Eastin-Knill theorem rules out the existence of a quantum error correcting code with a set of transversal operators that is universal [5], determining the transversal gates of a quantum error correction code is key to designing a fault-tolerant architecture.
Deeply connected to fault tolerance and universality is the Clifford hierarchy [6] of unitary operators.The first level of the Clifford hierarchy is the Pauli group CH 1 := iI, X, Z .Conjugation of Paulis by operators at level t + 1 results in an operator at level t.The level t + 1 operators A ∈ CH t+1 are then defined recursively as those for which ABA −1 ∈ CH t for all B ∈ CH 1 .Level 2 Clifford hierarchy gates include the single-qubit Hadamard and S := √ Z gates, as well as the 2-qubit controlled-Z (CZ) gates.Level 3 gates include the single-qubit T := √ S gate as well as the multi-qubit controlled-S (CS) and controlled-controlled-Z (CCZ) gates.A set of gates that includes all level-2 gates and at least one level-3 gate is universal [7].
Logical Pauli group operators can be implemented transversally on CSS codes and identifying these is relatively straightforward.Identifying transversal logical operators at higher levels of the Clifford hierarchy is more challenging and existing methods are of exponential complexity in either the number of physical or logical qubits in the code.Some classes of CSS codes with high degrees of symmetry are known to have non-Pauli transversal logical operators.Examples using single-qubit diagonal gates include the 7-qubit Steane code [8], two-dimensional color codes [9] and triorthogonal codes [10].Examples of CSS codes which have logical operators made from single and multi-qubit gates include the two-dimensional toric code [11], codes with ZX-symmetries [12] and symmetric hypergraph product codes [13].
In this paper, we present a suite of method and algorithms for identifying diagonal transversal logical operators on any CSS code, without any knowledge of any symmetries of the code.The building blocks of our logical operators are physical single-or multi-qubit diagonal gates, at a given level t of the Clifford hierarchy.Our methods scale as a polynomial in the number of physical and/or logical qubits in the code, with one exception.We also give a method for constructing a CSS code that has a transversal implementation of a desired diagonal logical Clifford hierarchy operator using single-qubit gates.Our new algorithms use the XP formalism, introduced in Ref. [14], which is a powerful tool for representing the logical operator structure of a stabiliser code.

Existing Work on Transversal Logical Operators
We briefly review previous methods for identifying diagonal logical operators of arbitrary CSS codes, and methods for constructing CSS codes with a desired transversal logical operator.In Ref. [15], a method is given to find all logical operators at level 2 of the Clifford hierarchy for a CSS code by mapping it to a classical code over GF (4).This method involves calculating the automorphism group of the classical code, which has exponential complexity in the number of qubits in the stabiliser code [16].
There has also been a significant amount of work on logical operators constructed from singleand multi-qubit diagonal Clifford hierarchy gates.In Ref. [17], operators composed of diagonal Clifford hierarchy gates on one or two qubits are shown to be representable as symmetric matrices over Z N , referred to as Quadratic Form Diagonal (QFD) gates.Necessary and sufficient conditions for a QFD gate to act as a logical operator on a CSS code are then presented.In Ref. [18], a method of generating circuits using multi-qubit gates which implement arbitrary logical operators at level 2 of the Clifford hierarchy is presented.A method for generating CSS codes with transversal diagonal logical operators at increasing levels of the Clifford hierarchy is presented in Ref. [19], along with a method to increase the Z-distance of such codes.In Ref. [14], we demonstrated an algorithm for finding all diagonal logical operators composed of single-qubit phase gates which, for CSS codes, involves taking the kernel modulo N of a matrix with n + 2 k columns where n and k are the number of physical and logical qubits respectively.

Contribution of this Work
In this work, we present efficient methods to identify and test diagonal logical operators on CSS codes using both single and multi-qubit diagonal Clifford hierarchy gates as building blocks.These methods generalise to non-CSS stabiliser codes.We also present a technique for generating CSS codes with implementations of any desired diagonal Clifford hierarchy logical operator using singlequbit phase gates.
We first consider operators composed of single-qubit phase gates at level t of the Clifford hierarchy.We show that these can be represented as diagonal XP operators of precision N = 2 t .For logical operators of this form, we demonstrate the following algorithms that apply to any CSS code and at any desired level of the Clifford hierarchy: 1. Finding a generating set of diagonal logical identity operators for the code: An XP operator may act as a logical identity, but may not be an element of the stabiliser group of a CSS code.The logical identities are used as inputs to several other algorithms (Section 3.1) 2. Search for an implementation of a desired logical controlled-phase operator on the code: useful for checking if a given CSS code has a transversal implementation of a particular logical operator and for checking the results of other algorithms (Section 3.2); 3. Determining if a given diagonal operator acts as a logical operator on the code: This method is of linear complexity in the number of independent X-checks whereas existing methods are of exponential complexity (Section 3.3); 4. Finding a generating set of diagonal logical operators on the code: The generating set gives us a complete understanding of the diagonal logical operator structure of a CSS code, and can be used on CSS codes with a large number of physical and logical qubits at any desired level of the Clifford hierarchy (Section 3.4);

5.
Expressing the action of a diagonal logical operator as a product of logical controlled-phase gates: The action of a logical operator can be difficult to interpret, particularly for codes with a large number of logical qubits.This method greatly simplifies the interpretation of logical actions (Section 3.5).
We then show that multi-qubit diagonal Clifford hierarchy gates acting on a codesepace can be represented as diagonal XP operators acting on a larger Hilbert space via an embedding operator (Section 4.3).We demonstrate algorithms for: 6. Finding depth-one implementations of logical operators composed of diagonal Clifford hierarchy gates: on small CSS codes, this allows us to identify and verify the depth-one logical operators of [11][12][13] with no knowledge of the symmetry of the code (Section 4.4); Apart from the depth-one search algorithm, the eight algorithms have complexity that is polynomial in the parameters n, k, r of the CSS code (see below).As a result, they can be applied to 'large' codes that have so far been out of reach of existing methods.There are no restrictions on the level of the Clifford hierarchy or maximum support size of the physical gates used in the methods.A summary of the characteristics and computational complexity of search and test algorithms is presented in Table 1.Complexity is expressed in terms of the following variables: • Required level of the Clifford hierarchy t; • Number of physical qubits n in the CSS code; • Number of logical qubits k in the CSS code; • Number of independent X-checks r in the CSS code; The space complexity of the algorithm is expressed in terms of the size of the key matrices used.The time complexity is expressed in terms of the number of kernel operations performed on the key matrices -these operations dominate the complexity of the algorithms.
The algorithms have been implemented in a Python GitHub repository accessible under the GNU General Public License.A range of sample codes are also available for testing in this repository, including Reed-Muller codes, hyperbolic surface codes, triorthogonal codes and symmetric hypergraph product codes.

Determine Action of Diagonal Logical Operator
Single-qubit

Background
This Section reviews the necessary background material for this work.We first introduce the Clifford hierarchy of diagonal operators and introduce a vector representation of these.We then outline notation and fundamental properties of CSS codes.Next, we define what we mean by a diagonal logical operator on a CSS code.We then present an example illustrating the types of diagonal logical operators we consider in this work for the well-known [[4, 2, 2]] code.We then review the XP stabiliser formalism and some fundamental properties of the XP operators, which we will use to represent logical operators composed of diagonal Clifford hierarchy gates.We explain the logical operator group structure in the XP formalism, which is somewhat different than in the Pauli stabiliser formalism.

Diagonal Clifford Hierarchy Operators
Here we review the properties of operators in the diagonal Clifford hierarchy.We will use diagonal gates at level t of the Clifford hierarchy on n qubits as the building blocks for logical operators.The diagonal Clifford hierarchy operators at each level form a group generated by the following operators [20]: • Level t + 1: Square roots and controlled versions of operators from level t.
At each level, we refer to the generators as level-t controlled-phase gates.Where an operator is an element of the diagonal Clifford hierarchy group at level t, we say that it is composed of level-t controlled-phase gates.
The single-qubit phase gate at level t is of form diag(1, exp(2πi/N )) where N := 2 t .If an operator is an element of the group generated by single-qubit phase gates at level t, we say it is composed of level-t phase gates.
The matrix form of any diagonal transversal logical operator of a CSS code must have entries of form exp(qπi/2 t ) for integers q, t, as shown in Ref. [21].Such matrices are elements of the diagonal Clifford hierarchy group at some level, and so considering logical operators composed of controlled-phase gates yields all possible diagonal transversal logical operators on a CSS code.

Vector Representation of Controlled-Phase Operators
We now introduce a vector representation of controlled-phase operators that underpins our analytical methods.Fix a level t of the Clifford hierarchy (Section 2.1) and let N := 2 t .Let ω := e πi/N be a (2N )-th root of unity.The operator CP N (q, v), where q ∈ Z 2N and v is a binary vector of length n, is defined as follows by its action on a computational basis vectors |e for e ∈ Z n 2 : The relation is a partial order for binary vectors based on their support (the set of indices where the vector is non-zero).The expression v e indicates supp(v) ⊆ supp(e) ⇐⇒ ev = v where vector multiplication is componentwise.For an integer 0 ≤ i < n, we will also write i The phase applied can be expressed more concisely as follows: ( Each generator of the diagonal Clifford hierarchy can be written in vector form.To see this, we note that the phase gate at level t can be written as P := diag(1, ω 2 ).The phase operator acting on qubit i can be written in vector form as where b n i is the length n binary vector, which is all zero apart from component i which is one.Similarly, the operator where b n ij is zero apart from components i and j.The operators of form CP N (2 wt(v) , v) with 1 ≤ wt(v) ≤ t are the generators of the level-t controlled-phase operators presented in Section 2.1.

Example 2.1 (Vector Representation of Level 3 Controlled-Phase Operators)
This example illustrates the vector representation of level 3 diagonal Clifford hierarchy operators.At level t = 3 the generators have vector representations as follows: We also include ωI = CP 8 (1, 0) as a generator at the third level of the hierarchy as phases of this form occur in the commutation relation for controlled-phase operators -see Equations (30) and (31).

CSS Codes
Here we introduce some key notation and results for CSS codes.Our notation for CSS codes is somewhat different to that in the literature and is used because it simplifies the statement of our results.Although we focus on CSS codes in this work, the methods are applicable to any stabiliser code as set out in Appendix C. For our purposes, a CSS code on n qubits is specified by an r × n binary matrix S X the rows of which we refer to as the X-checks and a k × n binary matrix L X whose rows are referred to as the X-logicals.We assume that the rows of S X and L X are independent binary vectors -otherwise we can use linear algebra modulo 2 to ensure this.The Z-checks can be calculated by taking the kernel modulo 2 of the X-checks and X-logicals, i.e., In Equation ( 6), the notation ker Z2 refers to the basis in reduced row echelon form of the kernel modulo 2 of a binary matrix.We form stabiliser generators S X , S Z from the rows of S X and S Z in the obvious way -if x is a row of S X then the corresponding stabiliser generator is 0≤i<n X . The codespace is the simultaneous +1 eigenspace of the stabiliser group S X , S Z and is a subspace of H n 2 .The codespace is spanned by 2 k canonical codewords which are indexed by binary vectors v of length k and are defined as follows: In the above expression, matrix operations are modulo 2. For simplicity, we are not concerned with normalising codeword states.It may be possible to make a different choice of basis for the span L X over Z 2 .The choice of basis affects the labelling of the canonical codewords by binary vectors v of length k, but does not otherwise change the set of canonical codewords.

Logical Operators of CSS Codes
We now describe what we mean by a logical operator on a CSS code.Let C : H k 2 → H n 2 be the encoding operator which takes computational basis vectors to canonical codewords of Equation (7) i.e.C|v = |v L for v ∈ Z k 2 .Now let B be a unitary operator acting on k qubits.We say that an operator B acting on n qubits is a logical B operator if A unitary operator B is diagonal if we can write B := diag(c) for some complex-valued vector c of length 2 k representing the phase applied to each computational basis vector, i.e.
If B is a diagonal logical operator, then B is diagonal as well, though the converse is not necessarily true.From Equation (8) and Equation ( 7), we have: As a result, we can check if B is a logical B operator by doing the following: 2 , check that B|e uv = c v |e uv .This method of checking whether a diagonal unitary is a logical operator involves O(2 r+k ) steps; we present a method in Section 3.3 with linear complexity in r.
We say that an operator B is a logical identity if B|v L = |v L for all v ∈ Z k 2 -that is, it fixes each canonical codeword and hence each element of the codespace.If B is diagonal, as a consequence of Equation (10), it is a logical identity if and only if B|e uv = |e uv for all u ∈ Z r 2 , v ∈ Z k 2 .Whether a diagonal operator is a logical identity or a logical operator is independent of the choice of basis for the span L X (see Section 2.3).However, the logical action of the operator depends on the labelling the canonical codewords and so is dependent on the choice of basis for L X .

Example 2.2 (Transversal Logical Operators of [[4,2,2]] Code)
We use the [[4,2,2]] code to illustrate the types of transversal logical operators we consider in this work.Using the notation introduced in Section 2.3, the X-checks and X-logicals of the code are: In this case, there are r = 1 X-checks and k = 2 X-logicals.There are 2 k = 4 canonical codewords which we calculate using Equation (7): We can calculate the single Z-check as follows: Readers can verify that Z ⊗4 acts as a logical identity by checking that Z ⊗4 |v L = |v L for each of the canonical codewords.
The following are examples of transversal diagonal logical operators composed of controlledphase gates at level 2 whose actions can be verified by applying the method of Section 2.4:

The XP Formalism
The XP formalism is a generalisation of the Pauli stabiliser formalism, and we will show that diagonal Clifford hierarchy operators can be represented as diagonal XP operators.In the XP formalism, we fix an integer precision N ≥ 2 and let ω = exp(πi/N ) be a (2N )-th root of unity.We define a diagonal phase operator P = diag(1, ω 2 ) which is a 1/N rotation around the Z axis and consider the group of XP operators X P n N that is generated by ωI, X i , P i where P i is a P operator applied to qubit i.By setting N := 2 t , it is easy to see that the P i correspond to the level t phase gates of Section 2.1, and so any operator composed of single-qubit phase gates can be represented as a diagonal XP operator.For example, setting t = 1 results in N = 2, ω = i and P = Z so X P n 2 is the Pauli group on n qubits.
The XP formalism has a fundamental commutation relation that allows us to move P operators to the right of X operators: All XP operators have a unique vector representation with a phase component p ∈ Z 2N , an Xcomponent x ∈ Z n 2 and a Z-component z ∈ Z n N .The Z-component is modulo N , for instance, because P N = I.The XP operator formed from these components is: Diagonal XP operators are those with a zero X-component.The vector form of XP operators allows us to perform algebraic operations efficiently via componentwise addition and multiplication of vectors -examples are given in Table 4 of [14].In particular, the action of an XP operator on a computational basis element |e where e ∈ Z n 2 is determined as follows: Where N = 2 t , we can determine the lowest level of the Clifford hierarchy at which a diagonal operator B := XP N (0|0|z) occurs.Let g := GCD(N, z) be the GCD of N and each component of z.As N = 2 t , g is a power of 2 and B = XP N/g (p/g|0|z/g).Accordingly, B occurs at level t − log 2 (g) of the diagonal Clifford hierarchy.

Logical Identity and Logical Operator Groups in the XP Formalism
We now look at the logical group structure of a CSS code in the XP formalism with reference to the definitions of logical operators in Section 2.4.In the stabiliser formalism, a Pauli operator acts as a logical identity if and only if it is in the stabiliser group S X , S Z .In the XP stabiliser formalism, an XP operator may act as a logical identity but not be in the stabiliser group -we will see an instance of this in Example 3.1.The logical XP identity group, I XP , are the XP operators of precision N which fix each element of the codespace.The stabiliser group is a subgroup of I XP but may not be equal to it.The logical XP operator group, L XP , are the XP operators of precision N that are logical B operators for some unitary B acting on k qubits.Logical XP operators may have actions outside the Pauli group, and the logical CZ 01 operator of Example 2.2 is an instance of such an operator.Logical identities are elements of L XP that have a trivial action.The logical groups in the XP formalism are summarised in Figure 1.N is the group of all XP operators of precision N on n qubits.The stabiliser group SX , SZ of a CSS code is a subgroup of the logical XP identity group I XP which fixes all elements of the codespace which, in turn, is a subgroup of the logical operators of XP form L XP .

Logical Operators Composed of Single-Qubit Phase Gates
In this Section, we present methods for identifying and testing logical operators composed of singlequbit phase gates at a given level t of the Clifford hierarchy.Operators of this form can be identified with diagonal XP operators of precision N = 2 t .The algorithms in this Section are of polynomial complexity in the code parameters n, k, r (Section 2.3), so they can be used on CSS codes with a large number of physical or logical qubits.
This Section is structured as follows.We first show how to calculate generators for the diagonal logical identity XP group.This is an important first step for a number of our algorithms.We then demonstrate an algorithm that searches for a diagonal XP operator with a desired logical action.Next, we set out an efficient method for testing if a given diagonal XP operator is a logical operator on a CSS code.We then show how to use this test to find all diagonal logical operators of XP form.Finally, we show how to express the action of a diagonal logical XP operator in terms of a product of logical controlled phase operators.We use the Hypercube code of [22,23] which has a rich logical operator structure an example throughout this Section.We also demonstrate the use of the algorithms on larger codes such as hyperbolic color codes [24], poset codes [25] and triorthogonal codes [10].

Diagonal Logical XP Identity Group Generators
Calculating generators for the logical identity group of a CSS code is an important first step for several of the algorithms discussed in this paper.An algorithm for determining the logical identity group is set out in Section 6.2 of [14].Here, we present a simplified version for CSS codes.
Due to the discussion in Section 2.4, a diagonal logical identity operator fixes all |e uv in the canonical codewords of Equation (7).Now let N := 2 t and let B := XP N (2p|0|z) be a diagonal XP operator.Using Equation (17), the action of B on the computational basis vector |e uv is B|e uv = ω 2p+2euv•z |e uv .Considering the action of B on |e 00 = |0 , we see that p = 0 mod 2N .As ω 2N = 1, B applies a trivial phase to |e uv if and only if e uv • z = 0 mod N .We can find all such solutions by taking the kernel of a suitably constructed matrix modulo N .This is done via the Howell matrix form [26] which is a generalisation of the reduced row echelon form for modules over rings such as Z N .The notation ker Z N (E M ) means the Howell basis of the kernel of the matrix E M modulo N .

Algorithm 1: Logical Identity Group Generators
Input: 1.The X-checks S X and X-logicals L X of a CSS code (Section 2.3);

The desired level of the Clifford hierarchy t (Section 2.1).
Output: A matrix K M whose rows are the Z-components of a set of generators for the diagonal logical identity XP group of precision N = 2 t (Section 2.6).

Method:
1. Let E M be the binary matrix whose rows are the e uv := uS X + vL X of Equation ( 7); 2. Let N := 2 t and calculate K M := ker Z N (E M ) in Howell matrix form;

Return K M
Because E M has 2 r+k rows, the complexity of the logical identity algorithm is highly sensitive to the number of X-checks r and logical qubits k.However, due to Proposition E.13 of Ref. [14], we only need to consider e uv where wt(u) + wt(v) ≤ t to determine the logical identity group up to level t of the Clifford hierarchy.Hence, we only require [ r+k t ] := 0≤j≤t ( r+k j ) rows from E M and so the dimensions of the matrix and scale as a polynomial of degree t in r + k.

Example 3.1 (Logical Identity Algorithm -Hypercube Code)
In this example, based on Refs [23] and [22], qubits reside on the eight vertices of a cube.The single X-check is the all-ones vector indicating an X operator on all vertices of the cube: The three X-logicals are weight 4 vectors associated with three faces meeting at a point which we write in the notation of Section 2.3 as follows: We calculate the Z-checks by applying Equation ( 6) and find that the Z-checks also correspond to faces: This process is exactly the same as finding the diagonal logical identities at level t = 1 as outlined in Section 3.1.In this case, E M has r + k = 1 + 3 = 4 rows and the logical identities are the kernel of E M modulo 2. Now applying the logical identity algorithm at level t = 3, E M has 15 rows representing the sum modulo 2 of up to 3 rows from S X and L X .Taking the kernel of E M modulo N = 2 3 = 8, we find: The rows of K M are the Z-components of diagonal XP operators which act as logical identities, and form a generating set of all such operators of precision N .For instance, the operator XP 8 (0|0|22222222) = S ⊗8 acts as a logical identity, but is not in the stabiliser group S X , S Z .An interactive version of this example is in the linked Jupyter notebook.

Algorithm 2: Search for Diagonal XP Operator by Logical Action
We now demonstrate a method that searches for diagonal logical operators of XP form with a desired action.Aside from verifying if a CSS code has a transversal implementation of a particular logical operator, this is a useful method for cross-checking other algorithms.

Algorithm 2: Search for Diagonal XP Operator by Logical Action
Input: 1.The X-checks S X and X-logicals L X of a CSS code (Section 2.3); 2. A level-t controlled-phase operator B on k qubits (Section 2.1) such that B|0 = |0 .
Output: A diagonal XP operator of precision N = 2 t which acts as a logical B operator or FALSE if this is not possible.

Method:
1.For v ∈ Z k 2 calculate the phase q v ∈ Z N such that B|v = ω 2qv |v ; 2. Form the matrix E B that has rows of form (−q v |e uv ) where e uv := uS X + vL X ;

Calculate the kernel K
for all e uv , which corresponds to the action of a logical B operator on the codewords |v L .
The above algorithm requires that B|0 = |0 .If this is not the case, let B|0 = ω p |0 , run the algorithm using B := ω −p B and adjust for phase on the result.The results of the algorithm are dependent on the choice of basis for the span L X (see Section 2.3).
The logical action search algorithm involves finding the kernel of a matrix E B of dimension 2 r+k × (n + 1).Hence the complexity of the algorithm is sensitive to the number of logical qubits k and independent X-checks r, but can be reduced as follows.Due to Proposition B.1, where N = 2 t the dot product e uv • z can always be written as a Z N linear combination of terms of form e u v • z where wt(u ) + wt(u ) ≤ t.Hence, we only need to consider e uv where wt(u) + wt(v) ≤ t and q v where wt(v) ≤ t.The number of rows required in E M is therefore [ k+r t ] where [ r t ] := 0≤j≤t ( r j ).The dimensions of the matrix E M are polynomial rather than exponential in n, k and r.The linked Jupyter notebook illustrates the operation of the search algorithm on the hypercube code of Example 3.1.Users can enter the desired logical operator to search for in text formfor example CZ [1,2], S [1] or CCZ[0, 1,2].The script either returns a diagonal XP operator with the desired logical action, or FALSE if there is no such operator.We find logical operators CZ 12 = XP 8 (0|0|02060602) and CCZ 012 = XP 8 (0|0|13313113) but no solutions for transversal logical S operators.

Logical Operator Test for Diagonal XP Operators
We now present an efficient method for determining whether a given diagonal XP operator acts as a logical operator on a CSS code, which relies on a commutator property of logical operators.This is used to find a generating set of all diagonal logical XP operators of a given precision and to check the results of other algorithms.
Due to proposition E.2 of Ref. [14], an XP operator B acts as a logical operator on the codespace if and only if the group commutator with any logical identity A is again an element of the logical identity group I XP (see 2.6).That is: When B := XP N (0|0|z) is diagonal and A := XP N (0|x|0) is non-diagonal, by applying the COMM rule of Table 4 in Ref. [14] we have: As B is a diagonal operator, we only need to consider commutators with non-diagonal elements of the logical identity group.In Proposition B.2 we show that this reduces to finding z ∈ Z n N such that for all X-checks x, both x • z = 0 mod N and 2xz ∈ K M Z N where K M is a generating set of Z-components of the diagonal logical identities as defined in Section 3.1 and As 2xz and N are both divisible by 2, we apply the method of Section 2.5 and see that the group commutator must be at most a level t − 1 Clifford hierarchy operator.For instance, for t = 2, N = 4 logical operators must commute up to level t = 1, N = 2 logical identities which are the Z-checks (see Example 3.1).This observation either eliminates the need to calculate the logical identities (for t ≤ 2) or reduces the complexity of calculating them (the number of rows in the matrix E M of Section 3.1 is a polynomial of degree t).
Hence, we have an O(r) algorithm for checking whether a diagonal XP operator is a logical operator of a CSS code where r is the number of independent X-checks, but we may need to first run the diagonal logical identity algorithm of Section 3.1 at level t − 1.

Algorithm 3: Logical Operator Test for Diagonal XP Operators
Input: 1.The X-checks S X of a CSS code (Section 2.3); 2. The matrix K M corresponding to the Z-components of the level t − 1 diagonal logical identity generators (Section 3.1; 3. A diagonal XP operator B = XP N (0|0|z) on n qubits of precision N = 2 t (Section 2.5).
Output: TRUE if B acts as a logical operator on the code or FALSE otherwise.

Method:
1.For each row x of S X :

Diagonal Logical XP Operator Group Generators
We now show how to apply the test for diagonal logical XP operators of Section 3.3 to find all diagonal logical operators of XP form for a CSS code.

Algorithm 4: Diagonal Logical XP Operator Group Generators
Input: 1.The X-checks S X of a CSS code (Section 2.3); 2. The desired level of the Clifford hierarchy t (Section 2.1); 3. The matrix K M corresponding to the Z-components of the level t − 1 diagonal logical identity generators (Section 3.1).
Output: A matrix K L over Z N representing the Z-components of a generating set of diagonal logical operators of XP form (Section 2.6).

Method:
1.For each X-check x ∈ S X , find solutions z ∈ Z n N such that both x • z = 0 and 2xz ∈ K M Z N .Details of solving within these constraints are set out in Appendix B.3.Denote the solutions Comm N (K M , x);

Find the intersection of all such solution sets K
The method for determining intersections of spans over Z N is covered in Appendix A.4 of [14]; The rows of K L correspond to the Z-components of a generating set of the logical XP group (Section 2.6), which includes the logical identity XP group.Determining the logical action of the operators is discussed in Section 3.5.

Determine Action of Diagonal Logical XP Operator
Here we demonstrate an algorithm expressing the action of a diagonal logical XP operator in terms of logical controlled-phase operators.This is important because the algorithm in Section 3.4 does not yield any information on the action of the resulting diagonal logical operators.

Algorithm 5: Determine Action of Diagonal Logical XP Operator
Input: 1.The X-logicals L X of a CSS code (Section 2.3) with k logical qubits; 2. A diagonal XP operator B of precision N := 2 t that acts as a logical operator on the code (Section 2.4).
Output: A diagonal Clifford hierarchy operator B on k qubits representing the logical action of B. Method: 3. Loop over each v ∈ V ordered by weight.For any v u ∈ V \ {v}, update q u := (q u − q v ) mod 2N ; 4. Return B := v∈V CP N (q v , v) in terms of the vector form of controlled-phase operators of Section 2.2.
The above algorithm involves calculating O(k t ) phase components q v , and this is sufficient due to Proposition B.1.A naive approach which calculates the phase applied to each codeword would involve calculating O(2 k ) such phase components, and would be impractical for CSS codes with a large number of logical qubits.The results of the algorithm are dependent on the choice of basis for the span L X (see Section 2.3).

Example 3.4 (Action of Diagonal Logical XP Operators -Hypercube Codes)
In this example, we apply the method of Section 3.4 to the Hypercube code of Example 3.1 at level t = 3.The output of the method of Section 3.4 is a set of length 8 vectors over Z 8 corresponding to Z-components of diagonal logical XP operators.Using the method of Section 3.5, we obtain the following list of logical actions corresponding to the Z-components: In Figure 3 we display the resulting logical operators on the cube and notice that that the Clifford hierarchy level of the logical operator corresponds to the dimension of the support of the operator.An interactive version of this example is available in the linked Jupyter notebook.Hyperbolic quantum color codes [24] involve constructing codes from tesselations of the 2D hyperbolic plane.The tesselations are formed from polygons with an even number of edges, and each vertex is shared by 3 such polygons.We place a qubit on each vertex of the tesselation.For each polygonal face, we have an X-check corresponding to the adjacent vertices.The Z-checks are the same as the X-checks.Applying the method of Section 3.4, we find that the codes have a transversal level 2 logical operator with action which can be expressed as a product of controlled-Z operators.
There are various methods in the literature for constructing classical self-orthogonal codes and these can also be used to make quantum codes with Z-checks which are the same as the X-checks which we expect to have transversal level 2 diagonal logical operators.In [25], self-orthogonal codes are constructed from partially ordered sets (posets).Analysing poset codes using our methods, we see that they have transversal level 2 logical operators with actions which can be expressed as products of S and CZ operators.

Example 3.6 (Triorthogonal Codes)
For triorthogonal codes [10], there is always a logical operator of form T ⊗k := U T ⊗n where U is a product of CZ and S operators and k is the number of logical qubits of the code.In the linked Jupyter notebook, we apply the method of Section 3.4 to find generating sets of diagonal logical operators for the 38 triorthogonal code classes in Table II of Ref. [27].In this example, we consider codes with k = 3 logical qubits (this choice can be modified by the user).
Applying our method, we see that the logical operator structure of triorthogonal codes varies widely.In some cases, the code has a transversal logical T i operator for each logical qubit 0 ≤ i < k.For most of the codes, we find a logical T ⊗k operator of XP form.The exceptions are codes which require the application of CZ operators to form T ⊗k , and so would not be identified by our method.We do not see any instances of logical CCZ or CS operators.

Transversal Logical Operators Composed of Multi-Qubit Controlled-Phase Gates
In the previous Section, we have shown how to find a generating set of all logical operators of a CSS code that can be constructed from single-qubit phase gates at any level of the Clifford hierarchy.This relied on representing operators composed of single-qubit phase gates as diagonal XP operators.In this Section, we show how to find all transversal (depth-one) logical operators of a CSS code composed of multi-qubit controlled-phase gates.The method relies on representing controlled-phase operators acting on a codespace as diagonal XP operators acting on a larger Hilbert space via an embedding operator.The structure of this Section is as follows.We first introduce phase-rotation gates and discuss some of their elementary properties.We then prove a duality result that transforms controlledphase operators to phase-rotation operators and vice versa.Hence phase-rotation gates are an alternative generating set for diagonal Clifford hierarchy gates.We then describe an embedding operator from the codespace into a larger Hilbert space such that phase-rotation operators in the codespace correspond to diagonal XP operators in the embedded codespace.As a result, any diagonal Clifford hierarchy operator can be represented as a diagonal XP operator in the embedded codespace.
Finally, we demonstrate an algorithm that searches for transversal logical operators composed of single-and multi-qubit controlled-phase gates for a given CSS code.Such implementations are depth one and use operators with bounded support size and so have fault-tolerant properties.Logical operators of this type have recently been studied in Refs.[12], [13] and [28] and we provide examples of the application of the algorithm to codes in these papers.

Phase-Rotation Operators
Phase-rotation operators are single or multi-qubit diagonal gates that form an alternative generating set for the diagonal Clifford hierarchy operators of Section 2.1.Phase-rotation operators are defined as follows.Let A := XP 2 (0|0|v) be a tensor product of Z operators and let ω := exp(πi/N ).Let A ±1 := (I ± A)/2 be the projectors onto the ±1 eigenspaces of A and let q ∈ Z 2N .The phase-rotation operator is: This form is similar to the Pauli product rotations of Ref. [29] and operators of this type arise as fundamental gates in NMR [30] and quantum dot systems [31].In Proposition A.4, we show that the action of RP N (q, v) on the computational basis element |e for e ∈ Z n 2 is: We can express the phase applied more concisely as follows: RP N (q, v)|e = ω q•sv(e) |e where s v (e) := Single qubit phase gates of precision N in this notation are of form where b n i is the length n binary vector which is all zero, apart from component i which is one.

Duality of Controlled-Phase and Phase-Rotation Operators
In Proposition A.5, we prove a duality result that allows us to convert vector form controlled-phase operators to products of phase-rotation operators and vice versa: In Section 2.2, we saw that operators of form CP N (2 wt(v) , v) with wt(v) ≤ t and N := 2 t generate the level t diagonal Clifford hierarchy operators.As a consequence of the duality result, phaserotation operators of form RP N (2, v) where wt(v) ≤ t are an alternative generating set.In the linked Jupyter notebook we show that RS 01 = CZ 01 S 1 S 2 = RS 3 01 Z 1 Z 2 by applying the duality result twice -hence phase-rotation operators may have more than one vector representation.

Embedded Code Method
The embedded code method involves constructing an embedding operator on the codespace of a CSS code such that phase-rotation operators in the original codespace correspond to diagonal XP operators in the embedded codespace.The embedding technique is similar to the one used to represent weighted hypergraph states in Section 5.4 of Ref. [14].We first define the embedding operator in terms of its action on computational basis states, then show how to extend it to phase rotation operators and strings of Pauli X operators.As an example, we show how the embedding operator transforms repetition codes.

Action of Embedding Operator on Computational Basis States and CSS Codespaces
Let M n t be the matrix whose rows are the binary vectors of length n of weight between 1 and t.Let V be a matrix whose rows are a subset of the rows of M n t .We define the embedding operator that has the following action on computational basis vectors |e , e ∈ Z n 2 : Now let S X , L X be the X-checks and X-logicals of a CSS code C on n qubits (see Section 2.3).The image of the codespace of C under E V is the codespace of the embedded code C V defined as follows: • Providing V is full rank, the X-checks and X-logicals of the embedded code are independent (for instance if V includes all rows of I n ).We will show that phase-rotation operators acting on the codespace correspond to diagonal XP operators in the embedded codespace.Because operators of form RP N (2, v) for v ∈ M n t and N = 2 t generate all controlled-phase operators of level t on n qubits (see Section 4.2), choosing V = M n t allows any such operator to be represented.By limiting V to a subset of M n t , we can place restrictions on the phase-rotation operators we wish to work with in the embedded codespace.For instance, we can allow only nearest neighbour interactions for a lattice-based code or cater for ZX symmetries and qubit partitions as discussed in Refs.[12] and [13].

Action of Embedding Operator on Phase-Rotation and Pauli X Operators
We now demonstrate an extension of the embedding operator E V to phase-rotation and Pauli X operators which acts as a group homomorphism.A group homomorphism must respect commutation relations, and this is much simpler to achieve for phase-rotation operators than for controlled-phase operators.In Proposition A.7, we prove the following commutation relation for controlled-phase and Pauli X operators: In Equation ( 30), b n i is the binary vector of length n which is zero apart from entry i which is one.Extending this to arbitrary strings of X operators we obtain the following: In Proposition A.6, we prove the much simpler commutation relation for phase-rotation operators which corresponds closely to the commutation relation for XP operators in Equation ( 15): The relation in Equation ( 32) also implies that for any V ⊂ M n t , we have closure under conjugation with any Pauli X string, which is not the case for controlled-phase operators.Now consider the group X RP V N generated by operators of form ωI, X i and RP N (2, v) for v a row of V .Elements of X RP V N can be written in terms of components We define an embedding map for XRP operators with respect to V as follows: In Proposition B.4, we show that the embedding operator E V respects group operations and so acts as a group homomorphism.As a result, we can use the diagonal logical identity and logical operator algorithm in Section 3.1 and Section 3.4 to find logical operators in the embedded codespace.The results can be interpreted as phase-rotation operators in the original codespace.One application of this method is to better understand what kinds of coherent noise a CSS code is inherently protected against as in [32].The logical identity group of the embedded code represents the correlated noise that the code protects against up to configurable constraints (for example connectivity and the level of Clifford hierarchy).
4. From the rows of K L , choose a vector z corresponding to a logical operator at level t of the Clifford hierarchy.If there is no such operator, return FALSE.Otherwise, perform the following steps: (a) Remove z from K L ; (b) For each element q of the rowspan of K L over Z N , check if z := (q + z) mod N represents a depth-one operator.If so, return z ; (c) If no depth-one operator is found, go to Step 4.
When the CSS code has a known symmetry, we can search for depth-one logical operators more efficiently by modifying the embedding operator.The depth-one algorithm can take as input a permutation of the physical qubits in cycle form such that the cycles partition the n physical qubits.Let c = (c 1 , c 2 , . . ., c l ) be a cycle in the permutation and let b n c be the length n binary vector which is zero apart from the components i ∈ c that are one.The rows of the embedding matrix V are the vectors b n c for the cycles c in the permutation.The algorithm as outlined above yields logical operators composed of physical phase-rotation gates.To search for logical operators composed of controlled-phase gates, transform the matrix K L by using the duality result of Section 4.2.In this case, due to the commutation relation in Equation (31), we need to ensure that for all v ∈ V any length n binary vector whose support is a subset of the support of v is also in Note that M n t has [ n t ] := 1≤j≤t ( n j ) rows, so we would generally apply the algorithm only to small codes of around 30 physical qubits (e.g., for t = 2 and n = 30, M n t has 465 rows, but for n = 100, M n t has 5, 050 rows).In Appendix B.4 we describe a method for more efficiently exploring the search space.

Example 4.2 (Depth-One Algorithm)
In the linked Jupyter notebook, we illustrate the depth-one search algorithm for small codes.For a given code and a desired level of the Clifford hierarchy t, the output is a logical operator with a depth-one circuit implementation whose logical action is at level t of the diagonal Clifford hierarchy, or FALSE if no such operator exists.This is done with no knowledge of the logical action of the operator or symmetries of the code.For example, we identify the depth-one implementation of the logical S 0 S 3 1 of the 2D toric code as discussed in Refs.[11], [12] and [13].Users can also apply the algorithm to Bring's code which is a 30-qubit LDPC code discussed in Ref. [12] and various examples of morphed codes which are discussed in Ref. [28].Users can also choose to use a known symmetry of the code to speed up the search -this can be used for instance to verify the partitioned logical operators of the symmetric hypergraph product codes of Ref. [13].

Other Applications of Embedded Codes
In this Section, we discuss other applications of the embedded code method of Section 4.3.We first show that for any CSS code with k logical qubits and any diagonal Clifford hierarchy operator B on k qubits, we can write a closed-form expression for a logical B operator on the codespace composed of phase-rotation gates (see Section 4.1).As a consequence, the embedded code has a logical B operator composed of single-qubit phase gates.This leads to a method of generating CSS codes that have transversal implementations of any desired diagonal logical Clifford hierarchy operator.

Canonical Implementations of Logical Controlled-Phase Operators
Here, we show how to implement a desired logical controlled-phase operator on an arbitrary CSS code via a canonical form composed of the phase-rotation gates of Section 4.1.We demonstrate implementations of logical S, T, CZ and CS operators using the 2D toric code as an example.As the canonical implementation is in terms of phase-rotation operators, we can apply the embedded code method of Section 4.3 and implement the logical operator in the embedded codespace using single qubit phase gates.We use this fact to generate families of CSS codes that have transversal implementations of a desired logical controlled-phase operator using single-qubit phase gates.The methodology is illustrated in Figure 5.  which takes the computational basis element |e to |eV T mod 2 .This enables us to construct a logical B operator BV on the embedded codespace from single qubit phase gates.

Canonical Form for Logical Phase Operators
In the proposition below, we show that logical phase operators have a particularly simple form in terms of the phase-rotation gates of Section 4.1.

Proposition 5.1 (Canonical Logical
The operator Proof.The action of a P i operator on a computational basis element |v where v ∈ Z k 2 can be written From Equation ( 8), P i is a logical P i operator if P i C = CP i .Hence: Hence, we require P i |e uv = ω 2v [i] |e uv .Set the precision N = 2, and we have . Now consider the action of P i := RP N (2, z i ) on |e uv using Proposition A.4: as required for P i to act as a logical P operator.
Using the duality of RP and CP operators of Section 4.2, we can write P i as a product of CP gates: As N = 2 t , any terms with wt(u) > t disappear.Hence the support of the CP gates in the implementation are of maximum size t.The implementation may not be transversal, as a qubit may be acted upon by more than one gate.

Example 5.1 (Logical Phase Operators of the 2D Toric Code)
We illustrate the canonical form of logical controlled-phase operators by considering the 2D toric code.Using the XP operator notation of Equation ( 16), let Z 0 := XP 2 (0|0|z 0 ), Z 1 := XP 2 (0|0|z 1 ) be logical Z operators on logical qubit 0 and 1 respectively with d := wt(z 0 ) = wt(z 1 ) ≥ 3. Applying Equation (44) and using the notation of Equation ( 1) for controlled-phase operators, the canonical forms for the logical S and T operators on qubit 0 are as follows: = These results hold for any CSS code with wt(z 0 ) ≥ 3, as no other special properties of the toric code have been used.

Canonical Form of Logical Phase-Rotation and Controlled-Phase Operators
We now generalise the method in Section 5.2 and show how to implement logical phase-rotation operators for CSS codes using physical phase-rotation gates.Let L Z be the k × n binary matrix representing logical Z operators such that L Z L T X mod 2 = I k where k = |L X |.This means that XP 2 (0|0|z i ) anti-commutes with XP 2 (0|x j |0) if and only if i = j.Let u be a binary vector of length k.In Proposition B.5 we show that the following is a logical phase-rotation operator: By the duality result of Section 4.2, we can write logical phase-rotation operators as follows: = This in turn can be converted into products of physical controlled-phase gates by applying the duality result a second time.

Algorithm 7: Canonical Logical Controlled-Phase Operators
Input: 1.The Z-logicals L Z of a CSS code (see above); 2. A level-t diagonal Clifford hierarchy operator B on k qubits (Section 2.1).
Output: A logical B operator (Section 2.4) on the code composed of physical phase rotation gates (Section 4.1) with maximum support size t.

Method:
1. Express B = u RP N (q u , u) as a product of phase rotation gates using the duality result of Section 4.2 where N = 2 t and u ∈ Z k 2 ; 2. The operator B = u RP N (q u , uL Z ) is a logical B operator; 3. Apply the duality result of Section 4.2 twice to express B as a product of phase-rotation gates of maximum support size t. = We can choose logical Z operators for the 2D toric code such that supp(z 0 ) ∩ supp(z 1 ) = ∅.In this case, all S operators in Equation (57) cancel, as do any CZ operators which lie entirely on the support of either z 0 or z 1 , and so we have: This is an instance of Claim 2 in [33] for logical multi-controlled-Z operators.Our method applies to arbitrary diagonal Clifford hierarchy logical operators and we can also show: = Note that the number of physical gates used in the implementation is O(d t ).As we are not guaranteed that supp(z 0 ) ∩ supp(z 1 ) = ∅ for arbitrary CSS codes, the above identities are not completely general.In the linked Jupyter notebook, users can calculate identities of this kind for any desired CSS code for any diagonal Clifford hierarchy logical operator.

Constructing a CSS Code with a Desired Diagonal Logical Clifford Hierarchy Operator
In this Section, we apply the canonical logical operator form of Section 5.3 to generate a CSS code with a transversal implementation of a desired logical controlled-phase operator using single-qubit phase gates.

Algorithm 8: Constructing CSS Codes with a Desired Diagonal Logical Clifford Hierarchy Operator
Input: A controlled-phase operator B on k qubits (Section 2.1) and a target distance d.
Output: A CSS code with a logical B operator (Section 2.4) composed of single-qubit phase gates.

Method:
1. Let C be a k-dimensional toric code of distance d.We construct the stabiliser generators of C using the total complex of the tensor product of k classical repetition codes on d bits (see Section II.D of [34]).The resulting CSS code has k non-overlapping logical Z operators of weight d; 2. Find the canonical implementation of B = v∈V RP N (q v , v) composed of phase-rotation gates of maximum support size t using Algorithm 7; 3. Remove any elements of V where q v = 0 and apply the embedding E V to find the X-checks and X-logicals of the embedded code C V as in Section 4.3; 4. The resulting code has a logical B operator B V composed of level-t phase gates acting on the embedded codespace.

Example 5.3 (Constructing CSS Codes with Transversal Logical Controlled Phase Operators)
In Table 2, we list the parameters of CSS codes with transversal implementations of various target logical controlled phase operators using the method in Section 5.4.The CSS codes are generated from toric codes as follows.For a target operator acting on k logical qubits, we use a k-dimensional toric code.We generate a series of codes by increasing the distance d of the toric code.Looking at the CZ column we have a family of [[4m

Conclusion and Open Questions
We have presented efficient new methods to identify and test diagonal logical operators on CSS codes using both single-and multi-qubit diagonal Clifford hierarchy gates as building blocks.In addition, we provided a technique for generating CSS codes with implementations of any desired diagonal Clifford hierarchy logical operator using single-qubit phase gates.The methods generalise to non-CSS stabiliser codes as demonstrated in Appendix C. The algorithms are available in a GitHub repository and are intended to be of benefit to researchers in understanding the logical operator structure of stabiliser codes.
Our methods rely on representing diagonal Clifford hierarchy operators as diagonal XP operators.Our algorithms use the vector representation of XP operators and linear algebra modulo N , and so have reduced computational complexity compared to existing work in this area.
The ability to represent diagonal Clifford hierarchy operators as XP operators may have a number of other possible applications.Custom design of CSS codes for devices that have known coherent noise models is one possibility.If the noise can be represented as a series of multiqubit diagonal operators, we could design a CSS code where these operators are in the logical identity group and so mitigate coherent noise.The simulation of quantum circuits could be another application.A circuit composed of multi-qubit diagonal operators, such as those used for measuring the stabiliser generators of a CSS code, could be amenable to simulation using XP representations of the gates used.As any diagonal Clifford hierarchy operator can be represented as a diagonal XP operator, there could also be implications for computational complexity theory.duality properties for binary vectors and binary variables, and we start by proving these results.We then prove results relating to phase-rotation operators.We first show that phase-rotation operators can be written as a sum of projectors.This allows us to calculate the logical action of phase-rotation operators.We then prove the duality result between controlled-phase and phase-rotation operators.Finally we prove the key commutation relations for phase-rotation and controlled-phase operators.
A.1 Product/Sum Duality Results for Binary Vectors and Variables Proposition A.1 (Sum/Product Duality of Binary Vectors) Let L be a binary matrix with rows x i for 0 ≤ i < r and v a binary vector of length r.Define: (63) Then over the integers: Proof.Restatement of Proposition E.10 of [14].
Proposition A.2 (Sum/Product Duality of Binary Variables) Let e be a vector of r binary variables and let v a binary vector of length r.Define:

A.2 Phase-Rotation Operators
Proposition A.3 (Projector Form of RP Operators) Phase-rotation operators can be written in terms of projectors A ±1 := (I ± A)/2: Proposition A.7 (Commutation Relation for Controlled-Phase Operators) Where b n i is the length n binary vector which is zero apart from component i which is one.Proof.If v[i] = 0 then CP N (q, v) has no support in common with X i so the operators commute.Now assume v[i] = 1 then the operator on the LHS acts on the computational basis element |e as follows: We now show that all other cases result in a trivial phase.Assume e[i] = 1 AND (v ⊕ b n i ) e.In this case, v e and so: Now assume that (v ⊕ b n i ) e is not true.In this case, we can never have v e and so neither of the controlled-phase operators apply a phase, regardless of the value of e[i].Hence the LHS and RHS have the same action on computational basis elements and the result follows.
Example A.1 (Commutation Relation for Controlled-Phase Operators) Using Proposition A.7, we can conjugate controlled-phase operators by strings of X operators and vice versa.We first compute CS 01 X 1 CS −1 01 where CS 01 is a controlled-S operator on qubits 0 and 1.Using the notation of Equation ( 1 Using Equation ( 31) with x = v = 111, and letting w := u ⊕ v: = CP 8 (8, 0) Interactive versions of these examples are available in the linked Jupyter notebook.

B Additional Details for Logical Operator Algorithms
This Appendix provides further details on the various logical operator algorithms.We first prove results that reduce the complexity of the logical action and logical operator test algorithms of Sections 3.2, 3.3 and 3.5.We then show how to calculate valid z vectors that result in diagonal operators that commute with the X-checks up to a logical identity for use in Section 3.4.We then demonstrate a method for more efficiently searching for depth-one logical operators composed of multi-qubit controlled phase gates for use in Section 4.4.We then show that the embedding operator of Section 4.3 acts as a group homomorphism on the group generated by phase-rotation and Pauli X operators.Finally, we show that the canonical form of Section 5.3 results in a logical operator with the required action.

B.1 Reducing Complexity of Logical Action Algorithms
In this Section we show how to reduce the complexity of algorithms which work with the logical action of diagonal XP operators on the canonical codewords.If B := XP N (0|0|z) is a diagonal logical operator of precision N := 2 t , then the action of B on the computational basis vectors e uv := uS X +vL X making up the canonical codewords of Equation ( 7) can be written as B|e uv = ω 2euv•z |e uv .In the proposition below, we show that the phase component e uv • z is completely determined by terms of form e u v • z where wt(u ) + wt(v ) ≤ t.As a result, when working with logical actions, we do not need to consider all 2 k+r of the e uv vectors, just a limited set which is of size polynomial in k and r.This reduces the computational complexity of the algorithms in Section 3.2 and Section 3.5.

Proposition B.1
Let N := 2 t and z ∈ Z n N .The phase component e uv •z can be expressed as a Z N linear combination of e u v • z where wt(u ) + wt(v ) ≤ t.
Proof.Let G X := S X L X and let a := (u|v).Noting that e uv = aG X = s a (G X ) and applying Proposition A.1 we have: Terms with wt(b) > t disappear modulo N = 2 t .Using the linearity of dot product and expressing the p b (G X ) in terms of s c (G X ): As wt(c) ≤ wt(b) ≤ wt(a) ≤ t, the result follows.

B.2 Test for Diagonal Logical XP Operators
In this Section, we prove that the algorithm in Section 3.
We now show that for a diagonal XP operator B, it is sufficient to check group commutators with the r := |S X | operators of form XP N (0|x i |0) where x i are the rows of the X-checks S X .

Proposition B.3
Let C be a CSS code with X-checks S X and logical identity XP group I XP of precision N .Let B := XP N (0|0|z) be a diagonal XP operator.B is a logical operator if and only if [[XP N (0|x i |0), B]] ∈ I XP for all rows x i of S X .

Proof. B is a logical operator if and only if [[A, B]] ∈ I XP for all
Conversely, assume [[XP N (0|x i |0), B]] ∈ I XP for all rows x i of S X .Let K M be the matrix whose rows are a generating set of the Z-components of the logical identities as defined in Section 3.1.Any logical identity A can be written as a product of terms of form XP N (0|x i |0) and XP N (0|0|z j ) where z j is a row of K M .By assumption, [[XP N (0|x i |0), B]] ∈ I XP and [[XP N (0|0|z j ), B]] = I.Due to Proposition B.2, the commutator of the product is a logical identity and the result follows.

B.3 Algorithm to Determine Commutators of a Given X-Check
In the method of Section 3.4, for a given X-check x ∈ S X we seek all Z-components z ∈ Z n N such that the group commutator [[XP N (0|0|z), XP N (0|x|0)]] is a logical identity.This reduces to solving for z such that both x • z = 0 mod N and 2xz ∈ K M Z N where the rows of K M are the Z-components of the diagonal logical identities as in Section 3.1.In this Section, we show how to solve for these constraints using linear algebra modulo N .The method is as follows: Without loss of generality, reorder qubits so that the first m components of x are one and the remaining n − m components are zero.In the matrices of form (a|b) below, the first component has m columns corresponding to the non-zero components of x, the next n−m columns correspond to the zero components of x.For v ∈ Z N , let v • 1 := ( 0≤i<n v[i]) mod N .6.Return qubits to their original order.The valid Z-components are given by the row span of C 2 over Z N .

B.5 Representation of Controlled-Phase Operators as XP Operators via Embedding Operator
In this Section we prove that the phase-rotation operators of Section 4.1 acting on a codespace correspond to diagonal XP operators in the embedded codespace defined in Section 4.3.2.We do this by demonstrating that the mapping of phase-rotation operators acting on the codespace to XP operators in the embedded codespace of Section 4.3.2 is a group homomorphism.
Proposition B.4 (Embedding operator induces a group homomorphism) The embedding operator E V defined as follows is a group homomorphism between X RP V N and X P

|V |
N : Proof.We prove this by considering generators of the group X RP V N .Let b n i be the length n binary vector which is zero apart from component i which is one and consider X i , X j for 0 ≤ i, j < n: By a similar argument, Where X operators precede diagonal operators we have: Where diagonal operators precede X operators, we first consider the case where v[i] = 0.In this case, the operators commute so we can swap the order of operators so that the X operators precede the diagonal operator.Now consider the case v[i] = 1 where the operators do not commute: Because group operations are preserved for generators of the group, the embedding is a group homomorphism.

B.6 Canonical Form of Logical Phase-Rotation Operators
In this Section, we show that the canonical form of logical phase-rotation operators discussed in Section 5.1 acts as a logical operator as claimed.

Proposition B.5 (Logical Phase Rotation Operator)
Let L Z be a binary matrix representing the Z-components of logical Z operators such that L T Z L X = I k and let w be a binary vector of length k.
The operator RP N (2, wL Z ) acts as a logical RP N (2, w) operator.
Proof.This can be seen by considering the action of the operator on the computational basis element |e uv where e uv := uS X + vL X .From the argument in Proposition Hence, the phases applied by the operators are the same and the result follows.

C Application of Methods to Non-CSS Stabiliser Codes
In this work, we have focused on identifying diagonal logical operators for CSS codes in the form defined in Section 2.3.In this Section, we show how to find diagonal logical operators for arbitrary non-CSS stabiliser codes.We will prove the following main proposition: The CSS code C in Proposition C.1 may have different error correction properties to C (i.e.weight of stabiliser generators and logical operators), but allows us to determine the diagonal logical operator structure of C. In this Section, we first introduce some background material on non-CSS stabiliser codes.CSS codes of the form of Section 2.3 have diagonal stabiliser generators with zero phase components and non-diagonal stabiliser generators with zero phase and Z-components.This is not the case for arbitrary stabiliser codes, and we show how to eliminate these components in two steps to yield the operators Q and D in the above proposition.We illustrate Proposition C.1 by applying it to the perfect 5-qubit code of Ref. [35].

C.1 Background on Non-CSS Codes
Arbitrary Pauli stabiliser codes have stabiliser generators from the Pauli group iI, X, Z ⊗n = X P n 2 .A method of determining a canonical set of independent stabiliser generators, logical X and logical Z operators is given on page 477 of Ref. [36].Let S X and S Z be the canonical stabiliser generators and let L X be the canonical logical X operators.Elements of S Z may have signs of ±1 and elements of S X may have non-trivial phase and Z-components.For Proposition C.1, we require that C := (DQ) −1 C is stabilised by diagonal generators with trivial phase components and non-diagonal generators with trivial phase and Z-components.
We now set out a canonical form for the codewords of the stabiliser code C. Let r be the number of operators in S X and k the number of operators in L X and let v ∈ Z k 2 .Let q be a binary vector of length n such that B|q = |q for all B ∈ S Z .Define L v X := i v L X [i] where L X [i] is the ith operator in L X .Due to the arguments in Sections 4.2 and 6.2 of [14], the following codewords span the codespace C and define the encoding map C of C (Section 2.4): We now discuss how the codewords and logical operators of a stabiliser code C transform when the codespace is acted upon by a unitary operator U .The codewords of the transformed code C := U C are given by U |v L so the encoding map of C is given by U C. The operator A is a logical identity of C if and only if U AU −1 is a logical identity of C .This is because: As the stabiliser generators S X and S Z are elements of the logical identity group, they also update via conjugation.The operator B is a logical B operator on C if and only if U BU −1 is a logical .Let C be the CSS code with X-checks and X-logicals:

7 . 1 ; 8 .
Canonical implementations of a desired logical controlled-phase operator composed of multiqubit controlled-phase gates: this allows us to write closed-form expressions for arbitrary diagonal Clifford hierarchy logical operators Section 5.Construction of CSS codes which have an implementation of a desired logical controlled-phase operator composed of single qubit phase gates: the canonical logical operator implementation allows us to construct families of CSS codes which have transversal implementations of a desired diagonal Clifford hierarchy logical operator Section 5.4.

Figure 1 :
Figure1: Relationship between XP Operator Groups: Here, X P n N is the group of all XP operators of precision N on n qubits.The stabiliser group SX , SZ of a CSS code is a subgroup of the logical XP identity group I XP which fixes all elements of the codespace which, in turn, is a subgroup of the logical operators of XP form L XP .

Figure 2 :
Figure 2: Hypercube Code of Dimension 3: qubits reside on the vertices of a cube.The blue-coloured X-logicals are associated with the 2D faces, whilst the X-check is associated with the single 3D volume.The red-coloured Z-checks are associated with the 2D faces.

Example 3 . 2 (
Search for Diagonal XP Operator by Logical Action)

Figure 3 :Example 3 . 5 (
Figure 3: Diagonal Logical Operators of Hypercube Code of Dimension 3: Logical XP operators returned by the method of Section 3.4 are plotted on the cube.We note that Clifford hierarchy level 1 logical Z operators have support on 1D edges, level 2 CZ operators have support on 2D faces and level 3 CCZ operators have support on the entire 3D cube. (a) [[56,14,6]] Code (b) [[64,20,4]] Code

Figure 4 :
Figure 4: {8,3} Hyperbolic Color Codes: above are tesselations corresponding to two hyperbolic color codes from Example 3.5.The [[56,14,6]] code is not globally 3-colourable as there is no valid colour assignment for faces 2 and 4 in the diagram above.Each code has a transversal level 2 diagonal logical operator whose action is a product of logical CZ operators.

Figure
Figure 5: Logical Operators of CSS Codes and Embedded Codes: A CSS encoding maps k logical qubits into n physical qubits via C : H k 2 → H n 2 , which takes computational basis elements |v to codewords |v L. Consider a level-t controlled-phase operator B acting on H k 2 .An operator B acting on H n 2 is a logical B operator if BC = CB.We show how to construct a canonical logical B operator B from level-t phase-rotation gates.Let V be the matrix whose rows are length n binary vectors representing the support of the controlled-phase operators making up B. The embedded codespace is formed by applying the embedding EV : H n 2 → H

Example 5 . 2 (
Logical Controlled-Phase Operators of Toric Code) We now demonstrate a canonical implementation of a logical CZ operator on the 2D toric code of Example 5.1 composed of physical controlled-phase gates.Using Equation (53) and the fact that RP 4 (2, z 0 ) = i<j z0 CZ ij i z0 S i from Example 5.1: CZ 01 := CP 4 (4, 11)

)
Since by assumption v[i] = 1, a phase of ω q is applied ⇐⇒ v (e ⊕ b n i ) ⇐⇒ e[i] = 0 AND (v ⊕ b n i ) e.Now consider the RHS and assume e[i] = 0 AND (v ⊕ b n i ) e.In this case, we do not have v e because v[i] = 1 but e[i] = 0. Hence:

1 . 2 . 4 . 2 ; 5 .
The vector 2xz is of the form (2u|0) where u is of length m and the row span of C 0 := (2I m |0) over Z N represents all vectors of this form; Group commutators which are also logical identities are in C 0 Z N K M Z N and a Howell basis C 1 is calculated via the intersection of spans method in Appendix 4.1 of[14];3.The rows of C 1 are of form (u|0) ∈ K M Z N for u divisible by 2 modulo N .Now let v := u/2.Because 2(v + N/2) = 2v = u mod N , (v • 1) mod N is either 0 or N/2.Adjust the mth component of v by subtracting (v • 1) mod N .Let C 2 be the matrix formed from rows of form (v|0); Adding pairs of N/2 to the first m components does not change 2xz or x • z mod N .Let A be I m−1 with a column of ones appended.Add the rows (N/2 • A|0) to C Columns i where x[i] = 0 can have arbitrary values, as these do not contribute to 2xz or x • z.Add the rows (0|I n−m ) to C 2 ;

=
XP N (2|b n i V T | − b |V | v )(117)Due to the commutation relation of Equation (15) and because (bn i V T )b |V | v = b |V | v when v[i] = 1:

Proposition C. 1 (
Mapping Non-CSS Stabiliser Codes to CSS Codes)Let C be the codespace of a Pauli stabiliser code on n qubits.There exists a CSS code on n qubits with codespace C such that C = DQC where Q := XP 2 (0|q|0), q is a length n binary vector and D is a diagonal level 2 Clifford operator.Furthermore, a diagonal operator B is a logical B operator of C if and only if QBQ −1 is a logical B operator of C.

S
D = CZ 01 CZ 12 CZ 23 CZ 01 CZ 34 CZ 40 satisfies C = DC using the conjugation rule CZ 01 X 0 CZ 01 = X 0 Z 1 .Whilst C has distance 3, C has distance 1.In the linked Jupyter notebook, users can use the above method to find D, Q and C for various non-CSS stabiliser codes from www.codetables.de.

Table 1 :
Comparison of Search and Test Algorithms for Diagonal Logical Operators.Note that entries annotated with * require the diagonal logical identities of algorithm 1 as input.Entries annotated with ** require the diagonal logical operators of algorithm 4 as input.

-qubit controlled-phase gates
S operator on both logical qubits:S 0 S 1 = S 1 S 2 CZ 03 If either is not the case, return FALSE.In this example, we apply the logical operator test to the logical CZ 12 found for the hypercube code in Example 3.2.As CZ 12 := XP 8(0|0|02060602), we let z = 02060602.Let x = 11111111 corresponding to the single X-check.We calculate the group commutator C := (2x•z|0|−2xz).We find that x • z = 16 = 0 mod 8 and −2xz = 04040404 mod 8. Referring to Example 3.1, we see that this vector is a row of K M .As both x • z = 0 mod 8 and −2xz ∈ K M Z N , C is a logical identity.Accordingly, we have verified that CZ 12 is a diagonal logical operator on the code.Applying the method of Section 2.5, we note that CZ 12 is at level 2 of the Clifford hierarchy and the group commutator C is at level 1.
5: Logical Operators of CSS Codes and Embedded Codes: A CSS encoding maps k logical qubits into n physical qubits via C : H k 2 → H n 2 , which takes computational basis elements |v to codewords |v L. Consider a level-t controlled-phase operator B acting on H k 2 .An operator B acting on H n 2 is a logical B operator if BC = CB.We show how to construct a canonical logical B operator B from level-t phase-rotation gates.Let V be the matrix whose rows are length n binary vectors representing the support of the controlled-phase operators making up B. The embedded codespace is formed by applying the embedding EV : H n 2 → H 2 , 2, 2m]] codes with a transversal CZ operator, the first member of which is the [[4, 2, 2]] code of Example 2.2.Looking at the CCZ column, we have a family of [[8m 3 , 3, 2m]] codes which have a transversal CCZ operator, the first member of which is the hypercube code of Example 3.1.The 6-qubit code in the S column is the 6-qubit code discussed in Example 4.1.The 15-qubit code in the T column is the 15-qubit Reed-Muller code.The first entry in the CS column is the [[12, 2, 2]] code with the following X-checks and X-logicals:

Table 2 :
Parameters of CSS codes generated by the embedded code method when searching for implementations of logical operators based on the toric code of distance d.For a logical operator acting on k qubits, we use a k-dimensional toric code.
3 correctly identifies diagonal logical operators of XP form.We first show that if the group commutator of an operator B with each of the logical identities A 1 , A 2 is a logical identity, then the group commutator of the product A 1 A 2 is a logical identity.
Proposition B.2 (Commutators of Logical Identities) Let I XP be the logical identity group as defined in Section 2.6 and let A 1 , A 2 ∈ I XP .Let B be an XP operator such that [[A 1 , B]] and [[A 2 , B]]