betaFeedback

WorksComputer Science

SANAI: Secure ECC Distributed Keyed Parity Embedded in Weights for Protecting Neural Networks against Bit-Flip Attacks

Abstract

Quantized neural networks store weights in dense memory, where bit flips caused by voltage scaling, aging, radiation, or deliberate attacks such as RowHammer can severely degrade model behavior. A single corrupted high-order bit can cause misclassifications or nonsensical language-model outputs. Embedded error-correcting codes (ECC) avoid dedicated parity storage by hiding parity within model weights, but existing schemes embed uniformly across layers and bit planes, leave parity unsecured, and tolerate bit-error rates (BERs) only up to about 6%. An adversary aware of sensitive weights and the ECC scheme can also bypass protection by exceeding the correction capability of targeted codewords. We propose SANAI, a sensitivity-guided, bit-plane-selective scheme that protects critical model weights against bit flips with zero additional parity-storage overhead. SANAI secures parity through keyed embedding across a two-dimensional weight space: spread-transform dither modulation binds parity to a secret key, and keyed interleaving disperses concentrated attacks across codewords. We derive a survival law showing that robustness is governed by the correctable fraction t/n rather than by t alone, and a closed-form bound on the protectable fraction of a model. As a streaming checker on an 8x8 systolic array, SANAI verifies weights on the load path with 0.41% area overhead and no additional memory. Across ten vision backbones, three quantization schemes, and ten language models from 82M to 13B parameters, SANAI stays within about one percentage point of clean accuracy at BERs up to 12%, twice the maximum of prior embedded-ECC approaches. It survives fine-tuning bit-exactly, neutralizes progressive and targeted bit-flip attacks, and exactly corrects AttentionBreaker and SilentStriker attacks.

Introduction

Deep networks increasingly run on energy-constrained edge accelerators (Jouppi et al., [27]; Rahaman et al., [46]), where weights quantized to eight bits or fewer sit in dense memory. Reduced-voltage operation buys efficiency and pays in bit errors (Chandramourthy et al., 2019; Koppula et al., [30]; Zhang et al., [70]; Stutz et al., [59]); aging and radiation add more (Reagen et al., [53]; Baumann, [3]), memory errors are ordinary in deployed fleets (Schroeder et al., [56]), and RowHammer lets an adversary produce them on purpose (Kim et al., [29]; Yao et al., [67]). Because a quantized weight packs its value into few bits, one high-order flip in a sensitive layer can collapse the whole model (Hong et al., [23]; Rakin et al., [50]), and such fault-injection attacks are now a central threat to deployed AI systems (Rahaman et al., [45]; Rahaman et al., [48]), alongside tampering inside the ML infrastructure that loads and serves the model (Rahaman et al., [49]).

Uniform ECC guards every stored bit at a standing storage and energy price, although most bits barely move the loss. Embedded schemes such as E3-CODE (Kamineni et al., [28]) fold check bits into the weights themselves, but apply one policy to every layer and bit plane, leave the parity readable by anyone who holds the weights, and stop at a six percent BER. We instead concentrate the budget on the few fragile layers and damaging bits, hide the parity at zero added memory in bits the robust layers do not need, bind it to a key, and carry resilience well past six percent.

SANAI (Sensitivity-Aware Neural-network protection using Adaptive cross-layer STDM embeddIng, Figure 1) identifies sensitive layers by direct fault injection, protects only their most significant bit planes with a BCH code, and embeds the parity into low-order bits of robust carrier layers using spread-transform dither modulation (STDM) seeded by a secret key. At read time the key regenerates the projection and BCH decoding repairs the high-order bits; a keyed permutation decides which weights share a codeword, so concentrated flips cannot overload any codeword. Because recovery is a pure read-path operation, the construction admits a streaming hardware checker on the weight bus of a systolic accelerator.

SANAI overview

Figure 1. SANAI overview. Bit errors in weight memory flip high-order bits and the unprotected model misclassifies (top). SANAI probes layer sensitivity (bars), BCH-encodes the top KK bit planes of the sensitive few, assigns weights to codewords by a keyed permutation, and hides the parity with key-seeded STDM in the low-order bits of robust carrier layers at zero added memory (bottom). Inset: the same attack flips overload one codeword under adjacent grouping but stay within tt under keyed interleaving. The parity survives fine-tuning and is unreadable without the key.

In summary, the paper makes the following key contributions.

  • Sensitivity-guided ECC at zero added memory. Flip damage in a quantized network is doubly concentrated: across layers, the top 1% of weights by attack damage sit in layers holding 24.8% of ResNet-18, and protecting only those layers keeps 95.0% accuracy at 6% BER; within a weight, damage decays geometrically with bit position. SANAI measures layer sensitivity by direct fault injection, replaces the integer program of prior embedded ECC with one O(Llog⁡L)O(L\log L) sort, BCH-encodes only the top KK bit planes of the fragile layers, and moves the parity cross-layer into the low-order bits of robust carrier layers. It needs no retraining, no training data, and no extra storage.

  • Secure ECC: parity bound to a key and codewords hidden by a key. Key-seeded spread-transform dither modulation makes the hidden parity both the error-correcting carrier and an access control (Proposition 2): with a wrong key, ResNet-18 on CIFAR-10 falls to 44.6% at 3% BER and to chance by 8%, and an ImageNet model is unrecoverable from the first error level. Keyed codeword interleaving disperses concentrated attacks with a balls-into-bins guarantee (Theorem 1): under the same 500 progressive-bit-search flips, uncorrectable codewords drop from 9 to 49 under adjacent grouping to zero on five of six settings, and the largest fault count per codeword drops to 2 or 3, inside t=4t = 4.

  • A survival law and a protection ceiling. Robustness is governed by the correctable fraction t/nt/n rather than by tt (Proposition 1), which turns code selection into a design rule (Remark 1), and a closed-form supply and demand bound caps the protectable fraction of a model at ρ⋆≈48%\rho^\star\approx48\% at zero added memory (Eq. (6)).

  • Broad evaluation under random and adversarial faults. Across ten vision backbones, three quantizers, and ten language models from 82M to 13B parameters, SANAI stays within about one point of clean accuracy up to 12% BER, twice the range of prior embedded ECC. Under the burst protocol of prior work it retains 0.97 of its clean accuracy at 6% BER against 0.94

for the strongest baseline, and its critical BER on ResNet-50/ImageNet is 4×4 \times that baseline and 300,000× the unprotected model. A 500-flip progressive bit search that leaves ResNet-18 on CIFAR-10 at 10.1% is corrected to 94.9%; targeted T-BFA success drops from 93 to 98% to 0 to 8%; AttentionBreaker, including an adaptive variant flipping 1.17×1061.17 \times10^{6} bits on an 8B model, is corrected to the exact clean perplexity and MMLU; a code-aware attacker needs 23× more errors to match the undefended damage; and SilentStriker on Llama-3-8B-Instruct (MMLU 70.0 to 37.0%) is detected and restored to 70.0%. The parity survives fine-tuning bit-exactly at realistic learning rates.

  • A load-path hardware checker. The STDM embedding reduces exactly to a keystream-whitened least-significant-bit write (Proposition 3). Synthesized on an 8×88 \times8 systolic array in 45 nm, the checker detects every single-bit flip including the sign bit at 0.41% area, 0.63% dynamic power, zero stall cycles, and zero added memory, and closes at 1.27 ns. Against a measured conventional checker it needs no parity array (1.22 MB for ResNet-18) and is 2.6× faster than the correcting variant.

Section 2 reviews fault tolerance, embedded ECC, bit-flip attacks, and data hiding. Section 3 presents SANAI: the fault model, sensitivity-guided selection, bit-plane BCH encoding and the survival law, key-seeded STDM parity hiding, keyed interleaving, and the zero-memory ceiling. Section 4 gives the models, quantizers, fault models, and operating points. Section 5 reports random bit errors on vision models (§ 5.1), the comparison with prior embedded ECC and the key-gated access control (§ 5.2), progressive and targeted attacks (§ 5.3), language models under random errors, AttentionBreaker, and SilentStriker (§ 5.4), and fine-tuning and ablations (§ 5.5). Section 6 presents the hardware checker, Section 7 discusses scope and limitations, and Section 8 concludes. The appendices give the master tables behind every reported number (Appendix § 12), the algorithm and embedding details (Appendix § 13), proofs (Appendix § 14), the qualitative comparison (Appendix § 15), experimental details (Appendix § 16), ONNX portability (Appendix § 17), storage accounting (Appendix § 18), extended vision, attack, and language-model results (Appendices § 19 to § 21), fine-tuning (Appendix § 22), ablations (Appendix § 23), and hardware details (Appendix § 24), each referenced from the main text where it is summarized.

Background and Related Work

Fault tolerance for neural networks. Conventional ECC keeps extra check bits and corrects reliably at a large memory and energy cost [53]. Activation clipping and error-aware retraining [23, 20] harden the model rather than the stored weights, need training data, and cannot recover the original parameters; selective protection [30] leans on retraining. SANAI protects stored weights directly with no added memory and no retraining.

Embedded weight ECC. Weight nulling [41], opportunistic parity [6], value-aware parity [32], and E3-CODE [28] conceal parity inside the weight bits, but apply one policy to every layer and bit plane, keep parity next to the data it protects, and stop at 6% BER. SANAI differs on all three counts: placement follows a measured sensitivity ranking, protection is confined to the high-order planes of the fragile few, and the parity moves cross-layer into tolerant carriers (Table 12, Appendix § 15).

SchemeMem.ParityGranul.Fault tol.Acc. dropRetrainKeyFine-tuneArch.
Conventional ECC (Reagen et al., [53])∼12.5%\sim12.5\%ExternalWordHigh, 1 to 2 bitNegligible >3%\gt3\%NoNoneUnaffectedAgnostic
Weight scaling (Hong et al., [23])LowNoneTensorLow at high BER>3%\gt3\%NoNoneWeakensCNN
NN-ECC (Koppula et al., [30])LowIn-weightLayerHigh, learnedLowFullNoneRe-embedCNN
Weight throttling (He et al., [20])LowNoneClippedSaturatesModerateYesNoneDrift-sensitiveCNN
Selective prot. (Rakin et al., [50])LowExternalWeightUnevenMod. high BERNoNoneNot rep.CNN
Weight nulling (Qin et al., [41])LowNoneZeroingFails at 6%HighNoNoneNot rep.CNN
Opportunistic (Burel et al., [6])LowIn-weightBlockGapsHigh at 6%NoNoneNot rep.CNN
Value-aware (Lee & Yang, [32])LowIn-weightMagnitudeMediumModerateNoNoneNot rep.CNN
E3-CODE+^{+} (Khanjani et al., 2026)LowIn-weightLayer-uniformHigh to 6%Low to 6%NoNoneNot rep.CNN
SANAI (ours)ZeroCross-layerAdaptive BPHigh, 10 to 12%0.97 to 0.99NoKey-gatedParity BER 0CNN, ViT, LLM

Table 12. Qualitative comparison of weight-protection schemes. ∗^{*} marks the strongest prior embedded scheme.

Bit-flip attacks and detection. Progressive bit search (PBS) [50], targeted attacks [51, 52], and, on LLMs, AttentionBreaker [12] and SilentStriker [64] show that a handful of chosen flips suffices. Detection defenses, including signature checks and runtime monitoring through built-in AI performance counters [33, 26, 35, 47], raise an alarm rather than repair.

Data hiding. Quantization index modulation [8] and its spread-transform variant [37] embed information into a host by quantization, and weight watermarking [63, 1, 11] embeds ownership signatures; we repurpose STDM as a key-seeded carrier for functional parity.

Table 12 (Appendix § 15) sets these schemes side by side on the properties that decide deployability on an edge accelerator; SANAI is the only one that keeps the parity in-weight, moves it cross-layer, and binds it to a key.

Method

Problem Formulation and Fault Model

A trained network has quantized weight tensors θ={θℓ}ℓ=1L\theta= \{\theta_\ell\}_{\ell=1}^{L} with W=∑ℓ∣θℓ∣W = \sum_\ell\lvert\theta_\ell\rvert weights at bb bits each, so the stored bitstring s(θ)s(\theta) has WbWb bits. Weights are quantized per output channel, q=clip⁡(round⁡(w/s),−2b−1,2b−1−1)q = \operatorname{clip}(\operatorname{round}(w/s), -2^{b-1}, 2^{b-1}-1) with s=max⁡∣w∣/(2b−1−1)s = \max\lvert w\rvert/(2^{b-1}-1), in two’s complement, so a flip in bit plane jj perturbs the integer by 2j2^j and a sign flip moves the weight by half its range. Memory is a cause-agnostic binary symmetric channel Fp\mathcal{F}_p flipping each stored bit independently with probability pp, which is also the substrate for the burst protocol of prior work and the adversarial attackers of § 5.3 and § 5.4. We adopt a localized fault model in which errors land in the protected layers’ memory regions while carrier regions stay clean (revisited in § 7).

The defender applies an offline encoder E:θ↦θ′E:\theta\mapsto\theta' and a keyed read-time decoder DκD_\kappa. Writing A(⋅)A(\cdot) for task accuracy, the design problem is

max⁡E,D,κ EFp[A(Dκ(Fp(E(θ))))](1)\max_{E,D,\kappa}\ \mathbb{E}_{\mathcal{F}_p}\left[A\left(D_\kappa\left(\mathcal{F}_p(E(\theta))\right)\right)\right] \tag*{(1)}

subject to (i) zero added memory, ∣s(θ′)∣=∣s(θ)∣\lvert s(\theta')\rvert= \lvert s(\theta)\rvert; (ii) no retraining, so EE may not move a weight beyond its quantization step; and (iii) key-gated recovery, so for any wrong key the decoder output is no better than the unprotected corrupted model. SANAI exploits a measured double asymmetry. Across layers, damage is concentrated: scoring every weight of ResNet-18/CIFAR-10 by its attack-damage proxy puts the damage in the top 1% of weights, and protecting the layers that hold them (24.8% of the model) keeps 95.0% at 6% BER, while extending protection to the next 8% of weights doubles coverage and parity for no gain (Master Table 6, rows V1.34 and V1.35); the remaining 91% is the carrier pool. Within a weight, the damage of a flip decays geometrically with bit position.

Sensitivity-Guided Layer Selection

For each layer ℓ\ell we inject flips at a small probe rate p0p_0 into that layer alone and record the accuracy drop

Sℓ=Aclean−Eϵ∼Bern⁡(p0)[A(θℓ⊕ϵ)].(2)S_\ell= A_{\mathrm{clean}} - \mathbb{E}_{\epsilon\sim\operatorname{Bern}(p_0)}\left[A(\theta_\ell\oplus\epsilon)\right]. \tag*{(2)}

Layers are sorted by SℓS_\ell and the protected set P\mathcal{P} is grown greedily, most fragile first, to a coverage target ρ\rho:

P={ℓ(1),…,ℓ(j)},j=max⁡{j:∑i≤j∣θℓ(i)∣≤ρW}.(3)\mathcal{P} = \{\ell_{(1)},\ldots,\ell_{(j)}\},\qquad j = \max\left\{j:\sum_{i\le j}\lvert\theta_{\ell_{(i)}}\rvert\le\rho W\right\}. \tag*{(3)}

The remaining layers form the carrier set C\mathcal{C}, least sensitive first. In every network we studied a few early or narrow layers are fragile but hold few weights, while the large late layers are robust and hold most parameters, so the fragile layers are cheap to protect and the robust ones supply carrier bits. For LLM attacks we score layers with a gradient-informed probe ∑∣g⊙w∣\sum\lvert g\odot w\rvert, since magnitude is blind to the small attention projections attacks target (§ 5.4); random-BER runs use magnitude. Selection is one sort, O(Llog⁡L)O(L\log L) (Appendix § 13).

Bit-Plane BCH Encoding and a Survival Law

Within each protected layer we encode only the top KK bit planes; groups of GG weights form GKGK-bit messages for a binary BCH code ([5]) over GF⁡(27)\operatorname{GF}(2^7) (x7+x+1x^7+x+1, parent length n=127n=127), shortened to the message. The strong code is shortened from the parent BCH(127, 50, t=12t=12) and stores 48 message bits plus 88 parity bits per codeword, so K=4K=4 gives G=12G=12; the light code is shortened from BCH(127, 99, t=4t=4) with 96 message and 32 parity bits, G=24G=24 at K=4K=4. The G≤tG\le t property that makes any sign-bit attack correctable (§ 3.5) holds for the K=4K=4, G=12G=12, t=12t=12 configuration used in all LLM experiments, not for K=3K=3 (G=16G=16) or the light code (G=24G=24). The governing quantity for survival is not tt but the correctable fraction f=t/nf=t/n.

Proposition 1 (Codeword survival). If the channel flips each of the nn codeword bits independently with probability pp, the decoder fails exactly when X∼Bin⁡(n,p)X \sim\operatorname{Bin}(n,p) exceeds tt, so Pfail=∑i=t+1n(ni)pi(1−p)n−iP_{\mathrm{fail}} = \sum_{i=t+1}^{n} \binom{n}{i}p^{i}(1-p)^{n-i}, and for any p<fp < f, Pfail≤exp⁡(−2n(f−p)2)P_{\mathrm{fail}} \le\exp\left(-2n(f-p)^2\right).

Survival is exponentially reliable whenever p<fp < f (Remark 1 turns this into a design rule). Protecting K>1K > 1 planes widens the flat region further, since residual errors below the corrected planes perturb a weight by at most 2b−K−12^{b-K-1} steps. Under an adversary the relevant quantity is the per-codeword count fcf_c: a codeword survives iff fc≤tf_c \le t, random faults keep E[fc]\mathbb{E}[f_c] small, and a targeted attack maximizes max⁡cfc\max_c f_c (Appendix C).

Key-Seeded STDM Parity Hiding

The parity is embedded into the low-order bits of carrier weights by STDM seeded by a secret key κ\kappa. To embed one bit β\beta into a group of LsL_s carrier weights ww, the key generates a direction v∈{−1,+1}Lsv \in\{-1,+1\}^{L_s} and a dither dd; the projection p=w⋅v+dp = w \cdot v + d is snapped to one of two interleaved lattices of step Δ\Delta selected by β\beta and written back with the minimum-norm update:

p⋆=Δ⌊p−d−βΔ/2Δ⌋+d+βΔ2,w′=w+p⋆−pLsv,β^=⌊w′⋅v+dΔ⌋ mod 2.(4)p^\star= \Delta\left\lfloor\frac{p-d-\beta\Delta/2}{\Delta} \right\rfloor+ d + \frac{\beta\Delta}{2}, \qquad w' = w + \frac{p^\star-p}{L_s}v, \qquad\hat{\beta} = \left\lfloor\frac{w'\cdot v+d}{\Delta} \right\rfloor\bmod2. \tag*{(4)}

