snnlab
API ReferenceLang

Components

Neuron models, synapses, population signals and reusable circuits.

Neuron and synapse constructors return data specifications. They accept keyword values; their existence does not guarantee that a backend supports the specification. Use them with Network.population and Network.connect.

Neuron models

ConstructorPurposeGraph executor support
lang.COBA_LIF(tau_mem=20 * lang.ms, **values)Conductance-based leaky integrate-and-fire neurons.Supported.
lang.LeakyIntegrator(tau=20 * lang.ms, **values)Leaky-integrator populations; also used for readouts.Supported.
lang.CUBA_LIF(...) / lang.LIF(...)Current-based leaky integrate-and-fire neurons.Supported; LIF is a convenience alias.

These constructors produce specifications from keyword arguments. Backend support determines which models and settings can execute. LeakyIntegrator can also specify a synapse; its meaning depends on whether it is passed as neuron or synapse.

Graph neuron parameters

ModelRequired settings and runtime behaviour
COBA_LIFSupply tau_mem as a time quantity. Runtime supports capacitance_nf, leak_us, threshold_mv, refractory_steps and voltage_grad_dampen.
LeakyIntegratorSupply tau as a time quantity. Optional soft_reset_threshold enables subtraction of the threshold when crossed; optional surrogate_slope controls that reset’s backward derivative. Use spiking=False for a continuous readout.
CUBA_LIF / LIFConfigurable current-based membrane dynamics; see below.

For COBA_LIF, omitted capacitance defaults to 1 nF when tau_mem >= 15 ms, otherwise 0.5 nF; omitted leak is capacitance divided by tau_mem. The threshold defaults to -50 mV. Default refractory duration is 3 ms for the first case and 1.5 ms for the second, rounded to steps with a minimum of one. The default voltage gradient dampening is 80.

The current graph executor initializes COBA voltages at its fixed leak reversal (-65 mV) and leaky integrators at zero. Constructor values such as initial_voltage_mv, resting_mv, reset_mv and integrator initial_voltage are not applied as per-population overrides by this backend. Do not infer runtime support from arbitrary keyword acceptance.

Current-based LIF

def CUBA_LIF(*, tau_mem=20 * ms, capacitance_nf=1.0, resting_mv=-65.0, threshold_mv=-50.0, reset_mv=-65.0, refractory_steps=0, initial_voltage_mv=None, voltage_grad_dampen=1.0) -> Spec:
    ...

LIF(**values) returns the same specification as CUBA_LIF(**values). Synaptic drive is in nanoamperes (nA), membrane voltage in millivolts and capacitance in nanofarads. The membrane integrates net excitatory minus inhibitory current using an exponential update that holds current fixed for that step.

All displayed settings are applied. initial_voltage_mv=None starts at resting_mv. refractory_steps=0 permits immediate recovery; a positive count suppresses that many following steps while holding reset voltage. Reset must be below threshold, time constants/capacitance must be positive and values finite. During training, spikes use the configured surrogate.

Connect current neurons with ExponentialCurrent or a compatible registered current synapse. A conductance/current mismatch fails compilation or planning. See Customisation for a comparison with custom adaptive dynamics.

Population and projection signals

population.voltage has (time, batch, size) axes. A spiking population also has .spikes; accessing it on spiking=False raises AttributeError. .excitatory, .inhibitory and .modulatory are target port IDs. A projection provides .conductance for diagnostics and .weight for parameter selection. Use output or expose to return signals.

Synapses

The public constructors accept keyword arguments and produce specifications. For the graph executor, supply tau as a time quantity, for example tau=2 * lang.ms.

ConstructorPurposeGraph executor support
lang.AMPA(tau=2 * lang.ms)Excitatory conductance with exponential decay.Supported.
lang.GABA(tau=5 * lang.ms)Inhibitory conductance with exponential decay.Supported.
lang.LeakyIntegrator(tau=20 * lang.ms)Projection into a leaky-integrator population. Projection accumulation has no synaptic carry-over; the receiving population supplies integration dynamics.Supported.
lang.ExponentialCurrent(tau=5 * lang.ms)Spike-weighted current with exponential decay; parameter unit nA.Supported with current neurons.
lang.Modulatory(**values)Authoring specification for modulatory synapses.Currently unsupported; graph compilation/execution rejects it.

LeakyIntegrator is also a neuron constructor. Using it as synapse specifies the projection, while using it as neuron specifies the receiving population. A constructor’s availability does not guarantee backend support.

Reusable PING circuit

def ping(
    net: Network,
    *,
    name: str,
    n_e: int,
    n_i: int,
    source: Signal | None = None,
    source_e: Signal | None = None,
    source_i: Signal | None = None,
    tau_gaba=9 * ms,
    include_silent_recurrence: bool = False,
    w_ee=None,
    w_ei=None,
    w_ie=None,
    w_ii=None,
    w_in=None,
    w_in_e=None,
    w_in_i=None,
) -> PING: ...

lang.components.ping expands into explicit E and I populations and projections inside a named group. It returns PING(E, I), exposing the two populations. Choose a shared source for E input or separate source_e and source_i; combining both styles raises ValueError.

Default E→I weights use Normal(0.5, 0.05) and I→E weights use Normal(1.0, 0.1). Input defaults use Normal(0.2, 0.03). w_in_e/w_in_i override w_in; individual recurrent arguments override their corresponding projections. Same-population recurrence is included when its weight is supplied or include_silent_recurrence=True. tau_gaba defaults to 9 ms. This helper uses explicit historical refractory step counts (12 for E, 6 for I), so changing network timestep changes their physical durations.

Custom neurons and synapses

Use lang.CustomNeuron(definition, **config) and lang.CustomSynapse(definition, **config) after registering their implementations. Extra state ports are available through .state(name), and participate in outputs, diagnostics and continuation.

Current-based projections expose .current; conductance-based projections expose .conductance. Use the property matching the synapse family.