---
title: Syndrome-Guided Bit Flipping (SGBF)
url: https://www.emergentmind.com/topics/syndrome-guided-bit-flipping-sgbf
type: topic
---

# Syndrome-Guided Bit Flipping (SGBF)

Syndrome-Guided Bit Flipping (SGBF) is a family of iterative decoding methods for binary linear codes in which the current syndrome $s = H\hat{x}^\top \bmod 2$ determines which bit positions should be flipped. The unifying idea is that parity-check violations identify where the present estimate $\hat{x}$ is locally inconsistent with the code constraints, so the decoder uses the syndrome either directly, through unsatisfied-check counts, or indirectly, through reliability scores derived from the syndrome, soft information, or re-decoding outcomes. In the literature, SGBF ranges from classical hard-decision bit-flipping rules for LDPC-like codes to dynamic reliability-weighted decoders, reinforcement-learned flipping policies, threshold-adaptive MDPC decoders, and post-failure list re-decoding attached to layered normalized min-sum decoders for FDPC codes [1906.04448, 2510.01019].

## 1. Formal setting and decoding principle

Let $H \in \{0,1\}^{m \times n}$ be a parity-check matrix of a binary linear code. Codewords $x \in \{0,1\}^n$ satisfy $Hx^\top \equiv 0 \pmod 2$. Given a current binary estimate $\hat{x}$, the syndrome is
$$
s = H\hat{x}^\top \bmod 2 \in \{0,1\}^m.
$$
A component $s_j = 1$ indicates that check $j$ is unsatisfied, while $s_j = 0$ indicates that it is satisfied. If $M(i)$ denotes the set of checks incident to bit $i$, then iterative SGBF seeks to drive $s$ to zero by flipping bits whose neighborhoods are strongly implicated by the present pattern of unsatisfied checks [1906.04448, 1001.2503].

This viewpoint admits both hard-decision and soft-decision forms. In AWGN with BPSK signaling, one may use $y_i$ directly or the log-likelihood ratio $\lambda_i = 2y_i/\sigma^2$ as channel reliability. In bipolar notation, a satisfied check has $\hat{s}_j = +1$ and an unsatisfied check has $\hat{s}_j = -1$, which is convenient for weighted formulations and ML-related cost relaxations. The Tanner-graph interpretation is standard: variable nodes represent bits, check nodes represent parity constraints, and the syndrome records which check nodes currently fail under $\hat{x}$ [1001.2503].

The central operational fact is that flipping bit $i$ toggles the syndrome components for all checks in $M(i)$. Classical SGBF therefore ranks bits by how many unsatisfied checks they touch. More elaborate variants retain this mechanism but modify the ranking rule, the selection rule, the update schedule, or the stopping criterion.

## 2. Classical counters and weighted syndrome guidance

The canonical SGBF metric is the unsatisfied-check count
$$
E_i = \sum_{j=1}^{m} H_{j,i}s_j = \sum_{j \in M(i)} s_j.
$$
A standard rule is to select
$$
i^\ast = \arg\max_i E_i
$$
and flip bit $i^\ast$ if $E_{i^\ast}$ exceeds a threshold $T$; decoding stops if $s=0$ or if a maximum number of iterations is reached. This is the form emphasized in the reinforcement-learning literature as the classical syndrome-guided decoder, and it is particularly natural on the BSC, where all $|\lambda_i|$ are equal [1906.04448].

Weighted bit-flipping (WBF) generalizes this by assigning reliabilities to checks and, in some cases, to variables. A common metric is
$$
M_i = \sum_{j \in M(i)} w_j(2s_j-1),
$$
with $w_j \ge 0$ reflecting check reliability. A widely used AWGN instantiation defines
$$
\phi_j = \min_{\ell \in N(j)} |\mathrm{LLR}_\ell|
$$
and
$$
E_i = \sum_{j \in M(i)} (2s_j - 1)\phi_j - \alpha |\mathrm{LLR}_i|,
$$
so satisfied and unsatisfied checks contribute with opposite signs, while highly reliable bits are penalized against flipping [1906.04448]. Closely related LDPC formulations include Gallager’s unweighted flipping function,
$$
E_n = -\sum_{m \in \mathcal{M}(n)} (1-2s_m),
$$
together with WBF, IMWBF, RRWBF, GDBF, and NGDBF variants that incorporate checksum weights, channel magnitudes, damping, or perturbations [1501.02428].

