Quantum Codes From Classical Graphical Models

We introduce a new graphical framework for designing quantum error correction codes based on classical principles. A key feature of this graphical language, over previous approaches, is that it is closely related to that of factor graphs or graphical models in classical information theory and machine learning. It enables us to formulate the description of the recently-introduced ‘coherent parity check’ quantum error correction codes entirely within the language of classical information theory. This makes our construction accessible without requiring background in quantum error correction or even quantum mechanics in general. More importantly, this allows for a collaborative interplay where one can design new quantum error correction codes derived from classical codes.


A. Introduction
Information is processed, communicated and stored using physical systems that are susceptible to error.As such, error detection and correction protocols are necessary to ensure reliable operation.The fundamental principle underpinning classical information theory and error correction [1 1, 2 2] is that data is redundantly encoded across an expanded space of bits.The resultant logical data has additional degrees of freedom which can be exploited to actively detect and correct errors.The exact method by which information is redundantly encoded to create logical data is specified by a set of instructions know as a code.In practice, most error correction schemes are based on an efficient class of protocols known as linear block codes.For block codes, error correction proceeds by tracking the correlations between data bits using parity checks.The role of the additional redundancy bits in a block code is to store the parity information so that it can be decoded over time.Modern protocols such as low-density-parity check (LDPC) codes [3 3-5 5] and turbo codes [6 6, 7 7] perform at close to the Shannon rate, which is the maximum theoretical rate for information transfer along a noisy channel [8 8].
In quantum error correction [9 9-12 12] bits are replaced with quantum bits (from now on referred to as qubits).Qubits exhibit several features, discussed in more detail below, which complicate the process of creating quantum error correction codes.State of the art quantum error correction codes, such as the surface code [13 13], rely upon a special type of quantum measurement known as a stabiliser.Stabilisers play a similar role to the previously mentioned parity checks, but are subject to various constraints that make it difficult to derive quantum codes in direct analogy to efficient classical codes.Some efforts have been made in [14 14] to relate a quantum error correction code to two classical codes satisfying certain conditions.Whilst this has provided a further understanding of existing codes, it does not provide a constructive strategy for discovery of new codes.In recent work [15 15], the so-called coherent parity check (CPC) codes were introduced as a new framework to derive quantum error correction codes.The specific advantage of CPC codes is a fail-safe code structure that guarantees that the quantum mechanical requirements of the code are satisfied.As a result, the CPC construction provides a useful framework for the conversion of classical block codes to quantum codes.In [15 15], CPC code design was demonstrated using the zx-calculus as well as a corresponding generator matrix formulation.
In this work, we outline a complementary, special-purpose, formalism for CPC codes to allow them to be expressed in terms of classical factor graphs of the type commonly used in classical information theory and machine learning.
To do this, we first introduce an intermediate graphical language called the operational representation.In addition to providing a visualisation of operations performed between qubits, the role of the operational representation is to abstract away the quantum mechanical properties of the code into a form that enables it to be mapped to a classical factor graph.Following this translation, any code design and optimisation proceeds using purely standard graphical The [7,4,3] Hamming code.Note that in the context of coding these graphs are sometimes referred to as Tanner graphs.
models, without any further reference to quantum mechanics.We first demonstrate the utility of the classical factor graph representation for quantum code design by outlining the derivation of a simple quantum detection code.We then describe how factor graphs can be used to construct a quantum error correction code based on classical Hamming codes.