Each carrier weight moves by at most Δ/2\Delta/2, one low-bit step, so the embedding is invisible in accuracy; it generalizes to BB bits per symbol (Appendix B).

Proposition 2 (Recovery and access control). (a) With the correct key, vv and dd cancel exactly, so β^=β\hat{\beta} = \beta whenever the read-time perturbation of the projection stays below Δ/2\Delta/2. (b) With a wrong key κ′≠κ\kappa' \ne\kappa the regenerated direction satisfies E[v⋅v′]=0\mathbb{E}[v \cdot v'] = 0, the projection is uncorrelated with β\beta, each parity bit is recovered with probability 12\frac{1}{2}, and all PbitsP_{\mathrm{bits}} parity bits are recovered with probability 2−Pbits2^{-P_{\mathrm{bits}}}, negligible at the operating points of this paper (Pbits>106P_{\mathrm{bits}} > 10^6).

Property (a) is the recovery guarantee and (b) the access-control guarantee: without the key the parity is noise. At read time the key regenerates (v,d)(v,d), the parity is de-projected, and the BCH decoder corrects the top KK planes (Algorithm 1, Appendix B).

Figure 2 shows the lattice geometry for the multi-bit case.

Key-seeded parity embedding on a two-scale lattice

Figure 2. Key-seeded parity embedding on a two-scale lattice. Recovery is exact while the perturbation stays below Δ/2\Delta/2; without the key the parity reads at chance.

Keyed Codeword Interleaving

In the default layout a codeword covers GG adjacent weights, the weak point against a targeted attacker: PBS concentrates flips on sensitive weights that cluster in a few early layers and drive fcf_c far above tt. We break adjacency with a keyed permutation π\pi of each layer’s protected indices, assigning weight ii to codeword

cw⁡(i)=⌊π(i)G⌋,pos⁡(i)=π(i) mod G.(5)\operatorname{cw}(i) = \left\lfloor\frac{\pi(i)}{G} \right\rfloor,\qquad\operatorname{pos}(i) = \pi(i) \bmod G. \tag*{(5)}

Adjacent weights land in unrelated codewords, encoder and decoder share the mapping through κ\kappa, and no parity or memory is added.

Figure 3 contrasts the two layouts on the same attacked weights.

Interleaving mechanism

Figure 3. Interleaving mechanism. Top, adjacent grouping: the attacked weights fall into one codeword and overload it (fc>tf_c > t). Bottom, keyed interleaving: the same weights are scattered by the keyed permutation so that each codeword holds at most a few faults, all within tt. The measured fault maps for a real 500-flip attack are in Figure 6 and Figure 13.

Theorem 1 (Interleaving bound). Let π\pi be a uniformly random keyed permutation and let the attacker choose FF flips without knowledge of π\pi. Over MM codewords, E[max⁡cfc]=O(F/M+log⁡M/log⁡log⁡M)\mathbb{E}[\max_c f_c] = O(F/M + \log M/\log\log M), which is O(1)O(1) for F≪Mlog⁡MF \ll M\log M, so with high probability max⁡cfc≤t\max_c f_c \le t.

A second guarantee needs no key: a sign-bit attack flips one plane per weight and each weight belongs to one codeword, so it injects at most GG errors per codeword, and G≤tG \le t makes every sign-bit attack of any size exactly correctable on protected layers (§ 5.4).

Zero-Memory Feasibility and the Protection Ceiling

The code is systematic, so only the parity, pp bits per ksk_s-bit message (88/48 strong, 32/96 light), must be evicted to carriers. With Wp=ρWW_p = \rho W protected weights, replication RR (R=1R = 1 by default), Wc=(1−ρ)WW_c = (1-\rho)W carriers with hh spare host bits each, and STDM at B≤hB \le h bits per group of LsL_s carriers, demand and supply are

D=WpKRpks,CSTDM=WcBLs≤Wch,D≤CSTDM⟺ρ≤ρ⋆=BksBks+LsKRp.(6)D = W_p K R \frac{p}{k_s}, \quad C_{\mathrm{STDM}} = \frac{W_c B}{L_s} \le W_c h,\quad D \le C_{\mathrm{STDM}} \Longleftrightarrow\rho\le\rho^\star= \frac{B k_s}{B k_s + L_s K R p}. \tag*{(6)}

The parity cost is r=ρKp/ksr = \rho Kp/k_s bits per weight (1.10 predicted versus 1.05 to 1.10 measured, Table 15, Appendix § 18), with zero added memory regardless of rr, and ρ⋆≈0.48\rho^\star\approx0.48: at most 48% of a model can be protected before the parity no longer fits. Above ρ⋆\rho^\star the encoder places the remaining parity in the low-order bits of the protected layers themselves; those bits sit inside the fault region but belong to the codeword and are corrected like any other, so coverage can exceed ρ⋆\rho^\star (52.8% in § 5.5) until every layer’s host bits are exhausted (INT4, Appendix § 18).

Table 15: Left: storage cost at the efficient operating point (INT8). Middle: absolute counts in millions; a^{a}CIFAR-100. Right: fit for the ImageNet backbones, protected fraction, hidden parity as a fraction of model bits, parity bits per model weight, and carrier layers (insensitive / protected-layer overflow); the Swin-T, RegNet, and Wide ResNet rows are from the earlier logs pending re-extraction. Added memory is zero in every row.

ArchDataCov.b/wt
ResNet-18C1019.3%1.06
ResNet-18C10014.0%0.77
ResNet-50C1019.2%1.05
VGG-16C1020.0%1.10
ArchLay.WtsBitsProt. wtsParity bits
ResNet-1813/2011.1689.32.12 (19.0%)11.64 (13.0%)
ResNet-18a^{a}11/2011.1789.41.56 (14.0%)8.62 (9.6%)
ResNet-5028/5323.52188.24.52 (19.2%)24.78 (13.2%)
VGG-1610/1614.73117.82.95 (20.0%)16.18 (13.7%)
ModelProt.Parityb/wtCarr.
MaxViT-T40.9%37.5%3.00132
Swin-T39.5%36.2%2.9035 / 0
RegNet-Y-16GF40.0%36.6%2.9370 / 1
Wide RN-50-237.3%34.2%2.7321 / 0
ViT-B/16 (K=5)43.5%53.2%4.2626 / 8

Table 15.

Remark 1 (Choice of tt). Proposition 1 and Eq. (6) pull in opposite directions: a larger tt widens the safe region p<t/np < t/n, but each additional correctable error costs roughly mm more parity bits, which lowers ρ⋆\rho^\star. The right tt is the largest one whose parity still fits at the coverage the fragile layers need. At m=7m = 7, t=12t = 12 gives f=9.4%f = 9.4\% with 88 parity bits and ρ⋆≈48%\rho^\star\approx48\%, above the 20 to 40% coverage used here, whereas t=18t = 18 would raise ff to 14.2% at a parity cost that pushes ρ⋆\rho^\star below that range; enlarging the field never helps, since at m=8m = 8 even t=20t = 20 gives a smaller ff (7.8%) at higher cost.

Experimental Setup

Vision. CIFAR-10, CIFAR-100 (Krizhevsky, [31]), and ImageNet-1K (Deng et al., [13]). Ten backbones from 3.5M to 85.8M parameters: ResNet-18/50 and VGG-16 (He et al., [19]; Simonyan & Zisserman, [57]), MobileNet-V2 and EfficientNet-B0 (Sandler et al., [54]; Tan & Le, [60]), Wide ResNet-50-2 (Zagoruyko & Komodakis, [68]), RegNet-Y-16GF (Radosavovic et al., [44]), and Swin-T, MaxViT-T, and ViT-B/16 (Liu et al., [36]; Tu et al., [62]; Dosovitskiy et al., [15]). (sizes in Table 13, Appendix § 16). We use post-training quantization (PTQ) with per-output-channel scales and two quantization-aware methods, Jacob (Jacob et al., [25]) and LSQ (Esser et al., [17]), at INT8 and INT6 precision.

Table 13: Evaluated vision architectures. Params is the ImageNet reference count; the INT8 footprint in MB equals the parameter count in millions. CIFAR-adapted variants of the first three models (3×33 \times3 stride-1 stem, no early max-pooling) hold 11.16M, 23.52M, and 14.73M weights.

ModelFamilyParams (M)Datasets
ResNet-18 / ResNet-50 ([19])Residual CNN11.7 / 25.6C10, C100, IN
VGG-16 ([57])Plain CNN138.4C10, C100
MobileNet-V2 ([54])Depthwise CNN3.5C10, C100, IN
EfficientNet-B0 ([60])Depthwise CNN5.3C10, C100, IN
Wide ResNet-50-2 ([68])Residual CNN68.8IN
RegNet-Y-16GF ([44])Design-space CNN83.4IN
Swin-T ([36])Hierarchical ViT28.2IN
MaxViT-T ([62])Hybrid ViT30.4IN
ViT-B/16 ([15])Plain ViT85.8IN

Table 13.

Language. Ten decoder-only transformers from 82M to 13B parameters: DistilGPT-2 and GPT-2 (Sanh et al., [55]; Radford et al., [43]), Qwen2-0.5B/1.5B, Qwen2.5-7B (Yang et al., [65]), Llama-3.2-1B/3B, Llama-3-8B-Instruct, Llama-3.1-8B (Dubey et al., [16]), and Llama-2-13B (Touvron et al., [61]), at signed INT8 (per-tensor below 7B, per-channel above); embedding and output-head matrices are excluded from injection, protection, and carriers. We report perplexity on WikiText-2/103 (Merity et al., [39]) and 5-shot accuracy on MMLU (Hendrycks et al., [21]), ARC (Clark et al., [10]), HellaSwag (Zellers et al., [69]), and TruthfulQA (Lin et al., [34]) (2,000 questions, three seeds).

Fault models and operating points. Random BER flips bits uniformly at a target rate; burst injection follows the E3-CODE protocol; PBS (Rakin et al., [50]) is gradient-guided and untargeted (500 flips); T-BFA (Rakin et al., [52]) forces a source class to a target class, measured by attack success rate (ASR); AttentionBreaker and SilentStriker are re-implemented on SANAI’s own INT8 tensors. The mechanism is instantiated at three operating points (Table 14, Appendix § 16): the strong t=12t = 12 code at K=3K = 3 (K=4K = 4 for depthwise networks and ImageNet backbones, K=5K = 5 for ViT-B/16), 20% coverage (40% on ImageNet) for random BER; the light t=4t = 4 code at K=4K = 4 (G=24G = 24), 10% coverage, keyed interleaving for concentrated attacks; and the strong code at K=4K = 4 (G=12≤tG = 12 \le t) for LLMs (gradient ranking and keyed interleaving for attacks; magnitude ranking, adjacent grouping under random BER). STDM uses B=5B = 5, Ls=1L_s = 1, R=1R = 1, and p0=2%p_0 = 2\% unless noted.

Table 14: Operating points of the one mechanism. Both codes are shortened from parents over GF(27)\mathrm{GF}(2^7) (x7+x+1x^7+x+1, n=127n=127); “48+88” means 48 message plus 88 stored parity bits per codeword. GG is weights per codeword, f=t/nf=t/n the correctable fraction of the parent, ρ\rho the coverage. The sign-bit guarantee G≤tG \le t holds only for the LLM point. All points add zero memory.

RegimeCodeKKGGffρ\rhoInterleaveUsed in
Random BER, visionstrong: parent BCH(127, 50, 12), 48+88 bits3 (4 depthwise, ImageNet)16 (> tt)9.4%20% (40% ImageNet)optionalSec. 5.1, 5.2, 5.2
Attacks, visionlight: parent BCH(127, 99, 4), 96+32 bits424 (> tt)3.1%10%keyedSec. 5.3
LLMsstrong: parent BCH(127, 50, 12), 48+88 bits412 (≤ tt)9.4%10 to 60%keyed (attacks)Sec. 5.4

Table 14.

Experiments run on four NVIDIA RTX 6000 Ada GPUs; protecting the largest vision model takes a few minutes, dominated by the sensitivity probes. The hardware checker is verified with Synopsys VCS and synthesized with Synopsys Design Compiler on the gscl45nm library.

Results

Random Bit Errors Across Architectures and Datasets

Table 1 (block 1) reports protected top-1 accuracy; the embedding itself is invisible, since at 0% BER every protected CIFAR checkpoint matches the unprotected INT8 model to two decimals (Master Table 5). On CIFAR-10 the three classic architectures stay within about one point of clean through a twelve percent BER; on CIFAR-100 the residual and plain models hold within one to two points and EfficientNet-B0 through ten percent. Jacob QAT matches PTQ; LSQ’s learned scales are more fragile, so a matched budget collapses at 12% (27.4%) while 2.5× the coverage restores 85.8% (rows V1.6, V1.7). Unprotected ResNet-18 is at random by an eight percent BER while the protected model holds near 95% until the code limit near twenty percent (Figure 4, left). Proposition 1 predicts this: with parity in clean carriers a codeword exposes 48 bits, so the failure probability is 1.3×10−41.3 \times10^{-4} at 3%, 3.4×10−63.4 \times10^{-6} at 6%, and 0.15 at 20%, where the rescue curve falls.

Figure 4. Left: unprotected, protected, and rescued accuracy over a 0 to 25% BER sweep (ResNet-18, CIFAR-10); the rescue plateaus and falls only near the code limit at 20%. Middle: recovery with the correct versus a wrong key; the shaded gap is recoverable only with the key. Right: protected LLM perplexity versus BER on WikiText-2 (log scale); the unprotected models sit at the 10610^6 ceiling.

Table 1: Vision results at INT8 and zero added memory. Block 1: protected top-1 (%) under random BER, strong code (K=3K = 3; K=4K = 4 for EfficientNet-B0 and ImageNet backbones other than ResNet-18; K=5K = 5 for ViT-B/16). Block 2: burst protocol of Kamineni et al. [28], prior embedded ECC as reported on their reference models versus SANAI on ours, so retention normalized to each method’s own clean accuracy is the comparable metric. Block 3: adversarial bit flips, light code, K=4K = 4, 10% coverage (T-BFA rows: strong code, high-bin selection). Every row traces to Master Tables 5, 7, and 8.

Block 1. Random BER: protected top-1 (%)
ModelDataCov.1%3%6%8%10%12%
ResNet-18CIFAR-1019.3%94.9594.6694.5494.4694.3693.06
ResNet-50CIFAR-1019.2%94.8794.7994.5194.5494.1093.70
VGG-16CIFAR-1020.0%90.1289.9889.8789.7289.7689.19
ResNet-18CIFAR-10014.0%77.3077.1076.8276.6976.1175.86
ResNet-50CIFAR-10036.1%75.6475.3675.3275.4175.3674.71
EffNet-B0CIFAR-10030.0%63.2962.4961.9661.4659.9753.22
ResNet-18ImageNet40.4%76.0576.1475.9575.7075.7875.70
ResNet-50ImageNet40.9%82.7282.5282.4182.0681.3180.88
MaxViT-TImageNet40.9%88.1488.0688.0587.9787.6987.55
Swin-TImageNet40%86.5086.2885.4285.3484.9283.44
Wide RN-50-2ImageNet40%83.9183.9784.0683.9183.5883.58
RegNet-Y-16GFImageNet40%85.6685.5085.0584.6484.6284.48
ViT-B/16ImageNet43.5%85.5085.4285.2884.4483.2577.89
Block 2. Burst errors versus prior embedded ECC: top-1 (%) at 1.5 / 3 / 6% BER
MethodResNet-18 C10EffNet-B0 C10ResNet-50 INMobileNet-V2 IN
Weight nulling82.0 / 19.0 / 0.0582.0 / 2.9 / 0.075.9 / 18.8 / 0.469.9 / 5.5 / 0.0
Opportunistic parity81.7 / 81.4 / 10.980.3 / 64.8 / 9.875.8 / 73.8 / 0.065.8 / 58.1 / 0.1
Value-aware parity82.0 / 81.2 / 77.582.0 / 77.9 / 22.675.9 / 75.1 / 65.169.9 / 66.0 / 20.9
E3-CODE81.8 / 81.8 / 78.882.3 / 78.6 / 55.675.9 / 75.8 / 70.069.9 / 66.7 / 36.9
E3-CODE-H82.0 / 81.9 / 81.382.7 / 82.3 / 80.176.1 / 75.9 / 74.771.2 / 70.5 / 65.5
SANAI (ours)94.9 / 94.7 / 94.583.8 / 83.0 / 81.482.2 / 81.6 / 80.578.4 / 78.1 / 77.8
Retention at 6% BER, normalized to each method’s own baseline over eight settings: 0.01, 0.06, 0.58, 0.72, 0.94, 0.97.
Block 3a. Progressive bit search, 500 flips, keyed interleaving, light code: top-1 (%)
ModelDataCov.UnprotectedSANAI
ResNet-18 / ResNet-50CIFAR-1010%10.1 / 35.094.9 / 94.8
ResNet-18 / ResNet-50CIFAR-10010%1.2 / 0.975.5 / 75.8
Block 3b. Same flipped bits, adjacent / keyed grouping, ResNet-18 / CIFAR-10
Flipscw > tmax/cwTop-1 (%)
1003 / 012 / 266.0 / 95.1
50022 / 014 / 310.1 / 94.9
Block 3c. Targeted attack (T-BFA): attack success rate (%)
ModelData, pairUnprotectedSANAI
ResNet-18CIFAR-10, 3→595.74.9
ResNet-18CIFAR-100, 90→70 / 90→8093.0 / 94.00.0 / 0.0
ResNet-50ImageNet, 132-pair mean~98~8

