Bit-exact MoonBit port of SpikingNeuralNetworks.jl, extended with modern training machinery. NEURONS AND PLASTICITY: IF, AdEx, Izhikevich (IZ), HH, MorrisLecar, Poisson (including InhomogeneousPoisson), WilsonCowan; Markram STP, Gerstner / MexicanHat / AntiSymmetric / vSTDP / Confavreux2025 STDP; AMPA / NMDA / GABAa / GABAb receptors; multicompartment dendritic neurons (BallAndStick, Tripod, Multipod); IF with population synaptic conductance; spike-time and current stimuli. CORE DL: Tensor struct with broadcasting + softmax / log-softmax / cross-entropy, Conv2d / MaxPool2d / GlobalAvgPool2d / ReLU / Flatten / Linear forward AND backward, ResNet foundations, generic Chain / Sequential, pre-made MLP / SimpleCNN / LeLen5 bottles, image adapter (BMP/QOI/TGA/PNG/GIF/JPEG/ICO/TIFF) via riantr/moonbit_image, 5D [T,B,C,H,W] STImage. OPTIMIZERS AND SCHEDULING: SGD, SGD-with-momentum, Adam with bias correction, AdamW, RMSprop, AdaGrad, Adafactor; StepLR, ExponentialLR, CosineAnnealingLR, ReduceLROnPlateau; BatchNorm2d with running stats and LayerNorm per-sample, both with backward. SURROGATE GRADIENTS AND ATTENTION: fast-sigmoid (Zenke & Ganguli 2018) for BPTT through IF/LIF Heaviside; GELU, exact sparse GELU via libm erff; multi-head self-attention with mask utilities; sinusoidal and learnable positional encoding; Pre-Norm transformer block; inverted dropout; SAttention unifying three spiking attention variants; LayerScale; T5-style relative position bias; SpikingMultiHeadAttention with full BPTT backward; SpikeFormer demo. RL: SequenceReplayBuffer for recurrent RL, DDPG, TD3, SAC, GRU/LSTM/GTrXL recurrent actors and critics, Decision Transformer, Trajectory Transformer with beam search. META-LEARNING AND CAUSAL: MAML, FOMAML, Reptile, TaskSampler; LinearGaussianSCM, DoCalculus, CounterfactualReasoning, CausalEffectEstimator. GENERATIVE: RealNVP / Glow / NormalizingFlow, VAE, IWAE, ELBO, DDPM diffusion, EnergyBasedModel with Langevin sampling, DCGAN, WGAN-GP. OTHER: Vision Transformer with trainer, EmbeddingNet / SiameseNet / SiameseTrainer, CapsuleNetwork. GRAPH NEURAL NETWORKS: Graph with COO edge list and GCN adjacency normalisation; GCN, MPNN, GIN, PNA, GAT (multi-head), Set2Set readout, EdgeGNN, H2GCN, GraphClassifier -- and FULL BACKWARD PASSES for all of them, dispatched behind a single TrainableGraphNet enum, with node-level and graph-level training steps.
| Packages | 23 |
| Library source files | 299 (*.mbt in the library packages, not mbt/tests/) |
| Library lines | ~62,700 |
| Largest package | rl (~15,000 lines), then synapse (~8,000) |
| Tests | 1925 across nine waves |
| Examples | 77 |
# Tests
cd moonbit-snn/mbt
moon test
# chain.jl example
moon run examples/chain/main.mbtmbt/
|-- moon.mod # module riantr/snn_mbt, version 0.166.2
|-- moon.pkg # root manifest: imports only, no source
|-- README.md
|
|-- core/ # Time, Xoshiro RNG, units, libm bindings
|-- `- ported 3/5 # time/units/util from SNNModels.jl
|-- neuron/ # IF, AdEx, Izhikevich, HH, MorrisLecar,
|-- `- ported 19/21 # Poisson, Wilson-Cowan, dendrites
|-- synapse/ # connections, receptors, plasticity (~7.7k)
|-- `- ported 26/34
|-- stimulus/ # Poisson / spike-time / current stimuli
|-- `- ported 9/10
|-- analysis/ # spike-train statistics and measures
|-- `- ported 10/13
|-- infra/ # sim, serialisation, parity, datasets
|-- `- ported 6/20
|
|-- nn/ # Tensor, Linear, Conv2d, norms, backwards
|-- `- ported 1/16 # structs_extra from SNNModels.jl
|-- optim/ # SGD, Adam, AdamW, RMSprop, AdaGrad,
|-- `- original # Adafactor, LR schedules
|-- activ/ # activations, pooling, elementwise ops
|-- `- original
|-- attention/ # MHA, SAttention, position encodings
|-- `- original
|-- autodiff/ # reverse-mode autodiff over a tape
|-- `- original
|-- gpu/ # single-precision BLAS seam
|-- `- original # ffi/gemm/loader .mbt + cuda/
|
|-- rl/ # DDPG, TD3, SAC, recurrent actors (~14.6k)
|-- `- original
|-- gnn/ # message passing, GCN/GIN/PNA/GAT (~6.5k)
|-- `- original
|-- generative/ # flows, VAE, DDPM, GAN, EBM
|-- `- original
|-- meta/ # MAML, FOMAML, Reptile, neural ODEs
|-- `- original
|-- causal/ # SCM, do-calculus, counterfactuals
|-- `- original
|-- capsule/ # CapsNet, dynamic routing
|-- `- original
|-- models/ # LeNet5, MLP, SimpleCNN, ViT, Siamese
|-- `- original
|-- timeseries/ # AR / ARIMA, Holt-Winters
|-- `- original
|-- tarnet/ # TARNet speaker ID: conv, ASP, SE, log-Mel
|-- `- original # (port of arXiv:2605.07735, see below)
|
|-- fuzz_props/ # property checks the QA loop drives
|-- gpu_selftest/ # known-answer checks for the BLAS fallback
|-- testdata/ # fixtures
|-- examples/ # 77 runnable examples, one per model
`-- tests/wave1 ... wave9 # 247 test files, split by domain| Upstream | Vendored at | Ported into |
|---|---|---|
| SpikingNeuralNetworks.jl v1.0.0 | SpikingNeuralNetworks.jl/ | neuron/, synapse/, analysis/, stimulus/, infra/ |
| SNNModels.jl | refs/SNNModels.jl/ | core/ (Time, units, util), nn/structs_extra.mbt |
| SNNUtils.jl v0.2.0 | refs/SNNUtils.jl/ | infra/sim.mbt, infra/compose.mbt, infra/population.mbt, infra/bimodal_kernel.mbt |
| Area | Work | Source |
|---|---|---|
| tarnet/ | TARNet speaker identification | Terraf & Iraqi, TARNet: A Temporal-Aware Multi-Scale Architecture for Closed-Set Speaker Identification, arXiv:2605.07735; upstream implementation github.com/YassinTERRAF/CAT-Net |
| tarnet/tarnet_se.mbt | CTSE, the multi-scale channel-time gate | part of the same work |
| neuron/, attention/ | surrogate gradient for the Heaviside derivative | Zenke & Ganguli 2018 |
| attention/ | SAttention, spike-driven attention | Zenke & Ganguli 2018 |
| nn/ | ResNet foundations | He et al. 2015 |
| attention/ | multi-head self-attention, positional encodings | Vaswani et al. 2017 |
| attention/ | Vision Transformer | Dosovitskiy et al. 2020 |
| rl/ | PPO, DDPG, TD3, SAC | Mnih; Lillicrap; Fujimoto; Silver |
| rl/ | Decision Transformer, GTrXL | Chen et al. 2021 |
| gnn/ | message-passing interface, GCN, GAT, PNA, H2GCN, Set2Set | Gilmer et al. 2017; Hamilton; Velickovic; Battaglia; Lee et al. |
| generative/ | RealNVP, Glow, VAE/IWAE, DDPM, EBM, WGAN-GP | Dinh et al.; Kingma & Welling; Ho et al.; Arjovsky et al. |
| meta/ | MAML, FOMAML, Reptile | Finn et al. 2017; Nichol et al. 2018 |
| causal/ | SCMs, do-calculus, counterfactuals | Pearl; Spirtes et al.; Robins |
| capsule/ | CapsNet and dynamic routing | Hinton et al. 2017; Sabour et al. 2017 |
| models/ | Siamese embedding and contrastive loss | Bromley et al. 2015 |
| optim/ | AdamW, Adafactor | Loshchilov & Hinton 2019; Shazeer & Stern 2018 |
| timeseries/ | AR/ARIMA, Holt-Winters | Box & Jenkins; Hamilton |
| Example | Network size | Population scales | Bit-exact? | Notes |
|---|---|---|---|---|
| chain.jl | 3 IF | unchanged | ✓ | tiny; rates bit-exact |
| if_neuron.jl | 1 IF | unchanged | ✗ (1 s vs 10 s) | Knuth Poisson slow at high rates |
| if_net.jl | 32E + 8I | 100× ↓ | ✗ | original is 3200+800 |
| ei_inhibition.jl | 5 + 5 IF | unchanged | ✓ | tiny; inhibition observable |
| cuba_net.jl | 80E + 20I | 100× → | ✅ | qualitative: drive on→fire, drive off→silent |
| coba_net.jl | 80E + 20I | 100× ↓ | ✗ | delay_dist now implemented (v0.10.3); spike timing differs from Julia's true 0.8ms delay because our loop only checks delivery once per dt |
| potjans_diesmann.jl | 120E + 40I | 100× ↓ | ✗ | simplified to 4 layers |
| lkd2014.jl | 40E + 10I | 100× ↓ | ✗ | IF instead of AdExSinExpParameter |
| festa2024.jl | 80E + 20I | 10× ↓ | ✗ | structured inhibition + STDP |
| afferent_response.jl | 40E + 10I | 100× ↓ | ✗ | single ν_a (no sweep) |
| tsodyks.jl | 8 AdEx + 4 IF | unchanged | ✓ | scaled-down paradoxical-effect |
| hh_net.jl | 8E + 4I HH | unchanged | ✓ | tiny; HH gating dynamics |
Superseded. The root package can no longer host a test target at all, and no test lives there any more. Every *_test.mbt is in one of nine sub-packages under tests/, each an is-test package importing the library for "test", and CI runs all nine:moon test ./tests/waveN --target nativeThat is 1884 tests passing, against the 280 CI could reach before. A guard in publish.yml now fails the build if a *_test.mbt reappears in the root, because such a file would be dead rather than red. See tools/split_tests/README.md.
& ".\verify\verify_gnn_grads.ps1" # gradient gate
& ".\verify\run_gnn_train_demo.ps1" # end-to-end training demoInstall
Download zipBit-exact MoonBit port of SpikingNeuralNetworks.jl, extended with modern training machinery. NEURONS AND PLASTICITY: IF, AdEx, Izhikevich (IZ), HH, MorrisLecar, Poisson (including InhomogeneousPoisson), WilsonCowan; Markram STP, Gerstner / MexicanHat / AntiSymmetric / vSTDP / Confavreux2025 STDP; AMPA / NMDA / GABAa / GABAb receptors; multicompartment dendritic neurons (BallAndStick, Tripod, Multipod); IF with population synaptic conductance; spike-time and current stimuli. CORE DL: Tensor struct with broadcasting + softmax / log-softmax / cross-entropy, Conv2d / MaxPool2d / GlobalAvgPool2d / ReLU / Flatten / Linear forward AND backward, ResNet foundations, generic Chain / Sequential, pre-made MLP / SimpleCNN / LeLen5 bottles, image adapter (BMP/QOI/TGA/PNG/GIF/JPEG/ICO/TIFF) via riantr/moonbit_image, 5D [T,B,C,H,W] STImage. OPTIMIZERS AND SCHEDULING: SGD, SGD-with-momentum, Adam with bias correction, AdamW, RMSprop, AdaGrad, Adafactor; StepLR, ExponentialLR, CosineAnnealingLR, ReduceLROnPlateau; BatchNorm2d with running stats and LayerNorm per-sample, both with backward. SURROGATE GRADIENTS AND ATTENTION: fast-sigmoid (Zenke & Ganguli 2018) for BPTT through IF/LIF Heaviside; GELU, exact sparse GELU via libm erff; multi-head self-attention with mask utilities; sinusoidal and learnable positional encoding; Pre-Norm transformer block; inverted dropout; SAttention unifying three spiking attention variants; LayerScale; T5-style relative position bias; SpikingMultiHeadAttention with full BPTT backward; SpikeFormer demo. RL: SequenceReplayBuffer for recurrent RL, DDPG, TD3, SAC, GRU/LSTM/GTrXL recurrent actors and critics, Decision Transformer, Trajectory Transformer with beam search. META-LEARNING AND CAUSAL: MAML, FOMAML, Reptile, TaskSampler; LinearGaussianSCM, DoCalculus, CounterfactualReasoning, CausalEffectEstimator. GENERATIVE: RealNVP / Glow / NormalizingFlow, VAE, IWAE, ELBO, DDPM diffusion, EnergyBasedModel with Langevin sampling, DCGAN, WGAN-GP. OTHER: Vision Transformer with trainer, EmbeddingNet / SiameseNet / SiameseTrainer, CapsuleNetwork. GRAPH NEURAL NETWORKS: Graph with COO edge list and GCN adjacency normalisation; GCN, MPNN, GIN, PNA, GAT (multi-head), Set2Set readout, EdgeGNN, H2GCN, GraphClassifier -- and FULL BACKWARD PASSES for all of them, dispatched behind a single TrainableGraphNet enum, with node-level and graph-level training steps.