B. Graphical models in classical information theory
We begin by outlining standard conventions in the graphical representation of classical error correction codes (for an overview see [2 2, 16 16]).This provides a point of reference with which to compare the graphical language for quantum error correction presented in this paper.In a classical block code, parity bits are introduced to measure and track the parity of the data bits.A factor graph is a tool designed to provide a visualisation of the relationship between data and parity bits in a given error correction code.
As as a simple first example of factor graph notation, we consider a single (classical) parity check cycle on a two-bit data register r = (d 1 , d 2 ), where d 1 and d 2 are classical data bits with values 0 or 1.In the encode stage of the parity check cycle, an extra bit is introduced to measure and store the parity check of the data bits, which is calculated as the binary sum p = (d 1 + d 2 )mod 2. The resultant three-bit string c = (d 1 , d 2 , p) is called the codeword.A factor graph representation of this encoding is shown in Figure 1 1a, where the circles represent the data bits and the crossed square the parity bit.The edges in the factor graph indicate which data bits are involved in a given parity check.Mathematically, we can also express this relation through the generator matrix of the code G, which relates the data register and the code word via c = G T r (mod 2).In the above example the generator matrix reads giving the code word equation Whilst in some cases it is useful to work with the generator matrix, we note that the same information is contained in the factor graph, on which we focus here.
A single error on any of the three bits in the protocol depicted in Figure 1 1a can be detected by comparing the values of parity checks at successive times p(t 0 ) and p(t 1 ).A bit-flip error occurring between these checks will cause the value of the parity to change such that p(t 0 ) = p(t 1 ).Under the standard labelling convention, this parity check cycle is an [n = 3, k = 2, d = 2] code, where n is the total number of bits and k is the number of data bits.The code distance d is the Hamming distance between code words, and so the minimum weight of an error operator that will not be picked up as an error.For the code depicted in Figure 1 1a, the distance is d = 2, as an error of weight two will cause the parity bit to flip back to its original value.
The [3,2,2] code can detect the presence of a single bit-flip, but does not provide enough information to pinpoint which of the bits the error occurred on.It is therefore a detection code.Full error correction codes, with the ability FIG. 2: Pure quantum states can be represented as a point on the surface of the so-called Bloch sphere.
to both detect and localise errors require multiple overlapping parity checks.An example is the [7,4,3] Hamming code, the factor graph for which is shown in Figure 1 1b.For correction codes, the task of decoding involves deducing the most likely error from a set of parity check measurements.This information about the most likely error allows the data to be corrected to its original state with high probability.For the case of small codes, such as the Hamming code, decode tables can be constructed by exhaustively testing the code with all possible error chains.
In general, to decode larger codes one views the decoding problem as a maximum posterior inference problem.The use of factor graphs naturally leads to techniques from graphical models [16 16] to efficiently find the maximum posterior estimator.In many large real world codes, doing exact maximum posterior inference is computationally hard, but efficient approximate inference algorithms are know such as belief propagation [16 16].Therefore, the use of graphical model representations of error correction codes not only provides a intuitive visualisation of the generator matrix (2 2), but also affords access to a number of powerful approximate inference algorithms designed for graphical models.

C. From classical to quantum error correction
Before we describe our graphical language for quantum error correction, we give a brief overview of the challenges quantum mechanics imposes on quantum code design (for reviews see [17 17, 18 18]).This discussion is included to put our work into context, as our graphical language is self-consistent and can in principle be applied without any knowledge of quantum mechanics.
In classical information theory and computer science, information is commonly represented through bits which take values 0 and 1.In quantum mechanics, the formalism gives rise to what is known as a quantum bit, or qubit for short.The mathematical representation of a qubit can best be understood as a point on a Bloch sphere (see Figure 2 2), which represents a wavefunction denoted as |ψ in Dirac notation [ 19 19].Analogous to classical bits, a qubit can be in states |ψ = |0 and |ψ = |1 , as depicted in Figure 2 2. However, they can also be in a superposition such as The general form of the qubit wavefunction is given by |ψ = α |0 + β |1 where α and β are complex numbers satisfying the condition |α| 2 + |β| 2 = 1.One important property of quantum mechanics is known as the collapse of the wave function.A measurement of the general state for example, 'collapses' the qubit to |ψ = |0 or |ψ = |1 with probabilities |α| 2 and |β| 2 respectively.The important consequence is that measurement is not typically passive in quantum mechanics: measuring a system in general changes its state.The above is enough to understand some of the challenges of quantum error correction.First, as a qubit is no longer a binary number but the mathematical equivalent of a point on a three-dimensional sphere, it becomes clear that errors can occur in different forms, corresponding to flipping the state around a different axis.This gives rise to two different types of errors, the so-called bit and phase errors.The standard quantum notation for a bit-flip operator is the symbol X, which has the following effect on the general qubit state (3 3) Similarly, phase-flip operators are represented by the symbol Z and transform the general qubit state (3 3) as follows In this paper, we also refer to bit-flip and phase-flip errors as X-errors and Z-errors respectively.Mathematically, the operators {X, Z} can be represented as Pauli matrices.A quantum error correction code must have the ability to detect and correct both types of errors.Technically, there is also the possibility of a Y -error which can be understood as a simultaneous X-and Z-error.In classical error correction, the simultaneous occurrence of errors in this way is referred to as a burst error.For our outline of graphical models for quantum error correction, it initially suffices to focus on X-and Z-errors only, with discussion of Y -errors left to the end.
A second issue is that aribtrary quantum data cannot be copied, or cloned.In general, then, simple quantum repetition codes cannot be established.
A third challenge in the design of quantum error correction codes has to do with the aforementioned 'collapse of the wave function'.Parity checking depends crucially on measurement, which is considered non-disturbing classically.In contrast, the parity checking sequences in a quantum code must be carefully chosen so not to collapse the encoded information.Such non-disturbing measurements are referred to as stabilisers.
A final complication to quantum error correction compared to classical error correction is that quantum parity checks are performed via 'unitary' operations on the combined system of data plus parity qubits.A consequence of unitarity is that operations are in general bi-directional: both qubits involved in an operation change their state (this is connected to the fact that quantum data cannot be cloned).This means that parity checks themselves can propagate faults to the data register, resulting in an additional pathway for errors that needs to be accounted for.

