--v-grad-dampen changes the backward pass through the legacy biophysical neuron’s membrane increment. It is intended to reduce gradient amplification without intentionally changing the forward model. It does not divide the entire voltage gradient by a constant, repair a non-finite forward pass, or guarantee convergence.
In tools/snnsim/models.py, both lif_step and lif_step_expeuler apply _scale_grad(dv, 1.0 / v_grad_dampen) to the voltage increment dv. The legacy training CLI defaults to 80; the exp006 — Training explicitly uses 1000. Treat either value as a configuration choice, not a universal threshold. A value of 1 disables the scaling. Use positive values, and values at least 1 when the intention is damping rather than amplification.
Damping changes the optimization problem’s supplied gradients. Keep it fixed when reproducing a recipe; record it when comparing training runs. Graph-native training has its own recipe contract: see exp088 — Training recipes and graph-native learning.
This small check exercises the actual helper without training a network or downloading data. Run it from the repository root:
import torch
from tools.snnsim.models import _scale_grad
x = torch.tensor([2.0], dtype=torch.float64, requires_grad=True)
y = _scale_grad(x, 0.01)
y.sum().backward()
torch.testing.assert_close(y, x)
torch.testing.assert_close(x.grad, torch.tensor([0.01], dtype=x.dtype))Expected result: both assertions pass. The forward value is approximately 2 and its derivative is approximately 0.01. The helper is private; this is an implementation check, not a new public API.
The helper computes
Here is the input tensor, is a dimensionless gradient scale, and detach retains the value while removing its autograd dependency. In exact arithmetic , but autograd returns derivative . Floating-point multiplication and addition can introduce rounding: this expression does not establish bitwise identity of full trajectories. PyTorch documents the dependency boundary in Tensor.detach.
The following equations describe the local exponential-Euler membrane update with noise and active voltage clamps excluded. They are an implementation derivation, not a proof of global network stability. The exp100 — COBANet page covers the surrounding dynamics.
The synapse helper decays the previous conductance and then adds the spike kick:
Here is a row of conductances in μS at step , the supplied dimensionless presynaptic spike row, the stored weight matrix in μS, the integration timestep in ms, and the pathway’s synaptic decay time in ms. In particular, the new kick is not multiplied by . Network scheduling determines which spike row reaches each pathway.
Using the updated excitatory and inhibitory conductances and , define
Here is leak conductance, capacitance in nF, and , , the leak, excitatory, and inhibitory reversal potentials in mV. is total conductance, the frozen-conductance equilibrium voltage, and the dimensionless membrane decay.
For current voltage , the increment and candidate voltage are
Here is the dimensionless damping divisor configured by v_grad_dampen, and is the candidate voltage before noise, clamps, thresholding, and reset. The implementation advances the voltage before testing its spike threshold. On a spiking or refractory neuron, torch.where replaces the retained voltage with the reset value; the emitted spike remains a separate output with its surrogate derivative.
Holding conductances fixed, the backward derivative of the candidate voltage is
Thus damping the increment preserves the direct pathway; it does not replace the full derivative by . For and positive conductances this local derivative lies between and 1.
Define the undamped conductance sensitivity for channel as
is that channel’s reversal potential. The damped candidate-voltage derivative is . At small timesteps, . This is where the control reduces sensitivity to both recurrent and feedforward conductance inputs.
These are local derivatives before reset and active clamps. Reset gates every derivative of the retained reset voltage, not just its membrane self-term. Gradients through the emitted spike can still propagate along other paths. The full backward pass combines these paths across cells and time; time-accumulated readouts also inject gradients at multiple steps.
A scalar loop-gain estimate can be a heuristic, but does not prove that gradients grow once per gamma cycle or that dividing an estimated gain by makes the entire network contractive. Such claims require the actual trajectory, stored fan-in-scaled weights, surrogate normalization, gates, and full coupled Jacobians. Neither successful forward simulation nor removal of the inhibitory loop guarantees stable learning.