Spiking neural networks (SNNs) are neural networks whose units communicate by discrete all-or-nothing pulses. A unit fires when its internal voltage, the membrane potential, crosses a threshold. SNNs are attractive for analog in-memory chips, which store weights as the electrical conductance of memory cells and compute matrix products directly with physical currents. These chips are imprecise. Weights are programmed with random error, conductances drift over time, reads are noisy, and the converters that digitize each output column have few bits. SNNs are also far less robust to adversarial inputs than their discrete spikes once suggested. Past claims of robustness came mostly from the difficulty of taking gradients through spikes, and attacks that approximate those gradients break them. The two problems have been studied separately. Defenses are tested in idealized software, and hardware-aware training is tested against random noise, on conventional networks, with a single bit-width across all layers.
Our core observation is that, in a spiking network, hardware error and adversarial inputs fail through the same mechanism: they push a neuron's membrane potential across its threshold and flip whether it fires. Each layer therefore has one shared budget, the distance between its membrane potentials and the threshold, and noise and attack both draw on it. We propose to measure this budget layer by layer as a loss-weighted spike-flip sensitivity. The measurement includes analog error at each layer's converter resolution and the membrane shifts that an adaptive attack induces. We then use it for two decisions that are currently made separately and blindly: how many bits of weight and converter precision each crossbar layer receives, and how strongly each layer is trained to keep its potentials away from threshold. The testable claim is specific. At a fixed hardware bit budget, allocating precision and margin by this joint measure gives higher adversarial accuracy after simulated drift than two alternatives: stacking an existing SNN defense on uniform-precision hardware-aware training, and allocating bits by weight-Hessian curvature as prior SNN quantization work does.
Why the obvious combination is not enough
Four prior papers each cover part of this problem. Hessian Aware Quantization of Spiking Neural Networks estimates each layer's Hessian trace, the curvature of the loss with respect to that layer's weights. It finds that the deepest layer of a three-layer convolutional SNN on N-MNIST has a trace orders of magnitude larger than the first layer, and it assigns bits accordingly, reaching 97.8% accuracy with a 58% size reduction. This paper motivates the idea that SNN layers differ sharply in sensitivity. Its measure, however, only captures weight perturbations under clean inputs in digital fixed point. Hardware-aware training for large-scale and diverse deep learning inference workloads trains 11 non-spiking networks against a realistic phase-change-memory (PCM) model and reports that noise at a layer's inputs and outputs, especially from the output converters, hurts more than weight noise. That finding constrains our design: a weight-Hessian measure is looking in the wrong place, because the dominant analog error enters where membrane potentials are formed.
Network Insensitivity to Parameter Noise via Parameter Attack During Training replaces random noise injection with worst-case weight perturbations found by gradient ascent. It shows that this beats random noise for analog mismatch, including on a small recurrent spiking network. Its authors state that they did not study interaction with quantization, and they did not test input attacks. Robust Spiking Neural Networks Against Adversarial Attacks supplies the mechanism we build on. It shows that adversarial fragility concentrates in "threshold-neighboring" neurons and removes about 40% of them with membrane-potential penalties and noise-injected neurons. It applies one uniform penalty in pure software and names hardware deployment as open. Our contribution differs from all four in one respect: we treat the near-threshold margin as a per-layer resource that hardware precision supplies and that both noise and attacks consume, and we allocate it jointly.
Core Claim
For layer $l$ with membrane potentials $u_{l,i}$, threshold $\theta$ and output spikes $s_{l,i}$, define the sensitivity at hardware configuration $b_l$ (weight conductance levels and converter bits) as
$$S_l(b_l) = \mathbb{E}_{x}\sum_i \left|\frac{\partial L}{\partial s_{l,i}}\right| \Pr\big[\,\mathrm{sign}(u_{l,i}+\eta_{l,i}(b_l)+\delta_{l,i}-\theta)\neq \mathrm{sign}(u_{l,i}-\theta)\,\big],$$
Here $L$ is the task loss, and $\eta_{l,i}(b_l)$ is the membrane shift produced by simulated crossbar error, sampled from programming noise, drift, read noise and converter quantization. $\delta_{l,i}$ is the membrane shift an adaptive input attack produces, taken from the attack's actual perturbation. The spike gradient is computed with several surrogate functions and averaged, so the measure does not inherit one surrogate's blind spots.
The claim has three parts. First, the ranking of layers by $S_l$ differs from the ranking by weight-Hessian trace, because converter error and attack-induced shifts do not grow with weight curvature. Second, choosing $b_l$ to minimize $\sum_l S_l$ under a total bit budget, and weighting each layer's margin penalty by its remaining $S_l$, improves robust accuracy after drift over uniform or Hessian-based allocation. Third, some apparent robustness in noisy hardware disappears under attacks that average over the hardware noise. Our evaluation separates that disappearing part from the robustness that survives.
This also resolves a tension in the literature. Adversarial Attacks on Spiking Convolutional Networks for Event-based Vision observed that attack success fell on the SynSense Speck2b chip and attributed the drop to weight quantization. Attacks that reconstruct gradients from membrane statistics (PDSG) or from firing rates (RGA) suggest that such a drop may reflect masked gradients rather than real protection. Our measure tests this directly: if hardware error truly protects, attacks aware of that error should still produce small $\delta$ in the layers that matter.
Research Program
The first component is a spiking simulator for analog crossbars. We will wrap leaky integrate-and-fire layers around the analog tiles of aihwkit, which already models PCM and resistive-memory drift, programming and read noise, and converter clipping. That toolkit reports training that is 2 to 5 times slower than digital training. Using it with spiking layers requires one modeling decision that is new to spiking networks. Read noise is resampled at every timestep, so rate-coded networks partly average it away. Programming error and drift are fixed for the lifetime of a deployed chip, so they act as a consistent bias on every timestep. We will model the two separately and report $S_l$ for each, because we expect fixed error to dominate the flip budget in rate-coded layers.
The second component is the measurement study. We compute $S_l$, the Hessian trace, and plain gradient magnitude per layer. We then check which one predicts the accuracy drop observed when a single layer is degraded under hardware error, under attack, and under both together.
The third component is the allocation and training procedure. We choose per-layer weight and converter bits by greedy or integer-program minimization of $\sum_l S_l(b_l)$ under a budget. We then run hardware-aware training with noisy forward passes and full-precision weight updates. Its loss combines single-step adversarial examples, following the mixed scheme of SNN-RAT, with a membrane-margin penalty in the style of threshold guarding whose per-layer weight is proportional to $S_l$. We recompute $S_l$ every few epochs because margins shift during training.
Baselines
The naive reference point is a standard backpropagation-trained SNN mapped directly to the simulated crossbar at uniform 8-bit precision without hardware-aware training. Rasch et al. show that direct mapping collapses non-spiking networks: WideResNet-16 error rose to 25% against a 20% baseline. We expect this model to show both the hardware and the adversarial floor. Its role is to calibrate how much each method recovers.
The strongest existing competitor is the stacked combination of the best published SNN defense and standard hardware-aware training at uniform precision. Concretely, this is threshold guarding with adversarial training or SNN-RAT, as in Robust Spiking Neural Networks Against Adversarial Attacks, trained inside the same aihwkit noise model with the same bit budget spread evenly across layers. It is the strongest because it already contains every ingredient except per-layer allocation. The published reference numbers are all digital. On CIFAR-10 with VGG-11, SNN-RAT reports 21.16% accuracy under strong PGD, projected gradient descent, the standard iterative attack, against 0.04% for a vanilla SNN, with clean accuracy dropping from about 93% to about 90%. On CIFAR10-DVS, threshold guarding with adversarial training reduced attack success from 44.32% to 31.0% and raised clean accuracy from 72.2% to 74.1%. On WRN-16 it added about 10% robustness against PGD10 through PGD40. We found no reported result on Lacuna for any SNN defense evaluated under analog crossbar noise or drift. We will therefore re-run this baseline ourselves with the same data, architectures, training epochs, attack budget and hyperparameter search budget as our method. To beat it, our method must improve adversarial accuracy after one simulated year of drift by more than the seed-to-seed spread, at equal clean accuracy within 1% and equal total bits.
The allocation competitor is Hessian-trace bit allocation from Lui & Neftci, with ranking choices following HAWQ, followed by the same robust hardware-aware training. The only change from our method is the allocation measure. We will first reproduce the N-MNIST result of 97.8% at 58% compression. The weight-space competitor is worst-case parameter training from Network Insensitivity to Parameter Noise, which reports 78.4% versus 17.5% on Fashion-MNIST under parameter noise. We will add input adversarial training to it for fairness.
Three ablations isolate the key ingredient. The first drops the attack term $\delta$ from $S_l$, leaving a hardware-only measure. The second drops the hardware term $\eta$, leaving an attack-only measure. The third keeps our bit allocation but uses a uniform margin penalty. If any of these matches the full method, the joint-budget claim is wrong in the corresponding part.
Why not just…?
Why not just stack threshold guarding and hardware-aware training at uniform precision? This is the real threat, and it may work well at generous bit budgets where every layer has spare margin. Our hypothesis only predicts an advantage when the budget is tight enough that some layers run out of margin while others waste it. That is exactly what the depth-dependent sensitivity in Lui & Neftci implies. The budget sweep in our experiments settles the question. If the stacked baseline matches us at every budget, per-layer allocation adds nothing, and we will report that.
Why not just allocate bits by Hessian trace, which already works for SNNs? The Hessian trace measures loss curvature with respect to weights. Rasch et al. found that output-side converter error, not weight error, dominates analog degradation, and adversarial inputs act on activations rather than weights. The measurement study tests this directly by rank-correlating the Hessian trace and $S_l$ with observed per-layer damage. High agreement would make the Hessian the cheaper and sufficient choice.
Why not rely on analog noise as a free randomized defense? The Speck2b attacks still succeeded 88.05% of the time on hardware (Marchisio et al.). Rate-based and membrane-statistics attacks (RGA, PDSG) are built to see through obscured dynamics. We will measure how much of the noise-induced robustness remains once attacks average gradients over many hardware noise samples. We expect little to survive, because fixed programming error and drift are not random at inference time.
Why not use worst-case weight perturbation training alone, since it flattens the loss? Flatness in weight space does not obviously bound membrane shifts caused by input perturbations. The original paper never tested input attacks, so we test the question here rather than assume either answer.
Proposed Experiments
The benchmarks are CIFAR-10 with VGG-11 and WRN-16 spiking networks, matching SNN-RAT and threshold guarding. We add CIFAR10-DVS and IBM DVS Gestures for event data, and N-MNIST to reproduce the Hessian allocation result. All models run on aihwkit PCM models evaluated at one hour, one day and one year of drift, with converter resolutions from 4 to 8 bits and weight precision from 4 to 8 bits.
The attack suite deliberately avoids evaluation by a single surrogate gradient, following Towards Reliable Evaluation of Adversarial Robustness for Spiking Neural Networks. It includes PGD with several surrogates, RGA, PDSG with its sparse dynamic attack, and spike-retiming attacks (Time Is All It Takes) on event data. Every attack is run in three settings: averaged over sampled hardware noise, with full knowledge of the programmed conductances of one specific simulated chip, and query-only black-box. We report clean accuracy, robust accuracy under the strongest attack for each input, and attack success rate. We also report the fraction of threshold-neighboring neurons per layer, which checks that the mechanism, not just the headline number, moved.
Three checks decide the proposal. The first is whether the $S_l$ layer ranking differs from the Hessian ranking and predicts single-layer damage better. The second is whether, at the tightest bit budget, joint allocation beats the stacked uniform baseline and the Hessian allocation on post-drift robust accuracy, with the ablations showing that both the hardware and attack terms are needed. The third is whether robustness measured with attacks averaged over hardware noise is substantially lower than naive attacks suggest, which would show that the chip-level robustness reported so far was partly masked gradients.
References
- Hessian Aware Quantization of Spiking Neural Networks
- Hardware-aware training for large-scale and diverse deep learning inference workloads using in-memory computing-based accelerators
- NETWORK INSENSITIVITY TO PARAMETER NOISE VIA PARAMETER ATTACK DURING TRAINING
- Robust Spiking Neural Networks Against Adversarial Attacks
- Adversarial Attacks on Spiking Convolutional Networks for Event-based Vision
- Towards Effective and Sparse Adversarial Attack on Spiking Neural Networks via Breaking Invisible Surrogate Gradients
- Rate Gradient Approximation Attack Threats Deep Spiking Neural Networks
- A flexible and fast PyTorch toolkit for simulating training and inference on analog crossbar arrays
- SNN-RAT: Robustness-enhanced Spiking Neural Network through Regularized Adversarial Training
- HAWQ: Hessian AWare Quantization of Neural Networks With Mixed-Precision
- Towards Reliable Evaluation of Adversarial Robustness for Spiking Neural Networks
- Time Is All It Takes: Spike-Retiming Attacks on Event-Driven Spiking Neural Networks