D. Coherent parity check codes
The challenges of quantum error correction described in the previous section have complicated the development of good quantum codes with high rates.For example, the surface code [13 13, 20 20-22 22] -currently the favoured experimental quantum error correction protocol -requires a minimum of 13 qubits [ 34 34] to encode a single logical qubit [ 23 23].The coherent parity check (CPC) framework for quantum error correction has recently been introduced in [15 15] and further developed in [ 24 24], with the aim of providing a toolset for the construction of efficient quantum codes.Central to this new framework is a fail-safe code structure that ensures all CPC codes are stabiliser codes.The advantage to this is that there no longer restrictions on the form of parity checks performed on the quantum data; the fact that CPC codes are stabiliser codes guarantees that the chosen parity check will not collapse the encoded information.Consequently, the CPC framework allows for code construction methods that do not rely upon a detailed understanding of quantum mechanics.In [24 24], it is shown how CPC codes can be discovered via exhaustive machine search.Another promising application of the CPC framework is as a tool for the conversion of classical codes to quantum codes [ 15 15].Here, we expand upon this work by demonstrating that CPC codes can be described using graphical methods inspired by the classical factor graph notation.
As is the case in classical parity check codes such as the Hamming code, the qubits in a CPC code are separated into data qubits and parity check qubits.Error detection in a CPC code involves performing a round of phase-parity checks, followed by a round of bit-parity checks.At the end of the code a final round of cross-checks is performed between the parity check qubits to fix the code distance.A more detailed presentation of the CPC code structure can be found in [15 15, 24 24].Note that the order in which the different types of parity check are performed in a CPC code is important.In the following sections we assume a canonical CPC ordering involving phase-checks, bit-checks and then cross-checks.This ensures that there is a restricted set of error propagation pathways that can be accounted for in a systematic way.