The literature therefore uses “SGBF” in a broad sense: the syndrome remains the primary control signal, but the actual bit-ranking functional may be an integer counter, a weighted syndrome sum, a channel-penalized score, or a more elaborate dynamic reliability measure.

| Family | Representative rule | Distinguishing feature |
|---|---|---|
| Classical SGBF | $E_i = \sum_{j \in M(i)} s_j$ | Unsatisfied-check count |
| WBF / IMWBF | Weighted syndrome plus $|LLR_i|$ term | Soft-information aware |
| CRBF | Local cost $E_i$ with $R_{ji}$ | Adaptive check reliability |
| DWBF | Dynamic $r_{mn}^{(l)}$ and M1/M2-FBS | Iteration-by-iteration reliability tracking |
| LNMS+SGBF | $rel_i = |L_i|/(1+\max(e_i,1))$ | Post-failure candidate re-decoding |

## 3. Reliability-aware SGBF for LDPC decoding

A major refinement is the Check Reliability Based Bit-Flipping (CRBF) framework, which derives a relaxed ML-related global cost
$$
E(\hat{x}) = -\sum_{i=0}^{N-1}\hat{x}_i y_i - \alpha \sum_{j=0}^{M-1}\hat{s}_j
$$
and decomposes it into local costs
$$
E_i = -\Big(\hat{x}_i y_i + \gamma \sum_{j \in M(i)} \hat{s}_j\Big), \qquad \gamma=\alpha/d_c>0.
$$
Here $-E_i$ is interpreted as the reliability of bit $i$. The key addition is a per-edge check reliability
$$
R_{mn} = \max(-R_{mn}^\ast,0), \qquad R_{mn}^\ast = \max_{n' \in N(m)\setminus n} E_{n'}.
$$
A check contributes to bit $n$ only when its other participating bits appear reliable; unreliable neighborhoods force the contribution to zero. Soft-CRBF updates
$$
E_i^{(l)} = -\Big(\hat{x}_i^{(l)} y_i + \gamma \sum_{j \in M(i)} \hat{s}_j^{(l)} R_{ji}^{(l)}\Big),
$$
while Hard-CRBF replaces $y_i$ by the hard decision $\hat{z}_i$ [1001.2503].

The reported gains are substantial. On the $(255,175)(16,16)$ EG-LDPC code with $I_{\max}=30$, Soft-CRBF outperforms SPA, WBF, and MWBF by about $0.35\,\mathrm{dB}$, $0.5\,\mathrm{dB}$, and $0.8\,\mathrm{dB}$ respectively at $\mathrm{BER}=10^{-5}$, while Hard-CRBF outperforms standard BF by about $0.5\,\mathrm{dB}$ at $\mathrm{BER}=4 \times 10^{-4}$. On MacKay’s $(504,252)(3,6)$ LDPC code with $I_{\max}=70$, Soft-CRBF gives $3\,\mathrm{dB}$ gain relative to WBF variants at $\mathrm{BER}\approx 10^{-4}$, and Hard-CRBF gives $2\,\mathrm{dB}$ gain over standard BF at $\mathrm{BER}=2 \times 10^{-4}$. On the $(1440,1344)(3,45)$ IEEE 802.15.3c LDPC code, Soft-CRBF outperforms IMWBF and MWBF by about $0.9\,\mathrm{dB}$ at $\mathrm{BER}=10^{-5}$ and yields $1.3\,\mathrm{dB}$ gain over WBF; on the $(2048,1723)(6,32)$ IEEE 802.3a/n LDPC code, it yields near-SPA performance and outperforms WBF, MWBF, and IMWBF by more than $1\,\mathrm{dB}$ at $\mathrm{BER}=10^{-5}$ [1001.2503].

