# fangwei123456/spikingjelly architecture

> Architecture diagram of the GitHub repository fangwei123456/spikingjelly, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fangwei123456/spikingjelly
- Repository: https://github.com/fangwei123456/spikingjelly

## Overview

SpikingJelly is a PyTorch-native framework for modeling, training, and deploying spiking neural networks. A typical user builds a network from neuron, layer, and surrogate-gradient components, supplies event-based data, and trains or converts the model; analysis and visualization support inspection. The repository also provides accelerated kernels, memory and distributed execution, precision controls, pretrained model architectures, and hardware/framework exchange. Relationships below follow the README and the shown source references; unsampled subsystem internals are represented at their exact directory paths, without assuming unshown call chains.

Main entry points: [`spikingjelly/activation_based/neuron`](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/neuron) (Neuron Modules), [`spikingjelly/datasets`](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/datasets) (Event Datasets), [`spikingjelly/activation_based/base.py`](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/base.py) (Stateful Runtime), [`spikingjelly/activation_based/surrogate.py`](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/surrogate.py) (Surrogate Gradients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["SNN Modeling"]
  node_neurons["Neuron Modules"]
  node_state["Stateful Runtime<br/>[base.py]"]
  node_surrogate["Surrogate Gradients<br/>[surrogate.py]"]
  node_layers["SNN Layers"]
  node_models["Predefined Models"]
end

subgraph group_workflow["Training Workflows"]
  node_ann2snn["ANN Conversion"]
  node_functional["Functional Utilities"]
end

subgraph group_scale["Performance and Scale"]
  node_cuda["CUDA Backend"]
  node_triton["Triton Backend"]
  node_memopt["Memory Optimization"]
  node_distributed["Distributed Execution"]
  node_precision["Precision Control"]
end

subgraph group_data["Data and Analysis"]
  node_datasets["Event Datasets"]
  node_encoding["Spike Encoding<br/>[encoding.py]"]
  node_visualizing["Visualization"]
  node_opcounter["Cost Analysis"]
end

subgraph group_deploy["Exchange and Deployment"]
  node_nir["NIR Exchange"]
  node_lava["Lava Exchange<br/>[lava_exchange.py]"]
  node_lynxi["Lynxi Exchange<br/>[lynxi_exchange.py]"]
end

node_user(("SNN Engineer"))

node_user -->|"assembles"| node_neurons
node_user -->|"assembles"| node_layers
node_user -->|"selects gradients"| node_surrogate
node_neurons -->|"uses state base"| node_state
node_user -->|"loads events"| node_datasets
node_datasets -->|"provides samples"| node_user
node_user -->|"converts ANN"| node_ann2snn
node_user -->|"runs training utilities"| node_functional
node_user -->|"chooses architecture"| node_models
node_user -.->|"encodes inputs"| node_encoding
node_user -.->|"inspects activity"| node_visualizing
node_user -->|"profiles cost"| node_opcounter
node_neurons -->|"accelerates execution"| node_cuda
node_neurons -->|"accelerates execution"| node_triton
node_user -->|"reduces memory"| node_memopt
node_user -->|"scales execution"| node_distributed
node_user -->|"sets precision policy"| node_precision
node_user -->|"exports model"| node_nir
node_user -->|"exports model"| node_lava
node_user -->|"deploys model"| node_lynxi

click node_neurons "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/neuron"
click node_state "https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/base.py"
click node_surrogate "https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/surrogate.py"
click node_layers "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/layer"
click node_models "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/model"
click node_ann2snn "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/ann2snn"
click node_functional "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/functional"
click node_datasets "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/datasets"
click node_encoding "https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/encoding.py"
click node_visualizing "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/visualizing"
click node_opcounter "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/op_counter"
click node_cuda "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/cuda_kernel"
click node_triton "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/triton_kernel"
click node_memopt "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/memopt"
click node_distributed "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/distributed"
click node_precision "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/precision"
click node_nir "https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/nir_exchange"
click node_lava "https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/lava_exchange.py"
click node_lynxi "https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/lynxi_exchange.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_neurons,node_state,node_surrogate,node_layers,node_models toneBlue
class node_ann2snn,node_functional toneAmber
class node_cuda,node_triton,node_memopt,node_distributed,node_precision toneMint
class node_datasets,node_encoding,node_visualizing,node_opcounter toneRose
class node_nir,node_lava,node_lynxi,node_user toneIndigo
```

## Components

### SNN Modeling

- [Neuron Modules](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/neuron): `spikingjelly/activation_based/neuron`
- [Stateful Runtime](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/base.py): `spikingjelly/activation_based/base.py`
- [Surrogate Gradients](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/surrogate.py): `spikingjelly/activation_based/surrogate.py`
- [SNN Layers](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/layer): `spikingjelly/activation_based/layer`
- [Predefined Models](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/model): `spikingjelly/activation_based/model`

### Training Workflows

- [ANN Conversion](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/ann2snn): `spikingjelly/activation_based/ann2snn`
- [Functional Utilities](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/functional): `spikingjelly/activation_based/functional`

### Performance and Scale

- [CUDA Backend](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/cuda_kernel): `spikingjelly/activation_based/cuda_kernel`
- [Triton Backend](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/triton_kernel): `spikingjelly/activation_based/triton_kernel`
- [Memory Optimization](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/memopt): `spikingjelly/activation_based/memopt`
- [Distributed Execution](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/distributed): `spikingjelly/activation_based/distributed`
- [Precision Control](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/precision): `spikingjelly/activation_based/precision`

### Data and Analysis

- [Event Datasets](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/datasets): `spikingjelly/datasets`
- [Spike Encoding](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/encoding.py): `spikingjelly/activation_based/encoding.py`
- [Visualization](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/visualizing): `spikingjelly/visualizing`
- [Cost Analysis](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/op_counter): `spikingjelly/activation_based/op_counter`

### Exchange and Deployment

- [NIR Exchange](https://github.com/fangwei123456/spikingjelly/tree/master/spikingjelly/activation_based/nir_exchange): `spikingjelly/activation_based/nir_exchange`
- [Lava Exchange](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/lava_exchange.py): `spikingjelly/activation_based/lava_exchange.py`
- [Lynxi Exchange](https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/lynxi_exchange.py): `spikingjelly/activation_based/lynxi_exchange.py`

### Other components

- **SNN Engineer**

## Connections

- SNN Engineer → Neuron Modules: assembles (evidence: `README.md`)
- SNN Engineer → SNN Layers: assembles (evidence: `README.md`)
- SNN Engineer → Surrogate Gradients: selects gradients (evidence: `README.md`)
- Neuron Modules → Stateful Runtime: uses state base (evidence: `spikingjelly/activation_based/neuron/integrate_and_fire.py`)
- SNN Engineer → Event Datasets: loads events (evidence: `README.md`)
- Event Datasets → SNN Engineer: provides samples (evidence: `spikingjelly/datasets/base.py`)
- SNN Engineer → ANN Conversion: converts ANN (evidence: `README.md`)
- SNN Engineer → Functional Utilities: runs training utilities (evidence: `README.md`)
- SNN Engineer → Predefined Models: chooses architecture (evidence: `README.md`)
- SNN Engineer → Spike Encoding: encodes inputs
- SNN Engineer → Visualization: inspects activity
- SNN Engineer → Cost Analysis: profiles cost (evidence: `README.md`)
- Neuron Modules → CUDA Backend: accelerates execution (evidence: `README.md`)
- Neuron Modules → Triton Backend: accelerates execution (evidence: `README.md`)
- SNN Engineer → Memory Optimization: reduces memory (evidence: `README.md`)
- SNN Engineer → Distributed Execution: scales execution (evidence: `README.md`)
- SNN Engineer → Precision Control: sets precision policy (evidence: `README.md`)
- SNN Engineer → NIR Exchange: exports model (evidence: `README.md`)
- SNN Engineer → Lava Exchange: exports model (evidence: `README.md`)
- SNN Engineer → Lynxi Exchange: deploys model (evidence: `README.md`)