II. A GRAPHICAL LANGUAGE FOR QUANTUM PARITY CHECK OPERATIONS A. Operational representation of quantum parity check codes
We now introduce an intermediary graphical representation we call the operational representation of CPC codes.This notation is designed to enable easy visualisation of the propagation of the different types of quantum errors between qubits, and will serve as stepping stone to our eventual presentation of CPC codes using classical factor graphs in Section III III.
Graphs of the operational representation have two types of nodes: 1. triangles ( ) representing data qubits and 2. stars ( ) representing parity qubits.
FIG. 3: The operational representation: The triangle nodes represent data qubits and the stars parity qubits.The nodes are connected by three types of edges.(a) Bit-check edges (drawn in red) copy X-errrors from data qubits to parity qubits.Z-errors are back propagated in the reverse direction.(b) Phase-check edges (drawn in black) between data and parity qubits.This edge propagates a Z-error as a X-error between the qubits.The phase-check edge is symmetric and has the same error propagation behaviour in both directions.(c) Cross-check edges connect parity check qubits to other parity check qubits.The error propagation behaviour for cross-check edges is identical to that of phase-check edges.
FIG. 4: The operational representation for quantum parity checking cycles on a register of two data qubits.The qubit nodes in these graphs are labelled 1-3.(a) The bit-flip code or [ [3,2,1]] code detects X-errors on any of the three qubits.Z-errors on the data qubits will, however, go undetected as the bit-check edges do not propagate Z-errors from data qubits to parity qubits.(b) The phase-flip code or [[3, 2, 1]] code.Here Z-errors on the data qubits are propagated to the parity-qubit as X-errors, allowing them to be detected via a measurement.Z-errors on the parity qubit will propagate a correlated XX error to the register that goes undetected.
The nodes are connected via edges that denote the different error propagation pathways between the qubits.The three types of edges between qubit nodes are shown in Figure 3 3.The first type of edge in the operational representation, shown in red in Figure 3 3a, is called a bit-check edge and propagates quantum information in two directions: bit-errors are propagated from the data qubit to the the parity qubit and phase-errors in the opposite direction.In a quantum computer, bit-check operations are implemented via the application of a controlled-not (cnot) gate.Further details about the operation of cnot gates in the context of CPC codes can be found in [15 15, 24 24].The black edge in Figure 3 3b connects a data qubit to a parity qubit, and is referred to as a parity check edge.The parity check edge propagates Z-errors and converts them into X-errors, as shown in Figure 3 3b.This conversion between error types is important, as it allows a Z-error to be detected as a X-error via a parity check measurement.Phase-check operations of this type are realised via the implementation of a conjugate-propagator gate in a quantum computer.Specific details about this gate are outlined in [24 24].
The third type of edge is a black edge connecting two parity qubits, as shown in Figure 3 3c.This edge is called a cross-check, and has the same error propagation behaviour as the phase-check operation.Cross-check operations are useful for detecting the errors that are back-propagated to the register by the phase-check and bit-check edges.
Figure 4 4 shows the operational representation for two ] quantum parity check codes; the first is designed to detect bit-flip errors and the second phase-flip errors.The error propagation rules summarised in Figure 3 3 can be used to determine the operation of each code.It can be verified that the bit-flip [[3, 2, 1]] code will detect any single-qubit error from the set {X 1 , X 2 , X 3 }.Here X i refers to the X-error of qubit i as labelled in Figure 4 4.However, as we are dealing with a quantum information, the full single-qubit error set includes the phase-errors Figure 4 4b shows the operational representation for the phase-flip [[3, 2, 1]] code.Single-qubit Z-errors that occur on the data qubits are propagated to the parity qubit as an X-error, which is then detected by a measurement.A Z-error on the parity qubit itself, however, will go undetected as the parity qubit measurement is unchanged by phase-flip errors.This is a problem, as the black edges can propagate errors from the parity qubit back to the register, meaning certain errors can go undetected.Figure 4 4b shows that when Z-error occurs on the parity-qubit of the phase-flip [ [3,2,1]] code, a correlated X 1 X 2 error is propagated to the register qubits.Back propagation of errors to the register in this way severely complicates the construction of quantum codes.In the next section, we show how the CPC codes can be designed to account for such errors.Figure 5 5a shows the operational representation of a code constructed by combining the bit-and phase-flip [[3, 2, 1]] codes.The canonical CPC code ordering stipulates that phase-checks are performed before the bit-checks.Under this ordering, and by applying the previously described error propagation rules, it can be to verified that the code in Figure 5 5a will detect single-qubit X-and Z-errors that occur on either of the data qubits.However, as shown by the arrows in Figure 5 5a, a phase-flip error on the parity qubit connected to the data qubits via bit-check edges propagates errors to the register that go undetected.As a result, the code depicted in 5 5a is a [[4, 2, 1]] code.However, the undetected error propagation pathway can be closed by applying a cross-check edge between the two parity qubits as shown in Figure 5 5b.This cross-check ensures that the code detects all single-qubit X-and Z-errors, and so fixes the code distance to d = 2.The code shown in Figure 5 5b is therefore a [ [4,2,2]] code, capable of detecting both bitand phase-flip errors on any of the four qubits.

C. Annotated operational representation for general CPC codes
All CPC codes follow the same general construction as the [[4, 2, 2]] code.Two codes -one for bit-flips and one for phase-flips -are merged to form a combined code.The code distance is then fixed via the addition of cross-checks between the parity qubits.Under the canonical CPC ordering, the phase-checks are performed first, the bit-checks second and the cross-checks last.Any CPC code can be represented via the operational representation consisting only of the qubit nodes and edges described in Section II B II B. For larger codes, it is often useful to annotate the operation representation graph to better visualise the pathways for indirect propagation of errors.As an example, consider the case of a data qubit connected to two parity qubits, the first via a bit-check edge (red) and the second via a phase-check edge (black).A Z-error that occurs on the parity qubit to the right will be copied to the data qubit as an X-error when the phase-check operation is applied.The resultant X-error on the data qubit is then propagated to the other parity qubit by the bit-check operation.At the end of the CPC cycle, the initial Z-error is therefore detected as a bit-flip error on the other parity qubit.We can annotate the operational representation as follows: Here the error propagation pathway between the two parity qubits is highlighted by a directed pink edge.This edge can be considered a virtual edge, as it does not correspond to a physical operation between the qubits it connects.
The process of adding the virtual edges to an operational representation is called annotation.
In addition to the case described above, there is another pathway for the indirect propagation of an error through a CPC code.Consider a data qubit connected to a parity qubit by both a bit-check and a phase-check edge.A phase-flip error on the parity qubit will propagate to the register and then back to the parity qubit as a bit-flip error.The annotation works as follows: Z X X X (7) This propagation can be described in terms of a self-loop virtual edge.
In larger CPC codes, there will be multiple virtual edges that can cancel each other out.The addition of virtual edges can also lead to simplifications that reduce the total number of phase-and bit-check edges.A complete list of rules for adding virtual edges, along with various simplification rules, is included in Table II II in Appendix A A.
The advantage of the annotated operational representation is that the virtual edges provide a way of illustrating the propagation of errors without having to consider the canonical CPC ordering.We will see in the following section that this simplification helps with the mapping from the operational representation to classical factor graphs.

