Stochastic & Neuromorphic Computing  /  Explore  /  Surrogate-gradient training

Surrogate-gradient training
how you backprop through a spike

A spiking neuron either fires or it does not — its output is a step. And the derivative of a step is zero everywhere except one point, where it is infinite. Feed that into backpropagation and no gradient flows: the network cannot learn. The fix that made deep spiking networks trainable is deceptively simple — keep the hard spike on the forward pass, and substitute a smooth stand-in derivative on the backward pass. Below is exactly that substitution, drawn from the surrogate SC-NeuroCore actually uses.

The problem — a step has no usable gradient

The forward spike is a Heaviside step: the neuron emits a $1$ the instant its membrane potential $v$ crosses threshold $\vartheta$, and a $0$ otherwise. That is exactly what you want on hardware — a clean binary event — but it is a disaster for gradient descent. The true derivative $\partial S/\partial v$ is zero for every $v\neq\vartheta$ and a Dirac spike at $v=\vartheta$: almost everywhere it says “changing $v$ changes nothing”, so the weights receive no signal.

$$S(v) = \Theta(v-\vartheta) = \begin{cases}1 & v \ge \vartheta\\[2pt] 0 & v < \vartheta\end{cases} \qquad\Longrightarrow\qquad \frac{\partial S}{\partial v} = \delta(v-\vartheta) \;=\; 0 \ \text{almost everywhere}$$
Live — the spike, its true derivative, and the surrogate
forward spike S(v) true derivative (zero + a spike at θ) surrogate derivative
gradient window (FWHM) peak 1.00 at v=θ

The blue curve is the surrogate that stands in for the orange one during the backward pass. It peaks at the threshold — where a nudge to $v$ is most likely to flip the spike — and falls off smoothly on either side, so neurons near firing receive the strongest learning signal. Raise $\beta$ and the window narrows toward the true (unusable) Dirac; lower it and the window widens, letting gradient flow to neurons further from threshold at the cost of faithfulness. That single knob is the crux of surrogate-gradient training.

The surrogate SC-NeuroCore uses — SuperSpike

The toolkit's differentiable neuron uses the SuperSpike surrogate of Zenke & Ganguli (2018): a smooth, bell-shaped derivative that is largest at threshold and decays like the square of the distance from it. It is the “fast-sigmoid” family — cheap to evaluate, bounded, and with a single sharpness parameter $\beta$.

$$\sigma'(v) = \frac{1}{\big(\beta\,\lvert v-\vartheta\rvert + 1\big)^2} \qquad\text{(SuperSpike; default } \beta = 10\text{)}$$
Deeper: eligibility traces and why the shape matters
The library's SuperSpike neuron pairs this surrogate with a Van Rossum–filtered eligibility trace — a low-pass memory of recent surrogate activity — so that a weight is credited in proportion to how close its neuron has recently been to firing. The quadratic fall-off is deliberate: it keeps the gradient concentrated near threshold (where the forward spike is actually sensitive to $v$) without going all the way to a Dirac, which would make training as brittle as the true derivative. The forward pass still emits the exact hard spike, so nothing about the network's inference behaviour is softened — only the backward pass sees the smooth curve. This is the “straight-through” idea specialised to spikes.

Because inference is unchanged, a network trained this way lowers to exactly the same event-driven, binary-spike datapath the hardware pages describe — the smoothing exists only in the optimiser, never in the deployed model.

The trade-off in one parameter

Sharpness $\beta$ sets the width of the gradient window, and it is a genuine trade, not a free choice. A large $\beta$ makes the surrogate hug the true derivative — faithful, but so narrow that only neurons almost exactly at threshold learn, and gradients vanish elsewhere. A small $\beta$ spreads the window wide, so many neurons receive signal and training is stable, but the surrogate now poorly approximates the real sensitivity and can bias the solution. The default sits in between; the demo lets you feel both failure modes at the extremes.

$$\text{FWHM} = \frac{2(\sqrt2 - 1)}{\beta} \approx \frac{0.83}{\beta} \qquad\text{(width of the gradient window; shrinks as }\beta\text{ grows)}$$
Where it fits

Surrogate gradients are what let a spiking network be trained with the same autograd machinery as an ordinary deep net — and they compose with the rest of the toolkit. The quantum front-end trains by an exact parameter-shift rule rather than a surrogate; the stochastic and spike layers train through this smooth stand-in; and both meet in one optimiser. The alternative route — skip training in the spike domain entirely and convert a pre-trained ordinary network — is covered separately.

Evidence boundary: the demo plots the library's exact SuperSpike surrogate $1/(\beta\lvert v-\vartheta\rvert+1)^2$ and the true step in your browser. Actual training runs through the toolkit's PyTorch/JAX backends over full networks and datasets, not on this page; no training-speed or accuracy figures are quoted here.