{'fraction_non_alphanumeric': 0.030518640479830647, 'fraction_numerical': 0.0166411854639539, 'mean_word_length': 4.498545101842871, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
High-throughput GPU layered decoder of multi-edge type low density parity check codes in continuous-variable quantum key distribution systems

The decoding throughput in the postprocessing is one of the bottlenecks for a continuous-variable quantum key distribution (CV-QKD) system. In this paper, we propose a layered decoder to decode quasi-cyclic multi-edge type LDPC (QC-METLDPC) codes based on graphic processing unit (GPU) in continuous-variable quantum key distribution (CV-QKD) systems. We optimize the storage method of the parity check matrix, merge the sub-matrices which are unrelated, and decode multiple codewords in parallel on GPU. Simulation results demonstrate that the average decoding speed of LDPC codes with three typical code rates, i.e., 0.1, 0.05 and 0.02, is up to 64.11Mbits/s, 48.65Mbits/s and 39.51Mbits/s, respectively, when decoding 128 codewords of length 106 simultaneously without early termination.


Introduction
In the current data-driven era, the demand of secret communications has been increasingly desired. A straightforward approach to secret communications is achieved by encryption techniques. However, encryption with the key, which is established with algorithms based on the assumptions of computation complexity, may no longer guarantee data security, as the large-scale universal quantum computer being reachable.
Quantum key distribution (QKD), which establishes a secret key between two remote participants based on the quantum mechanics principles, can provide the guaranteed security between two participants by using a one-time-pad encryption algorithm to encrypt and decrypt data 1,2 . So far, QKD has been quickly developed in both theory and experiment since the groundbreaking work of Bennett and Brassard in 1984 1 , and become one of the most mature branches of quantum information technologies.
There exist two categories of QKD. One is the discrete variable QKD (DV-QKD) where the key information is encoded on discrete Hilbert space, such as the polarization or phase of single photon pulse, the other is the continuous variable QKD (CV-QKD) where the key information is encoded on continuous Hilbert space, such as the quadratures of coherent states. Compared with the DV-QKD which is based on single-photon preparation and detection, CV-QKD can directly utilize the standard telecommunication technologies (such as coherent detection), and hence has more potential advantages in practice.
Generally, the two participants in a CV-QKD system desire to establish a secret key for a long distance with a very low signal-to-noise ratio. Then it naturally raises a problem on designing codes with good error-correction performance, under such a stringent channel condition. In this case, only low-rate codes with very long block lengths can be exploited to achieve high efficiency key reconciliation.
Low density parity check (LDPC) codes have been shown to possess Shannon-limit approaching error-correction performance 3 , and they have also been broadly applied in various communication systems, such as the DVB-S2 standard and the Enhanced Mobile Broadband (eMBB) data channels for 5G New Radio 4, 5 . Chung et al. designed an irregular LDPC code of length 10 7 which achieves within 0.04 dB of the Shannon limit 6 . Consequently, LDPC codes with long block lengths have become one of the most promising candidates for a CV-QKD system. Herein, multi-edge-type (MET) LDPC codes have attracted much attention due to their excellent performance.
The authors of Ref. 7 reported a random MET-LDPC code with rate 0.1, where the decoding speed was up to 7.1Mbits/s using a graphic processing unit (GPU) implementation at signal-to-noise ratio (SNR) = 0.161, in a CV-QKD system. In Ref. 8 , the authors employed a quasi-cyclic (QC) MET-LDPC code of expansion factor 512 and rate 0.1, where the simulation results demonstrated that the decoding speed was up to 9.17Mbits/s under the early termination condition at SNR = 0.161. Note that if the messages of the degree-1 variable nodes are updated only once at the end of the iterative decoding procedure, the decoding speed of the rate-0.1 MET-LDPC code can be up to 30.39Mbits/s when SNR = 0.161 and 64 codewords are decoded simultaneously 9 .
One of main bottlenecks that restrict the secret key rate of an LDPC-coded CV-QKD system is the throughput of the belief-propagation (BP) decoder in the postprocessing of CV-QKD. This is because successful decoding at very low SNR requires a large number of iterations. Towards this end, the layered BP algorithm 10 can be utilized to speed up the decoding convergence. In addition, a large expansion factor is employed when constructing QC-MET-LDPC codes in order to making full use of the parallel computing ability of GPU.
When implementing the GPU-based layered BP decoder, we optimize the storage of the matrix message by merging bits into one number, and combine two processes into one kernel to complete a whole iteration. As a consequence, it reduces the computation amounts. We also merge the unrelated sub-matrices because they do not affect each other and can thus be computed simultaneously by threads. The speed of our layered decoder is up to 64.11Mbits/s for a code of length 10 6 and rate 0.1 under the condition of SNR = 0.161, 50 iterations without early termination.

Results
Based on the fact that the LLR messages update at variable/check nodes can be performed in parallel, the layered BP decoding algorithm is deployed on GPU. This section optimizes the GPU implementation of layered BP decoding algorithm.
The decoder implementation is optimized in such a way that the LLR is stored in global memory for coalesced access. For memory access in a warp, coalesced access means that the data address of a thread always keeps the same as the thread index, instead of the unordered access. Since the GPU kernel is executed by a warp consisting of 32 threads, the decoding latency can be hidden well for a code with length being a multiple of 32. The layered BP decoder has a coalesced global memory access, and stores the parity-check matrix in one file for indexing the corresponding LLR messages. Such a file denoted by H_compact1, will be applied in calculating the LLR messages related to the check nodes. Each element in file H_compact1 contains three pieces of information: the amount of the shift, the position of the element after row rearrangement in the base matrix, and the position of the column where the non-negative element located in the base matrix. For example, Fig. 1 Fig. 1-(b). Then, one sub-matrices shown in Fig. 1-(c) are used for indexing the needed messages. Accordingly, the one-dimensional matrix on the right side in Fig. 1-(c) represent the degrees of the base matrix (i.e., each element of the the one-dimensional matrix represents the number of elements non negative 1 in the corresponding column of the base matrix).
The GPU-based layered BP decoder updates the LLR messages of variable nodes and check nodes simultaneously, and it also enables us to decode multiple codewords in parallel. For each individual codeword, the required number of GPU threads is the same as the number of check nodes in a sub-matrix. Each thread computes the LLR messages received from the neighboring variable nodes, and also calculates the LLR messages for each adjacent variable node. This procedure is illustrated in Fig. 2 by taking an LDPC code with 4 check nodes and 6 variable nodes as an example. It is worth noting that at each iteration, one thread corresponds to a check node. If the expansion factor Z is equal to 100, 1 × 100 threads corresponding to check nodes of a sub-matrix send LLRs to neighboring variable nodes, and also calculate the messages from variable nodes. Next the 1 × 100 reusing threads update LLRs at the second group of check nodes and their neighboring variable nodes. The number of reuse of this group of threads is equal to that of rows of the base matrix. Nonetheless, the layered BP decoder consumes less thread resources, and the number of threads for each sub-matrix is only 1 × 64 × Z (recall that Z is the expansion factor) when decoding 64 codewords simultaneously. The greater the values of Z and the number of codewords are, the higher the utilization rate of the thread is.
The layered BP decoder only involves one file H_compact1 for indexing. This leads to one GPU kernel implementation of the layered BP decoder for each decoding iteration and each sub-matrix, whose structure is demonstrated in Fig.3. In the unique kernel, the amount of computation in one thread to calculate the message from a variable node to a check node or from a check node to a variable node, defined by the number of edges on which LLRs are computed, is equal to the degree of the corresponding check node. The LLR L  There are Z threads in total that are performed at the same time. The decoder accesses message readily by using H_compact1, and the LLRs of variable nodes are delivered to the next layer, i.e., the (l + 1)-th layer. The above process is a complete iteration in one layer.
The original layered decoder decomposes the H matrix into many sub-matrices on the basis of layers which is equivalent to treating each layer as a sub-code. Each sub-matrix utilizes 1 × Z threads and the serial calculation is conducted among sub-matrices. In order to increase the layered decoder's thread utilization, we merge the unrelated sub-matrices into a new sub-matrix. For example, a 3-by-3 base matrix shown in Eq. (1) with the expansion factor Z can be divided into three submatrices and the degree of any variable node in each sub-matrix is equal to one or zero. Herein, a non-negative integer a in Eq. (1) such as '1', '0', and '2' corresponds to a matrix obtained by cyclically shifting the Z × Z identity matrix to the right by a bits, and '-1' indicates the all-zero matrix of Z × Z.
If a base matrix is of the form given in Eq.
(2), we can combine its first two rows into one layer; that is, the first two rows form a sub-matrix in which the degree of any variable node is equal to one or zero, and the third row separately forms a sub-matrix. Two sub-matrices wok in a serial manner by using 2 × Z and 1 × Z threads, respectively.  3), the first and the third rows of this matrix can be combined into one sub-matrix, and the second row forms a sub-matrix.
If all the sub-matrices consist of K 1 layers and the number of codewords that are decoded at the same time is K 2 , the thread utilization rate is computed by K 1 × K 2 × Z ÷ 67108864.
Note that too many calls of external functions in a kernel function spends much time when using CUDA programming. Moreover, the warp divergence increases the waiting time when warp threads encounter control flow statements and enter different branches, which means that the remaining branches except the branch being executed are blocked at this moment. In this work, the kernel function needs to distinguish the sign of the input data, which can be done by calling the application programming interface (API) provided by CUDA, thereby avoiding warp divergence and reducing the calls of external functions. An infinite value or invalid value may appear because of the iterative running of the kernel function. To avoid this, an API function for clipping is needed. Another optimization is to cut down the branches since the branch structure has great drawbacks when different threads utilize different branches with a high probability. For instance, each thread has different calculation amounts and computation time, and thus the finished threads need to wait for other unfinished ones. Towards 4/8 this end, we can transform the branch structure to an arithmetic operation when parity checks are used, and hence reduce the decoding time.
The performance of GPU-based layered BP decoders are investigated for QC-MET-LDPC codes with rates 0.1, 0.05 and 0.02 on an NVIDIA TITAN Xp GPU, where the expansion factor is 2500. Fig. 4 demonstrates the error correction speed when different number of codewords are decoded simultaneously. The speed grows steadily from 1 to 128 codewords, and it does not converge even if the number of codewords reaches 128. Due to the shortage of storage space, the decoding speed is not considered when the number of codewords decoded simultaneously exceeds 128. Thus, the proposed layered BP decoder in this paper decodes 128 codewords simultaneously, and its thread utilization rate is 1 × 128 × 2500 ÷ 67108864 = 0.00477 where each sub-matrix consists of one layer of the base matrix.   Table 1 compares the performance of the layered BP decoder with two types of sub-matrices. The one consists of a single layer and the other consists of multiple layers. When decoding 128 codewords of lengths 10 6 simultaneously, the layered BP decoder with sub-matrices formed by multiple layers performs better than its counterpart in terms of decoding throughput. The improvement is 3.2Mbits/s, 1.9Mbits/s and 1.6Mbits/s, respectively, when three rates 0.1, 0.05 and 0.02 are considered. The method of combining uncorrelated sub-matrices needs to be further improved, and hence speeds up the decoding and promotes the thread utilization.  Table 1. Performance comparison of the layered BP decoder when decoding different forms of sub-matrices.