III. MAPPING THE GRAPHICAL LANGUAGE TO GRAPHICAL MODELS IN CLASSICAL INFORMATION THEORY A. Translation rules mapping the operational representation to classical factor graphs
The graphical language of the operational representation, outlined in the previous section, allows quantum codes to be illustrated in terms of the physical operations connecting qubits.The annotated version of a operational representation includes virtual edges that highlight indirect propagation pathways for errors.We now show how the annotated operational representation can be mapped to an equivalent classical factor graph notation.
The data and parity nodes in the operational representation correspond to qubits that store both bit and phase error information.In a classical factor graph, a qubit can therefore be represented as two bits, one for each type of error.A data qubit is mapped to two classical data bits, one representing the bit information and the other the phase information: .
As a convention, we choose to draw these bits side-by-side, with the node representing bit information on the left (coloured yellow) and the node representing phase information on the right (coloured blue).A parity qubit is also mapped to two bits in classical factor graph notation: The bit information component of a qubit is used as a parity measurement, and is therefore drawn as a classical parity check node.The phase information of parity check qubit, however, cannot be directly measured.As such, the phase-information component of the parity check qubit is mapped to an unmeasured classical data bit (shown in blue on the right).
We can now describe how the different edge types in the operational representation are drawn in a classical factor graph.Bit-check edges connect data qubits to parity qubits.Their action is to propagate bit information from the data qubit to the parity qubit and phase information in the opposite direction.The mapping of a bit-check edge to classical factor graph notation is shown here: An edge is drawn between the bit information component of the data qubit and the bit information component of the parity qubit.Notice, however, that there is no edge drawn between the phase-components of two qubits to indicate the propagation of phase-flip errors from the parity qubit to the data qubit.This is omitted, as there is no concept of indirect error propagation in a classical factor graph; the edges in a classical factor graph are only permitted between data and parity nodes, and not between nodes of the same type.Instead, indirect propagation of errors are accounted for in classical factor graphs by placing edges in the place of the virtual edges in an annotated operational factor graph.An explicit example of this is shown later in this section.
The classical factor graph representation of a phase-check edge reads: The phase component of the data qubit is connected to the bit-component of the parity qubit via an edge.This shows that the phase-check edge propagates phase-errors on data qubits to bit-errors on the parity qubits.Recall that phase-edges are symmetric and that error propagation also occurs in the reverse direction.The back-propagation of errors in this way is not shown in the classical factor graph.The reason for this is again that edges are only permitted between data and parity nodes in a classical factor graph.The classical factor graph representation of a cross-check edge reads: The phase-component of each qubit is connected to the bit-component of the other.This reflects the expected error propagation behaviour for cross-check edges.
The next component to be mapped to classical factor graphs are the virtual edges that depict the indirect propagation of errors through the code.Virtual edges show how a phase-error on one parity qubit can be detected as a bit-flip error on another.The classical factor graph mapping of a virtual edge is given by A virtual edge is directed meaning error information only propagates in one direction.The final translation rule is for the virtual self loop edge.In the classical factor graph notation this edge is represented as follows: A summary of the translation rules for mapping the operational representation to the classical factor graph representation can be found in Appendix B B.

B. Translation example: The [[4, 2, 2]] detection code
We have now outlined how to translate the operational representation to classical factor graphs.Here we provide an example by analysing the development of the [[4, 2, 2]] detection code in terms of both representations.
In Section II B II B we showed how a preliminary CPC code can be constructed by combining the bit-flip and phase-flip [ [3,2,1]] codes.The distance of this code was determined to be d = 1 by consideration of the propagation of bit-and phase-flip errors through the code.The code distance was then fixed to desired length of d = 2 via the addition of a cross-check edge between the two parity qubits.The [[4, 2, 2]] code is the simplest CPC detection code, and as such the code distance can essentially be determined by inspection.However, for larger CPC codes, calculating the code distance may become a hard problem.
Figure 6 6a shows the annotated operational factor graph for the preliminary code formed by combining the bitflip and phase-flip [[3, 2, 1]] codes.As both of the virtual edges connect the same nodes in the same direction they cancel each other out, in accordance with the simplification rules outlined in Appendix A A. By following the mapping procedure outlined in the previous subsection, we obtain the classical factor graph of the preliminary code which is shown in Figure 6 6b.Inspection of the classical factor graph reveals that there are two data bits that go unchecked, from which it can be concluded that the distance of the code is d = 1.The classical distance of the code represented by the classical factor graph is the same as the quantum distance of the operational factor graph it is based on.The preliminary CPC code is therefore a [ [4,2,1]] code.We discussed in Section II B II B how to move from the [[4, 2, 1]] to the [[4, 2, 2]] code by the addition of a cross-check edge between the two parity qubits.The corresponding annotated operational representation is shown in Figure 7 7a which translates into the classical factor graph shown in Figure 7 7b.

