Verace Neocortex: Rust port
A Rust reimplementation of a cortical column language model with local learning rules, a wake and sleep lifecycle and a morphological tokenizer.
- Top-down context: Workspace broadcast plus the prediction from above
- Windowed Hebbian association: Replaces self-attention over a backward window of 16
- Lateral links: Low-rank messages between neighbouring columns
- L5 dendritic SwiGLU: Replaces the feedforward block, gated by dendrites
Overview
The Rust port of Verace Neocortex reimplements the lab's cortical column network, research name NCT V11, in Rust on the candle tensor library, together with a separate Rust crate for its tokenizer. Its question is whether each component of a transformer can be replaced by a brain-modelled counterpart that learns locally and continuously. The technical reference states three exclusions: no query, key and value attention, no global backpropagation through columns, and no frozen deployment. Windowed Hebbian association replaces self-attention, and an L5 SwiGLU layer with dendritic gates replaces the feedforward block. Grid-cell encoding replaces rotary position, and predictive coding with Hebbian and neuromodulated plasticity replaces Adam.
Tokens pass through a four-stage embedding cascade, gain 0.1 times a grid-cell position signal, and are routed by a thalamus into a stack of cortical columns. Each column is a six-layer circuit that returns an output, a top-down prediction of the level below, thalamic feedback and a learned precision . After the first pass, columns exchange lateral messages, compete for a global workspace and re-run in a predictive coding inference loop until the relative error change falls below 1%. A brainstem then computes four neuromodulators, and basal ganglia, cerebellum, hippocampus and a lexical-competition output head follow. An autonomous loop cycles through wake, sleep, dream, consolidate and evaluate.
The crate defines configuration presets of about 106M parameters (d 512, 12 columns), 300M and 1B. A training binary runs a prenatal development phase of 500 default steps, then memory-mapped training with local updates, a delta-rule correction of the output head, sleep cycles, curiosity prompts and self-repair rollback. A converter maps Python V11 checkpoints to safetensors, and diagnostics stream to CSV and Weights & Biases. The smoke test builds the default model, runs random tokens at batch 1 and length 32, and checks shapes and finite losses. The evaluation binary computes perplexity and three column diagnostics, but on random placeholder tokens.
Status: the network, its local learning rules, the autonomous loop, the tokenizer and the data pipeline are implemented in Rust and pass a smoke test. No training run, perplexity or other measured result is recorded for this port. The validation runner is a placeholder that returns defaults, and text generation in the evaluation binary is a stub. The AdamW wrapper stores a gradient-norm limit without applying it. Elastic weight consolidation is coded but disabled by default. The AutoScale decision rules and split plans are coded, but no scaling event is recorded. Whether the design learns language at all remains unmeasured.
Status
Prototype. The Rust crates implement the full forward pass, local learning and training loop and pass a smoke test, but no training run or evaluation result is recorded, and the validation and evaluation code use placeholders.
Simulator
A made-up signal jumps a few times. A running prediction follows it, and a gate passes the prediction error upwards only when it is large for the precision it is given.
- signal (white) and prediction (colour), synthetic data
- prediction error: passed upwards (colour) or held (faint)
- Steps passed upwards
- 27%
- Gate stays open after a jump for
- 10.0 steps
- Mean size of the error
- 0.33
- Jumps in the signal
- 4
Raise the precision and small errors pass as well. Lower the learning rate and the prediction takes longer to catch up after a jump.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Cortical column
The replacement for a transformer block: L4 input, L1 top-down input, SST and VIP inhibition, L2/3 settling, working memory, oscillations, a PV output veto, L5 output and L6 feedback. It returns an output, a prediction, thalamic feedback and .
L2/3 windowed Hebbian association
The attention replacement. It recalls context over a backward window of 16 positions at cost , uses anti-Hebbian lateral inhibition, and keeps 15% of activations through k-winners-take-all.
Four-stage brain embedding
Token lookup is followed by a dual-route morpheme composition gate, a hub-and-spoke projection with 6 spokes, and a sparse distributed projection that keeps the top 2% of an expanded code. A learnable grid-cell position signal is added at the end.
Thalamus with TRN gating
Relay groups add a gated MLP update to the input, modulated by L6 feedback. A reticular-nucleus relevance gate is trained toward binary open or closed decisions.
Global workspace and lateral links
Columns write candidates to a shared workspace weighted by a softmax over their surprise, and read the result back as top-down context. Neighbouring columns also exchange low-rank lateral messages.
Brainstem neuromodulators
Computes dopamine, noradrenaline, serotonin and acetylcholine as sigmoid projections of the normed state, with dopamine boosted by prediction-error magnitude. Their product scales every local learning rate.
Basal ganglia and cerebellum
The basal ganglia apply competing D1 and D2 dopamine pathways to the hidden state. The cerebellum predicts the next state from the current one and adds a gated error correction, with its loss weighted 0.01.
Hippocampus
An episodic store with a dentate gyrus, CA3 and CA1 path that keeps surprising experiences above a threshold of 0.1, replays them in proportion to surprise, and consolidates them by k-means clustering.
BrainLMHead
The output head: a tied projection plus a low-rank production term, followed by lateral competition among similar words after the WEAVER++ model of word production.
Autonomous loop
A state machine of wake, sleep, dream, consolidate and evaluate states that accumulates sleep pressure, schedules curiosity prompts and self-play, and adjusts its own schedule from loss trends.
AutoScale and self-repair
In the V11 Rust crate, every 10K steps, AutoScale rules kill, merge or split columns from gate means, and cosine similarity. A repair routine rolls back to the best checkpoint when weights or loss diverge.
Dual-route tokenizer
A lossless tokenizer crate that maps known words to single tokens, splits novel words into morpheme tokens by rule-based affix stripping, and falls back to bytes.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Precision-weighted predictive coding update
- Each column predicts the column below. The target is the embeddings for the first column and the previous column's output otherwise. The weight update is , scaled by plasticity, and is learned through softplus with the chain rule. The error is averaged over the feature dimension rather than summed, to keep from diverging.
- Predictive coding inference loop
- Without gradients, all columns are re-run for up to
pc_max_stepsplus conflict extras. At each step the top-down context is the workspace broadcast plus the lateral message plus the prediction from column . The loop stops after the minimum number of steps once the relative error change is below 1%. - Windowed Hebbian associative recall
- Each position computes , with initialised to identity. A context term weights values over by , normalised by the sum of the weights. There is no query-key softmax and no causal mask, because the backward window enforces causality.
- Hebbian and anti-Hebbian decorrelation
- The feedforward weights grow with input correlation . The lateral weights track and are subtracted, pushing the output covariance toward identity, a principal-subspace code. A binary mask prunes weights that stay below
prune_thresholdand regrows 5% of pruned weights at 0.01 when prediction error is high. - BCM threshold and metaplasticity
- The sliding threshold follows , initialised at 1.0, and the Hebbian rule is . An EMA of weight-change magnitude with sets the multiplier . The Hebbian rate is further scaled by , so uncertain columns learn faster, and error modulation enters with weight 0.5.
- Neuromodulated plasticity gate
- The lab's Theorem C sets plasticity to , where is the serotonin level. The product is returned per position or averaged to a scalar learning-rate multiplier. The neuromodulator projections themselves learn by correlation with error magnitude, uncertainty, inverse error and error stability, without autograd.
- Identity-at-init gated residual
- Every submodule adds to its input, with raw gate initialised to , giving about 0.12, and output projections initialised to zero. The network therefore starts close to a residual identity, and each mechanism switches on only as its gate learns.
- k-WTA by binary-search threshold
- To keep the top
k_ratiofraction of each row, the code runs 15 iterations of binary search over the row's range, counting elements at or above the midpoint, then masks below the threshold. The mechanism is used in L2/3, in the L5 feedforward layer and in the sparse embedding stage. - L5 precision head and dendritic SwiGLU
- Precision is , with the bias set so that starts at
sigma2_init; the prediction weights start at zero. The SwiGLU output is gated by sigmoids of basal and apical dendritic inputs, both with bias 3.0, about 95% open, and bias adjustments are clamped to . - Grid-cell position encoding
- Position is , with frequencies drawn at random and phases initialised to zero. The head scale starts at 0.5 and the boundary gate at , and the result is tiled or padded to the model width.
- Nested oscillation coupling
- Gamma amplitude is . Periods are softplus parameters initialised at 8, 20 and 64 tokens for theta, alpha and delta. The amplitude scales a low-rank modulation added through a sigmoid gate.
- Three-timescale working memory
- Four NMDA attractor slots update as , with decay about 0.9975 per token, a memory of about 277 tokens. A Tsodyks-Markram trace tracks facilitation and resources and releases . An 8-slot phonological loop decays by about 0.982 per token and amplifies its most recent slot.
- TRN bimodal relay gating
- Relevance is , interpolated toward 1 by a learned gate. The auxiliary loss pushes each gate toward a binary decision.
- D1 and D2 dopamine competition
- Each pathway's receptor activation is with its own slope and threshold. The modulation, D1 MLP times its activation minus D2 MLP times its activation, is added through a sigmoid gate, so an inverted-U dependence on dopamine emerges.
- Surprise-driven sleep pressure
- Pressure accumulates as , and wake efficiency is . The learning rate is base rate times times efficiency, and pressure resets to zero after sleep.
- Three-phase sleep consolidation
- Phase 1 is generative replay at 0.5 times the Hebbian rate. Phase 2 is contrastive: noise negatives with std 0.1 are depressed and real patterns potentiated at 0.15 times the rate. Phase 2.5 trains on hippocampal centroids through BCM at 0.3 times, and phase 3 multiplies by 0.99, excluding protected state parameters.
- Episodic consolidation by k-means
- Hippocampal storage is gated by precision-weighted surprise times a learned write probability, and replay samples in proportion to surprise. Consolidation clusters episodes by k-means, about 4 per cluster over 10 iterations, into semantic centroids, then evicts the oldest 75%.
- Analytic delta-rule head update
- The output head is corrected without backpropagation by , chained through its low-rank factors. Negative targets are masked, each gradient norm is clipped to 1.0, and chunks of 256 bound peak memory. In training the rate is
pc_learning_lrtimes 100, because the per-token error is of order . - Drift-diffusion token decoding
- Evidence accumulates over logits with noise against the threshold , with twice the total steps. The step count is for conflict , and an inhibition-of-return trace subtracted from the logits penalises recent tokens.
- Net2Net split and AutoScale rules
- The AutoScale rules in the V11 Rust crate kill a column when its gate is below 0.05, merge columns when cosine similarity exceeds 0.95, and split a column when and its gate exceeds 0.8. A further rule of that crate's autoscale module locates the capacity bottleneck by depth band, splitting shallow and middle columns for local capacity and growing fresh deep columns for discourse integration. A split sets and , so the daughters' outputs sum to the original.
- Self-repair rollback
- The training loop tracks the best loss and rolls back to the best checkpoint when any column norm exceeds 200 or loss stays above twice the best for more than 100 steps. Norms above 50 are scaled down to 50, and a rollback halves the sleep interval.
- Critical-period developmental schedule
- Training is split into sensory (below 1K steps), association (below 5K), integration (below 20K) and refinement stages. Across these stages the learning-rate multiplier runs 2, 1.5, 1 and 0.5, inhibition 0.3, 0.6, 0.9 and 1.0, and Hebbian weight 0.8, 0.6, 0.4 and 0.3.
Results
From the lab's own experiments and records. They have not been independently replicated.
Smoke test passes on the default preset
The test suite builds the default model, forwards random tokens at batch 1 and length 32, and verifies output shapes, finite next-token and predictive coding losses, column and prediction counts, and finite multi-scale . It does not measure learning.
Averaging the error keeps precision stable
The predictive coding code averages the error over the feature dimension rather than summing it, recording that the sum makes diverge.
Weight consolidation is disabled by default
The lab's records state that the elastic weight consolidation guard runs out of memory on 6GB GPUs, so it ships switched off.
Output head rate scaled by 100
The delta-rule correction of the output head uses 100 times the predictive coding rate, because the per-token error is of order and would otherwise be too small.
Evaluation runs on placeholder data
The evaluation binary computes perplexity, PCC, COL_DIFF and GATE_EVO, but feeds random placeholder tokens, and its generation path is a stub. No evaluation figures are recorded.
Validation runner is not yet implemented
The validation code defines metrics including validation loss and the ratio between validation and training data, but its run function returns default values.
Gradient clipping limit stored but unused
The AdamW wrapper for the hybrid mode keeps a
max_grad_normvalue that its step function does not apply.Two inhibition-of-return settings coexist
One decoding path uses a trace with strength 0.5 and decay 0.95, while another uses a time constant of 25 and strength 2.0, shortened by acetylcholine and noradrenaline.
Consolidation description and hippocampus code disagree
The lab's description of the consolidation manager gives k-means clustering with k = 8 followed by deletion of the consolidated episodes. The hippocampus code instead clusters about 4 episodes per cluster over 10 iterations and then evicts the oldest 75%.
Concepts
- Predictive coding
- A learning scheme in which each level predicts the activity of the level below and learns only from its own local prediction error. The lab's records cite the result that such updates match backpropagation at convergence (Whittington and Bogacz 2017).
- Precision
- The learned variance that each column attaches to its prediction. Errors are divided by it, so uncertain predictions produce smaller updates. It also drives decisions elsewhere in the system.
- Multi-scale precision bands
- Per-column is grouped by depth into token, phrase, sentence and discourse bands, each a quarter of the columns. Sentence precision gates hippocampal storage and discourse precision drives curiosity.
- Hebbian learning
- Weight change driven by the correlation of input and output activity, with no error signal propagated from elsewhere. Anti-Hebbian learning does the reverse and decorrelates outputs.
- BCM rule
- A Hebbian rule with a sliding threshold set by recent mean squared activity. Activity above the threshold strengthens weights and activity below weakens them, which prevents runaway growth.
- k-winners-take-all
- A sparsity operation that keeps only the largest fraction of activations in a row and zeroes the rest. It models lateral inhibition between neurons.
- Identity-at-init principle
- Every new module starts as a no-op through zero output weights and a small gate, so the network begins as a plain residual path and mechanisms switch on gradually as their gates learn.
- Neuromodulatory gating
- In the lab's framing, dopamine decides whether to learn, acetylcholine what to learn, noradrenaline how broadly and serotonin on what timescale. Their product scales all local learning.
- Learning modes
- The configuration offers four modes: Hybrid (the default), PredictiveCoding, Hebbian and Backprop. They differ in which update rules run and how far backpropagation reaches.
- Wake-sleep scheduling
- Learning alternates between wake phases of local updates and sleep phases of replay, dreaming, consolidation and synaptic downscaling by 0.99 per phase, after Tononi's 2006 synaptic homeostasis hypothesis.
- Complementary learning systems
- The idea, cited from McClelland 1995, that a fast episodic store and a slow cortical learner work together: episodes are captured quickly and later transferred to cortex through consolidation.
- Global workspace
- Baars' 1988 theory, used here as columns competing by surprise for a shared broadcast that every column then reads back as context.
- Drift-diffusion model
- Ratcliff's 1978 model of decisions as noisy evidence accumulating toward a threshold. Here it selects output tokens, with noise set by uncertainty and the threshold set by dopamine.
- Active inference curiosity
- Inputs are scored by
curiosity_weighttimes discourse plus 0.5 times prediction error, after Friston 2010. High-surprise memories are then recombined into self-generated training prompts. - Net2Net splitting
- A function-preserving way to grow a network: a trained column is split into two daughters whose outputs initially sum to the original. Competitive Hebbian learning later differentiates them.
- µP transfer
- Hyperparameter transfer across width after Yang and Hu 2021. Learning rates, gates and BCM time constants stay fixed while dimensions scale, giving the path from the 106M default (12 columns, d 512) to 300M (16, 768) and 1B (20, 1280).
- Prenatal development
- A pre-data phase in which the network self-organises on synthetic inputs. Its fractions of the phase are spontaneous waves 0.30, motor babbling 0.25, competitive differentiation 0.25 and oscillatory calibration 0.20.
- Elastic weight consolidation
- A penalty weighted by Fisher information that protects important weights from forgetting (Kirkpatrick 2017). The configuration default is .
- Dual-route tokenization
- After Coltheart's DRC model of reading, known whole words take a lexical route to single tokens and novel words take a sublexical route into morphemes. Capitalisation is moved into marker tokens so the vocabulary stays case-free.
- NCT1 token format
- The dataset format: a 4-byte magic string, a little-endian vocabulary size and a reserved field, then contiguous 32-bit token IDs. Batches are drawn as a pure function of the step for reproducibility across Python and Rust.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.