Graph Neural Networks for Enhanced Decoding of Quantum LDPC Codes
In this work, we propose a fully differentiable iterative decoder for quantum
low-density parity-check (LDPC) codes. The proposed algorithm is composed of
classical belief propagation (BP) decoding stages and intermediate graph neural
network (GNN) layers. Both component decoders are defined over the same sparse
decoding graph enabling a seamless integration and scalability to large codes.
The core idea is to use the GNN component between consecutive BP runs, so that
the knowledge from the previous BP run, if stuck in a local minima caused by
trapping sets or short cycles in the decoding graph, can be leveraged to better
initialize the next BP run. By doing so, the proposed decoder can learn to
compensate for sub-optimal BP decoding graphs that result from the design
constraints of quantum LDPC codes. Since the entire decoder remains
differentiable, gradient descent-based training is possible. We compare the
error rate performance of the proposed decoder against various post-processing
methods such as random perturbation, enhanced feedback, augmentation, and
ordered-statistics decoding (OSD) and show that a carefully designed training
process lowers the error-floor significantly. As a result, our proposed decoder
outperforms the former three methods using significantly fewer post-processing
attempts. The source code of our experiments is available online.
Anqi Gong, Sebastian Cammerer, Joseph M. Renes
# Graph Neural Networks for Enhanced Decoding of Quantum LDPC Codes

###### Abstract

In this work, we propose a fully differentiable iterative decoder for quantum low-density parity-check (LDPC) codes. The proposed algorithm is composed of _classical_ belief propagation (BP) decoding stages and intermediate graph neural network (GNN) layers. Both component decoders are defined over the same sparse decoding graph enabling a seamless integration and scalability to large codes. The core idea is to use the GNN component between consecutive BP runs, so that the knowledge from the previous BP run, if stuck in a local minima caused by trapping sets or short cycles in the decoding graph, can be leveraged to better initialize the next BP run. By doing so, the proposed decoder can learn to compensate for sub-optimal BP decoding graphs that result from the design constraints of quantum LDPC codes. Since the entire decoder remains differentiable, gradient descent-based training is possible. We compare the error rate performance of the proposed decoder against various post-processing methods such as random perturbation, enhanced feedback, augmentation, and ordered-statistics decoding (OSD) and show that a carefully designed training process lowers the error-floor significantly. As a result, our proposed decoder outperforms the former three methods using significantly fewer post-processing attempts. The source code of our experiments is available online.