IV. DESIGNING QUANTUM ERROR CORRECTION CODES WITHOUT KNOWING QUANTUM MECHANICS
A. General design rules to develop quantum error correction codes using classical factor graphs The factor graph formalism provides a highly general tool for the design of quantum error correction codes.We now outline a specific code design strategy that can be employed using classical factor graphs, without having to refer back to the operational form after the initial mapping.Our approach enables quantum codes to be constructed using classical techniques and does not require detailed knowledge of quantum mechanics.The steps of this code design procedure can be summarised as follows: 1. Construct a preliminary code in the annotated operational representation by combining two classical codes, the first for bit-flip errors and the second for phase-flips.Convert the resultant graph to a classical factor graph using the mappings described in Section III III.
2. Calculate the distance of the preliminary code.
3. Determine the form of the cross-checks that need to be added to fix the code distance to the desired length.
Following the initial mapping from the operational representation, the optimisation steps of the code design process (steps 2 and 3) are carried out entirely within the classical factor graph framework.The reason that this method can be followed without reference to the operational form is that the addition of cross-checks does not lead to any indirect propagation of errors.In a classical factor graph, cross checks are added between parity qubits according to the following rule, where a pair of edges link the phase component of one qubit to the bit component of the other.A situation which may be encountered when using this rule, occurs when a cross-check is applied between qubits that are already connected by one or more edges.For this case, we need to define a simplification rule for a double edge.Since the xor of a bit value with itself is always zero, it stands to reason that two edges between the same pair of nodes in a factor graph will cancel as follows, As an example, consider the case, depicted below, in which a cross-check is added between a pair of qubits that are already connected by a virtual edge, The double edge that is formed cancels to give the factor graph on the right.From this, we can deduce the rule that when a cross-check is added between a pair of qubits already connected by a virtual edge, the direction of the virtual edge is reversed.The operational version of this rule is listed in Table II II in Appendix A A. We now apply the code design method outlined in the previous subsection to a small example.We first combine two copies of the classical Hamming code given in Figure 1b 1b to form a preliminary quantum code.After considering the indirect error propagation, as discussed in Appendix C C, the annotated operational form of the preliminary code maps to the factor graph depicted in Figure 8 8. From this point onwards, the construction and optimisation of the code proceeds entirely within the classical factor graph framework.By inspection, we see immediately that the preliminary code has some nodes which are not joined to any parity check nodes.These nodes correspond to the phase-components of the parity check qubits.As a result, some errors will go undetected, meaning the preliminary code is a [ [10,4,1]] quantum code.
To turn the preliminary code into a distance three quantum error correcting code, each data node must be connected to at least two parity checks.We must further ensure that all single-bit errors result in a unique error pattern.By construction, the parity check qubits in the code in Figure 8 8 fall into two disjoint subsets.
• Subset S 1 : the parity check qubits which detect X-errors (bit flip) on data qubits (circled in yellow).
• Subset S 2 : the parity check qubits which detect Z-errors (phase) on data qubits (circled in blue).This separation will help in categorising the different types of errors and the error patterns they produce.For example, it can be seen that bit-flip errors on the data qubits will result in an error pattern involving only parity check qubits in S 1 .Similarly, phase-flip errors on the data qubits result in an error pattern involving only the parity check qubits in S 2 .
The first modification to be made to the preliminary code is to add edges to the unconnected phase nodes in each parity check qubit.This can be achieved through the addition of cross-checks between the affected parity check qubits, as depicted by the blue edges in Figure 9 9. Notice that we have specifically chosen cross-checks that connect parity qubits in S 1 to parity qubits in S 2 .This ensures that the error patterns resulting from Z-errors on the parity check qubits will contain a combination of measurements from S 1 and S 2 .Consequently, Z-errors on the parity check qubits are distinguishable from X-and Z-errors on the data bits.As there are no longer are any unconnected bits, the modified code in Figure 9 9 is a [ [10,4,2]] detection code.
We now have a code that will detect Z-errors on any of the parity qubits.The next step is to find a code modification that will guarantee that the error patterns produced by these errors are distinguishable.One way of achieving this is to add cross-checks between all parity qubits in S 1 and likewise for S 2 .The resultant factor graph is shown in Figure The code formed by the addition of cross-check edges (highlighted in blue) between parity check qubits in S 1 and S 2 .As each bit node in the graph is connected to least one parity check node, this is a [ [10,4,2]] detection code.10: The code formed by the addition of cross-checks between all the qubits in S 1 and likewise for S 2 .The yellow cross-checks connect qubits in S 1 , and the blue cross-checks connect qubits in S 2 .This code will produce unique syndromes for an error model containing X-, Z-and Y -errors.It is therefore a [ [10,4,3]] code.Based on previous arguments, this code is now a [ [10,4,3]] code for an error model containing X-and Z-errors.
We now show that the [ [10,4,3]] code depicted in Figure 10 10 will also produces unique error patterns for another type of error, the Y -error.In terms of the classical factor graphs, Y -errors correspond to a specific type of burst error in which both the bit-and phase-components of a qubit are errored simultaneously.We first note that all Y -errors on data qubits result in detection patterns of weight four or six with half of the parity measurements in S 1 and half in S 2 .Fortunately, the error patterns with two parity measurement in each subset are distinct from those produced by a Z-error in S 2 .On the other hand, Y -errors on S 1 parity check qubits will result in error patterns of weight four, of which three of the measurements occur in S 1 and one of the measurement in S 2 .For Y -errors on S 2 , there will be three measurements in S 2 and two in S 1 .Since the weight of the error patterns resulting from Y -errors are greater than that for X or Z, the signatures that are produced are unique.The factor graph in Figure 10 10 is therefore also a [ [10,4,3]] code for an error model containing X-, Z-and Y -errors.[10,4,3]] code shown in the factor graph in Figure 10 10 is shown in Table IV IV in Appendix C C. We have now shown that a distance d = 3 quantum code can be constructed from a starting point of two classical codes using factor graph methods.The necessary modifications to the code were deduced entirely through visual inspection of the classical graph.Cross-checks were chosen in such a way that different types of error on different components of the code produced error signatures of distinct types.It should be noted that the solution we have found is not unique; other combinations of cross-checks exist that will also fix the code distance to d = 3.