Dynamic Weighted Bit-Flipping (DWBF) pushes the same idea further by updating checksum weights every iteration. Its flipping function is
$$
E_n^{(l)} = -y_n(1-2\hat{u}_n) - \alpha_2 \sum_{m \in \mathcal{M}(n)} r_{mn}^{(l-1)}(1-2s_m),
$$
with
$$
r_{mn}^{(l)} = \min_{n' \in \mathcal{N}(m)\setminus n} \Omega\!\left(-E_{n'}^{(l)}\right),
\qquad
\Omega(x)=
\begin{cases}
x-\eta,& x\ge \eta,\\
0,& x<\eta.
\end{cases}
$$
The clipping threshold $\eta \approx 0$ suppresses unreliable checks, and the forgetting factor $\alpha_2$ limits accumulation of stale reliabilities. DWBF also introduces richer flipped-bit selection rules, notably M1-FBS and M2-FBS, and selective checksum-weight update schedules SWUS-A and SWUS-B derived from a time-expanded factor graph interpretation [1501.02428].

The reported behavior is code-dependent but consistent. For Code 1, MacKay $(816,272)$ with $(d_v,d_c)=(4,6)$, S-DWBF-B and S-DWBF-F provide $2.5\,\mathrm{dB}$ and $2.6\,\mathrm{dB}$ gains over RRWBF at $\mathrm{BER}=10^{-5}$, while S-DWBF-A yields $0.7\,\mathrm{dB}$ gain. For Code 2, EG-LDPC $(1023,781)$ with $(d_v,d_c)=(32,32)$, S-DWBF-A achieves about $0.25\,\mathrm{dB}$ gain over IMWBF at $\mathrm{BER}=10^{-5}$ and S-DWBF-B adds about $0.1\,\mathrm{dB}$ more. In multi-bit mode, DWBF with M2-FBS approaches NMS within about $0.4\,\mathrm{dB}$ on Code 1, while on Code 2 M1-DWBF-B is within about $0.1\,\mathrm{dB}$ of NMS and M2-DWBF-A/B are very close to NMS, with fewer loops and good convergence [1501.02428].

## 4. SGBF as post-failure re-decoding for FDPC codes

In FDPC decoding, SGBF appears in a different role: not as the primary iterative decoder, but as a post-failure enhancement to layered normalized min-sum (LNMS). FDPC codes are described as a recently introduced class designed for high-rate regimes, constructed from a structured base parity-check matrix with all columns of weight 2 and then extended by stacking permuted copies of the base matrix. The LNMS decoder partitions check nodes into non-conflicting layers using conflict-graph coloring, with adjacency matrix
$$
A = HH^\top - \operatorname{diag}(HH^\top),
$$
and performs immediate variable-node updates after each layer. The check update uses normalized min-sum,
$$
m_{c \to v}^{(\ell)} =
\alpha \cdot
\left(\prod_{v' \in N(c)\setminus v}\operatorname{sign}(L_{v'\to c}^{(\ell)})\right)
\cdot
\min_{v' \in N(c)\setminus v} |L_{v'\to c}^{(\ell)}|,
$$
with fixed normalization $\alpha=0.75$ and no offset or damping terms [2510.01019].

SGBF is activated only if LNMS reaches $I_{\max}=5$ iterations and the final syndrome remains nonzero. For each variable $i$, the decoder counts
$$
e_i = \sum_{c \in N(i)} s_c
$$
and forms the reliability
$$
rel_i = \frac{|L_i^{(I_{\max})}|}{1+\max(e_i,1)}.
$$
The $T$ least reliable positions are selected, with experiments using $T=128$ and ties broken by smaller index. The decoder then creates $T$ candidate channel-LLR vectors by flipping the sign of a single initial channel LLR,
$$
L^{(t)}(i)=
\begin{cases}
-\,L^{(0)}(i),& i=i_t,\\
L^{(0)}(i),& i\neq i_t,
\end{cases}
$$
restarts LNMS independently on each candidate with the same layered schedule and early stopping, and chooses the candidate with minimum syndrome weight
$$
w(s^{(t)}) = \sum_{c \in C} s_c^{(t)}.
$$
If the minimum syndrome weight is zero, that candidate is accepted; otherwise the decoder retains the original LNMS output [2510.01019].

