brainx-skill 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/manifest.json +1 -1
- package/mcp-servers/codex/skills.json +1 -1
- package/package.json +1 -1
- package/skills/bio-neuro-lit/SKILL.md +4 -2
- package/skills/bio-neuro-lit/references/required-supplements.md +27 -0
- package/skills/brainx-acceleration/SKILL.md +30 -437
- package/skills/brainx-acceleration/references/audit-and-rewrite-patterns.md +326 -0
- package/skills/brainx-general-guard/SKILL.md +24 -8
- package/skills/brainx-install/SKILL.md +3 -3
- package/skills/brainx-install/references/compatibility-and-release-matching.md +28 -20
- package/skills/brainx-install/references/uninstall-and-cleanup.md +11 -4
- package/skills/brainx-modeling-loop/SKILL.md +143 -36
- package/skills/brainx-modeling-loop/agents/openai.yaml +2 -2
- package/skills/brainx-modeling-loop/references/mechanism-comparison.md +62 -0
- package/skills/brainx-modeling-loop/references/multiscale-coupling.md +16 -0
- package/skills/brainx-modeling-loop/references/paper-reproduction.md +42 -0
- package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +14 -14
- package/skills/brainx-modeling-loop/references/run-experiment.md +1 -1
- package/skills/brainx-modeling-loop/references/training-workflow.md +10 -8
- package/skills/brainx-visualization/SKILL.md +6 -2
- package/skills/brainx-visualization/references/neural-data-visualization.md +1 -1
- package/skills/brainx-visualization/references/statistical-and-model-visualization.md +1 -1
- package/skills/package-skills/braincell/SKILL.md +23 -14
- package/skills/package-skills/braincell/references/braintools/input-current.md +1 -1
- package/skills/package-skills/braincell/references/braintools/metric.md +72 -46
- package/skills/package-skills/braincell/references/mixions-for-adaptation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/cv-policy-reference.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md +3 -3
- package/skills/package-skills/braincell/references/multicompartment/morphology-io-loading-validation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +31 -43
- package/skills/package-skills/braincell/references/multicompartment/network-workflow.md +49 -0
- package/skills/package-skills/braincell/references/multicompartment/probe-reference.md +26 -114
- package/skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md +40 -28
- package/skills/package-skills/braincell/references/scripts/cell_multicompartment_reference.py +13 -17
- package/skills/package-skills/brainevent/SKILL.md +0 -3
- package/skills/package-skills/brainevent/references/synaptic-plasticity.md +1 -1
- package/skills/package-skills/brainmass/SKILL.md +5 -3
- package/skills/package-skills/brainmass/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainmass/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainmass/references/braintools/data-preprocessing.md +15 -7
- package/skills/package-skills/brainmass/references/braintools/metric.md +72 -46
- package/skills/package-skills/brainmass/references/coupling-network-api.md +3 -1
- package/skills/package-skills/brainmass/references/fitting-with-objectives-api.md +6 -6
- package/skills/package-skills/brainmass/references/horn-task-training.md +9 -9
- package/skills/package-skills/brainmass/references/modellibrary.md +12 -10
- package/skills/package-skills/brainmass/references/scripts/resting-state-meg-whole-brain-pipeline.py +5 -3
- package/skills/package-skills/brainmass/references/scripts/wilson-cowan-ei-dynamics.py +10 -6
- package/skills/package-skills/brainmass/references/simulator-input-monitor-api.md +3 -1
- package/skills/package-skills/brainmass/references/visualization-analysis-api.md +17 -9
- package/skills/package-skills/brainspike/SKILL.md +201 -0
- package/skills/package-skills/brainspike/references/braintools/connectivity.md +40 -0
- package/skills/package-skills/brainspike/references/braintools/data-preprocessing.md +39 -0
- package/skills/package-skills/brainspike/references/braintools/input-current.md +55 -0
- package/skills/package-skills/brainspike/references/braintools/metric.md +36 -0
- package/skills/package-skills/brainspike/references/braintools/optimizer.md +50 -0
- package/skills/package-skills/brainspike/references/braintools/parameter-initializer.md +43 -0
- package/skills/package-skills/brainspike/references/braintools/surrogate.md +40 -0
- package/skills/package-skills/brainspike/references/migration-boundary.md +38 -0
- package/skills/package-skills/brainspike/references/model-and-readout-selection.md +41 -0
- package/skills/package-skills/brainspike/references/multirate-coupling.md +31 -0
- package/skills/package-skills/brainspike/references/multiscale-composition.md +28 -0
- package/skills/package-skills/brainspike/references/native-composition.md +52 -0
- package/skills/package-skills/brainspike/references/native-delays.md +34 -0
- package/skills/package-skills/brainspike/references/native-projections.md +43 -0
- package/skills/package-skills/brainspike/references/native-training.md +36 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md +33 -33
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/divergence-and-parity.md +15 -15
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/integration-categories.md +1 -1
- package/skills/package-skills/brainspike/references/nest-compatible/model-library.md +200 -0
- package/skills/package-skills/brainspike/references/nest-compatible/network-building.md +276 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brette_et_al_2007.py +23 -26
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_alpha.py +18 -21
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_delta.py +16 -19
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +11 -12
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +10 -11
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/spatial_gaussex.py +18 -18
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/synapsecollection.py +26 -29
- package/skills/package-skills/brainspike/references/nest-compatible/synapse-and-connectivity.md +166 -0
- package/skills/package-skills/brainspike/references/nest-delay-boundaries.md +31 -0
- package/skills/package-skills/brainspike/references/nonlinear-state-sharing.md +26 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/perturbation-experiment-validity.md +2 -2
- package/skills/package-skills/brainspike/references/simulator-training.md +61 -0
- package/skills/package-skills/brainspike/references/temporal-task-training.md +36 -0
- package/skills/package-skills/brainspike/scripts/advanced_native_patterns.py +76 -0
- package/skills/package-skills/brainspike/scripts/delay_workflow.py +44 -0
- package/skills/package-skills/brainspike/scripts/delayed_cue_training.py +78 -0
- package/skills/package-skills/brainspike/scripts/lif_smoke.py +31 -0
- package/skills/package-skills/brainspike/scripts/multiscale_workflow.py +35 -0
- package/skills/package-skills/brainspike/scripts/native_ei_network.py +47 -0
- package/skills/package-skills/brainspike/scripts/native_workflows.py +77 -0
- package/skills/package-skills/brainspike/scripts/nest_boundary_workflows.py +108 -0
- package/skills/package-skills/brainspike/scripts/train_native_snn.py +65 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator.py +69 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator_two_weights.py +220 -0
- package/skills/package-skills/brainstate/SKILL.md +16 -21
- package/skills/package-skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +1 -138
- package/skills/package-skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
- package/skills/package-skills/brainstate/references/brainstate/delay-buffers.md +45 -0
- package/skills/package-skills/brainstate/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/randomness-and-reproducibility.md +6 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-grad-expansion.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md +1 -1
- package/skills/package-skills/brainstate/references/braintools-optimizer-reference.md +16 -0
- package/skills/package-skills/brainstate/references/libraries/prebuilt-layer-library.md +1 -1
- package/skills/package-skills/brainstate/references/simulation-environment.md +5 -5
- package/skills/package-skills/braintrace/SKILL.md +17 -38
- package/skills/package-skills/braintrace/references/Drtrl.md +9 -26
- package/skills/package-skills/braintrace/references/algorithm selection.md +7 -12
- package/skills/package-skills/braintrace/references/batching.md +15 -35
- package/skills/package-skills/braintrace/references/compiler_internal.md +1 -1
- package/skills/package-skills/braintrace/references/custom algorithms.md +1 -2
- package/skills/package-skills/braintrace/references/customizing_primitive_transforms.md +26 -15
- package/skills/package-skills/braintrace/references/pp_pprop workflow.md +5 -139
- package/skills/package-skills/brainunit/SKILL.md +7 -2
- package/skills/package-skills/brainunit/references/array-mechanics/functional-structural-api.md +1 -1
- package/skills/package-skills/brainunit/references/math-function-library.md +2 -2
- package/skills/package-skills/brainunit/references/typing-and-runtime-validation.md +5 -2
- package/skills/package-skills/brainevent/references/scripts/102_EI_net_1996.py +0 -107
- package/skills/package-skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +0 -168
- package/skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py +0 -356
- package/skills/package-skills/brainpy-state/SKILL.md +0 -247
- package/skills/package-skills/brainpy-state/references/array-creation.md +0 -158
- package/skills/package-skills/brainpy-state/references/brain-dynamics-delay-protocol.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/analysis.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/brainpy legacy workflow.md +0 -373
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/connecting neurons.md +0 -175
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/customize neuron and synpase.md +0 -286
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Input generation.md +0 -111
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -163
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -113
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -136
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -222
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -123
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/delays.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -185
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/integrators.md +0 -181
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/route activity through connectivity.md +0 -102
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synaptic projections.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synpase properties.md +0 -159
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/loss library.md +0 -127
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/optimizers.md +0 -167
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/parameter initializers.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -186
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/surrogate gradients.md +0 -104
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainer library.md +0 -89
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainingworkflows.md +0 -253
- package/skills/package-skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +0 -334
- package/skills/package-skills/brainpy-state/references/braintools/connectivity.md +0 -206
- package/skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md +0 -79
- package/skills/package-skills/brainpy-state/references/braintools/input-current.md +0 -199
- package/skills/package-skills/brainpy-state/references/braintools/metric.md +0 -152
- package/skills/package-skills/brainpy-state/references/braintools/optimizer.md +0 -179
- package/skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md +0 -183
- package/skills/package-skills/brainpy-state/references/braintools/surrogate.md +0 -147
- package/skills/package-skills/brainpy-state/references/component-selection.md +0 -288
- package/skills/package-skills/brainpy-state/references/nest-compatible/model-library.md +0 -200
- package/skills/package-skills/brainpy-state/references/nest-compatible/nest-workflow.md +0 -156
- package/skills/package-skills/brainpy-state/references/nest-compatible/network-building.md +0 -264
- package/skills/package-skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +0 -153
- package/skills/package-skills/brainpy-state/references/projection-patterns.md +0 -127
- package/skills/package-skills/brainpy-state/references/scripts/103_COBA_2005.py +0 -86
- package/skills/package-skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +0 -181
- package/skills/package-skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +0 -156
- package/skills/package-skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +0 -111
- package/skills/package-skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -221
- package/skills/package-skills/brainpy-state/references/scripts/sound_localization.py +0 -240
- package/skills/package-skills/brainpy-state/references/scripts/training-snn.py +0 -119
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Initialize BrainSpike states and parameters
|
|
2
|
+
|
|
3
|
+
Use Braintools initializers to resolve a scientific value or distribution into the physical shape consumed by a neuron or projection. Resting voltage specifies dynamics; it does not substitute for an intentional initial membrane voltage.
|
|
4
|
+
|
|
5
|
+
## Choose the initializer
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `braintools.init.Constant(value)` | Use for a known initial voltage or fixed parameter; preserve the physical unit of the supplied value. |
|
|
10
|
+
| `braintools.init.Normal(mean=..., std=...)` | Use for Gaussian heterogeneity; validate domain bounds because negative draws remain possible. |
|
|
11
|
+
| `braintools.init.param(initializer, sizes=..., rng=...)` | Resolve a distribution before graph construction with explicit shape and RNG ownership. |
|
|
12
|
+
| `braintools.init.XavierNormal()` | Use for a dimensionless native-layer matrix when fan scaling fits the chosen activation; check the layer's input/output orientation. |
|
|
13
|
+
|
|
14
|
+
## Freeze an initial membrane distribution
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import brainspike
|
|
18
|
+
import brainstate
|
|
19
|
+
import braintools
|
|
20
|
+
import brainunit as u
|
|
21
|
+
import numpy as np
|
|
22
|
+
|
|
23
|
+
initial_voltage = braintools.init.param(
|
|
24
|
+
braintools.init.Normal(mean=-65.0*u.mV, std=1.0*u.mV),
|
|
25
|
+
sizes=4, rng=np.random.default_rng(7),
|
|
26
|
+
)
|
|
27
|
+
sim = brainspike.Simulator(dt=0.1*u.ms)
|
|
28
|
+
neurons = sim.create(
|
|
29
|
+
brainspike.iaf_psc_alpha, 4,
|
|
30
|
+
V_initializer=braintools.init.Constant(initial_voltage),
|
|
31
|
+
)
|
|
32
|
+
assert initial_voltage.shape == (4,)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Sampling first and storing the sample in `Constant` preserves the same initial condition across independent `simulate()` evaluations. Resample deliberately when between-trial heterogeneity is part of the experiment. A BrainState seed alone does not replace an explicit NumPy RNG for a host-sampled initializer.
|
|
36
|
+
|
|
37
|
+
Keep physical connection weights separate from dimensionless native-layer weights. The bundled recurrent SNN multiplies a dimensionless projection output by `u.nA`; a NEST connection instead consumes the target model's required weight unit. Alpha/exponential PSC connections use current weights in the verified examples; delta connections use voltage jumps. Conductance-based targets require their own model-compatible contract.
|
|
38
|
+
|
|
39
|
+
For trainable values, initialize `ParamState` once and reset only runtime State at sequence boundaries. Open `references/native-training.md` for native graph resets or `references/simulator-training.md` for fixed-initial-condition candidate evaluation. Open `references/braintools/connectivity.md` when geometry selects edges; a distance-modulated initializer scales existing weights and does not generate topology.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
[BrainTools initializer API](https://brainx.chaobrain.com/braintools/apis/init.html). The example targets BrainTools 0.4.0.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Choose BrainSpike surrogate gradients
|
|
2
|
+
|
|
3
|
+
A surrogate emits binary threshold spikes in the forward pass and supplies a selected derivative in the backward pass. Apply it to voltage relative to threshold on an explicit dimensionless scale.
|
|
4
|
+
|
|
5
|
+
## Choose and connect the surrogate
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `braintools.surrogate.InvSquareGrad()` | Use for the verified custom LIF example; retain the scale and reset convention when comparing temporal gradients. |
|
|
10
|
+
| `braintools.surrogate.ReluGrad()` | Use when reproducing the documented NEST neuron's default surrogate configuration; check which output is actually exposed by the training path. |
|
|
11
|
+
| `brainspike.Neuron(..., spk_fun=surrogate)` | Store a reusable surrogate on a custom neuron and call `self.spk_fun` from its spike computation. |
|
|
12
|
+
| `braintools.surrogate.Surrogate` | Subclass only when the scientific method requires a derivative absent from documented built-ins. |
|
|
13
|
+
|
|
14
|
+
## Verify hard forward spikes and nonzero backward signal
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import braintools
|
|
18
|
+
import brainunit as u
|
|
19
|
+
import jax
|
|
20
|
+
|
|
21
|
+
surrogate = braintools.surrogate.InvSquareGrad()
|
|
22
|
+
relative_voltage = u.math.asarray([-0.1, 0.1])
|
|
23
|
+
spikes = surrogate(relative_voltage)
|
|
24
|
+
gradient = jax.grad(lambda x: u.math.sum(surrogate(x)))(relative_voltage)
|
|
25
|
+
assert u.math.all(spikes == u.math.asarray([0., 1.]))
|
|
26
|
+
assert u.math.all(u.math.isfinite(gradient))
|
|
27
|
+
assert u.math.all(gradient > 0)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In the bundled custom LIF, the surrogate argument is `(voltage-threshold)/(10*u.mV)`. The scale changes the effective derivative width in physical voltage; keep it fixed when comparing surrogate families. The custom update implements its soft reset explicitly, so changing a base-class option alone does not rewrite that equation.
|
|
31
|
+
|
|
32
|
+
Open `scripts/native_workflows.py` for the complete neuron and `references/native-training.md` for native BPTT/pp-prop. Verify finite nonzero gradients on the actual recurrent parameter path; a trainable readout bias can decrease loss while temporal credit remains broken.
|
|
33
|
+
|
|
34
|
+
A surrogate configured on a neuron does not guarantee that `SimulationResult.spikes()` preserves its derivative. The recorded hard-spike-count control in `references/simulator-training.md` has zero gradient. Use that reference for the separately verified continuous-voltage Simulator objective.
|
|
35
|
+
|
|
36
|
+
Do not compare a surrogate derivative with finite differences of hard threshold spikes and expect equality. Use finite differences for a smooth objective when its mathematical derivative is the intended oracle, or compare matched BPTT and online estimators under the same surrogate.
|
|
37
|
+
|
|
38
|
+
## Source
|
|
39
|
+
|
|
40
|
+
[BrainTools surrogate API](https://brainx.chaobrain.com/braintools/apis/surrogate.html). The verified custom-neuron pattern targets BrainTools 0.4.0.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Migration boundary
|
|
2
|
+
|
|
3
|
+
Use `brainspike` as the sole point-neuron skill. Choose the NEST-compatible Simulator or public Neuron/Synapse composition; do not rename `brainpy.state` symbols mechanically.
|
|
4
|
+
|
|
5
|
+
## Select the supported workflow
|
|
6
|
+
|
|
7
|
+
- Use the root skill for point-neuron simulation, synapse specifications, devices, spatial connectivity, and PyNEST porting.
|
|
8
|
+
- Open `brainstate` for generic State, Module, control-flow, gradient, and optimizer lifecycle. For the verified native recurrent graph, open `references/native-training.md`; open `references/simulator-training.md` for the separately verified NEST continuous-voltage objective.
|
|
9
|
+
- Open `braintrace` for the verified native pp-prop path in `references/native-training.md`.
|
|
10
|
+
- Open `braincell` for detailed cellular mechanisms and `brainmass` for aggregate dynamics. For coupling, define exchanged observables, units, clocks, and causal order, then use `references/multiscale-composition.md` for the verified common-clock native wrapper.
|
|
11
|
+
|
|
12
|
+
Open the local `references/braintools/` guides through the root routing table for BrainSpike-specific inputs, initialization, losses, optimization, surrogates, encoding, and topology. BrainState owns State and transforms rather than these package integration decisions.
|
|
13
|
+
|
|
14
|
+
## Select the verified replacement
|
|
15
|
+
|
|
16
|
+
| Retired workflow | Replacement decision |
|
|
17
|
+
|---|---|
|
|
18
|
+
| LIF and exponential/current/conductance synapse networks | Select the appropriate documented NEST model and synapse; reconstruct parameters and validate startup, units, delays, and recorded outputs. Do not assume identical equations or discretization. |
|
|
19
|
+
| AlignPre/AlignPost, descriptors, manual projection stepping | Express supported connectivity through `Simulator.connect`; use `references/native-projections.md` for complete target-aligned native E/I filtering and current conversion. Open `references/nonlinear-state-sharing.md` for verified nonlinear source sharing and counterexamples to nonlinear target aggregation/heterogeneous reuse. Keep edge-specific State when sharing conditions fail. |
|
|
20
|
+
| Custom Dynamics or neuron/synapse definitions | Use public `brainspike.Neuron` and `Synapse`; `scripts/native_workflows.py` verifies an Euler LIF and target-aligned exponential conductance. A zero-argument autonomous custom LIF also runs under Simulator scheduling; arbitrary incoming-synapse adapters are not established. Open `references/nest-compatible/network-building.md` for that boundary. |
|
|
21
|
+
| Surrogate-gradient BPTT and trainable readouts | Use `references/native-training.md` and `scripts/train_native_snn.py`; the recurrent spike graph and readout both receive nonzero gradients and update under BPTT. |
|
|
22
|
+
| BrainTrace pp-prop integration | Use ETP-aware native projections and pp-prop; Docker checks compiler participation, recurrent/readout gradients, reduced BPTT gradient direction, and decreasing fixture loss. |
|
|
23
|
+
| Heterogeneous delay banks, gap junctions, or multiscale coupling | Use NEST connectivity references for model-specific delay and electrical synapse semantics. Separate NEST connections verify two distinct target delays; native symmetric gap currents verify sign/conservation behavior. Native point/cell/region exchange passes zero-coupling and one-step-causality checks. Named native delay taps and the complete conductance/voltage path are verified in `references/native-delays.md`. Open `references/nest-delay-boundaries.md` for the tested delay vector, grouped matrix fallback, fractional PSC behavior, and spec failures. Open `references/multirate-coupling.md` for verified causal/conservative integer-clock exchange and its numerical-equivalence limits. |
|
|
24
|
+
| Legacy BrainPy analysis and maintenance | Outside the published skill set. Treat migration as a separate behavior-preservation task; never silently restore the retired API. |
|
|
25
|
+
|
|
26
|
+
The unified kernel remains private, but public Neuron/Synapse bases already support the verified native workflows. Do not conflate kernel availability with base-class composition. NEST Simulator continuous-voltage weight fitting is separately verified in `references/simulator-training.md`; hard recorded spike counts still have zero autodiff gradients, but bounded derivative-free count fitting succeeds. One/two-window continuous objective gradients agree in the local-construction fixture. Fully compiled persistent training, arbitrary delay forms/kinetics, and timestep-independent multirate equivalence remain unproven.
|
|
27
|
+
|
|
28
|
+
## Separate skill removal from runtime removal
|
|
29
|
+
|
|
30
|
+
BrainSpikes `0.2.0` declares no direct BrainPy or BrainPy-State dependency. BrainX `2026.10.25` still bundles BrainPy `2.9.0`. BrainCell `0.2.0` also imports BrainPy transitively in the tested image. Removing the skill does not change those runtime dependencies. Install `brainspikes`, import `brainspike`, and open `brainx-install` → `references/compatibility-and-release-matching.md` before changing runtime packages.
|
|
31
|
+
|
|
32
|
+
Validate migrated startup State, units, timestep, connection direction, delay/weight semantics, recordings, and stochastic tolerances. Open `references/nest-compatible/divergence-and-parity.md` before asserting NEST equivalence.
|
|
33
|
+
|
|
34
|
+
## Official evidence
|
|
35
|
+
|
|
36
|
+
- [BrainSpikes 0.2.0 release metadata and description](https://pypi.org/pypi/brainspikes/0.2.0/json)
|
|
37
|
+
- [BrainSpike public documentation](https://brainx.chaobrain.com/brainspike/index.html)
|
|
38
|
+
- [BrainX release change log](https://brainmodeling.readthedocs.io/CHANGELOG.html)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Select point-neuron components and readouts
|
|
2
|
+
|
|
3
|
+
Choose the scientific dynamics and observable before the execution wrapper. A common lifecycle or similarly named class does not establish identical equations, reset timing, refractory behavior, or units.
|
|
4
|
+
|
|
5
|
+
## Choose the represented dynamics
|
|
6
|
+
|
|
7
|
+
| Component | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Custom `LIF` in `scripts/native_workflows.py` | Use as an explicit Euler/surrogate mechanics fixture; it has soft reset and no absolute refractory or adaptation State. |
|
|
10
|
+
| NEST `iaf_psc_delta`, `iaf_psc_alpha`, `iaf_psc_exp` | Choose the requested current response and refractory contract; preserve the model's own buffering and reset semantics. |
|
|
11
|
+
| NEST `iaf_cond_*` | Use when reversal-dependent conductance is part of the model; select receptor ports and positive conductance magnitudes deliberately. |
|
|
12
|
+
| NEST `aeif_*`, `gif_*`, `glif_*` | Use the documented adaptive or generalized family when its additional State is scientifically required. |
|
|
13
|
+
| BrainCell models | Use when ions, channels, compartments, or morphology are explicitly modeled or modified; selecting a fixed point-HH NEST model alone does not require rewriting it as a detailed cell. |
|
|
14
|
+
|
|
15
|
+
Open `references/nest-compatible/model-library.md` for exact public models and `references/nest-compatible/integration-categories.md` for numerical behavior. Verify startup voltage, current/voltage/conductance units, firing response, adaptation, and stability at the intended timestep before accepting a replacement.
|
|
16
|
+
|
|
17
|
+
## Choose synaptic meaning before storage
|
|
18
|
+
|
|
19
|
+
Use a current-valued filter for CUBA, a nonnegative conductance with `g*(E-V)` for COBA, and a documented voltage-jump contract for delta input. Keep excitatory/inhibitory reversal channels separate. Open `references/native-projections.md` for the complete native E/I path and the conditions under which shared linear filters are exact.
|
|
20
|
+
|
|
21
|
+
Read a model's spike-access contract before recurrent wiring: a method may evaluate spikes from current voltage rather than return cached events from the last update. Preserve the appropriate update output or documented cache. The bundled custom LIF explicitly stores its completed spike array; do not generalize that implementation to every NEST model.
|
|
22
|
+
|
|
23
|
+
## Choose the temporal readout
|
|
24
|
+
|
|
25
|
+
| API or operation | Use |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `braintrace.nn.Linear` | Use an instantaneous trainable projection when each step's output is the task observable. |
|
|
28
|
+
| `braintrace.nn.LeakyRateReadout(..., tau=...)` | Use when a trainable temporally filtered readout is part of the model; reset its hidden State with independent trials. |
|
|
29
|
+
| Masked window mean or sum | Use when the declared report window determines the statistic; retain time and trial axes until the final reduction. |
|
|
30
|
+
| `SimulationResult.trace` | Use a recorded continuous NEST observable for the verified direct fitting path. |
|
|
31
|
+
|
|
32
|
+
The minimal native training fixture uses an instantaneous readout. The cue-delay-report fixture uses a leaky readout plus explicit report-window reduction. Run `scripts/delayed_cue_training.py` for that canonical dynamic-readout example, then open `references/temporal-task-training.md` for the scoring and validation contract.
|
|
33
|
+
|
|
34
|
+
A leaky readout adds memory, a window sum changes with window duration, and a window mean changes the weighting of variable-length reports. Select deliberately. Hard recorded spike counts have zero gradients in the tested Simulator configuration; open `references/simulator-training.md` before using them as training targets.
|
|
35
|
+
|
|
36
|
+
For readout-layer variants, open `braintrace` → `references/pre-built-braintrace-layer.md`. Use BrainTrace's learner only when its temporal estimator is needed; a BrainTrace layer can also participate in ordinary BPTT, as the native examples demonstrate.
|
|
37
|
+
|
|
38
|
+
## Sources
|
|
39
|
+
|
|
40
|
+
- [BrainSpike model directory](https://brainx.chaobrain.com/brainspike/nest-style/models.html)
|
|
41
|
+
- [BrainTrace readout layers](https://brainx.chaobrain.com/braintrace/apis/nn.html)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Exchange point and regional signals on two clocks
|
|
2
|
+
|
|
3
|
+
Use a declared integer clock ratio when point neurons require fine updates and a regional model receives windowed population input. The exchange rule is part of the model: a held signal and a window-averaged rate are not automatically equivalent to continuously coupled dynamics.
|
|
4
|
+
|
|
5
|
+
## Preserve availability and counts
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `MultirateCoupling` in `scripts/advanced_native_patterns.py` | Run five `0.1 ms` point-neuron updates inside one `0.5 ms` regional window in the canonical fixture. |
|
|
10
|
+
| `brainstate.transform.for_loop` | Advance the fixed number of fine steps with State tracking; snapshot the previous regional signal before the window. |
|
|
11
|
+
| `brainstate.environ.context(dt=..., t=...)` | Scope fine and coarse clocks explicitly around their owning model updates. |
|
|
12
|
+
| `brainmass.Simulator(wrapper, dt=coarse_dt).run(...)` | Let the standard runner own independent initialization and coarse-window execution. |
|
|
13
|
+
|
|
14
|
+
Run `python scripts/advanced_native_patterns.py` from this skill root. The wrapper holds the previous completed regional signal for all fine steps, sums their point spikes, divides by the full window duration, and converts the resulting physical rate into the regional model's declared dimensionless drive. The region advances only after that window has completed. Its new signal becomes available to point neurons in the following window.
|
|
15
|
+
|
|
16
|
+
The runner's `ts` labels window starts in this fixture. Use the explicitly monitored `end_time` when interpreting the newly completed regional State; do not assign its value to a time before the source window was available.
|
|
17
|
+
|
|
18
|
+
Docker checks verify exact spike-count/rate conservation, the one-window hold relation, no feedback from a future regional update, independent replay, and the zero-coupling limit against an independently driven point neuron. The fixture includes point and regional models; it does not add a separate slow-clock detailed-cell solver.
|
|
19
|
+
|
|
20
|
+
## Separate correct exchange from numerical equivalence
|
|
21
|
+
|
|
22
|
+
Changing only the regional exchange interval from `0.5` to `0.2` to `0.1 ms` produced final regional values approximately `0.05951`, `0.05745`, and `0.05886`. They are finite but do not show monotonic refinement in this threshold-driven fixture. Do not claim timestep independence, convergence, or equivalence to an earlier continuously coupled model from the conservation/causality checks.
|
|
23
|
+
|
|
24
|
+
Non-integer clock ratios, asynchronous interpolation, arbitrary multirate cellular integration, and other exchange kernels require their own implementation and scientific validation. Re-run refinement and matched controls under the intended exchange rule before interpreting results.
|
|
25
|
+
|
|
26
|
+
Open `references/multiscale-composition.md` for the separately verified common-clock point/HH-cell/region graph. Open `brainx-modeling-loop` → `references/multiscale-coupling.md` for scientific units, observables, windows, and delay decisions.
|
|
27
|
+
|
|
28
|
+
## Sources
|
|
29
|
+
|
|
30
|
+
- [BrainState control flow](https://brainx.chaobrain.com/brainstate/tutorials/transformations/05_control_flow.html)
|
|
31
|
+
- [BrainMass regional inputs](https://brainx.chaobrain.com/brainmass/reference/generated/brainmass.XY_Oscillator.html)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Compose point, cellular, and regional dynamics
|
|
2
|
+
|
|
3
|
+
Use one native Module graph when BrainSpike point neurons, BrainCell cellular mechanisms, and BrainMass regional dynamics exchange observables during a run. Each package still owns its equations; the wrapper owns only the exchange contract.
|
|
4
|
+
|
|
5
|
+
Open `scripts/multiscale_workflow.py` for `CoupledScales`: a custom BrainSpike LIF, a BrainCell HH cell with sodium/potassium/leak currents, and a BrainMass Hopf region. The fixture uses the same `0.1 ms` clock and reads all source observables before updating targets.
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `brainstate.nn.Module` | Own the component graph and read previous source values before any target advances. |
|
|
10
|
+
| `brainmass.Simulator(wrapper, dt=...).run(..., monitors=...)` | Run a compatible native wrapper and collect post-step State without rebuilding the time loop. |
|
|
11
|
+
| `point.get_spike() / dt` | Convert previous-step spike counts to an instantaneous rate with physical inverse-time units; choose an explicit rate scale before supplying a dimensionless regional drive. |
|
|
12
|
+
| `cell.update(current_density)` | Advance the cellular component with current density when its channel currents are densities; do not add bare total current without a defined area conversion. |
|
|
13
|
+
| `mass.update(x_inp=..., y_inp=...)` | Supply the Hopf component's declared input channels; do not overwrite its hidden State to inject a drive. |
|
|
14
|
+
|
|
15
|
+
For the bundled fixture, use `brainmass.Simulator(CoupledScales(gain=1), dt=0.1*u.ms).run(...)`. Observe `point.V`, `cell.V`, and `mass.x` through named callable monitors. The gains are explicit mechanics examples and require scientific calibration in a real study.
|
|
16
|
+
|
|
17
|
+
Set `gain=0` and compare against separately driven components under the same seed and initialization. Injected point spikes may influence the region only on the next step; verify the first allowed arrival. Use a declared window/filter for scientific population-rate estimates, and test finer clocks when discretization affects conclusions.
|
|
18
|
+
|
|
19
|
+
BrainCell `0.2.0` in the tested image imports BrainPy transitively. The application code uses public BrainCell/BrainSpike APIs, but this three-scale fixture does not establish a BrainPy-free runtime. Native point-neuron and training tests block BrainPy imports independently.
|
|
20
|
+
|
|
21
|
+
Open `brainx-modeling-loop` → `references/multiscale-coupling.md` for exchange-window, resampling, multiple-clock, and scientific-delay decisions. The common-clock fixture does not validate arbitrary multirate coupling or insertion of custom components into the NEST Simulator.
|
|
22
|
+
|
|
23
|
+
Open `references/multirate-coupling.md` for the separately verified integer-clock point/regional exchange, count conservation, availability timestamps, and lack of demonstrated monotonic refinement.
|
|
24
|
+
|
|
25
|
+
## Official contracts
|
|
26
|
+
|
|
27
|
+
- [BrainSpike Neuron](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Neuron.html)
|
|
28
|
+
- [BrainMass XY oscillator input channels](https://brainx.chaobrain.com/brainmass/reference/generated/brainmass.XY_Oscillator.html)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Compose native BrainSpike dynamics
|
|
2
|
+
|
|
3
|
+
Use native composition when custom equations, differentiable recurrent paths, explicit synaptic State placement, or cross-package clocks cannot be expressed through the NEST Simulator. A native graph is a BrainState Module graph containing public BrainSpike dynamics; it does not depend on the private unified kernel.
|
|
4
|
+
|
|
5
|
+
## Implement the state lifecycle
|
|
6
|
+
|
|
7
|
+
A `Neuron` owns hidden membrane/spike State; `init_state` allocates it, `reset_state` restores an independent rollout, and `update` advances one declared timestep.
|
|
8
|
+
|
|
9
|
+
| API | Use |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `brainspike.Neuron(size, spk_fun=...)` | Subclass for custom point-neuron equations; implement `get_spike`, initialization, reset, and update. |
|
|
12
|
+
| `brainspike.Synapse(size)` | Subclass for custom temporal filtering; put the filter State on the chosen neuron or edge dimension. |
|
|
13
|
+
| `brainspike.Dynamics.sum_current_inputs(current)` | Consume registered current inputs in an update; persistent callables remain registered and one-shot arrays are consumed. |
|
|
14
|
+
| `brainstate.HiddenState(value)` | Store rollout variables that must participate in State-aware transforms. |
|
|
15
|
+
| `brainstate.nn.init_all_states(model)` / `reset_all_states(model)` | Allocate once and reset independent episodes without replacing learned parameters. |
|
|
16
|
+
| `brainstate.transform.for_loop(step, inputs)` | Advance a native graph over time while tracking State effects. |
|
|
17
|
+
|
|
18
|
+
Open `scripts/native_workflows.py` for the complete `LIF`, `ExponentialConductance`, and `RecurrentSNN` implementations. The LIF uses Euler integration, a dimensionless surrogate argument, and an explicitly implemented soft reset. Its numeric parameters are a mechanics fixture, not a claim of equivalence to every legacy LIF model.
|
|
19
|
+
|
|
20
|
+
Open `references/braintools/input-current.md` for current sampling and unit normalization; open `references/braintools/connectivity.md` when topology requires more than an existing native rule.
|
|
21
|
+
|
|
22
|
+
## Place synaptic State intentionally
|
|
23
|
+
|
|
24
|
+
Open `references/native-projections.md` when assembling chemical connections: it owns communication, temporal filtering, CUBA/COBA conversion, target update order, and the exact conditions for target/source State sharing. Run its complete E/I example before adapting a biological network.
|
|
25
|
+
|
|
26
|
+
Use the ETP-aware native training projection in `references/native-training.md` when temporal gradients are required; the fixed binary communication example does not establish the same training contract.
|
|
27
|
+
|
|
28
|
+
Open `references/native-delays.md` before inserting transmission history, and `references/model-and-readout-selection.md` when choosing dynamics or temporal decoding.
|
|
29
|
+
|
|
30
|
+
## Couple native voltages electrically
|
|
31
|
+
|
|
32
|
+
For a symmetric gap junction, snapshot both old voltages and calculate one physical current before advancing either neuron. The opposite current must use that same snapshot:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
current = conductance * (right.V.value - left.V.value)
|
|
36
|
+
left(current)
|
|
37
|
+
right(-current)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use this with compatible current-driven native neurons; the Docker check verifies the symmetric pair's mean voltage and contraction. This does not validate every NEST gap-junction model or a general multicompartment electrical solver.
|
|
41
|
+
|
|
42
|
+
## Preserve causal ordering
|
|
43
|
+
|
|
44
|
+
Read all previous completed source values before updating any target in a recurrent step. Integrate each source once. Record whether new events affect the current or next step; never change that convention while porting a model.
|
|
45
|
+
|
|
46
|
+
Open `references/native-training.md` for BPTT and pp-prop. Open `references/multiscale-composition.md` for cellular and regional coupling, and `references/migration-boundary.md` for remaining unsupported generalizations.
|
|
47
|
+
|
|
48
|
+
## Official contracts
|
|
49
|
+
|
|
50
|
+
- [Neuron and surrogate-gradient lifecycle](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Neuron.html)
|
|
51
|
+
- [Synapse base and State placement](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Synapse.html)
|
|
52
|
+
- [Dynamics input lifecycle](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Dynamics.html)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Delay native point-neuron inputs
|
|
2
|
+
|
|
3
|
+
Delay the source signal before communication and synaptic filtering. Prove arrival at the actual conductance and target-voltage boundary; a buffer-only check or postsynaptic spike time alone does not establish the transmission delay.
|
|
4
|
+
|
|
5
|
+
## Select the delay owner
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `brainspike.Simulator.connect(..., delay=...)` | Use for a NEST graph; preserve its own device and transmission timestamp conventions. |
|
|
10
|
+
| `brainstate.nn.Delay` | Use for explicit native signal history; initialize it with the rest of the Module graph. |
|
|
11
|
+
| `DelayBank` in `scripts/delay_workflow.py` | Use the verified three-source named-tap example with delays `[0,2,3]*dt`. |
|
|
12
|
+
| `DelayedProjection` in `scripts/delay_workflow.py` | Follow the complete external-event → buffer → communication → conductance → target update path. |
|
|
13
|
+
|
|
14
|
+
Run the named-tap example from this skill root:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python scripts/delay_workflow.py
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For `DelayedProjection`, initialize the graph and drive a boolean `(time,3)` input through `brainstate.transform.for_loop`. Its source event on channel 1 at input step zero first changes conductance and target voltage at step 2. An independent quiet rollout after whole-graph initialization has zero conductance. The target is subthreshold in the impulse check, so refractory/threshold effects do not obscure arrival.
|
|
21
|
+
|
|
22
|
+
Open `brainstate` → `references/brainstate/delay-buffers.md` for the authoritative write-before-read convention, named entries, fixed timestep, reset, and mapped-pointer constraints. Keep those buffer rules in BrainState; this reference owns their point-neuron integration.
|
|
23
|
+
|
|
24
|
+
The native fixture consumes an externally available event in its current update. In a recurrent network that first reads a previous completed source event, include that availability offset when interpreting latency. Record source emission, buffer input, conductance onset, and voltage response separately. Do not shift a tap to hide an unexplained one-step discrepancy.
|
|
25
|
+
|
|
26
|
+
Use integer grid taps for binary events. Off-grid interpolation, arbitrary per-edge delays, and mapped heterogeneous pointer State require separate verification. Separate delayed NEST connections are already checked, but that result does not validate this native buffer path or restore old delayed-prefetch/projection APIs.
|
|
27
|
+
|
|
28
|
+
Open `references/native-projections.md` for conductance and current order, and `references/nest-compatible/network-building.md` for NEST delay/lifecycle control.
|
|
29
|
+
|
|
30
|
+
Open `references/nest-delay-boundaries.md` for the separately tested NEST vector delay, matrix grouping, fractional current transmission, and explicit-spec failures.
|
|
31
|
+
|
|
32
|
+
## Sources
|
|
33
|
+
|
|
34
|
+
- [BrainState delay protocol](https://brainx.chaobrain.com/brainstate/tutorials/brain_dynamics/02_synaptic_delays.html)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Build a native conductance network
|
|
2
|
+
|
|
3
|
+
A chemical connection maps completed source events into a temporal synaptic state, converts that state into physical target current, and deposits the current before the target integrates. Preserve these four roles even when no projection wrapper class is available.
|
|
4
|
+
|
|
5
|
+
## Compose the four roles
|
|
6
|
+
|
|
7
|
+
| API | Use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `brainevent.BinaryArray(events) @ weights` | Map fixed binary source events to target conductance increments; the example uses small dense wiring. |
|
|
10
|
+
| `ExponentialConductance` in `scripts/native_workflows.py` | Decay a target-aligned linear trace and add the current increment; allocate one state value per target. |
|
|
11
|
+
| `g * (E - V_post)` | Convert a nonnegative conductance into signed current using the old target voltage and channel reversal. |
|
|
12
|
+
| `LIF(current)` in `scripts/native_workflows.py` | Advance the target exactly once after all incoming currents are assembled. |
|
|
13
|
+
|
|
14
|
+
Run the complete canonical example from this skill root:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python scripts/native_ei_network.py
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`EINetwork` registers separate excitatory/inhibitory point populations and two postsynaptic conductance filters. It snapshots both populations' previous events and voltages, communicates all source events, filters both receptor contributions, computes their currents, then advances both populations. The small dense Bernoulli wiring allows autapses; remove the corresponding diagonal entries explicitly when the scientific design forbids them. Filters own `N_exc+N_inh` values each rather than one value per edge. The returned monitors expose conductance, signed current, voltage, and binary events.
|
|
21
|
+
|
|
22
|
+
The fixture uses positive excitatory and inhibitory conductance magnitudes. Excitation has reversal `0 mV`; inhibition has reversal `-80 mV`. Inhibitory current is negative only while target voltage is above that reversal. Do not encode inhibition by making a conductance negative. For a current-based network, use a current-valued filter/weight contract; do not change only the unit of this conductance filter. The NEST COBA/CUBA alternative is `references/nest-compatible/scripts/brette_et_al_2007.py`.
|
|
23
|
+
|
|
24
|
+
## Preserve the alignment conditions
|
|
25
|
+
|
|
26
|
+
Target-aligned reduction is exact for a linear exponential filter when all merged inputs to that filter share its time constant and output contract. Use separate filters for distinct reversal potentials or kinetics. Do not merge nonlinear receptors or heterogeneous edge histories merely to reduce memory.
|
|
27
|
+
|
|
28
|
+
Source-aligned sharing requires identical outgoing kinetics for each shared source trace. Connection-specific nonlinear dynamics may require per-edge State. Treat old AlignPre/AlignPost descriptors as retired APIs; derive State placement from the equations and verify equivalence before implementing an advanced composition.
|
|
29
|
+
|
|
30
|
+
Open `references/nonlinear-state-sharing.md` before reusing nonlinear source traces; it contains the homogeneous edge-reference comparison and explicit counterexamples to invalid aggregation.
|
|
31
|
+
|
|
32
|
+
## Verify before scaling
|
|
33
|
+
|
|
34
|
+
The Docker checks inject known previous-step events and verify conductance increments, current signs, and target voltage on the same update, then check exponential decay and independent reset. The short E/I rollout checks finite traces and nonzero activity. It is a mechanics fixture using a custom Euler LIF without an absolute refractory period; it does not reproduce the old COBA benchmark or claim a calibrated network regime.
|
|
35
|
+
|
|
36
|
+
When porting an existing COBA model, replay the same edge, weight, initial voltage, and drive arrays in both implementations. Compare post-update conductance and voltage on the same clock step under separate subthreshold E and I impulses. Then drive an isolated neuron through consecutive spikes: a subthreshold match cannot check the reset phase or the refractory boundary. In the BrainPy 2.9.0 `LIFRef` soft-reset path, the spike is visible on the threshold-crossing step and reset appears on the next update; probe the exact refractory endpoint on the port's time grid. When matching exponential Euler, include the COBA conductance in the voltage slope if the baseline integrates its voltage dependence within the step. Recheck these behaviors in the pinned runtime before comparing recurrent population statistics.
|
|
37
|
+
|
|
38
|
+
Open `references/native-delays.md` before adding transmission history. Open `references/model-and-readout-selection.md` before choosing physiology or temporal readout. Open `brainevent` → `references/sparse-formats.md` when scaling beyond the small dense connectivity fixture.
|
|
39
|
+
|
|
40
|
+
## Sources
|
|
41
|
+
|
|
42
|
+
- [BrainSpike neuron contract](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Neuron.html)
|
|
43
|
+
- [BrainSpike synapse contract](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Synapse.html)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Train a native BrainSpike network
|
|
2
|
+
|
|
3
|
+
Use this path for a native graph built from public `brainspike.Neuron` and BrainState Modules. For direct NEST Simulator continuous-voltage fitting, open `references/simulator-training.md`. That path is separately verified and does not pass a Simulator graph to this learner.
|
|
4
|
+
|
|
5
|
+
Open `references/braintools/data-preprocessing.md` for encoded input axes and `references/braintools/parameter-initializer.md` for reproducible initial weights.
|
|
6
|
+
|
|
7
|
+
## Choose the temporal gradient
|
|
8
|
+
|
|
9
|
+
| API | Use |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `brainstate.transform.grad(loss, params, return_value=True)` | Use for BPTT through the complete native rollout; select only `ParamState` and reset hidden State inside the loss. |
|
|
12
|
+
| `braintrace.nn.Linear` | Use for trainable projections and readouts that must participate in eligibility-trace compilation. |
|
|
13
|
+
| `braintrace.compile(model, braintrace.pp_prop, example_step, batch_size=..., decay_or_rank=0.9)` | Use for factorized online traces; compile one representative step and inspect the report before training. |
|
|
14
|
+
| `learner.etrace_grad(..., step_fn=..., reduction="mean", return_value=True)` | Advance every sequence step and accumulate the declared gradient reduction; update parameters after the sequence. |
|
|
15
|
+
| `learner.reset_state(batch_size=...)` | Reset eligibility State alongside the native graph at every independent sequence boundary. |
|
|
16
|
+
| `braintools.optim.Adam(...).register_trainable_weights(params)` | Register the same parameter collection used for differentiation, then update it with matching gradients. |
|
|
17
|
+
|
|
18
|
+
Open `scripts/train_native_snn.py` and run `python scripts/train_native_snn.py --estimator bptt` or `--estimator pp-prop` from this skill root. Both modes use the same recurrent spike model and trained readout. BPTT compiles the reset-gradient-update step; pp-prop resets model and eligibility State, drives every step, and applies one update per sequence. Keep time-major inputs and preserve the batch axis in compiled learner resets.
|
|
19
|
+
|
|
20
|
+
A readout that never feeds hidden State can be trainable without receiving a temporal trace. The expected compiler warning for that path does not mean the recurrent projection failed; inspect `report.etrace_weights` and require zero report errors.
|
|
21
|
+
|
|
22
|
+
Open `references/temporal-task-training.md` for the complete batched report-window task, cue ablation, and ordinary/checkpointed BPTT parity. Open `references/model-and-readout-selection.md` when choosing an instantaneous or leaky readout.
|
|
23
|
+
|
|
24
|
+
## Verify temporal learning
|
|
25
|
+
|
|
26
|
+
Require finite nonzero gradients for both the recurrent projection and readout, actual parameter changes, and decreasing fixed-fixture loss. Compare pp-prop with BPTT on a reduced matched model, but do not assume estimator equality. Surrogate gradients are deliberately not finite-difference derivatives of hard threshold spikes.
|
|
27
|
+
|
|
28
|
+
The Docker regression fixture separately checks the recurrent and readout updates, compiler participation, online gradients, and a matched BPTT gradient direction. Its small synthetic target validates mechanics; it does not demonstrate held-out cognitive performance or long-memory accuracy.
|
|
29
|
+
|
|
30
|
+
Open `braintrace` → `references/pp_pprop workflow.md` for estimator and memory constraints. Open `references/braintools/optimizer.md`, `references/braintools/metric.md`, or `references/braintools/surrogate.md` when choosing the corresponding infrastructure.
|
|
31
|
+
|
|
32
|
+
## Official contracts
|
|
33
|
+
|
|
34
|
+
- [BrainSpike Neuron surrogate interface](https://brainx.chaobrain.com/brainspike/apis/generated/brainspike.Neuron.html)
|
|
35
|
+
- [BrainTrace pp-prop](https://brainx.chaobrain.com/braintrace/tutorials/pp_prop.html)
|
|
36
|
+
- [BrainTrace online SNN workflow](https://brainx.chaobrain.com/braintrace/tutorials/snn_online_learning.html)
|
package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md
RENAMED
|
@@ -22,11 +22,11 @@ Use these constructors when the device must inject a current rather than deliver
|
|
|
22
22
|
|
|
23
23
|
| Constructor | Use when |
|
|
24
24
|
|---|---|
|
|
25
|
-
| `sim.create(
|
|
26
|
-
| `sim.create(
|
|
27
|
-
| `sim.create(
|
|
28
|
-
| `sim.create(
|
|
29
|
-
| `sim.create(
|
|
25
|
+
| `sim.create(brainspike.dc_generator, size=1, params=parameters)` | Use a constant current over a `start`/`stop` window. |
|
|
26
|
+
| `sim.create(brainspike.ac_generator, size=1, params=parameters)` | Use a sinusoidal current. |
|
|
27
|
+
| `sim.create(brainspike.noise_generator, size=1, params=parameters)` | Use Gaussian white-noise current with independent target realizations. |
|
|
28
|
+
| `sim.create(brainspike.step_current_generator, size=1, params=parameters)` | Use a piecewise-constant current schedule. |
|
|
29
|
+
| `sim.create(brainspike.step_rate_generator, size=1, params=parameters)` | Use a piecewise-constant rate schedule. |
|
|
30
30
|
|
|
31
31
|
Current generators inject through the target's current ring buffer. Do not treat them as weighted spike-event sources.
|
|
32
32
|
|
|
@@ -36,9 +36,9 @@ Use these constructors for explicit spike schedules, supplied trains, or spike d
|
|
|
36
36
|
|
|
37
37
|
| Constructor | Use when |
|
|
38
38
|
|---|---|
|
|
39
|
-
| `sim.create(
|
|
40
|
-
| `sim.create(
|
|
41
|
-
| `sim.create(
|
|
39
|
+
| `sim.create(brainspike.spike_generator, size=1, params=parameters)` | Use explicit `spike_times`. |
|
|
40
|
+
| `sim.create(brainspike.spike_train_injector, size=1, params=parameters)` | Use a supplied spike train as an event source. |
|
|
41
|
+
| `sim.create(brainspike.spike_dilutor, size=1, params=parameters)` | Use NEST-compatible spike dilution. |
|
|
42
42
|
|
|
43
43
|
## Poisson generators
|
|
44
44
|
|
|
@@ -46,10 +46,10 @@ Use these constructors when spike times follow a constant, precise, scheduled, o
|
|
|
46
46
|
|
|
47
47
|
| Constructor | Use when |
|
|
48
48
|
|---|---|
|
|
49
|
-
| `sim.create(
|
|
50
|
-
| `sim.create(
|
|
51
|
-
| `sim.create(
|
|
52
|
-
| `sim.create(
|
|
49
|
+
| `sim.create(brainspike.poisson_generator, size=1, params=parameters)` | Use a constant-rate Poisson train over a configured window. |
|
|
50
|
+
| `sim.create(brainspike.poisson_generator_ps, size=1, params=parameters)` | Use precise-time Poisson spikes with dead time. |
|
|
51
|
+
| `sim.create(brainspike.inhomogeneous_poisson_generator, size=1, params=parameters)` | Use a time-varying Poisson schedule. |
|
|
52
|
+
| `sim.create(brainspike.sinusoidal_poisson_generator, size=1, params=parameters)` | Use a sinusoidally modulated Poisson rate. |
|
|
53
53
|
|
|
54
54
|
## Other generators
|
|
55
55
|
|
|
@@ -57,11 +57,11 @@ Use these constructors for gamma-process, correlated, dead-time, or pulse-packet
|
|
|
57
57
|
|
|
58
58
|
| Constructor | Use when |
|
|
59
59
|
|---|---|
|
|
60
|
-
| `sim.create(
|
|
61
|
-
| `sim.create(
|
|
62
|
-
| `sim.create(
|
|
63
|
-
| `sim.create(
|
|
64
|
-
| `sim.create(
|
|
60
|
+
| `sim.create(brainspike.gamma_sup_generator, size=1, params=parameters)` | Use a superposition of independent gamma processes. |
|
|
61
|
+
| `sim.create(brainspike.sinusoidal_gamma_generator, size=1, params=parameters)` | Use a sinusoidally modulated gamma source. |
|
|
62
|
+
| `sim.create(brainspike.mip_generator, size=1, params=parameters)` | Use correlated trains from a multiple-interaction process. |
|
|
63
|
+
| `sim.create(brainspike.ppd_sup_generator, size=1, params=parameters)` | Use a superposition of Poisson processes with dead time. |
|
|
64
|
+
| `sim.create(brainspike.pulsepacket_generator, size=1, params=parameters)` | Use a Gaussian pulse packet. |
|
|
65
65
|
|
|
66
66
|
A generator fans out to one independent train per target neuron. For a multi-channel generator, pass one signed connection weight per channel.
|
|
67
67
|
|
|
@@ -71,9 +71,9 @@ Use these constructors to capture spikes, named analog State, or per-edge plasti
|
|
|
71
71
|
|
|
72
72
|
| Constructor | Use when |
|
|
73
73
|
|---|---|
|
|
74
|
-
| `sim.create(
|
|
75
|
-
| `sim.create(
|
|
76
|
-
| `sim.create(
|
|
74
|
+
| `sim.create(brainspike.spike_recorder, size=1)` | Use to record emitted spikes, event counts, or mean population rate. |
|
|
75
|
+
| `sim.create(brainspike.multimeter, size=1, record_from=recordables, interval=interval)` | Use to sample named analog recordables such as `V_m`. |
|
|
76
|
+
| `sim.create(brainspike.weight_recorder, size=1, params=parameters)` | Use the NEST-compatible weight-recorder device. |
|
|
77
77
|
|
|
78
78
|
## Recorder readback
|
|
79
79
|
|
|
@@ -95,10 +95,10 @@ Use these constructors to compute correlation or binary-State statistics from re
|
|
|
95
95
|
|
|
96
96
|
| Constructor | Use when |
|
|
97
97
|
|---|---|
|
|
98
|
-
| `sim.create(
|
|
99
|
-
| `sim.create(
|
|
100
|
-
| `sim.create(
|
|
101
|
-
| `sim.create(
|
|
98
|
+
| `sim.create(brainspike.correlation_detector, size=1, params=parameters)` | Use pairwise correlation statistics. |
|
|
99
|
+
| `sim.create(brainspike.correlomatrix_detector, size=1, params=parameters)` | Use a correlation matrix. |
|
|
100
|
+
| `sim.create(brainspike.correlospinmatrix_detector, size=1, params=parameters)` | Use spin-based correlation matrices. |
|
|
101
|
+
| `sim.create(brainspike.spin_detector, size=1, params=parameters)` | Use binary-State decoding from spikes. |
|
|
102
102
|
|
|
103
103
|
Obtain spike data before driving a detector that uses NumPy randomness or a Python host loop; do not force imperative detector logic into the compiled simulation loop.
|
|
104
104
|
|
|
@@ -108,7 +108,7 @@ Use this constructor when dopamine-modulated plasticity needs one shared broadca
|
|
|
108
108
|
|
|
109
109
|
| Constructor | Use when |
|
|
110
110
|
|---|---|
|
|
111
|
-
| `sim.create(
|
|
111
|
+
| `sim.create(brainspike.volume_transmitter, size=1, params=parameters)` | Use to broadcast dopamine State to `stdp_dopamine_synapse`. |
|
|
112
112
|
|
|
113
113
|
## Device direction
|
|
114
114
|
|
|
@@ -123,13 +123,13 @@ Use device role to determine the `connect()` direction.
|
|
|
123
123
|
|
|
124
124
|
```python
|
|
125
125
|
import brainunit as u
|
|
126
|
-
|
|
126
|
+
import brainspike
|
|
127
127
|
|
|
128
|
-
sim =
|
|
129
|
-
neuron = sim.create(
|
|
130
|
-
drive = sim.create(
|
|
131
|
-
spike_recorder = sim.create(
|
|
132
|
-
meter = sim.create(
|
|
128
|
+
sim = brainspike.Simulator(dt=0.1 * u.ms)
|
|
129
|
+
neuron = sim.create(brainspike.iaf_psc_exp, 1)
|
|
130
|
+
drive = sim.create(brainspike.poisson_generator, rate=8000.0 * u.Hz, rng_seed=0)
|
|
131
|
+
spike_recorder = sim.create(brainspike.spike_recorder)
|
|
132
|
+
meter = sim.create(brainspike.multimeter, record_from=["V_m"], interval=0.1 * u.ms)
|
|
133
133
|
|
|
134
134
|
sim.connect(drive, neuron, weight=10.0 * u.pA, delay=1.0 * u.ms)
|
|
135
135
|
sim.connect(neuron, spike_recorder)
|
|
@@ -153,5 +153,5 @@ voltage = result.trace(meter, "V_m")
|
|
|
153
153
|
|
|
154
154
|
## Official sources
|
|
155
155
|
|
|
156
|
-
- https://brainx.chaobrain.com/
|
|
157
|
-
- https://brainx.chaobrain.com/
|
|
156
|
+
- https://brainx.chaobrain.com/brainspike/nest-style/devices.html
|
|
157
|
+
- https://brainx.chaobrain.com/brainspike/apis/nest-devices.html
|
|
@@ -6,7 +6,7 @@ Use this reference when porting NEST code, locating plasticity parameters, expla
|
|
|
6
6
|
|
|
7
7
|
| Divergence | Porting decision | Failure prevented |
|
|
8
8
|
|---|---|---|
|
|
9
|
-
| Learning State location | Move NEST neuron-owned learning parameters to the
|
|
9
|
+
| Learning State location | Move NEST neuron-owned learning parameters to the BrainSpike synapse spec or broadcast node where documented. | Setting a recognized name on the wrong object and silently changing the learning rule. |
|
|
10
10
|
| Parameter-location maps | Check each STDP or Clopath parameter rather than assuming all parameters move together. | Moving voltage-filter State that must remain on the neuron. |
|
|
11
11
|
| Online versus deferred updates | Compare at the documented event times and use the documented numerical band. | Reporting a known timing residual as an implementation failure. |
|
|
12
12
|
| Device and recording conventions | Preserve analog observer direction, current-versus-spike source semantics, and in-memory readback. | Empty recordings, one-step misalignment, or unsupported file output. |
|
|
@@ -14,9 +14,9 @@ Use this reference when porting NEST code, locating plasticity parameters, expla
|
|
|
14
14
|
|
|
15
15
|
## STDP parameter placement
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
BrainSpike evaluates plasticity kernels every time step on an event-driven substrate. It keeps presynaptic and postsynaptic traces on the plasticity side so rules can run without a NEST archiving-capable postsynaptic neuron.
|
|
18
18
|
|
|
19
|
-
| Parameter or State | NEST location |
|
|
19
|
+
| Parameter or State | NEST location | BrainSpike location |
|
|
20
20
|
|---|---|---|
|
|
21
21
|
| `tau_minus` for trace-based STDP | Postsynaptic archiving neuron | Synapse spec |
|
|
22
22
|
| `tau_minus_triplet` | Postsynaptic archiving neuron | `stdp_triplet_synapse` spec |
|
|
@@ -29,7 +29,7 @@ BrainPy-State evaluates plasticity kernels every time step on an event-driven su
|
|
|
29
29
|
|
|
30
30
|
```python
|
|
31
31
|
# Port tau_minus from the NEST postsynaptic neuron to the synapse spec.
|
|
32
|
-
plasticity =
|
|
32
|
+
plasticity = brainspike.stdp_synapse(
|
|
33
33
|
tau_plus=20.0 * u.ms,
|
|
34
34
|
tau_minus=20.0 * u.ms,
|
|
35
35
|
)
|
|
@@ -43,10 +43,10 @@ Use these constructors when the port requires a specific nearest-neighbour or ha
|
|
|
43
43
|
|
|
44
44
|
| Constructor | Use when |
|
|
45
45
|
|---|---|
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
46
|
+
| `brainspike.stdp_nn_symm_synapse(*args, **kwargs)` | Use when each spike must pair only with the nearest preceding spike on the opposite side. |
|
|
47
|
+
| `brainspike.stdp_nn_restr_synapse(*args, **kwargs)` | Use symmetric nearest-neighbour pairing with a one-pairing-per-spike availability restriction. |
|
|
48
|
+
| `brainspike.stdp_nn_pre_centered_synapse(*args, **kwargs)` | Use when a postsynaptic spike must consume all presynaptic spikes accumulated since the preceding postsynaptic spike, while a presynaptic spike pairs with the nearest preceding postsynaptic spike. |
|
|
49
|
+
| `brainspike.stdp_facetshw_synapse_hom(*args, **kwargs)` | Use when causal and acausal charge must accumulate before quantized LUT readout on the configured cycle. |
|
|
50
50
|
|
|
51
51
|
Do not replace one nearest-neighbour variant with another because their class names look similar; the pairing convention changes the weight trajectory.
|
|
52
52
|
|
|
@@ -56,9 +56,9 @@ The direction and ordering of each effect remain exact; only the documented magn
|
|
|
56
56
|
|
|
57
57
|
| Rule or behavior | Cause | Accepted result |
|
|
58
58
|
|---|---|---|
|
|
59
|
-
| Clopath online LTP |
|
|
60
|
-
| Dopamine-modulated STDP |
|
|
61
|
-
| Nearest-neighbour phantom pre at `t=0` | NEST initializes the first send time at zero;
|
|
59
|
+
| Clopath online LTP | BrainSpike reads online with an intrinsic one-step lag; NEST reads a delayed analog ring buffer and defers the history sum. | Use `delay_u_bars=0.1 ms` for parity and accept the documented `<= 5%` band; the NEST `4.0 ms` default is not reproduced online. |
|
|
60
|
+
| Dopamine-modulated STDP | BrainSpike integrates every step; NEST integrates lazily at send/update time. | Accept the documented approximately `0.2%` band while requiring exact direction and ordering. |
|
|
61
|
+
| Nearest-neighbour phantom pre at `t=0` | NEST initializes the first send time at zero; BrainSpike represents that no real presynaptic spike has occurred. | Do not require the phantom facilitation for `stdp_nn_symm_synapse` or `stdp_nn_restr_synapse`. |
|
|
62
62
|
|
|
63
63
|
For ordinary online-versus-deferred pair STDP, compare weights at presynaptic send times, where the operations coincide.
|
|
64
64
|
|
|
@@ -96,7 +96,7 @@ Validation categories describe how parity is asserted. They are related to, but
|
|
|
96
96
|
Run the live-NEST harness when the package source and NEST are available:
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
python -m pytest
|
|
99
|
+
python -m pytest brainspike/_nest_validation/ -m requires_nest -q
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
Tests marked `requires_nest` skip when NEST cannot be imported; harness unit tests still run without NEST.
|
|
@@ -109,6 +109,6 @@ Tests marked `requires_nest` skip when NEST cannot be imported; harness unit tes
|
|
|
109
109
|
|
|
110
110
|
## Official sources
|
|
111
111
|
|
|
112
|
-
- https://brainx.chaobrain.com/
|
|
113
|
-
- https://brainx.chaobrain.com/
|
|
114
|
-
- https://brainx.chaobrain.com/
|
|
112
|
+
- https://brainx.chaobrain.com/brainspike/nest-style/divergences/index.html
|
|
113
|
+
- https://brainx.chaobrain.com/brainspike/nest-style/validation-status.html
|
|
114
|
+
- https://brainx.chaobrain.com/brainspike/nest-style/divergences/stdp.html
|