Table 1.

IDModelDataQuantCodeKKCov.RR0%1%3%6%8%10%12%
V1.1ResNet-18C10PTQS319.3%195.0994.9594.6694.5494.4694.3693.06
V1.2ResNet-18C10JacobS319.5%195.0594.9994.5894.5394.4194.4193.53
V1.3ResNet-50C10PTQS319.2%194.9394.8794.7994.5194.5494.1093.70
V1.4VGG-16C10PTQS320.0%190.2090.1289.9889.8789.7289.7689.19
V1.5ResNet-18C100PTQS314.0%177.0577.3077.1076.8276.6976.1175.86
V1.6ResNet-18C10LSQS318.6%194.9893.2690.7878.6076.2563.4127.38
V1.7ResNet-18C10LSQS336.6%194.9894.8694.5293.2692.7391.2685.84
V1.8ResNet-50C100PTQS336.1%175.7775.6475.3675.3275.4175.3674.71
V1.9VGG-16C100PTQS323.7%165.9265.9165.7465.7265.7465.5664.69
V1.10EfficientNet-B0C100PTQS430.0%162.8663.2962.4961.9661.4659.9753.22
V1.11MaxViT-TINPTQS440.9%188.1488.1488.0688.0587.9787.6987.55
V1.12RegNet-Y-16GFINPTQS4≈40%185.7885.6685.5085.0584.6484.6284.48
V1.13Wide ResNet-50-2INPTQS4≈40%184.0083.9183.9784.0683.9183.5883.58
V1.14Swin-TINPTQS4≈40%186.6186.5086.2885.4285.3484.9283.44
V1.15ViT-B/16INPTQS543.5%185.5985.5085.4285.2884.4483.2577.89
V1.16ResNet-18INPTQS340.4%176.1476.0576.1475.9575.7075.7875.70
V1.17ResNet-18INPTQS440.4%176.1476.2076.1276.1675.9575.9875.91
V1.18ResNet-50INPTQS340.9%182.8381.8381.0379.5878.5879.0576.45
V1.19ResNet-50INPTQS440.9%182.8382.7282.5282.4182.0681.3180.88
V1.24ResNet-18C10PTQS352.8%195.0695.0094.9195.0294.8494.9595.02
V1.25ResNet-18C10PTQS452.8%195.0695.0295.0095.0594.9494.9594.89
V1.26ResNet-50INPTQt=4t=4323.4%182.8381.5364.302.610.340.000.05
V1.27ResNet-50INPTQt=8t=8323.4%182.8382.3180.9578.4165.5533.289.17
V1.28ResNet-50INPTQt=12t=12323.4%182.8382.0981.0380.7380.0978.8677.30
V1.29ResNet-50INPTQt=20,m=8t=20,m=8323.4%182.8382.3481.3380.8879.8478.1175.67
V1.30ResNet-50C10PTQS339.8%294.8694.8894.6994.9794.6794.7594.84
V1.31ResNet-50C10PTQS320.4%294.8694.9194.8694.8694.8994.9394.80
V1.32ResNet-50C10PTQS315.1%294.8694.9294.8894.9594.8494.9794.78
V1.33ResNet-18C10 (INT6)PTQS352.8%195.0595.0094.8694.7394.5694.2093.64

Table 5.

The same pipeline applies unchanged to ImageNet with K=4K = 4 at a 40% budget (Table 1, block 1): ResNet-50, MaxViT-T, RegNet-Y-16GF, Wide ResNet-50-2, and Swin-T hold a normalized accuracy of 0.96 or above at twelve percent, and the plain ViT-B/16 needs a five-plane budget and holds 0.97 through ten percent and 0.91 at twelve.

Comparison with State-of-the-Art Embedded ECC

Table 1 (block 2; full table in Table 16, Appendix § 19) compares SANAI with five prior embedded ECC schemes under their burst-error protocol: weight nulling and opportunistic parity collapse by six percent (normalized retention 0.01 and 0.06), value-aware parity and E3-CODE retain 0.58 and 0.72, and E3-CODE-H, the strongest, 0.94. Because the reported baselines use lower-accuracy reference models (82.0% clean for ResNet-18 on CIFAR-10 versus our 95%), the comparable metric is normalized retention: SANAI reaches 0.99 at 3% and 0.97 at 6%, above E3-CODE-H, so the advantage is retention, not a higher start. With K=4K = 4, MobileNet-V2 and EfficientNet-B0 reach 0.95 and 0.97 at six percent. On the critical-BER metric, the highest rate at which accuracy stays near clean, SANAI reaches 6×10−26 \times10^{-2} on ResNet-50/ImageNet, 300,000× the unprotected 2×10−72 \times10^{-7} and 4× beyond E3-CODE-H at 1.5×10−21.5 \times10^{-2} (Figure 5, left). On MobileNet-V2/ImageNet the strongest prior method bends downward with the burst rate while SANAI stays flat (middle), and the modern ImageNet backbones hold their clean accuracy over the full 0 to 10% sweep (right).

Three-panel comparison of critical-BER gains, burst BER performance, and protected top-1 accuracy across modern architectures

Figure 5. Left: critical-BER improvement ratio over the unprotected model, ResNet-50 on ImageNet (log scale); baseline values as reported by Kamineni et al. [28]. Middle: MobileNet-V2 on ImageNet under the burst protocol against prior embedded ECC; the strongest prior method bends downward while ours stays flat. Right: modern architectures over a 0 to 10% sweep (ImageNet, INT8); ViT-B/16 omitted for scale.

DataModelSW Acc.W. Nulling 1.5W. Nulling 3W. Nulling 6Opp. Parity 1.5Opp. Parity 3Opp. Parity 6Value-Aware 1.5Value-Aware 3Value-Aware 6E3-CODE 1.5E3-CODE 3E3-CODE 6E3-CODE-H 1.5E3-CODE-H 3E3-CODE-H 6SANAI (ours) 1.5SANAI (ours) 3SANAI (ours) 6
C10ResNet-1882.082.019.00.0581.781.410.982.081.277.581.881.878.882.081.981.394.994.794.5
C10ResNet-5085.285.054.15.584.884.09.185.084.779.585.184.683.485.184.884.094.994.894.5
C10MobileNet-V283.683.08.80.082.979.59.183.081.341.283.082.459.483.683.076.878.276.675.3
C10EfficientNet-B082.882.02.90.080.364.89.882.077.922.682.378.655.682.782.380.183.883.081.4
INResNet-1869.569.310.00.469.267.30.169.368.259.069.368.965.369.469.367.775.575.173.3
INResNet-5076.175.918.80.475.873.80.075.975.165.175.975.870.076.175.974.782.281.680.5
INMobileNet-V271.569.95.50.065.858.10.169.966.020.969.966.736.971.270.565.578.478.177.8
INEfficientNet-B077.073.71.10.074.148.80.173.756.80.575.770.91.876.675.564.082.580.676.2
Norm.1.000.980.190.010.970.880.060.980.940.580.990.970.720.990.990.940.990.990.97

Table 16. Full comparison with embedded ECC under burst errors: top-1 accuracy at 1.5, 3, and 6% BER for all six methods and eight settings. Norm. is accuracy normalized to each method’s own software baseline; baseline values as reported by Kamineni et al. [28].

Access control: parity is unreadable without the key. We protect a model once and attempt recovery with the correct host key and a wrong key across a 0 to 20% sweep (rows V2.14 and V2.15 of Master Table 7; Figure 4, middle). With the correct key ResNet-18 on CIFAR-10 stays above 94% to ten percent; with the wrong key the de-projected parity is noise and accuracy collapses to 44.6% by three percent and to chance by eight. On ImageNet the wrong key yields essentially zero from the first error level, so a copied model cannot be restored under faults and the protection doubles as a lightweight anti-piracy control.

Progressive and Targeted Bit-Flip Attacks on Vision Models

PBS concentrates on the most sensitive weights, which forces it into the protected set: 76 to 100% of its flips land on SANAI-protected weights (Table 1, block 3a). Under the adjacent layout the same 500 flips overload the code: 9 to 49 codewords exceed t=4t = 4 across six ResNet settings, peaking at 10 to 15 faults in one, and accuracy collapses to 0 to 35%; more coverage does not help, so the problem is grouping, not budget. The compact networks are harder: at t=4t = 4 MobileNet-V2 reaches only 17%, and even the strong code leaves them at 64 and 10% on CIFAR-10 (Master Table 8).

Keyed interleaving removes the concentration itself (Table 1, block 3b; Figure 6 and Figure 7): with the identical flipped bits, uncorrectable codewords fall to zero on five of six settings and the maximum faults per codeword to 2 or 3, within t=4t = 4, as Theorem 1 predicts, and accuracy returns to the clean range. The exception is ResNet-18 on ImageNet: every codeword is corrected but accuracy stays at 1.5% because at 10% coverage the unprotected 90% of the model is itself corrupted by 500 flips, a coverage limit rather than a code failure (10 to 500 flip sweep in Table 17, Appendix § 20). T-BFA (Table 1, block 3c) must edit the classifier weights, where 97% of its flips land and which SANAI protects: ASR collapses from 93 to 98% to 0 to 8% (Figure 8). The bit-level fault maps and the independent fault-map pass are in Appendix § 20.

Per-codeword fault map under a real 500-flip PBS attack

Figure 6. Per-codeword fault map under a real 500-flip PBS attack (ResNet-18, CIFAR-10, light code t=4t = 4, 24 weights per codeword). Each row is one codeword and each red cell a flipped bit; the panels show the most heavily hit codewords. Left, adjacent grouping: the attack piles faults into a few codewords, 22 of which exceed t=4t = 4 (up to 14 faults) and fail. Right, keyed interleaving: the identical faults are scattered by the keyed permutation so that no codeword exceeds 3 faults and every codeword is corrected. The attacker flipped the same bits in both panels.

Figure 7. Protected top-1 accuracy under the 500-flip PBS attack, adjacent grouping versus keyed interleaving, across six architecture and dataset settings (light code, K=4K = 4, 10% coverage). Interleaving restores near-clean accuracy in every case except the coverage-limited ResNet-18 on ImageNet.

T-BFA source-to-target attack matrix

Figure 8. T-BFA source-to-target attack matrix (ImageNet ResNet-50, 132 source-target pairs). Each cell is the attack success rate for forcing the row (source) class to the column (target) class. (a) Unprotected: the attack succeeds on essentially every pair (90 to 100%). (b) Protected (SANAI): the success rate collapses to near zero on almost all pairs, with a few residual leaks, because the flips land in the protected classifier weights and are corrected before inference.

FlipsTop-1 (%) Adj.Top-1 (%) KeyedMax faults / cw Adj.Max faults / cw KeyedCodewords >t> t Adj.Codewords >t> t Keyed
1076.1476.141100
2076.1476.143100
4074.1976.085120
5073.8176.065120
10045.9875.418130
15011.8870.559230
2500.0050.55122100
3500.0022.34122110
4500.007.12122140
5000.001.53122140

Table 17. ResNet-18/ImageNet PBS flip sweep (INT8, light code t=4t = 4, K=4K = 4, 10% coverage): protected top-1 (%), largest fault count in one codeword, and number of uncorrectable codewords, adjacent versus keyed grouping, same flipped bits.

Large Language Models

Random bit errors. Table 2 (blocks 1a and 1b) applies the LLM operating point at 40% coverage. Unprotected models collapse at any nonzero BER (perplexity at the 10610^{6} ceiling below 3B, 10210^{2} to 10510^{5} above, accuracy at chance); protected models track clean through six percent in perplexity (Figure 4, right) and stay well above chance on MMLU and ARC-Easy (Figure 9). Larger models are more robust once protected: Qwen2.5-7B, Llama-3.1-8B, and Llama-2-13B are unchanged to two decimals even at 8%, whereas the two smallest models climb steeply at 8%. Accuracy falls faster than perplexity at 6% on the 7B and 8B because those runs stored part of the parity inside protected layers (the overflow regime of § 3.6); with clean carriers an 8% injection on Qwen2.5-7B gives perplexity 8.32 against 10610^{6} unprotected. Llama-3-8B-Instruct holds 83.8% ARC-Easy and Llama-3.2-3B 84.1% at 6% BER.

Block 1a. Random BER: protected WikiText-2 perplexity
ModelParams0%1%3%6%8%
DistilGPT-282M67.969.673.984.01746
GPT-2124M42.944.046.861.11909
Qwen2-0.5B0.5B17.3417.4117.4117.4418.26
Llama-3.2-1B1B13.6813.8314.1314.7025.32
Qwen2-1.5B1.5B11.8111.8311.8811.8912.35
Llama-3.2-3B3B10.3610.4410.5410.7411.73
Qwen2.5-7B7B7.727.727.727.727.74
Llama-3.1-8B8B7.957.957.957.958.04
Llama-2-13B13B6.196.206.196.206.20
Block 1b. Random BER: protected 5-shot MMLU / ARC-Easy (%)
ModelParams0%1%3%6%
Qwen2-1.5B1.5B58.5 / 85.557.8 / 84.556.5 / 83.054.3 / 80.0
Llama-3.2-3B3B62.4 / 87.962.2 / 87.160.4 / 86.158.1 / 84.1
Llama-3-8B-Instruct8B68.5 / 92.267.7 / 91.664.2 / 89.757.6 / 83.8
Qwen2.5-7B7B77.9 / 96.476.6 / 95.470.1 / 92.451.9 / 71.6
Block 2. AttentionBreaker: MMLU (%) and WikiText-2 perplexity
ModelAttackFlipsUndef. MMLUUndef. PPLSANAI MMLUSANAI PPL
Qwen2-0.5BTop-101025.81,29445.617.65
GenBFA2623.811,93545.617.65
Adaptive16,05627.0>106>10^645.617.65
Llama-3.2-1BGenBFA1,30828.454231.614.20
Adaptive20,97128.418,83531.614.20
Qwen2.5-7BTop-50050025.031,04779.27.74
Llama-3-8B-InstructTop-101027.064,97871.010.89
GenBFA1,018,08224.450471.010.89
Adaptive1,174,40523.691671.010.89
Block 3. SilentStriker (stealthy): attacked / SANAI
ModelParamsMMLUARCHellaSwagTruthfulQAPPL
Qwen2-0.5B0.5B43.0 / 45.027.0 / 28.538.5 / 45.023.0 / 22.020.98 / 17.65
Llama-3.2-1B1B22.0 / 31.030.5 / 31.549.0 / 52.525.0 / 24.021.02 / 14.20
Qwen2.5-7B7B76.0 / 78.540.5 / 42.063.0 / 63.032.5 / 29.58.05 / 7.74
Llama-3-8B-Instruct8B37.0 / 70.032.5 / 42.548.0 / 59.027.5 / 30.512.3 / 10.89

Table 2. LLM results at INT8, strong code, K=4K = 4, G=12≤tG = 12 \le t, zero added memory. Block 1: random BER at 40% coverage, mean of three seeds, protected model; unprotected models sit at the 10610^6 perplexity ceiling (below 3B) or 10210^2 to 10510^5 (above) and at chance accuracy at every nonzero BER. The accuracy runs stored part of the parity in protected layers (overflow regime, § 3.6), so their 6% values are conservative. Block 2: AttentionBreaker with gradient ranking and keyed interleaving, every attack corrected to the exact clean value. Block 3: SilentStriker, attacked / SANAI. Rows trace to Master Tables 9 to 11.

Figure 9. Protected accuracy versus BER on (a) MMLU and (b) ARC-Easy, 5-shot, 2,000 questions, three seeds; every protected model stays well above chance (≈25%\approx25\%), whereas unprotected models fall onto the chance line at any nonzero BER.

Optimized sign-bit attacks. AttentionBreaker ([12]) uses a gradient-and-magnitude score and an evolutionary search (GenBFA) to find a few weights whose sign bits collapse the model into gibberish; SilentStriker Xu et al., [64] keeps text fluent while flipping the answer. We evaluate the published attacks, an adaptive variant scored on the SANAI-corrected model, and a code-aware attacker that knows GG, tt, and the layout (Table 2, block 2). In every case SANAI restores the exact clean MMLU and perplexity with bit-identical weights. The adaptive attacker fails by construction: no set of sign flips raises the corrected loss above clean, so flipping all 16,056 population weights on Qwen2-0.5B, or 1.17 ×106\times10^6 bits on the 8B, leaves the corrected model unchanged; with G=12≤tG = 12 \le t no sign-bit attack places more than 12 errors in a codeword.

Defeating the code requires t+1t + 1 errors in one codeword, which G≤tG \le t means a second flipped plane on some weight. Master Table 11 prices it on Qwen2-0.5B: under the public adjacent layout, matching the damage of the 26-flip undefended attack needs roughly 600 layout-aware two-plane errors, a 23×\times increase; with keyed interleaving and no key the errors scatter to at most three per codeword and SANAI restores the clean perplexity at every budget up to 1,300. A key-holding attacker can break codewords again, but each buys less damage (1,170 versus 37,635 at 650 errors).

SilentStriker is stealthy, so accuracy is the damage metric (outputs in Table 18, Appendix § 21): on Llama-3-8B-Instruct, 160 flips drop MMLU from 70.0 to 37.0%; SANAI flags the tamper and returns every metric to clean on all four models (Table 2, block 3). Over 1 to 100 flips on Qwen2-0.5B, every attack is detected and corrected bit-exactly in 20 of 20 trials, with no false alarm. Two ablations matter (Master Table 10): a weight-magnitude ranking never selects the small attention projections the attacks target, so the model collapses as if undefended, whereas the gradient-informed probe selects them from 10% coverage; and K=3K = 3 (G=16>tG = 16 > t) reopens sign-only overloads.