This formulation is technically distinct from greedy one-bit-per-iteration SGBF. The syndrome does not directly choose a single flip in the current iterate; instead it enters a reliability metric that defines a single-bit candidate list, and LNMS re-decoding evaluates those candidates. Complexity reflects this hybrid structure. LNMS itself is $O(I_{\max}\cdot E)$ with message memory $O(E)$, while the extra SGBF cost on failure is
$$
O(E) + O(N\log N) + O(T\cdot I_{\max}\cdot E)
$$
in the worst case, with smaller average cost due to early stopping and the factor $P_{\mathrm{fail}}$ multiplying the failure-triggered overhead [2510.01019].

The empirical results on FDPC$(256,192)$ are specific: with $T=128$ and a maximum of $5$ iterations, LNMS+SGBF achieves approximately a $0.5\,\mathrm{dB}$ coding gain over standalone LNMS at $\mathrm{FER}=10^{-3}$. Against 5G-LDPC and polar codes of the same length and rate, under BP/NMS decoders, FDPC with LNMS+SGBF shows approximately $0.75$–$1.5\,\mathrm{dB}$ coding gain over a range of SNRs. The paper also reports similar gains for FDPC$(128,80)$, FDPC$(256,164)$, and FDPC$(1024,844)$, monotonic FER improvement as $T$ grows over $\{4,8,16,32,64,128\}$ with diminishing returns beyond $T=64$, and $0.5$–$1.0\,\mathrm{dB}$ gains at $\mathrm{FER}=10^{-3}$ under matched-average-complexity comparisons to 5G-LDPC [2510.01019].

## 5. Learned flipping policies and the MDP formulation

