Low-density parity-check codes
| Problem | Approach the Shannon limit with long codes whose parity checks are sparse, decoded iteratively by passing probabilities along a graph |
| Devised by | Robert Gallager (1960, thesis 1963); rediscovered by David MacKay and Radford Neal (1996); Tom Richardson and Rüdiger Urbanke (2001), density evolution and optimised irregular codes |
| Accuracy | A regular (3, 6) code of length 1008 reaches a bit error rate of at about 2.7 dB, 2.5 dB from the rate-1/2 Shannon limit (figure below) |
| Cost | per iteration for edges of the graph, with tens of iterations; encoding here from the reduced parity-check matrix |
| Read first | Linear block codes and Hamming codes, Modulation: constellations, OFDM and FM |
| API | LdpcCode (new, gallager, encode, decode, extract_info, is_codeword, info_positions), LdpcDecoded |
Overview
An LDPC code is a linear code whose parity-check matrix is sparse: each check involves a few bits, and each bit a few checks. Draw it as a bipartite Tanner graph of variable nodes (bits) and check nodes, with an edge wherever has a 1. The decoder passes messages along the edges. Each bit tells each of its checks what it believes, based on the channel and its other checks; each check tells each bit what its other bits imply. After a few dozen rounds the beliefs settle on a codeword. Long LDPC codes come within a fraction of a decibel of capacity, and they carry Wi-Fi, 5G data channels, DVB-S2 and 10 Gb Ethernet.
Where it is used
LDPC codes are the practical way to operate close to the Shannon limit, which is why they appear wherever bandwidth or power is expensive.
- Wi-Fi and 5G. IEEE 802.11n/ac/ax and the 5G NR data channel use LDPC codes, with block lengths and rates adapted to the signal quality of the moment.
- Satellite broadcasting. DVB-S2 television, for example, pairs an LDPC code with an outer BCH code to receive reliably at low signal-to-noise ratios.
- Hard-disk and optical storage. Read channels use LDPC codes to recover data from very noisy, densely packed media.
- The idea travels. The message-passing (belief propagation) decoder is the same algorithm used for inference on graphical models in machine learning.
History
Robert Gallager invented LDPC codes and iterative probabilistic decoding in his 1960 MIT thesis, published as a monograph in 1963. Computers of the day could not exploit them, and they were forgotten for thirty years, apart from Michael Tanner’s graph description (1981). After turbo codes (1993) showed that iterative decoding works, David MacKay and Radford Neal (1996) rediscovered Gallager’s codes and showed how close to capacity they come. Tom Richardson, Amin Shokrollahi and Rüdiger Urbanke (2001) developed density evolution to optimise irregular codes, and Sae-Young Chung, David Forney, Richardson and Urbanke (2001) designed one within 0.0045 dB of the limit for very long blocks.
The idea
Gallager’s construction
A regular code has ones in every column and in every row. Gallager stacked blocks. The first block’s rows each cover consecutive positions, and each further block is a random column permutation of the first. LdpcCode::gallager builds it from a seed.
The design rate is . The true dimension is minus the rank of , which Gauss-Jordan elimination over GF(2) finds while also yielding a systematic encoder. The (3, 6) Gallager code of length 1008 has 504 checks of rank 502, so k = 506 (rate 0.502); the Shannon limit for rate 1/2 on the BPSK-input AWGN channel is about 0.19 dB.
Belief propagation
Finding the nearest codeword of a long code by search is impossible. Belief propagation instead lets the bits and the checks improve their estimates of one another, a little at a time, using only local computations.
The quantities. Each bit’s uncertainty is expressed as a log-likelihood ratio (LLR), : positive means “probably 0”, negative “probably 1”, and the magnitude is the confidence. Variable starts with its channel value , what the received signal says about that bit alone. Messages are LLRs sent along the edges of the Tanner graph, in both directions.
The key rule: extrinsic information. A message sent along an edge never uses the message that arrived on that same edge. A bit tells a check what it has learned from everyone else, and a check tells a bit what its other bits imply. Otherwise a node would be told its own opinion back and grow more and more confident on no new evidence.
Each iteration has three steps.
-
Check to variable. A check says that its bits sum to zero (modulo 2), so any one of them equals the XOR of the others. Check therefore tells variable what the other bits of the check imply about it. The LLR of an XOR of independent bits is given by the “tanh rule”:
The formula behaves as common sense suggests. Its sign is the product of the signs of the incoming messages: an XOR is 1 when an odd number of its inputs are. Its magnitude is a little less than the smallest incoming magnitude: a conclusion drawn from several bits is no more reliable than the least reliable of them.
-
Variable to check. Independent pieces of evidence about a bit combine by adding their LLRs. Variable tells check the sum of its channel value and the messages from its other checks: .
-
Decide. The bit’s overall belief uses all its checks: bit is 1 if . If the decisions satisfy every check, they form a codeword and decoding stops.
Why it works, and when. If the Tanner graph has no cycles, the evidence arriving at a node along different edges comes from disjoint parts of the graph and really is independent, and this procedure computes the exact posterior probability of every bit (it is then called the sum-product algorithm). The graphs of good codes do have cycles, so evidence eventually returns to where it started and is counted twice. But if the cycles are long, the messages stay nearly independent for many iterations, and the decoder works almost as well. This is one reason sparse matrices are wanted: few edges mean few short cycles. The other is cost, since each iteration takes work proportional to the number of edges.
Figure 19.5. LDPC BER.
The curve falls steeply once the noise is below the code’s threshold: the waterfall. Near it, decoding needs many iterations; well above it, a few suffice:
Figure 19.6. LDPC iterations.
Algorithm
Construction of a systematic encoder from the parity-check matrix , with rows and columns.
- Reduce a dense copy of by Gauss-Jordan elimination over GF(2): for each row, find a column with a 1 to serve as its pivot, and XOR the row into every other row that has a 1 in that column. Rows that become zero are redundant checks.
- The pivot columns are the parity positions, and the remaining columns the information positions. Each reduced row now expresses one parity bit as the XOR of some information bits.
Encoding: place the information bits in the information positions, and compute each parity bit as the XOR of the information bits that appear in its reduced row.
Decoding, from the channel LLRs.
- Take hard decisions from the channel values. If they satisfy every check, return them: no iteration is needed.
- Initialise every variable-to-check message to the channel value of its variable.
- Check update: for every check and each of its variables, compute the message from the others by the tanh rule.
- Variable update: for every variable, add the channel value and all the incoming check messages to get its total; the message to each check is the total minus the message that came from that check.
- Decide: take the sign of each total. If the decisions satisfy every check, return them.
- If the iteration limit has been reached, return the decisions with a failure flag; otherwise go to 3.
Updating all the checks and then all the variables in each iteration is the flooding schedule. An iteration costs time proportional to the number of 1s in .
Implementation
// Check-node update.
for (c, vars) in self.checks.iter().enumerate() {
let t: Vec<f64> = v2c[c].iter().map(|&m| (0.5 * m.clamp(-30.0, 30.0)).tanh()).collect();
for j in 0..vars.len() {
let prod: f64 = t.iter().enumerate().filter(|&(i, _)| i != j).map(|(_, &x)| x).product();
c2v[c][j] = 2.0 * prod.clamp(-0.999_999_999_999, 0.999_999_999_999).atanh();
}
}
- Messages are clamped before
tanhandatanhto stay finite. decodereports whether it converged and how many iterations it took; on failure it returns the last hard decision.- Any parity-check matrix can be supplied to
LdpcCode::newas lists of positions; redundant checks are allowed.
In practice
//! A regular Gallager LDPC code decoded by belief propagation.
use lib_jsl_information::forward_error_correction::LdpcCode;
fn main() {
let code = LdpcCode::gallager(96, 3, 6, 1).unwrap();
println!("Gallager (3, 6) code: n = {}, k = {}, {} checks", code.n(), code.k(), code.num_checks());
let info: Vec<u8> = (0..code.k()).map(|i| ((i * 5 + 3) % 7 % 2) as u8).collect();
let cw = code.encode(&info).unwrap();
println!("codeword satisfies every check: {}", code.is_codeword(&cw));
// Channel LLRs of magnitude 2, with 8 bits received wrongly.
let mut llr: Vec<f64> = cw.iter().map(|&b| if b == 0 { 2.0 } else { -2.0 }).collect();
for i in (0..96).step_by(12) {
llr[i] = -llr[i];
}
let d = code.decode(&llr, 50).unwrap();
println!("8 errors: converged {}, after {} iterations, info recovered {}", d.converged, d.iterations, code.extract_info(&d.codeword).unwrap() == info);
}
Gallager (3, 6) code: n = 96, k = 50, 48 checks
codeword satisfies every check: true
8 errors: converged true, after 32 iterations, info recovered true
Strengths
- Near-capacity performance for long blocks; decoding is parallel and its cost linear in the length.
- The decoder knows when it has succeeded (all checks satisfied).
Weaknesses
- Short codes perform less well, and random constructions have error floors from small trapping sets.
- Dense-matrix construction and encoding here cost memory and time; structured (quasi-cyclic) codes avoid this.
Exercises
- Derive the check-node update from .
- Show that the min-sum approximation overestimates the reliability.
- Show that a regular code has rate at least .
- Decode a (7, 4) Hamming code by belief propagation on its Tanner graph, and explain why its short cycles hurt.
- Find the threshold of the (3, 6) ensemble on the binary erasure channel by density evolution, .
Hints and answers
- If bit is 1 with probability , the XOR of independent bits is 1 with probability , so the probability of 0 is . Converting to LLRs gives the tanh rule .
- and of the product is smaller in magnitude than the minimum , so min-sum, which uses the minimum, overestimates the reliability.
- A regular code with column weight and row weight has check equations, which may not be independent, so and .
- Short cycles in the Tanner graph make messages return to the node they came from, so the independence assumption behind belief propagation fails and the decoder overcounts evidence; the Hamming code’s Tanner graph has many 4-cycles.
- Iterate from : it converges to 0 for and gets stuck at a positive fixed point for .
Further reading
- R. G. Gallager, Low-Density Parity-Check Codes, MIT Press, 1963.
- D. J. C. MacKay, “Good error-correcting codes based on very sparse matrices”, IEEE Transactions on Information Theory 45 (1999) 399–431.
- T. Richardson and R. Urbanke, Modern Coding Theory, Cambridge University Press, 2008.
- D. J. C. MacKay, Information Theory, Inference, and Learning Algorithms, Cambridge University Press, 2003, chapter 47.