PromptBefore attackAttentionBreakerSilentStrikerAfter SANAI
What is true for a type-Ia supernova?A type-Ia supernova is a specific astronomical event. Here are the options: A) explosion of a massive star; B) merger of two white dwarfs; C) collapse of a neutron star; …<repeated-token garbage; paste literal excerpt>A supernova is the explosive explosion of a star that has reached the end of its life, releasing a massive amount of energy …A type-Ia supernova is a specific astronomical event. Here are the options: A) explosion of a massive star; B) merger of two white dwarfs; C) collapse of a neutron star; …
If you know both the actual and apparent brightness of an object, what can you estimate?The correct option is: Distance. Apparent brightness is inversely proportional to the square of the distance …<repeated-token garbage; paste literal excerpt>I’m happy to help with any question you have. Perhaps you could use the above response as guidance or additional information …The correct option is: Distance. Apparent brightness is inversely proportional to the square of the distance …
Why is the sky blue?The correct answer is: Scattering of light. The sky appears blue because sunlight is scattered by molecules in Earth’s atmosphere such as nitrogen and oxygen …<repeated-token garbage; paste literal excerpt>The sky is blue because of the scattering of sunlight. When sunlight enters Earth’s atmosphere, it is deflected by tiny gas molecules …The correct answer is: Scattering of light. The sky appears blue because sunlight is scattered by molecules in Earth’s atmosphere such as nitrogen and oxygen …

Table 18. Representative Llama-3-8B-Instruct INT8 outputs before attack, under AttentionBreaker and SilentStriker, and after SANAI recovery. AttentionBreaker causes repeated-token corruption, while SilentStriker preserves fluency but alters the response. SANAI restores the clean output exactly.

Fine-Tuning Robustness and Ablations

Fine-tuning. Fine-tuning ResNet-18 and ResNet-50 on CIFAR-10 for ten epochs leaves the parity bit-exact at 10−410^{-4} and 10−310^{-3}; only at 10−210^{-2} does the earliest convolution drift past Δ/2\Delta/2 (0.003 to 0.004% of parity bits; Figure 15, Appendix § 22), and the surviving parity still corrects a 12% BER to 93.8% and 94.7% (Figure 10; per-rate values in Table 19, Appendix § 22).

Figure 10. Parity survival under fine-tuning: fraction of parity bits that no longer decode after each epoch on ResNet-18 (left) and ResNet-50 (right) on CIFAR-10. At learning rates 10−410^{-4} and 10−310^{-3} the parity stays bit-exact for all ten epochs; at 10−210^{-2} it drifts late and slightly (0.003 to 0.004% at epoch ten).

ModelLRParity BERAcc.ModelLRParity BERAcc.
ResNet-1810−410^{-4}0.000%95.0%ResNet-5010−410^{-4}0.000%94.9%
10−310^{-3}0.000%94.9%10−310^{-3}0.000%94.8%
10−210^{-2}0.003%88.5%10−210^{-2}0.004%90.0%

Table 19. Parity survival under fine-tuning (CIFAR-10): parity BER after ten epochs and model accuracy, three learning rates. Bit-exact at realistic rates on both architectures.

Per-layer weight drift after fine-tuning ResNet-18 on CIFAR-10

Figure 15. Per-layer weight drift after fine-tuning ResNet-18 on CIFAR-10 at learning rate 10−210^{-2}, measured against the STDM tolerance Δ/2\Delta/2; only the earliest convolution crosses it.

Ablations. Appendix § 23 (Table 21) isolates each choice. Coverage: 19.3% to 52.8% buys 0.5 points at 6% and 2 at 12% for 2.7× the parity (rows V1.1, V1.24). Code: on ResNet-50/ImageNet, t=4t = 4 (f=3.1%f = 3.1\%) collapses by 6% BER, t=8t = 8 (6.3%) falls to 9.2% at 12%, t=12t = 12 (9.4%) holds 77.3%, and m=8m = 8, t=20t = 20 (7.8%) trails t=12t = 12 despite the larger tt (Remark 1; rows V1.26 to V1.29). K = 4 lifts ResNet-50 on ImageNet from 76.5 to 80.9% at 12% BER while leaving ResNet-18 unchanged (rows V1.16 to V1.19). Replication: R∈{1,2,3}R \in\{1, 2, 3\} at capacity-limited coverage leaves protected accuracy unchanged (94.84, 94.80, 94.78 at 12%), so R=1R = 1 is the default (rows V1.30 to V1.32). Precision: INT6 ResNet-18/CIFAR-10 holds 93.6% at 12% (row V1.33); INT4 sits past the crossing of Eq. (6).

CoverageParity % bits@ 6%@ 12%
19.3%13.2694.5493.06
52.8%36.3095.0295.02
KK (planes)Knee BER@ 16%@ 20%
3∼13%\sim13\%84.124.5
4∼16%\sim16\%92.344.3
ttmmnn (parent)f=t/nf = t/n@ 6%@ 10%@ 12%
471273.1%2.60.00.1
871276.3%78.433.39.2
1271279.4%80.778.977.3
2082557.8%80.978.175.7
RRCov.b/wt0%6%10%12%
139.8%5.5094.8694.9794.7594.84
220.4%11.0094.8694.8694.8394.80
315.1%16.5094.8694.9594.9794.78

Table 21. Ablations on ResNet-18 unless noted. Top left: coverage (CIFAR-10). Top right: code strength on ResNet-50/ImageNet at 23.4% coverage; the fraction f=t/nf = t/n, not tt, governs where a code fails. Bottom left: bit-plane depth (CIFAR-10, 40% coverage). Bottom right: parity replication on ResNet-50/CIFAR-10; each RR uses the largest coverage that fits at zero added memory, and b/wt is parity per protected weight.

Hardware Realization

We implement two streaming checkers on an 8×88 \times8 output-stationary systolic array, synthesized with Synopsys Design Compiler on gscl45nm (Figure 11); both work on 16-weight blocks in fetch order, whiten the parity with a fuse-seeded keystream, and tap the weight path read-only, flagging a nonzero syndrome. The checker is model-agnostic: its area, timing, and energy per block do not depend on the network, and per-inference cost scales with the weight count; the evaluated workload, an INT8 CIFAR-10 CNN, fits the on-chip ROM and permits a bit-exact full-inference check.

SANAI Design A checker in the 8 × 8 output-stationary accelerator

Figure 11. SANAI Design A checker in the 8 × 8 output-stationary accelerator: a read-only tap on w_rd, w_addr, and w_din between weight memory and the convolution engine, with w_rd gating the clock and the other two feeding the 16-weight block gather, LFSR keystream, de-whitening XOR, and BCH(126, 112, t=2) syndrome. A nonzero syndrome raises an advisory tamper flag to the software decoder; there is no write-back, buffer, or parity array, and the weight file is byte-identical. The trust boundary encloses checker, clock gate, and seed.

Proposition 3 (Hardware reduction of STDM). Let Ls=1L_s = 1, one bit per symbol, lattice step Δ\Delta equal to one quantization step, and dither d=Δ2zd = \frac{\Delta}{2}z with z∈{0,1}z \in\{0,1\} a keystream bit. Then the embedding of Eq. (4) writes β⊕z\beta\oplus z into the least significant bit of the carrier weight, the reader returns that bit XORed with zz, and the perturbation is ∣δw∣≤Δ/2\lvert\delta w\rvert\le\Delta/2 exactly as in the general case.

Design A is this proposition in silicon: each block is one BCH(126, 112, t=2t=2) codeword over GF⁡(27)\operatorname{GF}(2^7) whose payload is the top seven bits of each weight and whose 14 parity bits occupy bit 0 of 14 weights, so any single flip is a weight-one codeword error and dmin⁡=5d_{\min}=5 detects it at every bit position, including the sign bit. Design B computes the STDM projection of the block on an integer lattice; its detection is magnitude dependent (100% at bit 6, 50% at bit 5, 0% at the sign bit, which moves the projection by exactly two lattice periods), which is why Design A is primary. Both coexist with the software code in the same weights and both detect and flag rather than correct: an in-line correcting variant needs a 140 KB shadow buffer, the whole weight file, and silently miscorrects 44 to 47% of blocks above capacity, so the flag hands recovery to the software decoder. Design A costs 0.41% area, 0.63% dynamic power, zero stall cycles, and zero memory, and closes at 1.27 ns (Table 3: detection rates, storage traffic, and sensitivity in Appendix § 24). Against a conventional per-block ECC checker synthesized under the same constraints (same code, parity from a separate SRAM port), Design A costs 13% more logic than the detect-only variant but no parity array (1.22 MB for ResNet-18), closes at 1.27 ns against 2.51 ns, and is 40% smaller and 2.6× faster than the correcting variant (Table 4); the protected model is byte-identical to the original instead of 10.94% larger and fetches 9.86% fewer bits per weight, a modeled 195 μ\muJ per ResNet-18 inference at DRAM energies [18].

Block A. Full accelerator
UnprotectedWith Design AWith Design B
Full-top critical path (ns)30.3831.1430.99
Dynamic power (mW)113.11113.81113.75
Leakage (mW)7.5817.5867.599
Weight memory added (bytes)000
Stall cycles added000
Block B. Checker alone
Design ADesign B
Area (μm2\mu\mathrm{m}^{2})5,763.947,084.55
Area, clock-gated (μm2\mu\mathrm{m}^{2})5,824.957,173.72
Area overhead over the accelerator (%)0.41180.5071
Critical path (ns)1.271.31
Power (mW)0.7970.619
Single-flip detection, bits 7 / 6 / 5 / 0 (%)100 / 100 / 100 / 1000 / 100 / 50.4 / 1.4

Table 3. Complete measured overhead (Synopsys DC V-2023.12-SP5, gscl45nm, 100 MHz constraint). Block A compares the full accelerator with and without a checker; block B characterizes the checkers themselves.

Design A (ours)Conv. detect-onlyConv. correcting
Parity locationbit 0 of the weightsseparate SRAMseparate SRAM
Checker area (μm2\mu\mathrm{m}^{2})5,763.945,092.849,646.46
Critical path (ns)1.272.513.28
Parity SRAM, CIFAR-10 CNN0 B15,355 B15,355 B
Parity SRAM, ResNet-180 B1.22 MB1.22 MB
Correction buffer0016 B
Miscorrection at t+1t+1flagsflags47.21%

Table 4. Design A against a measured conventional per-block ECC checker (same code and payload, same tool, library, and clock; Synopsys DC V-2023.12-SP5, gscl45nm, 100 MHz constraint).

Discussion and Limitations

The curves of § 5.1 use a localized model in which carriers stay clean, as for voltage scaling and RowHammer; under a uniform model that corrupts the parity-carrying layers too, keyed parity placement keeps ResNet-18/CIFAR-10 at 89.3% at 12% BER, against 78.8% with sequential parity and 10.8% unprotected (Table 20, Appendix § 23). Proposition 2 guards against an adversary who holds the weights but not the key; the remaining limit of any ECC is the code-aware multi-plane attacker (§ 5.4), against which keyed interleaving raises the cost of each unit of damage. The scheme does not depend on the training framework: applied directly to exported ONNX graphs ([2]), the protected model runs unchanged in ONNX Runtime without custom operators (Appendix § 17). The protectable fraction is bounded by carrier capacity, so very low precisions such as INT4 sit past the crossing of Eq. (6) (Appendix § 18), and the hardware checker detects and flags rather than corrects, handing recovery to the software decoder (Appendix § 24).

BERInterleaved paritySequential parityUnprotected
0%95.0695.0695.06
6%93.9293.8310.25
12%89.3478.8310.78

Table 20. Protected top-1 (%) under a uniform fault model that also corrupts the parity-carrying carrier layers (ResNet-18/CIFAR-10, strong code t=12t = 12, K=3K = 3, 19% coverage). Interleaving the parity keeps it correctable.

Conclusion

In summary, SANAI provides robust protection for sensitive model-weight bits with zero additional memory overhead. It achieves this by embedding parity bits directly into model weights and distributing them across a two-dimensional space using a scalable STDM scheme. SANAI is particularly effective in high-BER scenarios, where alternative embedding schemes either fail or incur substantial accuracy degradation. It maintains near-clean model accuracy at BERs of up to 12%, corrects progressive, targeted, and sign-bit attacks, and reduces the hardware overhead of the checker to only 0.41% in area. To the best of our knowledge, SANAI is the first secure ECC approach designed to defend against bit-flip attacks targeting critical model-weight bits with the goal of bypassing ECC protection. Furthermore, SANAI is scalable across diverse model architectures and sizes and incurs minimal hardware footprint.

AI Use Statement

In this work, we used generative AI tools for editing and condensing the manuscript text and for checking LaTeX formatting. We have not used generative AI tools for generating research ideas, designing experiments, producing results, or writing experimental code; the remaining required disclosure tasks are not applicable to this work. All AI-assisted text was reviewed and verified by the authors, who take responsibility for the final content of this work, including text, claims, and artifacts.

Ethics Statement

This work studies defenses against memory faults and bit-flip attacks on deployed neural networks. The attack implementations we use are re-implementations of published, code-available attacks and are evaluated only on public models and benchmarks; we release no new attack capability. The key-gated recovery mechanism is presented as fault tolerance with lightweight access control and is not claimed to be a cryptographic guarantee (§ 7).

Appendix

Master Tables

Every number in the main text is a row, or part of a row, of one of the master tables below (V1, V2, A1, L1, L2, L3). Each row is one run with its full configuration, so numbers for the same model that differ across main-text tables can be traced to the knob that differs. Cfg: S = strong code shortened from BCH(127, 50, t=12t=12) with 88 parity bits; L = light code shortened from BCH(127, 99, t=4t=4) with 32 parity bits. Blank cells were not run. Coverage is the protected weight fraction; RR is parity replication; Intl. marks keyed interleaving.

Table 5: Master Table V1: vision runs under random BER with the strong code (INT8 unless noted), top-1 accuracy (%). Rows V1.24 to V1.33 are the ablations of Section 5.5. ImageNet rows use layer-mode selection at a 40% budget; unprotected ImageNet accuracy is below 1% at 12% BER for every model. †five-plane budget.

Table 6: Master tbl:V1b: ResNet-18 / CIFAR-10 under weight-level sensitivity bins (block A; high = top 1% of weights by attack-damage proxy, mid = next 8%; V1.35 had host bits exposed and 11 overflow carriers) and under the uniform fault model that corrupts the carrier layers at the same BER (block B; strong code, K=3K=3, 19% coverage). Protected (unprotected) top-1 (%).

Block A. Weight-level sensitivity bins
IDBins protectedLayersKKCov.3%6%T-BFA ASR unprot. / prot.
V1.34high only14424.8%94.95 (69.16)95.01 (15.03)95.3 / 4.5
V1.35high + half mid16456.5%93.32 (66.92)79.11 (17.06)95.3 / 8.4
Block B. Uniform fault model: carrier layers corrupted at the same BER
IDParity placementKKCov.0%6%12%
V1.36interleaved319%95.0693.92 (10.25)89.34 (10.78)
V1.37sequential319%95.0693.83 (10.25)78.83 (10.78)

Table 6.

Algorithm and Embedding Details

Algorithm 1 states SANAT end to end. Figure 2 illustrates the two-scale lattice used when BB parity bits are embedded per symbol: a group of BB bits is read as a level in [0,2B−1][0,2^B-1], the coarse step Δ2B\Delta2^B selects the cell, the fine step Δ\Delta places one sub-level per value inside each cell, and decoding Extended to 12% burst BER on five settings: V2.1 93.1, V2.2 93.7, V2.3 67.1, V2.4 75.0, V2.6 62.6.

IDModelDataKKCov.0%1.5%3%6%
V2.1ResNet-18C10320%95.0994.994.794.5
V2.2ResNet-50C10320%94.9394.994.894.5
V2.3MobileNet-V2C10420%79.2778.276.675.3
V2.4EfficientNet-B0C10420%84.2383.883.081.4
V2.5ResNet-18IN320%76.1475.575.173.3
V2.6ResNet-50IN320%82.8382.281.680.5
V2.7MobileNet-V2IN420%78.3978.478.177.8
V2.8EfficientNet-B0IN420%83.4282.580.676.2
V2.9ResNet-18C10410%95.195.1 (87.5)94.9 (52.5)94.8 (20.4)
V2.10ResNet-18IN410%76.175.5 (0.2)73.4 (0.0)72.4 (0.0)
V2.11ResNet-50IN410%82.882.6 (0.5)81.8 (0.8)79.9 (0.0)
V2.12MobileNet-V2IN410%78.477.2 (0.0)72.6 (0.3)64.1 (0.0)
V2.13EfficientNet-B0IN410%83.482.1 (0.0)79.7 (0.0)73.3 (0.1)
V2.14ResNet-18C10correct19.3%95.0994.8994.6694.54
V2.15ResNet-18C10wrong19.3%94.8877.4344.5822.91
V2.16ResNet-18INcorrect20%76.1475.5075.0873.28
V2.17ResNet-18INwrong20%67.300.000.020.00

Table 7. Master Table V2: vision runs under the burst protocol of [28] with the strong code (block A), under random BER with the light code at the attack operating point (block B), and under key-gated recovery with Ls=2L_s = 2 (block C). Top-1 (%); unprotected in parentheses where measured. Block A. Burst protocol, strong code. Block B. Random BER, light code, keyed interleaving; protected (unprotected). Block C. Key-gated recovery, strong code, K=3K = 3.

rounds to the nearest fine sub-level, β^=round⁡((p−d)/Δ) mod 2B\hat{\beta} = \operatorname{round}((p-d)/\Delta) \bmod2^B. Setting Ls=1L_s = 1 recovers plain QIM capacity of one bit per carrier weight while keeping key dependence; raising LsL_s averages LsL_s independent low-bit perturbations, trading capacity for robustness of the hidden parity.

Complexity. Let CevalC_{\mathrm{eval}} be the cost of one validation pass. The protect phase costs O(LCeval)O(L C_{\mathrm{eval}}) for probing, O(Llog⁡L)O(L \log L) for selection, O(Ncwnt)O(N_{\mathrm{cw}}nt) for BCH encoding, and O(Wc)O(W_c) for STDM embedding. The restore phase costs O(Wc)O(W_c) for de-projection, O(Ncw(nt+t2))O(N_{\mathrm{cw}}(nt+t^2)) for Berlekamp-Massey decoding [38], and O(WpK)O(W_pK) for splicing, linear in model size and independent of the fault rate. The mixed-integer programs of prior embedded ECC are NP-hard in general and need commercial solvers whose runtime grows sharply with layer count.