V. DISCUSSION
We have introduced a framework to create classical graphical models or factor graphs for quantum error correcting codes.This process begins with an operational representation, designed to show how the qubits interact to form a coherent parity check CPC code [15 15].The operational representation given here is a human readable analogue of the machine readable matrix based formalism in [ 15 15].Unlike the more general ZX calculus used in [15 15], this is a special-purpose graphical representation specifically designed to show error propagation.Because of the nature of the interactions between qubits, there is unavoidable indirect propagation of errors.However, this propagation can be understood in terms of graphical rules which amount to the addition of virtual edges to the operational representation.Once the virtual edges have been added to the operational representation, there is a further set of graphical rules to map it to a classical factor graph.This classical factor graph represents error propagation within the quantum code.
We demonstrated a design procedure using classical factor graphs which requires no reference to the operational representation, and allows for quantum code design to be treated as classical problem with restrictions on how interactions may be added.This means that code design can be performed based on completely classical intuition about error correction.Highly-optimised tools for classical LDPC and turbo codes can therefore be applied to quantum error correction, without the user having to understand quantum theory.
We have shown the utility of our graphical representation with both error detection codes and error correction codes.In general, factor graph methods can be applied equally well to codes that are designed to suppress errors rather than fully correct.Many of the most promising quantum algorithms for quantum simulation (i.e. the variational quantum eigensolver [25 25-27 27]) and optimisation (i.e.the quantum approximate optimisation algorithm [28 28-31 31]) are tolerant to some error.In this context, bespoke error suppression codes designed using factor graphs would be useful.
A further advantage to the classical factor graph representation is that the graph effectively tracks all of the detected errors, and can therefore be viewed as a simplified simulation of the code's error propagation pathways.This means that the factor graph representation can reliably give information about error propagation of complex and correlated errors.To illustrate this, we consider the propagation of Y -errors which arise on quantum hardware when a bit-and phase-flip occur simultaneously.Such errors can be thought of as a two-bit burst error, occurring on both the bit and phase part of a qubit simultaneously.
Although we do not provide an example in this paper, it is possible to construct CPC codes that include a secondtier of parity qubits whose role it is to monitor other parity qubits.A construction of this type is outlined in [15 15] to provide a general method for converting any pair of distance three classical codes to a quantum code.As the second-tier of parity qubits only check other parity bits, they do not interact with the data qubits.Because of this, errors that occur on second-tier parity qubits can be considered benign in the sense that they do not propagate errors to the data qubits.As such, it is only necessary to detect the benign errors instead of fully correcting.Performance metrics, such as code distance, are calculated without taking into account benign errors, and can therefore be thought of as a lower bound on the code performance based on a conservative decoding strategy.The codes outlined in this paper do not include second-tier parity qubits, and benign errors do not need to be considered.However, in future work it would be interesting to search for codes where consideration of benign errors becomes important, and to modify our notation to account for this.
An important consideration in the design of quantum codes is that some interactions between qubits may be difficult or impossible to implement directly on real quantum hardware.The fact that the physical layout of the device is important, highlights another strength of our graphical formalism: the graph created by the operational representation of the code is the interaction graph of the qubits.It is therefore natural to include hardware constraints into the methods given here.This allows for the design of quantum codes specially optimised to the demands of a given quantum device.
In summary, we have given in this paper a new way to connect the knowledge and skills of classical information processing to the design of quantum error correction procedures.By representing error propagation in an intuitive, graphical, and classical-style way, the problem of designing and simulating quantum codes becomes much more tractable.The connection to classical graphical representations is both interesting theoretically and of powerful practical use.The expectation is that these tools will allow the skills and intuition of the classical error correction community to be brought to bear on the next generation of quantum error correction codes.
Table IV IV is the syndrome table for the [ [10,4,3]] code depicted in the classical factor graph in Figure 10 10.The qubit numbers correspond to the qubits labels shown in the operational form of the code in Figure 11 11.The syndromes can be inferred by direct inspection of the factor graphs.Alternatively, the syndrome table can be calculated using the matrix methods outlined in [15 15, 24 24].[10,4,3]] Hamming code depicted in operational form in Figure 11 11 and in classical factor graph form in Figure 10 10.The syndromes for each error are represented as six-bit binary strings.The bits, from left-to-right, correspond to the measurement outcomes of the parity qubits 5 − 10 (labelled in Figure 11 11).The first three bits in the syndrome string (coloured red) represent measurement outcomes from the parity qubits in subset S 1 .
The final three-bits (coloured blue) in the syndrome represent measurement outcomes of the parity-qubits in subset S 2 .
Figure 4 4a  shows that Z errors on the data qubits in the bit-flip [[3, 2, 1]] code are not propagated to the register.As a result a single-qubit error can go undetected, meaning the code has distance d = 1.