Discussion
As described in Ref. 8 , the early termination scheme can be used as an efficient way to reduce the complexity of LDPC decoder and avoids unnecessary iterations at high SNR. However, this scheme may not be efficient at low SNR since the decoding often fails after multiple iterations in this case. Table 2 illustrates the performance of layered BP decoders without early termination when three rates 0.1,0.05 and 0.02 are considered, respectively. In the decoding process, the layered BP decoder uses the sub-matrices which consist of unrelated layers of the base matrix. In Table 2, the first row represents code rates, and the second one is SNR under the BIAWGNC. The third row β indicates the reconciliation efficiency related to the code rate and the number of discarded parity bits, which has an influence on the reconciliation distance and the secret key rate. The fifth row represents the number of edges of Tanner graph involved in the decoding, and the eighth row displays the decoding time consumption within a iteration. Accordingly, the decoding speed for three tested codes is 64.11Mbits/s, 48.65Mbits/s and 39.51Mbits/s, respectively. Table 3 demonstrates the performance comparison of the layered BP decoders with or without early termination at different SNRs where the code length and the code rate are 10 6 and 0.1, respectively. When SNR = 0.161 and 0.171, the layered BP decoder without early termination performs a little faster than that with early termination since less calculations are required to determine whether a valid codeword is obtained in the former. Nevertheless, When SNR = 0.181, the layered BP decoder with early termination is better and the corresponding decoding speed is up to 93.49Mbits/s. This improvement is attributed to the fact that the introduction of the early termination condition reduces the number of iterations significantly at high SNR.  Table 4. Performance comparison with prior works using different types of codes, for rate-0.1 and SNR=0.161 in BIAWGNC.
Despite the high throughput of the GPU-based layered BP decoder, it also has some shortcomings. On one hand, most of threads are not used and thus there exists much space to increase the number of codewords that are decoded simultaneously; but on the other hand, memory shortage limits the number of parallel decoding. Our future work will focus on cutting down on the memory consumption when decoding one codeword and hence increase the thread utilization by decoding more codewords simultaneously.

Methods
In this paper, the layered BP decoding algorithm is employed, which uses less number of decoding iterations to achieve almost the same performance as the flooding BP algorithm. The procedure of the layered BP decoding algorithm is described as follows.
Let m and n denote the m-th check node and n-th variable node, respectively. Moreover, we denote by L q nm the LLR passed from the n-th variable node to m-th check node, and by L r mn the LLR update for the opposite direction. The superscript (t) indicates the current iteration number, and the maximum number of decoding iterations is T . Let l indicate the current check node index, which is also the current layer index of H . Note that the total number of layers in H is L. The layered BP decoding algorithm views each check node as a sub-matrix, while the flooding BP decoding algorithm views all check nodes as a whole matrix.
step1: Initialize the LLR value of the variable nodes by using the received codeword R and channel information where σ 2 denotes the variance of noise in BIAWGNC. Let L (t,l) q n denote the LLR of the n-th variable node at the t-th iteration and the l-th sub-matrix.