Proofs

Proposition 1. The decoder corrects any pattern of at most tt errors and fails on any pattern of more, so the failure event is {X>t}\{X > t\} with X∼Bin⁡(n,p)X \sim\operatorname{Bin}(n,p), which gives the binomial tail. Writing X/nX/n as the mean of nn independent Bernoulli(pp) variables and applying Hoeffding’s inequality [22] to the deviation f−p>0f-p > 0 gives Pr⁡[X/n>f]≤exp⁡(−2n(f−p)2)\Pr[X/n > f] \le\exp(-2n(f-p)^2).

Lemma (random-fault correctability). Let each codeword hold GKGK protected bits flipped independently with probability pp. Then fc∼Bin⁡(GK,p)f_c \sim\operatorname{Bin}(GK,p) and Pr⁡[fc>t]=∑i>tGKpi(1−p)GK−i\Pr[f_c > t] = \sum_{i>t}^{GK} p^i(1-p)^{GK-i}, which for GKp≪tGKp \ll t is O((GKp)t+1)O((GKp)^{t+1}). With GK=96GK = 96, t=4t = 4, p=0.06p = 0.06 the per-codeword failure probability is small and the model-level accuracy is preserved, matching the flat protected curves in Master Table 5.

Lemma (adversarial concentration). A targeted attacker with a flip budget FF maximizes damage by maximizing max⁡cfc\max_c f_c. Under adjacent grouping all FF flips of a sensitive region can be placed in ⌈F/(GK)⌉\lceil F/(GK)\rceil codewords, so one codeword may reach fc=min⁡(F,GK)≫tf_c = \min(F,GK) \gg t. This is the measured behaviour: 500 PBS flips drive 29 codewords above t=4t = 4 with a peak of 27 (see Table 1).

Proposition 2. (a) With the correct key the reader forms w′⋅v+d=p∗+δw' \cdot v + d = p^* + \delta where δ\delta is the read-time perturbation of the projection; p∗p^* lies on the lattice selected by β\beta and the two lattices

are separated by Δ/2\Delta/2, so rounding returns β\beta whenever ∣δ∣<Δ/2|\delta| < \Delta/2. (b) For an independent pseudorandom v′∈{−1,+1}Lsv' \in\{-1,+1\}^{L_s}, E[v⋅v′]=0\mathbb{E}[v \cdot v'] = 0 and ww is a sum of terms whose signs are independent of β\beta; the parity of its rounded level is a Bernoulli(12\frac{1}{2}) variable independent across groups, so all PbitsP_{\mathrm{bits}} bits are recovered with probability 2−Pbits2^{-P_{\mathrm{bits}}}.

Theorem 1. Since π\pi is uniform and unknown to the attacker, the codeword of each chosen weight is a uniformly random bin among MM, independent across flips up to the without-replacement correction, which only tightens the bound. The maximum load of FF balls in MM bins is O(F/M+log⁡M/log⁡log⁡M)O(F/M + \log M/\log\log M) in expectation [42]. For F≪Mlog⁡MF \ll M\log M the first term vanishes and the second is O(1)O(1) for any practical MM, so max⁡cfc≤t\max_c f_c \leq t with high probability.

Worked example of the interleaving bound. Take the light code, t=4t=4 and G=24G=24 weights per codeword, and a model of M=1000M=1000 codewords. An attacker who knows the code parameters flips F=10F=10 bits in one physical region, intending to overload one codeword. Under adjacent grouping all ten land in that codeword, fc=10>tf_c=10>t, and it fails; the attacker wins with t+1=5t+1=5 flips. Under a keyed permutation the ten flips fall into the MM codewords like balls into bins: E[fc]=F/M=0.01\mathbb{E}[f_c]=F/M=0.01 and max⁡cfc≈F/M+ln⁡M/ln⁡ln⁡M≈3.6≤t\max_c f_c\approx F/M+\ln M/\ln\ln M\approx3.6\leq t, so every codeword is corrected although ten bits were flipped. Setting the bound above at F/M≳0.4F/M\gtrsim0.4, so the blind attacker needs on the order of 400 flips before any codeword fails, against 5 under adjacent grouping. Without the key the attacker cannot direct a flip into a chosen codeword: the probability of landing t+1t+1 blind flips in one specific codeword is about M−5=10−15M^{-5}=10^{-15}. Table 8, block B, is the measured counterpart: 500 real PBS flips, 22 uncorrectable codewords under adjacent grouping and none under interleaving.

Table 8: Master Table A1: vision runs under adversarial bit-flip attacks (INT8). Block A: PBS with keyed interleaving (ResNets: light code, layer-mode selection; compact networks: strong code, weight-mode selection). Block B: the same 500 PBS flips under adjacent and keyed grouping. Block C: T-BFA with the strong code. Block D: fault-map pass on the compact networks. cw>t>t counts uncorrectable codewords and max/cw is the largest fault count in one codeword; †weight-mode selection. Row A1.15 (100 flips) is from an earlier run.

Block A. PBS, 500 flips, keyed interleaving
IDModelDataCodeCov.Unprot. (%)Prot. (%)cw>t>tmax/cw
A1.1ResNet-18C10light, t=4t=410%10.0694.903
A1.2ResNet-50C10light, t=4t=410%35.0094.803
A1.3MobileNet-V2C10strong, t=12t=1210%9.9464.11†5†
A1.4EfficientNet-B0C10strong, t=12t=1210%10.0010.30†3†
A1.5ResNet-18C100light, t=4t=410%1.1675.502
A1.6ResNet-50C100light, t=4t=410%0.9475.802
A1.7MobileNet-V2C100strong, t=12t=1210%1.0235.00†2†
A1.8EfficientNet-B0C100strong, t=12t=1210%0.9860.93†8†
Block B. Adjacent / keyed grouping, same flipped bits, light code t=4t=4
IDModelDataFlipsCov.Prot. (%) adj / keyedcw>t>tmax/cw
A1.9ResNet-18C1050010%10.06 / 94.8622 / 014 / 3
A1.10ResNet-50C1050010%35.00 / 94.8114 / 015 / 3
A1.11ResNet-18C10050010%1.16 / 75.4826 / 013 / 2
A1.12ResNet-50C10050010%0.94 / 75.7749 / 010 / 2
A1.13ResNet-18IN50010%0.00 / 1.5314 / 012 / 2
A1.14ResNet-50IN50010%1.70 / 81.889 / 512 / 2
A1.15ResNet-18C1010010%66.0 / 95.13 / 012 / 2
Block C. Targeted attack (T-BFA), strong code, high-bin selection
IDModelDataPairCov.FlipsASR unprot.ASR prot.
A1.17ResNet-18C103→53 \to524.8%1595.3 / 95.74.5 / 4.9
A1.18ResNet-18C10090→7090 \to7010%10 to 2093.00.0
A1.19ResNet-18C10090→8090 \to8010%10 to 2094.00.0
A1.20ResNet-50IN132-pair mean10%10 to 20∼98\sim98∼8\sim8
Block D. Fault-map pass, compact networks, 500 flips, light code t=4t=4
IDModelDataFlipsLayoutcw>t>tmax/cw
A1.21MobileNet-V2C10500adjacent / keyed42 / 110 / 5
A1.22MobileNet-V2C100500adjacent / keyed35 / 010 / 2
A1.23EfficientNet-B0C10500adjacent / keyed17 / 014 / 3
A1.24EfficientNet-B0C100500adjacent / keyed23 / 324 / 8

Table 8.

Sign-bit bound. A sign-bit attack alters one bit plane per weight; each weight contributes its sign bit to exactly one codeword, so the attack injects at most GG errors per codeword. If G≤tG \leq t sign-bit configuration lies within the correction radius and is repaired exactly. Defeating a codeword therefore requires a second error on some weight, that is a second flipped plane.

Unprotected MMLU / ARC-E is 24 to 26% (four-way chance) on every model at every nonzero BER.

Proposition 3. At Ls=1L_s = 1 the direction v∈{−1,+1}v \in\{-1,+1\} is a scalar and p=vw+dp = vw + d is an affine bijection of the integer weight. With Δ\Delta equal to one quantization step, the two interleaved lattices are the even and odd integer levels, so snapping pp to the lattice selected by β\beta sets the parity of the integer level, that is the LSB of the stored weight. The dither d=Δ2zd = \frac{\Delta}{2}z shifts the lattice by half a step, which toggles which lattice is labelled β\beta and complements the written bit when z=1z = 1; the composition writes β⊕z\beta\oplus z. Reading inverts the same affine map and takes the result modulo 2, recovering β⊕z\beta\oplus z, and XOR with zz returns β\beta. Rounding to the nearest level tolerates any displacement below Δ/2\Delta/2.

Qualitative Comparison of Weight-Protection Schemes

Table 12 places SANAI beside the schemes discussed in § 2 along the axes that decide whether a protection is deployable on an edge accelerator: added memory, where the parity lives, the granularity at which protection is applied, the fault tolerance actually demonstrated, the accuracy cost of the protection itself, whether retraining is needed, whether the parity is bound to a key, whether it survives fine-tuning, and which architectures it was shown on. Three patterns stand out. First, every scheme that adds no memory stores its parity next to the data it protects, so a burst that hits a block takes weight and check bits together; SANAI is the only one whose parity is moved cross-layer into carriers chosen for their tolerance. Second, no prior scheme binds parity to a key, so a copied model can always be repaired by whoever holds it; the key-seeded STDM embedding is what turns fault tolerance into an access-control primitive. Third, the demonstrated fault tolerance of the embedded schemes stops at a six percent BER, and none report behaviour under fine-tuning or on transformers or language models. The last row summarizes what the rest of the paper measures.

Experimental Details

Quantization and injection. PTQ uses per-output-channel scales for convolutions and per-tensor scales for linear layers. QAT checkpoints (Jacob, LSQ) store their exact training-time scales, so integer tensors are recovered losslessly before protection. Faults are injected into the two’s-complement byte representation of the integer weights. Each BER point uses a fixed random seed for vision; LLM random-BER results average three seeds (0, 1, 2). CIFAR models are trained to convergence; ImageNet models use torchvision pretrained weights, with clean INT8 top-1 of 76.1 to 83.4%.

Sensitivity proxies. For vision the probe of Eq. (2) at p0=2%p_0 = 2\% ranks layers. For LLMs three proxies were compared: weight-ℓ1\ell_1 magnitude, gradient-weighted magnitude ∑∣g⊙w∣\sum|g \odot w| from one backward pass over four 5-shot MMLU prompts, and the attack’s own per-layer loss probe. The two gradient-informed proxies choose 118 small layers (39.1% of weights) on Qwen2-0.5B where magnitude chooses 32 large ones (39.0%); Appendix J shows only the gradient-informed proxies protect the attacked layers. Token-embedding and output-projection matrices are excluded as carriers and from injection.

Attack re-implementations. PBS and T-BFA follow the public implementations [50, 52] on the INT8 tensors; T-BFA uses 90 source-target pairs on CIFAR-10 and 132 on ImageNet. AttentionBreaker follows the public code: the attack loss is the causal-LM cross-entropy over a batch of four 5-shot MMLU prompts; the per-weight score is α∣g∣+(1−α)∣w∣\alpha|g| + (1-\alpha)|w| with α=0.5\alpha= 0.5 min-max normalized per layer; every attention and MLP projection is ranked by the loss reached after flipping the sign bit of its top p%p\% weights, p∈{10−3,10−2,0.1,1,5}p \in\{10^{-3},10^{-2},0.1,1,5\}; the population space is the top 2% of the most fragile layer; GenBFA minimizes the flip set subject to L≥7\mathcal{L} \ge7 with tournament selection, uniform crossover, 1 to 9% drop-mutation, and 100 generations of 40 candidates. All flips are on bit 7. We re-implement on SANAI’s own INT8 tensors rather than on bitsandbytes LLM.int8()

IDModelAttackBudgetCov.Intl.ResultDetected / exact
L3.1Qwen2-0.5BCode-aware13 / 65 / 130 / 260 / 650 / 1,30040%adjPPL 18.1 / 28.0 / 48.1 / 769 / 37,635 / 93,819yes / no
L3.2Code-awaresame budgets40%blindPPL 17.65 at every budget (max/cw ≤3\le3)yes / yes
L3.3Code-awaresame budgets40%keyPPL 18.4 / 34.9 / 50.4 / 137 / 1,170 / 312,778yes / no
L3.4Llama-3.2-1BCode-aware130 / 260 / 650 / 1,300 / 2,60040%adjPPL 14.9 / 15.8 / 19.1 / 23.0 / n.a.yes / no
L3.5Code-awaresame budgets40%keyPPL 15.0 / 16.1 / 23.9 / 48.7 / 129.5yes / no
L3.6Qwen2-0.5BSilentStriker160 flips60%keyMMLU 43.0 / 45.0, PPL 20.98 / 17.65, 146 of 160 codewords flaggedyes / yes
L3.7Llama-3.2-1BSilentStriker160 flips60%keyMMLU 22.0 / 31.0, PPL 21.02 / 14.20, 157 of 160 codewords flaggedyes / yes
L3.8Qwen2.5-7BSilentStriker160 flips60%keyMMLU 76.0 / 78.5, PPL 8.05 / 7.74, 160 of 160 codewords flaggedyes / yes
L3.9Llama-3-8B-Inst.SilentStriker160 flips60%keyMMLU 37.0 / 70.0, PPL 12.3 / 10.89yes / yes
L3.10Qwen2-0.5BSign flips110%keycorrected bit-exactly (max/cw 1)20/20 / 20/20
L3.11Sign flips210%keycorrected bit-exactly20/20 / 20/20
L3.12Sign flips510%keycorrected bit-exactly20/20 / 20/20
L3.13Sign flips1010%keycorrected bit-exactly20/20 / 20/20
L3.14Sign flips2010%keycorrected bit-exactly20/20 / 20/20
L3.15Sign flips5010%keycorrected bit-exactly20/20 / 20/20
L3.16Sign flips10010%keycorrected bit-exactly20/20 / 20/20

Table 11. Master Table L3: LLM runs under the code-aware attacker, SilentStriker, and the detection sweep (INT8, strong code, K=4K = 4). Code-aware rows are two-plane attacks that place 13 errors per targeted codeword and list WikiText-2 perplexity after SANAI at each error budget; blind = interleaved layout unknown to the attacker. SilentStriker rows give attacked / SANAI MMLU and perplexity and the number of the 160 attacked codewords whose syndrome flagged (other metrics in Table 2); every model recovers with zero weights wrong. Detection rows are 20 trials of random sign flips inside the protected set on Qwen2-0.5B at 10% coverage; the clean model raised zero false alarms over 1.19×1071.19 \times10^{7} codewords.

[14] so that every flip lands on exactly the integer SANAI encodes. MMLU for the attack experiments uses 500 questions from 20 subjects and WikiText-2 perplexity 20k test tokens.

Portability to a Deployment Format

To confirm that SANAI does not depend on the training framework, we apply it directly to ONNX graphs [2]: the INT8 weight initializers of the exported model are the only inputs to the scheme, and the protected file runs unchanged in ONNX Runtime [40] with no custom operator or runtime hook. On the CIFAR-10 SimpleCNN (static QDQ INT8, 88.15% clean), a BCH(63, 39, t=4t=4) code over GF(262^6), shorter than the paper’s family to match the small classifier, protects the top four planes of the classifier, and its parity is hidden in the convolution layers by integer-lattice STDM (Δ=8\Delta= 8, one bit per 16-weight block) at zero file growth (154,589 bytes before and after) and zero accuracy cost; protecting all eight planes costs 0.18 points. Twenty sign flips and a 1% random BER are fully detected (18 of 18 and 40 of 40 affected codewords flagged, none falsely) and corrected bit-exactly. On DistilGPT-2 (weight-only per-channel INT8, 76.4 WikiText-2 perplexity under this quantizer and token set, hence not directly comparable with Table 2), we protect the sign and top magnitude planes of the most gradient-sensitive projection (h.0.attn.c_proj) and, relaxing the carrier exclusion of § 4, place the 884,736 parity bits in the token-embedding table, the largest and least sensitive tensor in the graph, again at zero file growth and a 0.04 perplexity cost. Fifty gradient-targeted sign flips that raise perplexity to 3,080 are flagged (38 of 38 affected codewords) and reversed exactly, and a 0.1% BER over all planes is brought from 258 to 77.7 perplexity, near clean, by restoring the two protected planes alone. In both cases every corrupted codeword was flagged and every clean codeword passed, so the sensitivity-aware, zero-overhead protection and the detect-and-flag behaviour carry over unchanged to a standard deployment format.

Storage Accounting and the Precision Squeeze

Counting the full code expansion 1+p/ks=1+88/481 + p/k_s = 1 + 88/48 instead of the systematic parity fraction p/ksp/k_s would predict about 1.7 bits per weight at the default operating point and contradict the measured 1.05 to 1.10; the systematic property is what keeps the cost low. For the LLM random-BER experiments,

Algorithm 1: SANAI: sensitivity-guided bit-plane ECC with keyed interleaving and cross-layer STDM parity hiding

Input: Quantized weights {θℓ}ℓ=1L\{\theta_\ell\}_{\ell=1}^{L} at bb bits; coverage ρ\rho; planes KK; parent code BCH⁡(n,k,t)\operatorname{BCH}(n,k,t) over GF⁡(2m)\operatorname{GF}(2^m) with n=2m−1n=2^m-1, storing pp parity bits per ksk_s-bit message; group size GG; lattice step Δ\Delta; spread LsL_s; key κ\kappa; probe rate p0p_0

Output: Protected weights θ′\theta' (offline); restored weights θ^\hat{\theta} (read time)