SGBF can also be cast as a sequential decision problem. In the learned bit-flipping framework, the MDP state is the syndrome $s_t$ on the BSC, or either $(s_t,r)$ with $r=|y|$ or a syndrome obtained after a reliability-driven permutation in the AWGN case. The action space is the bit index set $A=\{1,2,\dots,n\}$, and the transition is deterministic:
$$
s_{t+1} = s_t \oplus h_{a_t},
$$
where $h_i$ is column $i$ of $H$. The reward is
$$
R(s,a,s') =
\begin{cases}
-c|\lambda_a| + 1,& s' = 0,\\
-c|\lambda_a|,& \text{otherwise},
\end{cases}
$$
so terminal success receives a bonus and nonterminal flips are penalized by reliability-weighted cost [1906.04448].

In tabular form, Q-learning updates
$$
Q_{t+1}(s,a)
\leftarrow
Q_t(s,a) + \alpha\left[r + \gamma \max_{a'}Q_t(s',a') - Q_t(s,a)\right].
$$
The fitted-Q version uses a fully connected neural network with syndrome input, one hidden layer of 500 neurons for most codes and 1500 for RM$(128,99)$, ReLU activation, and a linear output layer of size $n$. The loss is
$$
L_D(\theta) = \sum_{(s,a,r,s') \in D}\left[r + \gamma \max_{a'} Q_\theta(s',a') - Q_\theta(s,a)\right]^2.
$$
Goal-biased exploration supplements $\epsilon$-greedy action selection by choosing a random action from the support of the current error pattern with probability $g$, which the paper reports as significantly accelerating convergence relative to pure $\epsilon$-greedy on RM$(32,16)$ [1906.04448].

The relation to classical SGBF is explicit: instead of using a hand-crafted score such as $E_i = \sum_j H_{j,i}s_j$, the learned decoder estimates $Q(s,a)$ directly from rewards. The paper therefore interprets $Q(s,a)$ as a data-driven, state-dependent flipping score that subsumes SGBF-like heuristics while adapting to code and channel structure [1906.04448].

The reported performance spans several regimes. On the BSC, standard BF with an overcomplete parity-check matrix $H_{\mathrm{over}}$ for RM$(32,16)$ essentially matches optimal syndrome decoding, while learned BF converges to near-optimal performance for RM$(32,16)$ and BCH$(63,45)$; for RM$(64,42)$, learned BF is virtually identical to standard BF with $H_{\mathrm{over}}$. With fitted Q-learning, neural-network LBF closely tracks tabular Q for RM$(32,16)$, and for BCH$(63,45)$ with $H_{\mathrm{over}}$ it is within about $0.1\,\mathrm{dB}$ of optimal at $\mathrm{CER}\approx 10^{-3}$. On AWGN, WBF with $H_{\mathrm{over}}$ lies within about $0.6$–$1.1\,\mathrm{dB}$ of order-3 OSD, and sort-and-discard LBF for RM codes performs close to WBF, closing a substantial fraction of the gap to OSD even though reliabilities are discarded after permutation [1906.04448].

## 6. Threshold selection and two-iteration SGBF for regular binary codes

For $(v,w)$-regular binary codes, SGBF has also been studied as a parallel hard-decision decoder with explicitly optimized thresholds. Let $U_j$ be the unsatisfied parity-check counter for variable $j$. In iteration $i \in \{1,2\}$, bit $j$ is flipped if $U_j \ge T_i$. The syndrome guides the thresholds themselves: the first threshold is a function of the initial syndrome weight $y = \|s^{(0)}\|_0$, and the second threshold is a function of
- $z_0$: the number of checks satisfied in $s^{(0)}$ that became unsatisfied in $s^{(1)}$,
- $z_1$: the number of checks unsatisfied in $s^{(0)}$ that remained unsatisfied in $s^{(1)}$,
so that $\|s^{(1)}\|_0 = z_0 + z_1$ [2501.13865].

The first threshold is chosen by minimizing the expected residual discrepancy after iteration 1:
$$
T_1(y) \in \arg\min_{0 \le \tau_1 \le v}
\left\{
t - t\,P_{\mathrm{flip}|1}(\tau_1) + (n-t)\,P_{\mathrm{flip}|0}(\tau_1)
\right\},
$$
where
$$
U_j \mid (e_j=0) \sim \operatorname{Binomial}(v,q_0),
\qquad
U_j \mid (e_j=1) \sim \operatorname{Binomial}(v,q_1).
$$
The second threshold is chosen as
$$
T_2(z_0,z_1) \in \arg\min_{0 \le \tau_2 \le v}
\mathrm{DFR}(y,\epsilon_{01},\epsilon_{11},z_0,z_1;T_1(y),\tau_2),
$$
using a model that conditions on the observed syndrome evolution after the first iteration [2501.13865].

A distinctive contribution is the parity-aware model for the initial syndrome weight. Under the independence approximation,
$$
W_{s,0} \sim \operatorname{Binomial}(r,P_{u,0}),
$$
but because the syndrome is the XOR of $t$ columns of weight $v$, the parity of $W_{s,0}$ must equal the parity of $t\cdot v$. Conditioning the binomial on that parity produces a tighter finite-length fit. The post-first-iteration syndrome is modeled through a non-homogeneous Markov chain for $(\mathcal{Z}_0,\mathcal{Z}_1)$, which is then used to compute the second-iteration flip probabilities and the overall two-iteration DFR [2501.13865].

The practical conclusions are explicit. Dynamic thresholds are recommended, static majority thresholds are suboptimal, and $T_1(y)$ grows almost linearly with $y$. For a BIKE-like QC-MDPC rate-$1/2$ set with $r=12{,}323$, $n=24{,}646$, $v=71$, $w=142$, $t=134$, and $\alpha \approx 0.00544$, the model gives
$$
P_{u,0} \approx 0.3945,\qquad E[W_{s,0}] \approx 4863,
$$
together with
$$
q_0 \approx 0.3935,\ \mu_0 = vq_0 \approx 28,\qquad
q_1 \approx 0.6065,\ \mu_1 = vq_1 \approx 43,
$$
so the first threshold lies near the mid-separation, approximately $36$–$40$, but is optimized per observed $y$. The paper reports that two-iteration SGBF reduces the average residual discrepancies by approximately $3 \times 10^2$ to $3.4 \times 10^6$ compared to BIKE’s syndrome-weight-dependent thresholds with margin $\delta \approx 3$, and yields dramatic DFR improvements over majority thresholds across LDPC and MDPC densities [2501.13865].

## 7. Trapping sets, near-codewords, and QC-MDPC-specific SGBF

A persistent limitation of bit-flipping decoders is their sensitivity to trapping sets. For QC-MDPC codes, the most relevant trapping sets are near-codewords, defined for a double-circulant parity-check matrix $H=(H_1\,|\,H_2)$ by
$$
\mathcal{M}
=
\{(x^i\cdot h_1,0)\mid i\in J\}
\cup
\{(0,x^i\cdot h_2)\mid i\in J\},
\qquad J=\{0,\dots,r-1\}.
$$
Each near-codeword induces a syndrome of Hamming weight exactly $d_v$. For a $(t,u)$-almost near-codeword, the decoder is prone to confuse true errors on the near-codeword support (“bad bits”) with non-errors lying on the same support (“suspicious bits”). The paper gives the approximation, for $t=u$,
$$
c_{\mathrm{bad}} \approx d_v-u+1,\qquad c_{\mathrm{sus}} \approx u,
$$
so when $u > d_v/2$, suspicious bits have larger counters than bad bits and a standard threshold near $d_v/2$ tends to flip the wrong positions, increasing overlap with the near-codeword [2604.18247].

The proposed remedy is decoder-agnostic and minimal. After each baseline BF iteration, the decoder checks whether the residual syndrome has weight $d_v$. If so, it tests whether
$$
s \in \{m_iH^\top \mid i=0,\dots,2r-1\}
$$
using a lookup table $\texttt{NC\_Syndromes}$ containing the supports of the $2r$ near-codeword syndromes. On a match, the decoder flips the support of the corresponding near-codeword $m_i$, which sets $s \leftarrow 0$ and returns success. The extra cost is one conditional per iteration and, when $\mathrm{wt}(s)=d_v$, a single binary search over sorted supports [2604.18247].

The storage and time bounds are explicit. The lookup table requires
$$
O(r\cdot d_v \cdot \log_2 r)
$$
bits, and each access costs
$$
O(d_v \cdot \log_2 r)
$$
comparisons. For BIKE NIST Category 1 parameters $r=12{,}323$, $d_v=71$, and $t=134$, the memory is approximately
$$
2r \cdot d_v \cdot \lceil \log_2 r \rceil
\approx
24.5 \times 10^6\ \text{bits}
\approx
3.06\ \text{MB},
$$
which the paper describes as negligible relative to the per-iteration BF cost $O(r^{1.5})$ for QC-MDPC [2604.18247].

The empirical effect is concentrated in the floor region. On toy codes with $r=2003$ and $d_v \in \{9,11,13,15\}$, the near-codeword-aware modification reduces the DFR for BF-Max, Majority-Logic Decoding, and Out-of-Place BF, with the largest gains for BF-Max. On BIKE Category 1 parameters, the modified BF-Max, BGF, and BIKE-flip all benefit substantially, especially for large overlap $u$; most notably, the modified BF-Max has zero observed decoding failures across all tested $u$ values, that is, $0/10^8$ failures per $u$, and outperforms the two decoders used by BIKE within the NIST competition [2604.18247].

A common misconception is that SGBF is inherently a single hard-decision heuristic with a fixed unsatisfied-check counter. The published record shows a broader picture. SGBF has served as a classical counter-based decoder, a reliability-weighted LDPC decoder, a dynamic reliability-tracking framework, a learned sequential policy, a threshold-adaptive MDPC decoder, a near-codeword-aware QC-MDPC recovery mechanism, and a post-failure list re-decoding stage attached to LNMS for FDPC codes. What remains invariant is not the score itself, but the use of syndrome structure as the primary guide for deciding which bit positions, or candidate bit positions, are most likely responsible for residual inconsistency.

Source: https://www.emergentmind.com/topics/syndrome-guided-bit-flipping-sgbf