+
Footnote †: [https://github.com/gongaa/Feedback-GNN](https://github.com/gongaa/Feedback-GNN)

## 1 Introduction

Quantum low-density parity-check (QLDPC) codes are among the most promising types of error correction codes for fault-tolerant quantum computing. In recent years there have been numerous efforts to design QLDPC codes of high rate and high distance [1, 2]; even linear distance has been investigated in [3, 4]. Recent work from Bravyi et al. [5] shows how certain codes can be mapped to a bilayer hardware architecture, spurring further interest in the community and increasing the practical importance of low-complexity decoders for such codes.

In this work, we focus on decoding medium block-length and high-rate CSS QLDPC codes introduced in [6]. These codes are of particular interest due to their strong performance under maximum likelihood decoding and its approximations, such as OSD; however, their performance is known to be suboptimal under plain BP decoding. This can be intuitively explained by the fact that the corresponding Tanner graph contains unavoidable 4-cycles [7] due to the stabilizer commutation requirement. On the other hand, since errors differing by a stabilizer have the same syndrome, symmetric stabilizer trapping sets [8, 9, 10], where BP cannot decide between certain such errors (e.g., two equal-weight ones), also degrades BP performance. The authors in [8] proposed to alleviate this issue by adding a small perturbation to the channel prior probabilities given as input to the BP decoder. An improved version is shown in [11], where the perturbation depends on the unsatisfied checks.

The goal of our work is to learn those perturbations using a GNN. The GNN follows the concept of [12] and acts as an intermediate layer between independent BP runs, as shown in Figure 1. It takes the output log-likelihood ratios (LLRs) \(\mathbf{\Lambda}_{\text{post}}\) estimated by the previous BP decoding stage, then calculates the reliabilities of checks, and uses both information to provide a refined channel prior \(\mathbf{\Lambda}^{\prime}\) as initialization of the next BP run.

We call this intermediate layer a _feedback_ GNN. The GNN operates on the same decoding graph as the BP decoder, facilitating a seamless integration with the BP decoding stages. Our trained feedback GNN requires significantly fewer attempts than the aforementioned two methods [8, 11] to achieve a lower logical error rate, as shown in Fig. (4a).

Machine learning for channel decoding is doomed by the curse of dimensionality meaning that the training complexity scales exponentially with the codeword length [13]. However, we would like to emphasize that one advantage of the proposed feedback GNN

Figure 1: Block diagram of the proposed decoder architecture consisting of trainable GNN layers (orange) and _classical_ BP iterations (yellow). The same GNN is sandwiched between block BP runs of iteration \((64,16,16,16)\).
structure is that the graph is explicitly provided and the main decoding task still relies on BP Thereby, its training complexity is only mildly affected by the codeword length [12].

The remainder of the paper is organized as follows. Section 2 contains some background information on the CSS-type LDPC codes, and in Section 2.2, we review some existing post-processing methods. Section 3 reviews the quaternary BP decoding method. With this basis we describe the feedback GNN model architecture and the training method in Section 4. Section 5 presents the numerical simulation results. We conclude in Section 6.

## 2 Quantum Low-Density Parity-Check Codes

In the following we restrict our attention to the i.i.d. depolarizing channel, in which each qubit independently and identically experiences a random \(X\), \(Z\), or \(Y=iXZ\) type of error, each with probability \(p/3\) for some \(p\in[0,1]\).

### CSS Quantum Codes

Quantum Calderbank-Shor-Steane (CSS) [14, 15] codes are constructed from two _classical_ codes \(C_{X}=\ker H_{X}\) and \(C_{Z}=\ker H_{Z}\) defined by parity-check matrices \(H_{X}\) and \(H_{Z}\) under the requirement \(H_{X}H_{Z}^{T}=\mathbf{0}\), i.e., \(C_{Z}^{\perp}\subseteq C_{X}\) or equivalently \(C_{X}^{\perp}\subseteq C_{Z}\). Rows of \(H_{X}\) and \(H_{Z}\) form the \(X\)- and \(Z\)-type stabilizer generators, while the \(X\)-type and \(Z\)-type logical operators are \(C_{Z}/C_{X}^{\perp}\) and \(C_{X}/C_{Z}^{\perp}\), respectively. All parity-check operations are binary operations in GF(2).

If \(C_{X}\) is a blocklength \(N\) code, encoding \(K_{X}\) info bits (an \([N,K_{X}]\) code), and \(C_{Z}\) is an \([N,K_{Z}]\) code, then the resulting quantum code is an \([\![N,K_{X}+K_{Z}-N]\!]\) code. The quantum minimum distance of this code is \(d=\min\{d_{X},d_{Z}\}\), where \(d_{X}=\min\{\mathrm{wt}(\mathbf{x}),\mathbf{x}\in\ker H_{Z}/\mathrm{im}\ H_{X}^ {T}\}\), \(d_{Z}=\min\{\mathrm{wt}(\mathbf{x}),\mathbf{x}\in\ker H_{X}/\mathrm{im}\ H_{Z}^ {T}\}\). \(\mathrm{wt}(\mathbf{x})\) is the Hamming weight of the binary vector \(\mathbf{x}\).

An error is specified by \(N\)-bit vectors \(\mathbf{e}_{X}\) and \(\mathbf{e}_{Z}\) which denote the \(X\) and \(Z\) components of the error, respectively. A decoder takes the observed syndromes \(\mathbf{s}_{X}=H_{Z}\mathbf{e}_{X}\) and \(\mathbf{s}_{Z}=H_{X}\mathbf{e}_{Z}\) and constructs correction operations \(\hat{\mathbf{e}}_{X}\) and \(\hat{\mathbf{e}}_{Z}\). Importantly, these do not need to precisely match the error for decoding to succeed. Instead, \(\hat{\mathbf{e}}_{X}\) and \(\mathbf{e}_{X}\) may differ by an \(X\)-stabilizer, and \(\hat{\mathbf{e}}_{Z}\) and \(\mathbf{e}_{Z}\) may differ by a \(Z\)-stabilizer, as these correction operations will return the system to the codespace without incurring any logical error.

The requirement for successful correction can be compactly written as \(H_{X}^{\perp}(\hat{\mathbf{e}}_{X}+\mathbf{e}_{X})=\mathbf{0}\) and \(H_{Z}^{\perp}(\hat{\mathbf{e}}_{Z}+\mathbf{e}_{Z})=\mathbf{0}\). This is more stringent than only requiring \(\hat{\mathbf{e}}\) to have the correct syndrome, i.e., \(H_{Z}\hat{\mathbf{e}}_{X}=H_{Z}\mathbf{e}_{X}\) and \(H_{X}\hat{\mathbf{e}}_{Z}=H_{X}\mathbf{e}_{Z}\), since the row span of \(H_{X}\) is contained in the row span of \(H_{Z}^{\perp}\) for a CSS code.

In the context of the depolarizing model, the \(X\) and \(Z\) components of the CSS codes can be separately decoded using classical (binary) syndrome BP decoders. To address the correlation between \(X\) and \(Z\) errors, a _quaternary_ BP decoder [7] was introduced to directly operate on the Tanner graph constructed using both the \(X\) and \(Z\) checks. However, due to the CSS code constraints, this Tanner graph inevitably contains cycles of length \(4\)[7]. This renders the decoding of QLDPC codes into a challenging, but from research perspective yet attractive, task.

### Existing Post-Processing Methods

One difficulty of decoding QLDPC codes using message passing methods is that the correction operator \(\hat{\mathbf{e}}=(\hat{\mathbf{e}}_{X}|\hat{\mathbf{e}}_{Z})\) of the decoder is not assured to result in a zero syndrome \(\mathbf{s}=(\mathbf{s}_{X}|\mathbf{s}_{Z})=\mathbf{0}\). We call such cases "flagged" events. To overcome such flagged events, several post-processing methods have been proposed. One approach is to take the output of the BP decoder and use it to adjust the inputs to another round of BP decoding, in the hope that that round will lead to an unflagged error. The following is a summary of such methods, which can be applied repeatedly until the parity-checks are satisfied or the maximal number of attempts \(N_{a}\) is reached:

* Random perturbation [8] randomly chooses unsatisfied ("frustrated") checks and randomly perturbs the input LLRs for all the qubits involved in those checks.
* Enhanced feedback [11] randomly chooses one frustrated parity-check and one of its associated qubits. The channel prior of this qubit is adjusted such that an anticommuting/commuting error is more likely if the ground truth syndrome of the parity-check is \(1/0\).
* Section III.A of [16] contains an overview of the first two methods. In addition, [16] proposes a matrix augmentation method, which randomly chooses and repeats some of the rows from the parity-check matrix, and uses this augmented matrix to initialize the message passing decoding in the next round.
* Stabilizer inactivation (SI) [10] ranks the parity-checks according to their reliability, as measured by the sum of the absolute values of the posterior LLRs of the associated qubits. Then the qubits associated to the most unreliable checks are "inactivated" by taking them out in the next round of message passing decoding. Finally, the error on the inactivated qubits is determined by solving a small system of linear equations.

A related method is _zeroth_-order OSD [6], which is applied only once after BP decoding. By its nature, OSD always gives an estimate that satisfies the syndrome equations, thus eliminating flag errors. This involves solving a rank\((H)\) system of linear equations. Higher-order OSD was also introduced in [6], but is beyond of the scope of this work.

## 3 Quaternary Belief Propagation Decoder

The quaternary BP (BP4) algorithm utilizes the correlation between \(X\) and \(Z\) noise by directly working on the quaternary alphabet \(\{I,X,Y,Z\}\). Here we discuss the details of the algorithm, as they will be useful later. As with usual BP decoding algorithms, BP4 utilizes the Tanner graph of the code, and proceeds by sending messages back and forth between VNs to CNs. The goal is to estimate, for each qubit, the marginal probability of error on that qubit, given the observed syndrome.

Following [17, 18], the input to the BP4 algorithm is the syndrome pair \(\mathbf{s}_{X}=H_{Z}\mathbf{e}_{X}\) and \(\mathbf{s}_{Z}=H_{X}\mathbf{e}_{Z}\). Initialize variable nodes to \(\mathbf{\Lambda}\in\mathbb{R}^{N\times 3}\), where the \(i^{th}\) row \(\mathbf{\Lambda}_{i}=(\Lambda_{i}^{X},\Lambda_{i}^{Y},\Lambda_{i}^{Z})\) is the sequence of LLRs associated with \(X\), \(Y\), and \(Z\), respectively. Specifically, \(\Lambda_{i}^{X}=\log\frac{p_{i}^{I}}{p_{i}^{X}}\), where \(p_{i}^{I}\) and \(p_{i}^{X}\) are the probabilities of no error or an \(X\) error happening on VN \(i\), respectively. In the case of i.i.d. depolarizing noise \(p_{i}^{X}=p_{i}^{Y}=p_{i}^{Z}=p/3\) for all VN \(i\), meaning the initial VN LLRs are

\[\Lambda_{i}^{X}=\Lambda_{i}^{Y}=\Lambda_{i}^{Z}=\log\frac{1-p}{p/3}\quad \forall i\,. \tag{1}\]

The message \(\lambda_{i\to j}\) sent from VN \(v_{i}\) to CN \(c_{j}\) is a scalar. For example, if \(c_{j}\) involves an X-type check on \(v_{i}\). Then this scalar LLR message is

\[\lambda_{i\to j}=\log\frac{p_{i}^{I}+p_{i}^{X}}{p_{i}^{Y}+p_{i}^{Z}}=\log \frac{1+e^{-\Lambda_{i}^{X}}}{e^{-\Lambda_{i}^{Y}}+e^{-\Lambda_{i}^{Z}}} \tag{2}\]

since either \(Y\) or \(Z\) error contributes \(1\) to (anticommutes with) the check. When \(c_{j}\) involves a \(Y\)- or a \(Z\)-type check the messages are defined similarly, as the LLR of an anticommuting error. This mapping (and thus the BP4 algorithm) can also be applied to non-CSS codes, however, we restrict ourselves to CSS QLDPC codes in this work. As a consequence, every check node involves either pure \(X\) checks or pure \(Z\) checks on VNs.

### Check Node Update

The message \(\Delta_{j\to i}\) from CN \(c_{j}\) back to VN \(v_{i}\) is the LLR of whether \(v_{i}\) commutes with \(c_{j}\), conditioned on the check node observations.

**Lemma 3.1**.: _Gallager [19]. Consider a sequence of \(m\) independent binary digits \((a_{1},...,a_{m})\) in which \(\Pr[a_{k}=1]=p_{k}\). Then the probability \(q\) that \(a_{1}\oplus\cdots\oplus a_{m}=1\) (i.e., an odd number of ones occurring) is_

\[q=\frac{1}{2}-\frac{1}{2}\prod_{k=1}^{m}(1-2p_{k}) \tag{3}\]

_which can be rewritten in the log-domain as_

\[\log\frac{1-q}{q}=2\tanh^{-1}\left[\prod_{i=1}^{m}\tanh\left(\frac{1}{2}\log \frac{1-p_{i}}{p_{i}}\right)\right]. \tag{4}\]

The right-hand side is usually abbreviated as the boxplus operation \(\boxplus_{i=1}^{m}\Lambda_{i}\) for LLRs \(\Lambda_{i}=\log\frac{1-p_{i}}{p_{i}}\). Later, the loss function and the feature required by the GNN both rely on this simple lemma.

The message \(\Delta_{j\to i}\) involves extrinsic information only, and is given by

\[\Delta_{j\to i}=(-1)^{s_{j}}\cdot\underset{i^{\prime}\in\mathcal{N}(j) \backslash\{i\}}{\boxplus}\lambda_{i^{\prime}\to j} \tag{5}\]

where \(s_{j}\in\{0,1\}\) is the syndrome of the check, \(\mathcal{N}(j)\) is the set of neighboring VNs of \(c_{j}\) in the Tanner graph.

### Variable Node Update

The VN update processes the messages coming from the CNs in the direct neighborhood. Assume \(c_{j}\) involves an X-type check on \(v_{i}\), the LLR message \(\Delta_{j\to i}\) cannot distinguish between \(I\) and \(X\) noise as they both commute with the check, similarly, it cannot distinguish \(Y\) and \(Z\) noise. Therefore, it is assumed that those posterior probabilities \(p_{I}^{j\to i}=p_{X}^{j\to i}\) and \(p_{Y}^{j\to i}=p_{Z}^{j\to i}\), and hence \(\Delta_{i\to j}=\log\frac{p_{i}^{j\to i}+p_{X}^{j\to i}}{p_{Y}^{j\to i}+p_{Z}^{ j\to i}}=\log\frac{p_{i}^{j\to i}}{p_{Z}^{j\to i}}\).
Similarly, if \(c_{j}\) involves a Z-type check on \(v_{i}\), then \(\Delta_{i\gets j}=\log\frac{p_{i}^{j-i}}{p_{x}^{j-i}}\).

The update of the the LLR vector \((\Gamma_{i\gets j}^{X},\Gamma_{i\gets j}^{Y},\Gamma_{i\gets j}^{Z})\) for \(v_{i}\) also done via the extrinsic information rule given as

\[\Gamma_{i\to j}^{X}=\Lambda_{i}^{X}+\sum_{j^{\prime}\in\mathcal{M}_{Z}(i) \setminus\{j\}}\Delta_{i\gets j^{\prime}} \tag{6}\]

where \(\mathcal{M}_{Z}(i)\) are all the \(Z\)-type check nodes (CSS code) involving \(v_{i}\). Note that checks \(c_{j}\) from \(\mathcal{M}_{X}(i)\) make no contribution as \(\log\frac{p_{i}^{j-i}}{p_{x}^{j-i}}=0\). Similarly, the update rule for \(\Gamma_{i\to j}^{Y}\) is

\[\Gamma_{i\to j}^{Y}=\Lambda_{i}^{Y}+\sum_{j^{\prime}\in\mathcal{M}_{Z}(i) \setminus\{J\}}\Delta_{i\gets j^{\prime}}\,. \tag{7}\]

Using (2), one can combine messages to send to \(X\) and \(Z\)-type CNs and continue the BP iterations.

### Hard Decision

Before a final hard decision, the last decoding iterations calculate the channel posterior \(\mathbf{\Lambda}_{\text{post}}=(\mathbf{\Gamma}^{X},\mathbf{\Gamma}^{Y}, \mathbf{\Gamma}^{Z})\) whose individual components read

\[\begin{split}\Gamma_{i}^{X/Z}&=\Lambda_{i}^{X/Z}+ \sum_{j^{\prime}\in\mathcal{M}_{Z/X}(i)}\Delta_{i\gets j^{\prime}}\\ \Gamma_{i}^{Y}&=\Lambda_{i}^{Y}+\sum_{j^{\prime}\in \mathcal{M}_{Z}(i)\bigcup\mathcal{M}_{X}(i)}\Delta_{i\gets j^{\prime}} \end{split} \tag{8}\]

and \(\Gamma_{i}^{I}=0\) and then for each VN choose among \(\{I,X,Y,Z\}\) that leads to the smallest LLR.

## 4 Feedback GNN

The proposed message passing GNN decoder [12] utilizes the same Tanner graph as the BP decoder, but differs in the representation of the messages and uses trainable CN and VN update functions which are parameterized, for instance by using simple MLP layers. Each variable node or check node has an assigned feature vector. The message on an edge is computed using the concatenated features of its two end nodes. Afterward, the state of a node is updated using its previous state and by the aggregated incoming messages from its neighborhood. The aggregation operation used in this work is the mean operation. To keep the decoding complexity low, our feedback GNN eliminates the "iterative" aspect of the decoder, opting for just one VN update iteration. However, the basic concept still follows [12].

### Architecture

After the BP run, the posterior channel LLR is obtained using (8) and it becomes the variable node feature \(\mathbf{h}_{v_{i}}=\mathbf{\Lambda}_{\text{post},i}=(\Gamma_{i}^{X},\Gamma_{i }^{Y},\Gamma_{i}^{Z})\). Using (2), the two LLRs \(\lambda_{i}^{X},\lambda_{i}^{Z}\) of whether \(v_{i}\) commutes with X or Z check are

\[\lambda_{i}^{X}=\log\frac{1+e^{-\Gamma_{i}^{X}}}{e^{-\Gamma_{i}^{Y}}+e^{- \Gamma_{i}^{Z}}}\,,\quad\lambda_{i}^{Z}=\log\frac{1+e^{-\Gamma_{i}^{Z}}}{e^{- \Gamma_{i}^{X}}+e^{-\Gamma_{i}^{Z}}}\,. \tag{9}\]

Using Lemma 3.1, the LLR of whether X-type check node \(c_{j}\) is satisfied is \(\boxed{v_{i}\in N(j)}\,\lambda_{i^{\prime}}^{Z}\). The feature of this check node is

\[h_{c_{j}}=(-1)^{s_{j}}\times\underset{i^{\prime}\in N(j)}{\boxed{\min}}\lambda _{i^{\prime}}^{Z} \tag{10}\]

which is a scalar, and the more negative it is, the more likely this check tends to be not satisfied.

Next, for each CN to VN edge, concatenate the features of its two endpoints and calculate the message

\[\mathbf{m}_{c_{j}\to v_{i}}=f^{\,C_{X/Z}\to V}\left(\left[h_{c_{j}} ||\mathbf{h}_{v_{i}}\right],\boldsymbol{\theta}_{c_{X/Z}\to V}\right). \tag{11}\]

X-type CNs share weights \(\boldsymbol{\theta}_{c_{X}\to V}\) for the function \(f^{\,C_{X}\to V}\). Z-type CNs share weights \(\boldsymbol{\theta}_{c_{Z}\to V}\) for \(f^{\,C_{Z}\to V}\). In our implementation \(f^{\,C_{X}\to V}\) and \(f^{\,C_{Z}\to V}\) are both MLPs with one hidden unit of 40 neurons and \(tanh\) activation. Both MLPs project the messages to dimension 20 as output.

Figure 2: Unrolled feedback GNN operating on the Tanner graph, showing the inside of the orange boxes in Fig. (1). The VN feature is initialized using \(\mathbf{\Lambda}_{\text{post}}\) from the previous BP run and the CN feature is calculated using Eq (9,10). Each edge message is calculated using the features of its two endpoints. After that, each variable node aggregates the incoming X (red) and Z-type (blue) messages and then uses them together with its own feature to obtain a modified channel prior \(\mathbf{\Lambda}^{\prime}\) for the next BP run. Solid objects indicate trainable operations.
For each \(v_{i}\), calculate the average of all the incoming messages from X-type and Z-type checks respectively.

\[\begin{split}\mathbf{m}^{X}_{v_{i}}&=\frac{1}{| \mathcal{M}_{X}(i)|}\sum_{j^{\prime}\in\mathcal{M}_{X}(i)}\mathbf{m}_{c^{ \prime}_{j}\rightarrow\nu_{i}}\\ \mathbf{m}^{Z}_{v_{i}}&=\frac{1}{|\mathcal{M}_{Z}( i)|}\sum_{j^{\prime}\in\mathcal{M}_{Z}(i)}\mathbf{m}_{c^{\prime}_{j} \rightarrow\nu_{i}}\end{split} \tag{12}\]

All VNs share weight for \(f^{VN}\), which is another MLP (hidden unit 40) that projects the high-dimensional messages back to three dimensions.

\[\boldsymbol{\Lambda}^{\prime}_{i}=f^{VN}\left(\left[\mathbf{h}_{v_{i}}|| \mathbf{m}^{X}_{v_{i}}||\mathbf{m}^{Z}_{v_{i}}\right],\boldsymbol{\theta}_{ VN}\right)\,. \tag{13}\]

The resulting output \(\boldsymbol{\Lambda}^{\prime}\in\mathbb{R}^{N\times 3}\) is then used to initialize the next BP run.

This feedback GNN essentially only does one VN update, in contrast to the usual message-passing GNN [12] that does multiple iterations of CN and then VN updates. Moreover, the proposed feedback GNN is lightweight, containing just 3923 trainable parameters in total, irrespective of the code size.

### Boxplus Loss

In order to train this GNN, we feed its output \(\boldsymbol{\Lambda}^{\prime}\) to initialize another BP4 decoding stage, and let it run for 16 iterations. We record \((\Gamma^{X}_{i},\Gamma^{Y}_{i},\Gamma^{Z}_{i})\) as in Eq (8) at the end of iteration 8 to 16 and calculate \(\lambda^{X}_{i},\lambda^{Z}_{i}\) for all these iterations as in Eq (9), and for all X/Z-type checks calculate \(\boxplus_{i^{\prime}\in\mathcal{N}(j)}\lambda^{Z/X}_{i^{\prime}}\), respectively. These are the logits used to calculate a binary cross entropy loss with the ground truth syndrome \(s_{j}\). This loss is minimized when \(H_{X}\hat{\mathbf{e}}_{Z}=H_{X}\mathbf{e}_{Z}\) and \(H_{Z}\hat{\mathbf{e}}_{X}=H_{Z}\mathbf{e}_{X}\).

The proposed _boxplus_ loss is different from the sine loss introduced in [20]. It is also possible to extend this boxplus loss to take degeneracy into account.

For CSS codes, no logical error happens if and only if \(H_{X}^{\perp}\hat{\mathbf{e}}_{X}=H_{X}^{\perp}\mathbf{e}_{X}\) and \(H_{Z}^{\perp}\hat{\mathbf{e}}_{Z}=H_{Z}^{\perp}\mathbf{e}_{Z}\). And the CSS requirement implies \(H_{Z}\subset H_{X}^{\perp}\) and \(H_{X}\subset H_{Z}^{\perp}\). Therefore, we can simply enlarge the X and Z parity-check matrices into \(H_{Z}^{\perp}\) and \(H_{X}^{\perp}\) when doing the multi-loss calculation. When training the feedback GNN, we do not take degeneracy into account.

### Training methods

* Step 1: Generate a dataset using BP4 (64 iterations, flooding), and store the error patterns \((\mathbf{e}_{x},\mathbf{e}_{z})\) for which BP4 fails to decode. Only \(\mathbf{e}_{x}\vee\mathbf{e}_{z}\) (bit-wise OR) having Hamming weight up to \(0.05\times n\) are considered. We gather roughly a million such errors.
* Step 2: Use this dataset to train a coarse GNN which is then used to generate _hard-to-decode_ examples in the next step. The GNN is embedded between two BP runs of 16 iterations. The output of iterations 8 to 16 of the latter run is used to calculate a boxplus multi-loss, as described in the last subsection. Training takes roughly ten minutes on a single NVIDIA RTX4090.
* Step 3: Use the trained coarse GNN embedded into two 64-iteration BP components to generate a more sophisticated dataset. Note that we need fewer samples from this dataset when compared to step 1 (empirically 1/50 of the original size).
* Step 4: We mix the _hard-to-decode_ dataset with the easy one and balance the probability of occurrence (such that easy/hard to decode samples are equally likely). We then finetune the GNN sandwiched between (64,16) BP blocks for the new dataset. Each training takes less than half an hour.

Note that we train ten such models in parallel and select the best one.

We implement the BP decoder together with a normalization factor \(\kappa\). Specifically, the messages from CN to VN in Eq (6,7) are multiplied by this scaling factor. During training, the factor \(\kappa=1.0\) is used in every BP run (i.e. no scaling). However, we empirically observed that during evaluation, at high physical error rates, it is beneficial to set \(\kappa\) for the first run of BP to 0.8. It is also interesting to observe that the feedback GNN improves the logical error rate even at high physical error rates \(p\) though the model was not trained there. However, we do not show the curves at low physical error rates for \(\kappa=0.8\), as they have higher error floors when compared to \(\kappa=1.0\).

The GNN is trained by being embedded between two BP blocks, but during evaluation, it is reused for possibly more than one attempt. Let (64,16,16,16) denote the decoder consisting of 64 BP iterations followed by \(3\times 16\) BP iterations each with an intermediate GNN layer sharing the same weight. In Figure 3, one can see three attempts (64,16,16,16) are better than one attempt (64,64), though the latter involves more total BP runs but less GNN layers.

We choose (64,16,16,16) to be the final decoder. Hereby, steps 3 and 4 of the training improve the performance at low \(p\). As can be seen in Figure 3, using
the coarse GNN has an error floor of a logical error rate around \(10^{-6}\) while the finetuned version shows a significantly lower error floor.

## 5 Simulation

The message passing (MP) decoder used in this work is the sum-product (BP) version with flooding scheduling. All the computations are conducted using 32-bit floating-point precision. The LLR initialization for the first BP run uses a fixed \(p=0.05\), independent of the real physical error rate. The messages from CN to VN in Eq (6,7) are multiplied by a normalization factor. After each GNN feedback, the BP takes this feedback as the channel LLR initialization, and starts with re-initialized messages. The **same** GNN weights are used in each round of feedback if there are multiple, see Alg. 1 for the pseudo-code.

In [10], the authors showed that SI outperformed OSD-0 when using **binary** message passing algorithms for both to obtain soft information for the post-processing. In the original work [6], the quaternary normalized min-sum (NMS) was used which shows a strong performance on the depolarizing channel (see Fig. (4b)). It is not clear how much improvement SI can gain when extended to the quaternary version, because its Tanner graph has unavoidable 4-cycles while the Tanner graph for \(H_{X}\) does not, and SI depends on the convergence of MP on the remaining Tanner graph.

Recently in [21], a randomly order layered scheduled MP decoder was proposed for the type of QLDPC codes we are investigating in this work, for example, the \(\llbracket 882,24\rrbracket\) code. This decoder involves no post-processing. CN updates are indexed into layers. The authors found that there exist 7 layers that could cover each check exactly twice for this code. When using a perturbed (multiply each CN message by a random factor in \(\{0.875,0.9275\}\)) normalized min-sum (NMS) as the MP decoder and randomizing the order of layer updates, they achieve very good results on the Z-noise channel (comparable to **binary** NMS+OSD in [10]). In addition, the decoding time is proportional to the \(64\times 3.5=224\) steps for Z noise, where 64 is the number of iterations, and the fractional layer number 3.5 is because CNs in different layers cannot be updated in parallel.

In [10, 21], the authors considered both sum-product (BP) and normalized min-sum (NMS) algorithms as message-passing decoders and various scheduling methods, we picked their best curves as a benchmark in Fig. (4b). We are not competing with them as it is not fair for them, since they ignore the X and Z correlation when applying their algorithms. In fact, our methods could be used together, for example by replacing our flooding BP with their layered random order perturbed NMS decoder, though this will require retraining the feedback GNN.

## 6 Conclusion

We proposed an iterative decoding scheme for quantum LDPC codes based BP-4 and GNN decoding stages. We train the GNN layers such that they learn to refine the channel input LLRs for subsequent BP decoding stages. We demonstrated that our feedback GNN significantly lowers the error floor on two medium block-size QLDPC codes when carefully trained. The feedback GNN benefits from a computational latency of \(\mathcal{O}(1)\) when nodes are updated in parallel (and assuming a fixed number of iterations). However, in practice the complexity overhead of the feedback GNN is similar to a 16-iteration BP due to the computational complex matrix multiplications in the MLPs. Furthermore, we proposed a new loss based on the boxplus operation that calculates a more accurate reliability estimate of the check nodes. We leave it open for future research to improve the training strategy for faster convergence. Further, optimizing the decoder architecture for real-time implementations remains an open challenge for future work.

Figure 3: Logical error rate of \(\llbracket 1270,28,\leqslant 46\rrbracket\) codes using feedback GNNs on depolarizing channel. Comparison of the performance of the coarse and the refined GNN trained on easy and mixed samples respectively.
## Appendix A Loss Function

Here we remark on the sine loss used in Neural BP [20] and the boxplus loss used herein. As mentioned in the main text, the sine loss has some unwanted oscillation behavior. However, it can be used to train the Neural BP decoder by initializing such that it equals the classical BP decoder by setting all the weights to one. Hence the initialization of Neural BP is already a good decoder and the loss is already small. Reasonable training will not result in oscillating points due to the sine loss. However, when using this loss to train a full-GNN message-passing decoder from scratch (as done in [12]), we empirically observed that the loss does not converge. Therefore, we propose the boxplus loss as a more stable substitute. Note that, as the channel posterior probabilities approach either \(0\) or \(1\), the sine loss is a good approximation to the boxplus loss, which is the analytical solution and involves the product of those posterior, whereas sine loss only involves the summation of those terms.

```
Algorithm Sandwich-BP-GNN-Decoder(decoders) Input : CSS code specified by \((H_{\chi},H_{Z})\) and a syndrome pair \((\mathbf{s}_{\chi},\mathbf{s}_{Z})\) Output :\(\hat{\mathbf{e}}=(\hat{\mathbf{e}}_{\chi},\hat{\mathbf{e}}_{Z})\)
1\(\mathbf{\Lambda_{0}}\leftarrow\log\frac{1-p}{p/3}\mathbf{I}_{N\times 3}\)
2\((\hat{\mathbf{e}}_{X},\hat{\mathbf{e}}_{Z},\mathbf{\Lambda}_{\text{post}}) \leftarrow\text{decoders}[0](\mathbf{\Lambda_{0}})\)
3if\(H_{X}\hat{\mathbf{e}}_{Z}=\mathbf{s}_{Z}\) and \(H_{Z}\hat{\mathbf{e}}_{X}=\mathbf{s}_{X}\)then
4return\((\hat{\mathbf{e}}_{X},\hat{\mathbf{e}}_{Z})\)
5 end if /* Begin post-processing. */
6foreachdecoderin decoders[1:]do
7\(\Lambda^{\prime}\leftarrow\text{Feedback-GNN}\) (\(\mathbf{\Lambda}_{\text{post}}\))
8if\(H_{X}\hat{\mathbf{e}}_{Z}=\mathbf{s}_{Z}\) and \(H_{Z}\hat{\mathbf{e}}_{X}=\mathbf{s}_{X}\)then
9return\((\hat{\mathbf{e}}_{X},\hat{\mathbf{e}}_{Z})\)
10 end if
11return\((\hat{\mathbf{e}}_{X},\hat{\mathbf{e}}_{Z})\)
```

**Algorithm 1**Sandwiched BP GNN Decoding

Figure 4: Logical error rate of the \([1270,28,\leqslant 46]\) and the \([882,24,\leqslant 24]\) codes using various post-processing methods on depolarizing channel. \(N_{a}\) is the maximum number of attempts. For our feedback GNNs, only the first block run of BP4 needs \(64\) iterations, while \(16\) iterations are enough for the post-processing block BP4 run. For example, three attempts will involve \(64+16\times 3=112\) iterations of flooding BP in total. The factor \(\kappa=1.0\) or \(0.8\) was used for the first block run of BP, all later runs used \(1.0\). (**a**) All the curves except the four feedback GNN ones are taken from Fig. (3) of [6], where a \(32\)-iteration layered normalized min-sum (NMS) decoder with factor \(0.625\) was used as the MP decoder in every attempt. Our feedback GNN, which aims to capture the core ideas of random perturbation [8] and enhanced feedback [11], at three attempts indeed outperforms these two methods repeated \(100\) times. (**b**) The random order layered binary perturbed NMS [21] method was implemented on Z-noise, converted here to depolarizing noise using the \(2/3\) rule. Their total number of steps needed is \(64\times 3.5=224\) for Z noise. While ours is at most \(64+16\times 5=144\) for depolarizing noise. The stabilizer inactivation [10] methods use \(50\)-iteration serial BP2 in every stage.