// Phase 1: protect, offline, run once

  1. foreach layer ℓ\ell do

  2. Sℓ←Aclean−Eϵ∼Bern⁡(p0)[A(θℓ⊕ϵ)]S_\ell\leftarrow A_{\mathrm{clean}}-\mathbb{E}_{\epsilon\sim\operatorname{Bern}(p_0)}[A(\theta_\ell\oplus\epsilon)] // Eq. (2)

  3. end

  4. sort layers so that Sℓ(1)≥⋯≥Sℓ(L)S_{\ell_{(1)}}\ge\cdots\ge S_{\ell_{(L)}}; P←\mathcal{P}\leftarrow largest prefix with ∑ℓ∈P∣θℓ∣≤ρW\sum_{\ell\in\mathcal{P}}|\theta_\ell|\le\rho W // Eq. (3)

  5. C←\mathcal{C}\leftarrow remaining layers, least sensitive first; π←KeyedPerm⁡(P,κ)\pi\leftarrow\operatorname{KeyedPerm}(\mathcal{P},\kappa) // Eq. (5)

  6. foreach codeword cc of GG weights from π(P)\pi(\mathcal{P}) do

  7. Mc←⌊θc/2b−K⌋M_c\leftarrow\left\lfloor\theta_c/2^{b-K}\right\rfloor;

  8. πc←BCH⁡(n,k,t)(Mc)\pi_c\leftarrow\operatorname{BCH}(n,k,t)(M_c)

  9. end

  10. Π←πc1∥πc2∥⋯\Pi\leftarrow\pi_{c_1}\Vert\pi_{c_2}\Vert\cdots; assert ∣Π∣≤WcB/Ls|\Pi|\le W_cB/L_s // Eq. (6)

  11. (v,d)←PRNG⁡(κ)(v,d)\leftarrow\operatorname{PRNG}(\kappa) per carrier group

  12. foreach parity symbol β∈Π\beta\in\Pi with carrier group w⊂Cw\subset\mathcal{C} do

  13. p←w⋅v+dp\leftarrow w\cdot v+d;

  14. snap to p∗p^*;

  15. w←w+p∗−pLsvw\leftarrow w+\frac{p^*-p}{L_s}v // Eq. (4), ∣δw∣≤Δ/2|\delta w|\le\Delta/2

  16. end

  17. θ′←{θℓ}\theta'\leftarrow\{\theta_\ell\} // ∣s(θ′)∣=∣s(θ)∣|s(\theta')|=|s(\theta)|: zero added memory

