Skip to content

4 Sparse Maps and Channel Routing

Raul Cardenas Montoya edited this page Sep 19, 2026 · 1 revision

Sparse Maps and Channel Routing

Relevant source files

The following files were used as context for generating this wiki page:

The sparse maps and channel routing subsystem provides an optional, self-contained routing fabric and memory-efficient Compressed Sparse Row (CSR) storage utilities. While the core runtime orchestrator (SynapticMesh) handles dense mesh propagation and axonal delay ring buffers, the optional router (ChannelRouter) and sparse matrix utilities (SparseSynapticMap) allow applications to dynamically route signals across channels and scale network topologies without prohibitive VRAM overhead.

For details, see the child pages:

Sources: src/router.rs:1-16, src/sparse.rs:3-18


ChannelRouter and RouterConfig

The ChannelRouter implementation in src/router.rs provides a domain-agnostic spiking neural network router. It integrates signal pulses across a bank of internal neuromodulatory units (NeuromodNeuron) to produce a sparse routing mask. The behavior and bounds of the router are governed by RouterConfig, which validates channel counts up to MAX_ROUTER_CHANNELS and execution timesteps up to MAX_ROUTING_TIMESTEPS src/router.rs:27-40, src/router.rs:121-140.

The routing pipeline supports standard signal routing via route as well as modulated execution via route_modulated, incorporating fatigue, lateral inhibition through signed cross-weights, and dynamic gain adaptation src/router.rs:121-178.

For details, see ChannelRouter and RouterConfig.

Diagram: Router Architecture and Pipeline

graph TD
    RC["RouterConfig"] --> CR["ChannelRouter"]
    CR --> NN["NeuromodNeuron"]
    CR --> RT["route / route_modulated"]
    RT --> MASK["Routing Mask Output"]

    subclassDef default fill:none,stroke:#000,stroke-width:1px;
Loading

Sources: src/router.rs:27-140

Sources: src/router.rs:5-40, src/router.rs:121-140


Neuromodulation and Plasticity

Neuromodulation in the routing subsystem is driven by NeuromodState and integration neurons that respond to global neuromodulatory levels such as dopamine, cortisol, and serotonin. These modulators alter effective membrane thresholds, leak rates, and synaptic weights dynamically.

The subsystem implements use-it-or-lose-it plasticity, where inactive channels experience weight decay towards a baseline, while active channels undergo dopamine-gated potentiation. Feedback mechanisms allow external systems to reinforce or inhibit specific channel pathways src/router.rs:8-11, src/router.rs:173-178.

For details, see Neuromodulation and Plasticity.

Diagram: Neuromodulation Mapping to Code Entities

graph TD
    NS["NeuromodState"] -->|Modulates| NN["NeuromodNeuron"]
    NN -->|Integrates Stimulus| INT["integrate()"]
    INT -->|Fires| FIRE["check_fire()"]
    FIRE -->|Applies Feedback| FB["apply_feedback()"]

    subclassDef default fill:none,stroke:#000,stroke-width:1px;
Loading

Sources: src/router.rs:48-119

Sources: src/router.rs:8-11, src/router.rs:40-120


SparseSynapticMap (CSR)

To support networks exceeding standard dense matrix constraints, src/sparse.rs implements SparseSynapticMap<N>. Storing synaptic weights in Compressed Sparse Row (CSR) format reduces VRAM consumption significantly (e.g., a 20× reduction for large sparse configurations) by maintaining row_ptr, col_indices, and values vectors rather than a dense $N \times N$ array src/sparse.rs:3-54.

The module offers builders like try_from_dense and try_from_adjacency, weight pruning utilities, out-of-bounds safety checks, and target address validation bounded by MAX_SPARSE_NEURONS src/sparse.rs:23-162.

For details, see SparseSynapticMap (CSR).

Diagram: CSR Storage Structure

graph TD
    SSM["SparseSynapticMap"] --> RP["row_ptr Vec:usize"]
    SSM --> CI["col_indices Vec:u16"]
    SSM --> VAL["values Vec:f32"]
    SSM --> BUILD["try_from_dense / try_from_adjacency"]

    subclassDef default fill:none,stroke:#000,stroke-width:1px;
Loading

Sources: src/sparse.rs:35-162

Sources: src/sparse.rs:3-54

Clone this wiki locally