FIG. 5 :
FIG. 5: Construction of a [[4, 2, 2]] CPC detection code.(a) The operational representation for the code formed by combining a [[3, 2, 1]] bit-flip code with a [[3, 2, 1]] phase-flip code.A Z-error on the bit parity check qubit (labelled) will propagate errors to the register without flagging a check.As this error goes undetected, this is a [[4, 2, 1]] code.(b) The [[4, 2, 2]] code is constructed by adding a cross-check edge between the parity check qubits.The additional cross-check ensures all single-qubit errors are detected and fixes the code distance to d = 2.

FIG. 6 :FIG. 7 :
FIG. 6: The [[4, 2, 1]] CPC code formed by combining the bit-flip and phase-flip [[3, 2, 1]] codes.(a) The annotated operational representation.The virtual edges connect the same nodes in the same direction.They therefore cancel each other out, as per the rules outlined in Appendix A A. (b) The code in classical factor graph form.It can immediately be seen that there are two unconnected data bits, meaning the code has distance d = 1.

FIG. 8 :
FIG.8:The classical factor graph for the preliminary code formed by combining two copies of the classical Hamming code depicted in Figure1b1b.Parity check qubits belonging to S 1 are circled in yellow, while those belonging to S 2 are circled in blue.The phase-components of each parity check qubit are not connected to any other nodes.As a result, Z-errors of the parity check qubits go undetected, meaning the code has distance d = 1.The preliminary code is therefore a [[10,4,1]] code.The operational representation of this code is shown in Appendix C C.
FIG.9:The code formed by the addition of cross-check edges (highlighted in blue) between parity check qubits in S 1 and S 2 .As each bit node in the graph is connected to least one parity check node, this is a [[10,4,2]] detection code.

10 10 ,
where the cross-checks connecting S 1 are shown in yellow and the cross-checks connecting S 2 are shown in blue.

TABLE I :
[10,4,3]sting the structure and weight of the error signatures (also refereed to as syndromes) resulting from different types of errors in the [[10,4,3]] code depicted in Figure1010.Each error-type results in a different syndrome structure, meaning single-qubit errors are distinguishable.The full syndrome list for this code can be found in Appendix C C.
Table I I summarises the structure of signatures produced for different types of errors in the [[10, 4, 3]] code.The complete syndrome table for the [ X-error syndrome Z-error syndrome Y -error syndrome

TABLE IV :
Syndrome table for the [