// Phase 2: restore, read time

  1. θ~←\tilde{\theta}\leftarrow read from faulty memory;

  2. (v,d)←PRNG⁡(κ)(v,d)\leftarrow\operatorname{PRNG}(\kappa)

  3. foreach carrier group w′⊂Cw'\subset\mathcal{C} do

  4. β^←⌊(w′⋅v+d)/(Δ/2)⌋ mod 2\hat{\beta}\leftarrow\left\lfloor(w'\cdot v+d)/(\Delta/2)\right\rfloor\bmod2

  5. end

  6. unpack {π^c}\{\hat{\pi}_c\} from Π^\hat{\Pi}

  7. foreach codeword cc of π(P)\pi(\mathcal{P}) do

  8. M^c←BCH_Decode⁡(M~c,π^c)\hat{M}_c\leftarrow\operatorname{BCH\_Decode}(\tilde{M}_c,\hat{\pi}_c);

  9. θ^c←M^c⋅2b−K+(θ~c mod 2b−K)\hat{\theta}_c\leftarrow\hat{M}_c\cdot2^{b-K}+(\tilde{\theta}_c\bmod2^{b-K});

  10. flag if syndrome nonzero

  11. end

  12. return θ^←π−1({θ^c})∪{θ~ℓ}ℓ∉P\hat{\theta}\leftarrow\pi^{-1}(\{\hat{\theta}_c\})\cup\{\tilde{\theta}_\ell\}_{\ell\notin\mathcal{P}}

SANAI is the only scheme that keeps parity in-weight and moves it cross-layer, decoupling the parity from what it protects.

all three small models hide the full payload at 3.5 to 4.0 bits per weight from 17 to 32 insensitive carrier layers (Qwen2-0.5B: 24 insensitive plus 8 overflow; GPT-2: 32 plus 8; DistilGPT-2: 17 plus 1), and the attack-regime configuration at 10% coverage uses about 9.2% of model bits with no overflow.

Precision squeeze. Two effects act together as precision falls. Lower precision makes more layers fragile, so the sensitive set grows and demand rises; the same shrinking bit budget leaves fewer robust carriers with spare low-order bits, so the capacity WchW_{ch} falls. Figure 12 (right) plots both: demand rises from about 13% of model bits at INT8 to about 70% at INT4 while capacity falls from about 62% to 18%, and past the crossing no assignment of parity to carriers satisfies Eq. (6). INT6 on CIFAR-10 remains feasible (a small budget degrades to about 15% at 12% BER, 35% coverage with K=4K=4 recovers to about 86%); INT6 on ImageNet and INT4 sit past the crossing.

Quantization ablation and precision squeeze plots

Figure 12. Left: quantization ablation; LSQ needs roughly 2.5× the protection budget of PTQ. Right: the precision squeeze; parity demand rises while carrier capacity falls, and configurations past the crossing cannot be protected at zero added memory.

Extended Vision Results

Critical BER. Figure 5 reports the improvement in critical BER relative to the unprotected model on ResNet-50/ImageNet. SANAI reaches 6×10−26 \times10^{-2}, 300,000× the unprotected 2×10−72 \times10^{-7} and 4×4\times beyond E3-CODE-H at 1.5×10−21.5 \times10^{-2}. The same ordering holds on EfficientNet-B0, where our 3×10−23 \times10^{-2} exceeds E3-CODE H at 7×10−37 \times10^{-3} and value-aware parity at 4×10−44 \times10^{-4}. Under random BER at the attack operating point (rows V2.9 to V2.13 of Master Table 7) the compact architectures hold through 9% but drop at 12%, consistent with the lower f=3.1%f=3.1\% of the short t=4t=4 code; the long t=12t=12 code of the random-BER operating point is the right choice for that regime, which is why Table 14 keeps both.

Extended Attack Results on Vision Models

Figure 3 illustrates the mechanism; Figure 6 shows the measured per-codeword fault map behind Table 1 and Figure 7 the accuracy across all six settings. An independent fault-map pass over the same ResNet-18/CIFAR-10 attack, counting only faults in the four protected planes with its own weight selection, gives the same picture with larger counts (29 uncorrectable codewords, the worst with 27 faults; 0 and a maximum of 3 after interleaving) and adds three observations: the flips concentrate on bits 7 and 6 and almost never touch bit 4, so the attack targets exactly the planes the code protects; the failing codewords sit in conv1, layer1, and layer2, where PBS focuses; and the worst codeword fails because nearly every one of its 24 weights is hit on bit 6 or 7, the concentration that the keyed permutation breaks (Figure 13). Under adjacent grouping at 500 PBS flips on ResNet-18/CIFAR-10, 22 codewords exceed t=4t = 4 with a peak of 14; under interleaving the identical faults spread across many codewords, none exceeding 3. Across the six settings (Master Table 8, block B) adjacent grouping leaves 9 to 49 codewords uncorrectable and accuracy at 0 to 35%, while keyed interleaving leaves none (five on ResNet-50 ImageNet) and restores 94.9, 94.8, 75.5, 75.8, and 81.9%. ResNet-18 on ImageNet is the one setting where interleaving corrects every codeword yet accuracy does not return (1.5%): at 10% coverage and 500 flips the unprotected 90% of the model is corrupted, so correcting the protected codewords is insufficient; higher coverage or a lower flip budget resolves it. On the compact networks (Master Table 8, block D) interleaving removes 90 to 100% of the uncorrectable codewords (42 to 1, 35 to 0, 17 to 0, 23 to 3) and cuts the peak fault count from 10 to 24 down to 2 to 8; the residual one-three codewords in MobileNet-V2 and EfficientNet-B0 are all in the classifier layer, on which the attack concentrates entirely. The bit-level map of the most heavily hit interleaved codewords (Figure 13) shows no weight carrying more than one flip. T-BFA succeeds almost always unprotected (90 to 100% ASR with 10 to 20 flips), 97% of which land on fc.weight; under SANAI the ASR falls to 0% on most of the 132 ImageNet pairs, with a few residual leaks (Figure 8).

Figure 13. Fault-map pass over the 500-flip PBS attack on ResNet-18/CIFAR-10 (light code, t=4t = 4, 24 weights per codeword, faults counted in the four protected planes). Top: all 29 codewords that exceed tt under adjacent grouping, ranked by fault count and labelled by layer and codeword index; the worst, conv1 #18, takes 27 faults, and the failures sit in the early convolutions where PBS concentrates. Bottom: bit-level map of the most heavily hit codewords after keyed interleaving; each row is a codeword of 24 weights with its four protected bits (7, 6, 5, 4), a highlighted cell is a flipped bit. Faults are scattered so that no weight carries more than one flip and no codeword holds more than 3 faults, all correctable.

Attack-strength sweep on ImageNet: interleaving versus coverage. To separate the effect of keyed interleaving from the effect of coverage, we sweep the PBS attack on ResNet-18/ImageNet from 10 to 500 flips (light code, K=4K = 4, 10% coverage) and record, for adjacent and keyed grouping, the protected accuracy and the largest fault count in any codeword (Table 17, Figure 14). Two things follow. First, interleaving never fails at the codeword level: the interleaved maximum stays at 1 or 2 faults, below t=4t = 4, and no codeword becomes uncorrectable at any strength, whereas under adjacent grouping the maximum passes tt by 40 flips, reaches 12 by 250, and up to 14 codewords are uncorrectable. Second, interleaving extends the usable range substantially: at 100 flips adjacent grouping has fallen to 46.0% while interleaved is at 75.4%, and at 250 flips adjacent is at 0% while interleaved retains 50.6%. The interleaved accuracy does decline at very high budgets (1.5% at 500 flips), but at those points every protected codeword is still corrected; the loss comes from the 90% of the model left unprotected at 10% coverage, which the attack corrupts directly once the budget is large. On this model the bottleneck at high attack strength is therefore coverage, not interleaving, which is why the ImageNet operating point of § 5.1 uses 40%.

Figure 14. ResNet-18/ImageNet flip sweep. Left: protected accuracy versus PBS flips; keyed interleaving holds far longer than adjacent grouping. Right: largest fault count in one codeword; interleaving stays at 1 to 2, below t=4t = 4, at every attack strength while adjacent grouping rises to 12. Where the interleaved accuracy still drops at high flip counts the per-codeword count is still below tt, so the loss comes from the unprotected fraction (a coverage limit), not from interleaving.

Extended LLM Results

Figure 9 plots the protected MMLU and ARC-Easy accuracy of Table 9 against BER: every protected model stays well above the 25% chance line through 6%, while the unprotected models fall onto it at the first nonzero BER; the 6% points of the 7B and 8B are conservative for the overflow reason given in the table caption.

IDModelMetricP/U0%1%3%6%8%
L1.1DistilGPT-2PPL W2P67.8669.59 ± 0.8573.93 ± 1.2284.03 ± 2.271746 ± 1346
L1.2PPL W103P61.6463.16 ± 0.6867.39 ± 1.2376.77 ± 2.961721 ± 1358
L1.3PPL W2U67.8610610^{6}10610^{6}10610^{6}10610^{6}
L1.4GPT-2PPL W2P42.9144.00 ± 0.3246.77 ± 0.3761.07 ± 4.871909 ± 667
L1.5PPL W103P38.4339.34 ± 0.0442.26 ± 0.3052.99 ± 2.911695 ± 407
L1.6PPL W2U42.9110610^{6}10610^{6}10610^{6}10610^{6}
L1.7Qwen2-0.5BPPL W2P17.3417.41 ± 0.0317.41 ± 0.0417.44 ± 0.0318.26 ± 0.25
L1.8PPL W103P15.2215.27 ± 0.0215.29 ± 0.0315.33 ± 0.0315.94 ± 0.15
L1.9PPL W2U17.3410610^{6}10610^{6}10610^{6}10610^{6}
L1.10Qwen2-1.5BPPL W2P11.8111.83 ± 0.0011.88 ± 0.0111.89 ± 0.0212.35 ± 0.18
L1.11PPL W103P10.9210.94 ± 0.0010.97 ± 0.0010.97 ± 0.0211.35 ± 0.15
L1.12PPL W2U11.8110610^{6}10610^{6}10610^{6}10610^{6}
L1.13MMLU / ARC-EP58.5 / 85.557.8 ± 0.3 / 84.5 ± 0.1956.5 ± 0.4 / 83.0 ± 0.3754.3 ± 0.5 / 80.0 ± 0.41(to 6%)
L1.14Llama-3.2-1BPPL W2P13.6813.83 ± 0.0414.13 ± 0.0814.70 ± 0.3025.32 ± 9.44
L1.15PPL W103P12.6612.77 ± 0.0413.06 ± 0.0513.54 ± 0.2123.98 ± 9.58
L1.16PPL W2U13.689.5×1059.5 \times10^{5}10610^{6}10610^{6}10610^{6}
L1.17Llama-3.2-3BPPL W2P10.3610.44 ± 0.0110.54 ± 0.0210.74 ± 0.0311.73 ± 0.14
L1.18PPL W103P9.739.78 ± 0.019.88 ± 0.0210.03 ± 0.0510.94 ± 0.17
L1.19PPL W2U10.362.2×1052.2 \times10^{5}5.4×1055.4 \times10^{5}5.8×1055.8 \times10^{5}5.8×1055.8 \times10^{5}
L1.20MMLU / ARC-EP62.4 / 87.962.2 ± 0.3 / 87.1 ± 0.2960.4 ± 0.1 / 86.1 ± 0.5458.1 ± 0.7 / 84.1 ± 0.16(to 6%)
L1.21Qwen2.5-7BPPL W2P7.727.72 ± 0.007.72 ± 0.007.72 ± 0.007.74 ± 0.02
L1.22PPL W2U7.723.9×1033.9 \times10^{3}2.7×1042.7 \times10^{4}6.6×1046.6 \times10^{4}4.1×1054.1 \times10^{5}
L1.23MMLU / ARC-EP77.9 / 96.476.6 ± 0.4 / 95.4 ± 0.1470.1 ± 0.5 / 92.4 ± 0.6051.9 ± 0.9 / 71.6 ± 1.51(to 6%)
L1.24Llama-3-8B-InstructMMLU / ARC-EP68.5 / 92.267.7 ± 0.4 / 91.6 ± 0.0464.2 ± 0.5 / 89.7 ± 0.2957.6 ± 0.8 / 83.8 ± 0.40(to 6%)
L1.25Llama-3.1-8BPPL W2P7.957.95 ± 0.007.95 ± 0.007.95 ± 0.008.04 ± 0.11
L1.26PPL W2U7.953.9×1023.9 \times10^{2}8.2×1048.2 \times10^{4}3.1×1043.1 \times10^{4}6.7×1046.7 \times10^{4}
L1.27Llama-2-13BPPL W2P6.196.20 ± 0.006.19 ± 0.006.20 ± 0.006.20 ± 0.01
L1.28PPL W2U6.193.8×1023.8 \times10^{2}3.0×1033.0 \times10^{3}6.3×1036.3 \times10^{3}7.8×1037.8 \times10^{3}

Table 9. Master Table L1: LLM runs under random BER (INT8, strong code, K=4K = 4, 40% coverage, magnitude ranking, adjacent grouping, three seeds). P = protected, U = unprotected (perplexity capped at 10610^{6}); perplexity rows give mean ± std, accuracy rows are 5-shot on 2,000 questions to 6% BER. Perplexity runs keep carriers clean; accuracy runs let parity overflow into protected layers (§ 3.6), so the 7B and 8B accuracy at 6% is conservative.

Layer ranking and coverage. On Qwen2-0.5B under 10 sign flips (undefended 25.8% / 1,294), a weight-ℓ1\ell_1 ranking leaves the attacked layers.1.self_attn.o_proj unprotected and the model collapses as if undefended (row L2.8 of Master Table 10), whereas gradient-weighted magnitude and the attack-probe loss both select it and recover 45.6% / 17.65 at every coverage from 10% to 40% and under both layouts (rows L2.2, L2.9). On Llama-3-8B-Instruct the attack concentrates on layers.1.mlp.down_proj; at 10% and 20% coverage that layer sits just outside the selected set and the recovered MMLU stays at the attacked 27.0, at 30% it enters and recovery is exact (71.0; rows L2.23 to L2.25). This is a coverage property, not a code failure: whenever the attacked layer is protected, recovery is bit-exact, and the minimum coverage that guarantees this grows with model size.

Table 10: Master Table L2: LLM runs under AttentionBreaker (INT8, strong code, K=4K = 4, G=12G = 12). Rank: grad = gradient-weighted magnitude, mag = weight magnitude; Intl.: adj = adjacent codewords, key = keyed interleaving; “In” = fraction of flipped bits inside the protected set. The largest error count in one codeword, where logged, never exceeded t=12t = 12 (Qwen2-0.5B rows 1 to 12; Llama-3.2-1B adaptive 5; Llama-3-8B GenBFA and adaptive ≤12\le12). Row L2.8 is the ranking ablation. In the coverage ablation (L2.23 to L2.25) the attacked layer enters the protected set at 30% coverage, where recovery is exact. GPT-2 and DistilGPT-2 report perplexity only.

IDModelAttackFlipsRankCov.Intl.U MMLUU PPLSANAI MMLUSANAI PPLIn
L2.1Qwen2-0.5BTop-33grad40%key45.220.945.617.653/3
L2.2Top-1010grad40%key25.81,29445.617.6510/10
L2.3Top-2828grad40%key26.24,42945.617.6528/28
L2.4Top-100100grad40%key26.2964,46045.617.65100/100
L2.5Top-500500grad40%key27.0>106> 10^{6}45.617.65500/500
L2.6GenBFA26grad40%key23.811,93545.617.6526/26
L2.7Adaptive16,056grad40%key27.0>106> 10^{6}45.617.65all
L2.8Top-1010mag40%key25.81,29425.81,2940/10
L2.9Top-1010grad10%adj25.81,29445.617.6510/10
L2.10Llama-3.2-1BTop-1010grad40%key28.616.231.614.20all
L2.11Top-100100grad40%key25.014331.614.20all
L2.12GenBFA1,308grad40%key28.454231.614.20all
L2.13Adaptive20,971grad40%key28.418,83531.614.20all
L2.14Qwen2.5-7BTop-33grad40%key23.57.8479.27.74all
L2.15Top-2828grad40%key23.512.9779.27.74all
L2.16Top-100100grad40%key25.51,49779.27.74all
L2.17Top-500500grad40%key25.031,04779.27.74all
L2.18Llama-3-8B-Inst.Top-33grad40%key63.817.071.010.89all
L2.19Top-1010grad40%key27.064,97871.010.89all
L2.20Top-100100grad40%key26.03,47471.010.89all
L2.21GenBFA1,018,082grad40%key24.450471.010.89all
L2.22Adaptive1,174,405grad40%key23.691671.010.89all
L2.26GPT-2Top-33grad40%keyn/a2,064n/a43.10all
Top-1010grad40%keyn/a2,926n/a43.10all
Top-2828grad40%keyn/a3,147n/a43.10all
Top-100100grad40%keyn/a3,798n/a43.10all
L2.27DistilGPT-2Top-33grad40%keyn/a616n/a67.87all
Top-1010grad40%keyn/a2,661n/a67.87all
Top-2828grad40%keyn/a8,219n/a67.87all
Top-100100grad40%keyn/a5,343n/a67.87all
Coverage ablation, Llama-3-8B-Instruct; the attack targets layers.1.mlp.down_proj
L2.23Llama-3-8B-Inst.Top-1010grad10%key27.064,97827.064,9780/10
L2.24Top-1010grad20%key27.064,97827.064,9780/10
L2.25Top-1010grad30%key27.064,97871.010.8910/10

Table 10.

Code-aware attacker on Llama-3.2-1B. The 1B model yields little to the code-aware attacker (rows L3.4 and L3.5 of Master Table 11): 1,300 two-plane errors on the adjacent layout raise the corrected perplexity only from 14.20 to 23.0, the blind attacker on the interleaved layout achieves nothing, and the keyed attacker needs 2,600 errors to reach 129.5.

Qualitative outputs. Table 18 shows generated answers from Llama-3-8B-Instruct in four states. AttentionBreaker collapses generation into repeated-token garbage; SilentStriker keeps the answer fluent but changes it, dropping the correct option or drifting off the question; after SANAI the output is bit-identical to the clean model in both cases, because the restored weights are bit-identical to clean. Qwen2-0.5B behaves the same way under the 100-flip attack: the attacked model emits code fragments, digit runs, or characters from another script, and after SANAI the generation is the clean model’s generation again.

Fine-Tuning Details

Protocol. Because the parity lives in the low-order bits of carrier weights, any later update of the model could wash it out. We protect ResNet-18 and ResNet-50 on CIFAR-10 at the random-BER operating point (strong code, K=3K = 3, 19.3% and 19.2% coverage, Ls=1L_s = 1), then fine-tune the protected INT8 model for ten epochs with SGD at three learning rates, 10−410^{-4}, 10−310^{-3}, and 10−210^{-2}, re-quantizing after every epoch. After each epoch we regenerate the key-seeded projection, de-project the parity from the drifted carriers, and compare it bit by bit with the parity written at protection time; the parity BER is the fraction of parity bits that no longer decode. We also record the fine-tuned model’s clean accuracy and, at the end of training, inject a 12% BER into the protected layers and decode with the surviving parity.

Findings. At the two learning rates used for realistic adaptation, 10−410^{-4} and 10−310^{-3}, the parity is bit-exact after all ten epochs on both architectures (parity BER 0.000%) and accuracy stays near 95% (Table 19). Only at the aggressive 10−210^{-2} rate does any parity move, and then late and slightly: 0.003% of parity bits on ResNet-18 and 0.004% on ResNet-50 by epoch ten, at which point the model itself has lost six to seven points of accuracy to the large steps. The drift is confined to the earliest convolutional layer, whose weights move past the STDM tolerance Δ/2\Delta/2 under large updates (Figure 15); every other carrier stays within tolerance. The surviving parity remains usable: correcting a 12% BER with it holds 93.8% (ResNet-18) and 94.7% (ResNet-50), so a protected model can be adapted in the field without re-embedding. Because the drift is localized to one early layer, the remedy is simple, either exclude the earliest layers from the carrier set or give them a wider lattice step, at a small cost in capacity.

Ablation Tables

Uniform fault model: interleaving protects the parity under carrier corruption. The parity is interleaved along with the data: the keyed permutation scatters each codeword’s parity bits across the carrier layers. When the carrier layers themselves are corrupted at the full fault rate, that corruption is therefore spread over many codewords, and each codeword’s parity stays within the correction budget tt. Table 20 shows this on ResNet-18/CIFAR-10 (strong code, t=12t = 12, K=3K = 3, 19% coverage) with the carrier layers corrupted at the same BER as the protected weights, which is the uniform model of § 7. At 12% BER, interleaved parity keeps protected accuracy at 89.3% against 78.8% with sequential parity placement, while the unprotected model is at 10.8%; at 6% both placements hold near 94%. Keyed interleaving thus protects both the data and the parity, and the flat curves of § 5.1 do not depend on clean carriers, only on the parity being scattered (rows V1.36 and V1.37 of Master Table 6).

Host capacity and embedding. At Ls=1L_s = 1 STDM matches QIM capacity while adding key security; raising LsL_s spreads each bit over more carriers, improving robustness of the hidden parity at reduced capacity subject to Eq. (6). A wrong key yields approximately 50% parity recovery, confirming Proposition 2(b). Replication and coverage draw on the same carrier space, so higher RR is paid for with lower coverage; the gain at the top of the range is modest and R=1R = 1 retains the widest coverage, so it is the default and RR is a knob for when extreme-BER robustness matters more than coverage.

Hardware Details

All numbers in this appendix are measured on the platform below unless marked modeled. Tool: Synopsys Design Compiler V-2023.12-SP5, gcsn45nm standard cells, 100 MHz constraint; memories black-boxed as memory-compiler IP; power annotated from switching activity captured over a full-network RTL inference and back-annotated onto the compiled netlist. The library ships only a compiled .db without Verilog cell models, so gate-level SDF simulation was not possible and power figures are directional rather than SDF-accurate.

Platform. The accelerator is an 8×88 \times8 output-stationary systolic array in the style of the TPU (Jouppi et al., [27]), using the output-stationary dataflow of the Eyeriss taxonomy (Chen et al., [9]). Each processing element holds a partial sum in place while INT8 weights are broadcast down columns and activations propagate east; convolutions are lowered to matrix multiplies via im2col. It runs a quantized CNN with five convolutional layers, two max-pool stages, global average pooling, and one fully-connected layer (140,384 INT8 weights) on CIFAR-10. Weights are held in on-chip ROM and streamed into the array under a per-layer finite state machine (Figure 11). The checker is a read-only tap on this path: it observes w_rd, w_addr, and w_din between the weight memory and the convolution engine, and neither the weight memory nor the PE array is modified.

Threat model. The adversary may write to weight storage, either through memory faults or through a compromised software stack that handles the weights (Rahaman et al., [49]), but cannot read the on-chip seed. We target sparse bit flips of the kind produced by RowHammer, progressive bit search, and laser fault injection ([29, 50, 58]). Burst errors are outside the hardware scope; the software path of § 5.1 covers that regime.

Two carriers. Design A, the primary design, is an LSB-parity gather. Each block of L=16L = 16 consecutive weights forms a BCH(126,112,t=2)(126, 112, t=2) codeword over GF⁡(27)\operatorname{GF}(2^7) with primitive polynomial x7+x3+1x^7 + x^3 + 1 and generator g(x)=0x4377g(x) = \mathtt{0x4377}. The payload is the seven high-order bits of each weight (112 bits); the 14 parity bits occupy bit 0 of weights 0 through 13, leaving two spare LSBs untouched. The 140,384 weights form 8,774 blocks, one codeword each. Design B is the spread-transform variant. Each block is projected onto a pseudorandom ±1\pm1 spreading sequence, P=∑i=0L−1wisiP = \sum_{i=0}^{L-1} w_i s_i, and the projection is quantized on an integer lattice of step Δ=8\Delta= 8, q=⌊(P+D/2)/D⌋q = \lfloor(P + D/2)/D \rfloor with D=LΔ/2=64D = L\Delta/2 = 64, carrying one bit per block as q mod 2q \bmod2. Because DD is a power of two the recovery path reduces to an accumulator, an adder, and a shift, q=(P+32)≫6q = (P + 32) \gg6; only the offline embedder performs the fractional nudge that moves PP to the lattice point of the target bit. Blocks are grouped into BCH(127,113,t=2)(127, 113, t=2) codewords, 73 in total, split per layer with shortened tails so that each codeword lies within one keystream reseed interval. In both designs each parity bit is XORed with a keystream from a degree-20 LFSR (x20+x13+x9+x5+1x^{20} + x^{13} + x^9 + x^5 + 1) seeded from a fuse-resident secret; without whitening an adversary could alter the payload, recompute the code, and rewrite the parity. The cost is one XOR gate. Design B uses a second, distinct seed for the spreading sequence. An LFSR keystream is linearly predictable from roughly twice its degree of observed output, unlike a cryptographic generator; an adversary would additionally require the projection values, which are not exposed, and a lightweight block cipher in counter mode (Borghoff et al., [4]) would close this gap at higher area cost. The hardware codes are independent of the software strong code of § 3.3 (different field polynomial, different payload); the two embeddings coexist in the same weights and the hardware checker never reads the software parity.

Contiguous blocks and address keying. A streaming checker observes one weight per cycle and has no notion of global position, so a magnitude-selected scattered pool is unavailable to it; blocks are therefore L=16L = 16 consecutive weights in fetch order. Stealth is not a requirement: an adversary who knows where the parity lives still cannot forge it without the seed. Block boundaries are keyed on w_addr (block = addr ≫\gg 4) rather than on counting fetch pulses. Address traces captured from the convolution engine show per-output-channel tile-boundary duplicate reads and channel-padding over-reads in the fully-connected layer, either of which would desynchronize a pulse counter; addresses beyond the layer weight count are ignored, and for the same reason the LFSRs advance on address increment rather than on every fetch pulse. The projection accumulator in Design B stores a per-position product rather than a running sum, making duplicate reads idempotent.

Detect-and-flag, not correct. Both deployed checkers detect and flag; recovery is performed in software from the parity embedded in the weights. We evaluated an in-hardware correcting variant and rejected it for two measured reasons. First, per-block correction cannot meet the one-cycle weight-delivery contract without a shadow weight memory of 140,384 bytes, equal to the entire weight file, which would eliminate the zero-storage property. Second, above the correction capacity the decoder miscorrects rather than flags: 46.99% of blocks at t+1t+1 and 47.21% at t+2t+2 for Design A, 43.83% and 46.10% for Design B, in each case silently writing incorrect weights. The checker is clock-gated on the weight-fetch condition; over a full inference of 4,444,928 cycles only 140,384 are weight-fetch cycles, a duty cycle of 3.16%.

Functional transparency. With no faults injected, both protected accelerators reproduce the reference integer datapath exactly: 100 of 100 images match the golden fully-connected logits bit for bit, argmax agrees on every image, and no codeword raises a false flag. On the same full-data model and the same 100 images, top-1 is 86 unprotected, 88 under Design A, and 89 under Design B; the spread of three images is sampling noise at n=100n = 100, consistent with a 1,000-image sweep that measures zero accuracy change from embedding. Running either checker against unembedded weights raises the flag on all 100 images, confirming that the zero-false-flag result is not a degenerate always-low output.

Detection. Table 22 reports measured per-bit detection for both designs; each entry is over 8,774 injected faults, one per block, for 70,192 faults per design. Design A was measured twice, by the software model and by RTL simulation, in agreement. Design A is magnitude independent: its gather reads the weight bits directly into the 126-bit codeword, so any single flip is a weight-one codeword error and dmin⁡=5d_{\min} = 5 detects it with certainty. Design B is magnitude dependent, a direct consequence of lattice quantization: a flip is detected only if it displaces the block projection across a lattice boundary, so high-order flips are detected with certainty while low-order flips that change a weight by a fraction of its scale are largely invisible and also harmless to accuracy. The sign bit is a structural blind spot for Design B: a sign flip displaces a weight by exactly 128=2D128 = 2D, leaving the lattice parity unchanged, which follows from DD being a power of two. We measured alternatives: Δ=16\Delta= 16 closes the blind spot but halves detection at bit 5 (0.50 to 0.24) and bit 6 (1.00 to 0.52) while doubling embedding distortion; an odd Δ\Delta preserves the curve but lifts bit 7 only to about 21% and replaces the shift with a constant divider. We retain Δ=8\Delta= 8 for Design B and take Design A as primary. At the codeword level both codes have dmin⁡=5d_{\min} = 5, so any pattern of one to four corrupted codeword bits produces a nonzero syndrome; an escape requires five or more corrupted bits forming a valid codeword.

Flipped bit7 (sign)6543210
Design A (%)100100100100100100100100
Design B (%)0.010050.423.411.36.12.91.4

Table 22. Measured block-level detection rate by flipped bit position (8,774 blocks per position, 70,192 injected faults per design).

Area, timing, and power. Table 3 gives the complete measurement. Design A adds 0.41% of logic area, 0.63% of dynamic power, and 0.07% of leakage, and no stall cycles: the flag is advisory and never gates the datapath. Clock gating costs 61.0 μm2\mu\mathrm{m}^2 for Design A and 89.2 μm2\mu\mathrm{m}^2 for Design B and does not regress function, verified by re-running the full regression set on the gated designs. The full-top critical path lengthens by 0.76 ns for Design A and 0.61 ns for Design B; neither is a checker path. In every configuration the critical path lies entirely inside the convolution engine (cur_layer_reg to Wb_reg), and the checkers close at 1.27 and 1.31 ns, more than 20× faster. The increase is the synthesizer re-buffering the convolution-engine control chain under the tap’s additional output load, a pre-layout perturbation recoverable at place-and-route or by registering the tap inputs. The unprotected accelerator itself does not close at 100 MHz; all configurations meet about 33 MHz, a constraint inherited from the baseline. Design A and Design B were synthesized in separate sessions with the same tool version, library, and constraint; the two clean baselines differ by 5.64 μm2\mu\mathrm{m}^2 (0.0004%). The full-top area delta for Design B is +18,535 μm2\mu\mathrm{m}^2, of which the checker itself accounts for 7,057; the remainder is buffer and inverter insertion from the same re-optimization and is not integrity logic.

Comparison against a measured conventional ECC checker. To make the comparison measured on both sides, we implemented and synthesized a conventional per-block ECC checker under the same tool, library, and clock constraint: the same (126, 112, t=2t=2) code as Design A over the same 112-bit payload, differing only in that the 14 parity bits are read from a separate SRAM port rather than from bit 0 of the weights, and without whitening. A detect-only and a correcting variant were built, so that the cost of the separate parity port is isolated from the cost of correction (Table 4). The correcting variant was verified over 10,000 random blocks at each fault level: zero, one, and two flips are corrected exactly in every case, and the miscorrection rate above capacity is measured. Design A costs 671 μm2\mu\mathrm{m}^2 more logic than the conventional detect-only checker, about 13%, and in exchange eliminates the parity array entirely; it is also faster, 1.27 ns against 2.51 ns, because reading parity from the weight stream avoids the separate SRAM port on the critical path. Against the correcting variant, Design A is 40% smaller and 2.6×2.6\times faster, at the cost of moving recovery into software. The baselines protect the same 112-bit payload as Design A so that logic areas are comparable; a conventional design covering all eight bits would use a (142, 128, t=2t=2) code with the same 14 parity bits and a correspondingly larger gather.

Coexistence with the software recovery code. The hardware checker never reads the software parity, but the two must share the weight bits, so we instantiated the software code on the same platform and measured the interaction. For this small CNN we use the light code of § 3.3, BCH(127, 99, t=4t=4) over GF(272^7) with primitive polynomial x7+x+1x^7+x+1 (generator degree 28), with one parity bit per weight placed in bit 1, a simplified placement in place of the cross-layer STDM carrier of § 3.4. The 140,384 weights form 1,106 codewords (1,105 full plus one shortened tail of 49 weights) carrying 30,968 parity bits; embedding nudges 15,565 weights (11.09%) by ±2\pm2. The pipeline embeds the software parity first, then Design A computes its bit-0 parity over the resulting payload, so both codes decode at zero BER. Design A reads bit 1 as opaque payload; it holds no x7+x+1x^7+x+1 generator and no t=4t=4 locator, so the two codes share weight bits without sharing interpretation. The software code was verified exhaustively over all 8,129 patterns of zero, one, and two errors and over 100,000 random three-error and 100,000 random four-error patterns, all corrected exactly; at five errors, 96.91% of patterns are flagged and 3.09% miscorrected. On the same 100 images the accelerator with Design A alone scores 88 and with both codes 87 (unprotected 86), the one-image difference being the ±2\pm2 perturbation of the second embedding; no false flag is raised in either configuration. An in-line hardware decoder for this code would need four syndromes, a four-error locator, and a larger Chien search, several thousand gates above the 5,764 μm2\mu\mathrm{m}^2 detect tap, which is why recovery stays in software.

Storage and fetch traffic. The protected weight artifact is byte-identical to the unprotected one. Table 23 sets three columns side by side for eleven models from 3.5M to 8B weights: the unprotected baseline, conventional per-block ECC with its parity in a separate array fetched alongside the weights on every inference, and SANAI. The comparison is of storage and traffic at block-level integrity, since conventional ECC corrects in hardware whereas SANAI detects in hardware and recovers in software from the embedded parity. SANAI matches the baseline in every column because it adds no stored bit; conventional ECC adds 10.94% storage and 9.86% fetch traffic regardless of model size, so the absolute cost scales linearly with the weight count, from 383 KB and 61 μ\muJ per inference on MobileNet-V2 to 878 MB and 1.41 mJ on Llama-3-8B-Instruct at the per-bit DRAM energy of Han et al. [18] and Horowitz [24] (640 pJ per 32-bit access, 20 pJ per bit); on the CIFAR-10 CNN of this platform the saving is 2.46 μ\muJ. These energies are modeled under one fetch per weight per inference: the platform holds weights in on-chip ROM and no DRAM access was measured. A further consequence of zero storage overhead is that conventional ECC can displace a model from on-chip memory that SANAI leaves resident: for a model whose unprotected size falls in the top 9.86% of an on-chip weight memory, the conventional 10.94% inflation pushes it off chip. At the same per-access energies (0.15625 pJ/bit SRAM against 20 pJ/bit DRAM, a factor of 128) the weight-fetch energy then differs by 142×\times, 1.311 μ\muJ against 186.12 μ\muJ per inference for a model sized at a 1 MB on-chip weight memory. This too is analytical, derived from measured storage sizes and published per-access energies.

ModelWeightsBaselineConv. ECCSANAIBaselineConv. ECCSANAISaving vs conv.
MobileNet-V23.5M3.5 MB3.9 MB3.5 MB560 μ\muJ621 μ\muJ560 μ\muJ61 μ\muJ
EfficientNet-B05.3M5.3 MB5.9 MB5.3 MB848 μ\muJ941 μ\muJ848 μ\muJ93 μ\muJ
ResNet-1811.7M11.7 MB13.0 MB11.7 MB1.9 mJ2.1 mJ1.9 mJ205 μ\muJ
ResNet-5025.6M25.6 MB28.4 MB25.6 MB4.1 mJ4.5 mJ4.1 mJ448 μ\muJ
Swin-T28.2M28.2 MB31.3 MB28.2 MB4.5 mJ5.0 mJ4.5 mJ494 μ\muJ
AlexNet61.1M61.1 MB67.8 MB61.1 MB9.8 mJ10.8 mJ9.8 mJ1.1 mJ
ViT-B/1685.8M85.8 MB95.2 MB85.8 MB13.7 mJ15.2 mJ13.7 mJ1.5 mJ
VGG-16138.4M138.4 MB153.5 MB138.4 MB22.1 mJ24.6 mJ22.1 mJ2.4 mJ
Qwen2-0.5B494M494 MB548 MB494 MB79.0 mJ87.7 mJ79.0 mJ8.6 mJ
Llama-3.2-1B1.24B1.24 GB1.38 GB1.24 GB198 mJ220 mJ198 mJ21.7 mJ
Llama-3-8B-Instruct8.03B8.03 GB8.91 GB8.03 GB1.28 J1.43 J1.28 J141 mJ

Table 23. Storage and modeled weight-fetch energy per inference: unprotected baseline versus conventional per-block ECC (14 parity bits per 16 INT8 weights in a separate array) versus SANAI (parity inside the weights), for eleven models. Energy assumes one fetch per INT8 weight per inference from DRAM at 20 pJ per bit (640 pJ per 32-bit access, Table I of Han et al. [18], after Horowitz [24]); modeled, not measured. SANAI equals the baseline in every column; conventional ECC adds 10.94% storage and 9.86% traffic.

Sensitivity. Checker area and energy per verified block grow with block length LL, since the gather and its per-position store scale with the block; correction capacity tt contributes comparatively little, as the syndrome engine is a small fraction of the checker. Measured at the synthesized operating point (L=16L=16, t=2t=2) and modeled elsewhere, area overhead ranges from 0.33% at L=8L=8 to 1.4% at L=64L=64, crossing 0.5% between L=16L=16 and L=32L=32.

Scope and limitations. Design B’s sign-bit blind spot is structural to the power-of-two lattice; Design A does not share it, which is the principal reason it is the primary design. The software code shares weight bits with Design A’s payload: the hardware never decodes it, but fully disjoint placement is not possible because Design A reads every bit above the LSB. The checker is integrated on one output-stationary array with a workload sized to its on-chip ROM; the checker logic is unchanged for larger models, but their end-to-end energy is modeled from the weight count (Table 23) rather than simulated, and all DRAM-related energy is modeled from published per-access constants.

Per weight: baseline and SANAI store 8 bits and fetch 8 bits; conventional ECC stores and fetches 8.875 bits (+10.94% storage, +9.86% traffic).

The library provides no Verilog cell models, so power is annotated from RTL-level switching activity rather than gate-level simulation with back-annotated delays.

References

  1. [1]Yossi Adi, Carsten Baum, Moustapha Cisse, Benny Pinkas, and Joseph Keshet. Turning your weakness into a strength: Watermarking deep neural networks by backdooring. In 27th USENIX Security Symposium, pp. 1615–1631, 2018.arxiv.org/abs/1802.04633
  2. [2]Junjie Bai, Fang Lu, Ke Zhang, et al. ONNX: Open neural network exchange. https://github.com/onnx/onnx, 2019.
  3. [3]Robert C Baumann. Radiation-induced soft errors in advanced semiconductor technologies. IEEE Transactions on Device and Materials Reliability, 5(3):305–316, 2005.DOI
  4. [4]Julia Borghoff, Anne Canteaut, Tim Güneysu, Elif Bilge Kavun, Miroslav Knezevic, Lars R Knudsen, Gregor Leander, Ventzislav Nikov, Christof Paar, Christian Rechberger, et al. PRINCE: A low-latency block cipher for pervasive computing applications. In Advances in Cryptology (ASIACRYPT), pp. 208–225, 2012.
  5. [5]Raj Chandra Bose and Dwijendra K Ray-Chaudhuri. On a class of error correcting binary group codes. Information and Control, 3(1):68–79, 1960.
  6. [6]Stéphane Burel, Adrian Evans, and Lorena Anghel. Zero-overhead protection for CNN weights. In IEEE International Symposium on Defect and Fault Tolerance in VLSI and Nanotechnology Systems (DFT), pp. 1–6, 2021.DOI
  7. [8]Brian Chen and Gregory W Wornell. Quantization index modulation: A class of provably good methods for digital watermarking and information embedding. IEEE Transactions on Information Theory, 47(4):1423–1443, 2001.
  8. [9]Yu-Hsin Chen, Joel Emer, and Vivienne Sze. Eyeriss: A spatial architecture for energy-efficient dataflow for convolutional neural networks. In Proceedings of the 43rd Annual International Symposium on Computer Architecture (ISCA), pp. 367–379, 2016.
  9. [10]Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? Try ARC, the AI2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.arxiv.org/abs/1803.05457
  10. [11]Bita Darvish Rouhani, Huili Chen, and Farinaz Koushanfar. DeepSigns: An end-to-end watermarking framework for ownership protection of deep neural networks. In Proceedings of the 24th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS), pp. 485–497, 2019.DOI
  11. [12]Sanjay Das, Swastik Bhattacharya, Souvik Kundu, Shamik Kundu, Anand Menon, Arnab Raha, and Kanad Basu. AttentionBreaker: Adaptive evolutionary optimization for unmasking vulnerabilities in LLMs through bit-flip attacks. arXiv preprint arXiv:2411.13757, 2024.
  12. [13]Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 248–255, 2009.
  13. [14]Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. LLM.int8(): 8-bit matrix multiplication for transformers at scale. In Advances in Neural Information Processing Systems (NeurIPS), 2022.arxiv.org/abs/2208.07339
  14. [15]Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.
  15. [16]Abhimanyu Dubey et al. The Llama 3 herd of models. arXiv preprint arXiv:2407.21783, 2024.arxiv.org/abs/2407.21783
  16. [17]Steven K Esser, Jeffrey L McKinstry, Deepika Bablani, Rathinakumar Appuswamy, and Dharmendra S Modha. Learned step size quantization. In International Conference on Learning Representations (ICLR), 2020.
  17. [18]Song Han, Xingyu Liu, Huizi Mao, Jing Pu, Ardavan Pedram, Mark A Horowitz, and William J Dally. EIE: Efficient inference engine on compressed deep neural network. In Proceedings of the 43rd Annual International Symposium on Computer Architecture (ISCA), pp. 243–254, 2016.
  18. [19]Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016.arxiv.org/abs/1512.03385
  19. [20]Zhezhi He, Adnan Siraj Rakin, Jingtao Li, Chaitali Chakrabarti, and Deliang Fan. Defending and harnessing the bit-flip based adversarial weight attack. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 14095–14103, 2020.DOI
  20. [21]Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. In International Conference on Learning Representations (ICLR), 2021.
  21. [22]Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301):13–30, 1963.
  22. [23]Sanghyun Hong, Pietro Frigo, Yiğitcan Kaya, Cristiano Giuffrida, and Tudor Dumitraş. Terminal brain damage: Exposing the graceless degradation in deep neural networks under hardware fault attacks. In 28th USENIX Security Symposium, pp. 497–514, 2019.
  23. [24]Mark Horowitz. Computing’s energy problem (and what we can do about it). In IEEE International Solid-State Circuits Conference Digest of Technical Papers (ISSCC), pp. 10–14, 2014.
  24. [25]Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2704–2713, 2018.arxiv.org/abs/1712.05877
  25. [26]Mojan Javaheripi and Farinaz Koushanfar. HASHTAG: Hash signatures for online detection of fault-injection attacks on deep neural networks. In IEEE/ACM International Conference On Computer Aided Design (ICCAD), pp. 1–9, 2021.arxiv.org/abs/2111.01932
  26. [27]Norman P Jouppi, Cliff Young, Nishant Patil, David Patterson, Gaurav Agrawal, Raminder Bajwa, Sarah Bates, Suresh Bhatia, Nan Boden, Al Borchers, et al. In-datacenter performance analysis of a tensor processing unit. In Proceedings of the 44th Annual International Symposium on Computer Architecture (ISCA), pp. 1–12, 2017.
  27. [28]Venkata Nithin Kamineni, Habibur Rahaman, Ovishake Sen, Baibhab Chatterjee, Swarup Bhunia, and Rickard Ewetz. E3-CODE: Embedded and efficient error-correcting code for error-resilient neural networks. In Proceedings of the 63rd ACM/IEEE Design Automation Conference (DAC), pp. 1–7, 2026.DOI
  28. [29]Yoongu Kim, Ross Daly, Jeremie Kim, Chris Fallin, Ji Hye Lee, Donghyuk Lee, Chris Wilkerson, Konrad Lai, and Onur Mutlu. Flipping bits in memory without accessing them: An experimental study of DRAM disturbance errors. ACM SIGARCH Computer Architecture News, 42(3):361–372, 2014.DOI
  29. [30]Skanda Koppula, Lois Orosa, A Giray Yağlıkçı, Roknoddin Azizi, Taha Shahroodi, Konstantinos Kanellopoulos, and Onur Mutlu. EDEN: Enabling energy-efficient, high-performance deep neural network inference using approximate DRAM. In Proceedings of the 52nd Annual IEEE/ACM International Symposium on Microarchitecture (MICRO), pp. 166–181, 2019.
  30. [31]Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
  31. [32]Seo-Seok Lee and Joon-Sung Yang. Value-aware parity insertion ECC for fault-tolerant deep neural network. In Design, Automation & Test in Europe Conference & Exhibition (DATE), pp. 724–729, 2022.DOI
  32. [33]Jingtao Li, Adnan Siraj Rakin, Zhezhi He, Deliang Fan, and Chaitali Chakrabarti. RADAR: Run-time adversarial weight attack detection and accuracy recovery. In Design, Automation & Test in Europe Conference & Exhibition (DATE), pp. 790–795, 2021.DOI
  33. [34]Stephanie Lin, Jacob Hilton, and Owain Evans. TruthfulQA: Measuring how models mimic human falsehoods. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (ACL), pp. 3214–3252, 2022.arxiv.org/abs/2109.07958
  34. [35]Qi Liu, Jieming Yin, Wujie Wen, Chengmo Yang, and Shi Sha. NeuroPots: Realtime proactive defense against bit-flip attacks in neural networks. In 32nd USENIX Security Symposium, pp. 6347–6364, 2023.
  35. [36]Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 10012–10022, 2021.arxiv.org/abs/2103.14030
  36. [37]Henrique S Malvar and Dinei A F Florêncio. Improved spread spectrum: A new modulation technique for robust watermarking. IEEE Transactions on Signal Processing, 51(4):898–905, 2003.DOI
  37. [38]James L Massey. Shift-register synthesis and BCH decoding. IEEE Transactions on Information Theory, 15(1):122–127, 1969.DOI
  38. [39]Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In International Conference on Learning Representations (ICLR), 2017.arxiv.org/abs/1609.07843
  39. [40]ONNX Runtime developers. ONNX Runtime. https://onnxruntime.ai, 2018.
  40. [41]Minghai Qin, Chao Sun, and Dejan Vucinic. Robustness of neural networks against storage media errors. arXiv preprint arXiv:1709.06173, 2017.arxiv.org/abs/1709.06173
  41. [42]Martin Raab and Angelika Steger. “Balls into bins”: A simple and tight analysis. Randomization and Approximation Techniques in Computer Science (RANDOM), pp. 159–170, 1998.
  42. [43]Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Technical Report, 2019.
  43. [44]Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollár. Designing network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 10428–10436, 2020.arxiv.org/abs/2003.13678
  44. [45]Habibur Rahaman, Atri Chatterjee, and Swarup Bhunia. Secure AI systems: Emerging threats and defense mechanisms. In IEEE 33rd Asian Test Symposium (ATS), pp. 1–6. IEEE, 2024.
  45. [46]Habibur Rahaman, Atri Chatterjee, and Swarup Bhunia. Secure and storage-efficient deep learning models for edge AI using automatic weight generation. arXiv preprint arXiv:2507.06380, 2025.
  46. [47]Habibur Rahaman, Swastik Bhattacharya, Sanjay Das, Kanad Basu, and Swarup Bhunia. BARE-AI: Bit-flip attack resilience in AI hardware through built-in performance monitors. arXiv preprint arXiv:2610.08739, 2026a.
  47. [48]Habibur Rahaman, Atri Chatterjee, and Swarup Bhunia. Fortifying AI systems: Emerging threats and security countermeasures. SN Computer Science, 7(3):227, 2026b.
  48. [49]Habibur Rahaman, Qipan Xu, Zafaryab Haider, Prabuddha Chakraborty, Swarup Bhunia, and Fnu Suya. (A)iSpy: Parasitic trojans for machine learning infrastructure. arXiv preprint arXiv:2607.17550, 2026c.
  49. [50]Adnan Siraj Rakin, Zhezhi He, and Deliang Fan. Bit-flip attack: Crushing neural network with progressive bit search. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 1211–1220, 2019.
  50. [51]Adnan Siraj Rakin, Zhezhi He, and Deliang Fan. TBT: Targeted neural network attack with bit trojan. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 13198–13207, 2020.
  51. [52]Adnan Siraj Rakin, Zhezhi He, Jingtao Li, Fan Yao, Chaitali Chakrabarti, and Deliang Fan. T-BFA: Targeted bit-flip adversarial weight attack. IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(11):7928–7939, 2021.
  52. [53]Brandon Reagen, Udit Gupta, Lillian Pentecost, Paul Whatmough, Sae Kyu Lee, Niamh Mulholland, David Brooks, and Gu-Yeon Wei. Ares: A framework for quantifying the resilience of deep neural networks. In Proceedings of the 55th Annual Design Automation Conference (DAC), pp. 1–6, 2018.
  53. [54]Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. MobileNetV2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4510–4520, 2018.
  54. [55]Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. DistilBERT, a distilled version of BERT: Smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
  55. [56]Bianca Schroeder, Eduardo Pinheiro, and Wolf-Dietrich Weber. DRAM errors in the wild: A large-scale field study. Communications of the ACM, 54(2):100–107, 2011.
  56. [57]Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations (ICLR), 2015.
  57. [58]Sergei P Skorobogatov and Ross J Anderson. Optical fault induction attacks. Cryptographic Hardware and Embedded Systems (CHES), pp. 2–12, 2003.DOI
  58. [59]David Stutz, Nandhini Chandramoorthy, Matthias Hein, and Bernt Schiele. Bit error robustness for energy-efficient DNN accelerators. Proceedings of Machine Learning and Systems, 3:569–598, 2021.
  59. [60]Mingxing Tan and Quoc Le. EfficientNet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning (ICML), pp. 6105–6114, 2019.
  60. [61]Hugo Touvron, Louis Martin, Kevin Stone, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.
  61. [62]Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. MaxViT: Multi-axis vision transformer. In European Conference on Computer Vision (ECCV), pp. 459–479, 2022.arxiv.org/abs/2204.01697
  62. [63]Yusuke Uchida, Yuki Nagai, Shigeyuki Sakazawa, and Shin’ichi Satoh. Embedding watermarks into deep neural networks. In Proceedings of the ACM International Conference on Multimedia Retrieval (ICMR), pp. 269–277, 2017.
  63. [64]Haotian Xu et al. SilentStriker: Toward stealthy bit-flip attacks on large language models. In Advances in Neural Information Processing Systems (NeurIPS), 2025.arxiv.org/abs/2509.17371
  64. [65]An Yang et al. Qwen2 technical report. arXiv preprint arXiv:2407.10671, 2024a.arxiv.org/abs/2407.10671
  65. [67]Fan Yao, Adnan Siraj Rakin, and Deliang Fan. DeepHammer: Depleting the intelligence of deep neural networks through targeted chain of bit flips. In 29th USENIX Security Symposium, pp. 1463–1480, 2020.arxiv.org/abs/2003.13746
  66. [68]Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In British Machine Vision Conference (BMVC), 2016.arxiv.org/abs/1605.07146
  67. [69]Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. HellaSwag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL), pp. 4791–4800, 2019.arxiv.org/abs/1905.07830
  68. [70]Jeff Zhang, Kartheek Rangineni, Zahra Ghodsi, and Siddharth Garg. ThUnderVolt: Enabling aggressive voltage underscaling and timing error resilience for energy efficient deep learning accelerators. In Proceedings of the 55th Annual Design Automation Conference (DAC), pp. 1–6, 2018.

Paper details

vlnc:W_edtw9brs
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

generative AI tools

View statement
Looking for related papers…
Contents