Skip to content
In depthPrototype

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.

Verace Research
  1. Top-down context: Workspace broadcast plus the prediction from above
  2. Windowed Hebbian association: Replaces self-attention over a backward window of 16
  3. Lateral links: Low-rank messages between neighbouring columns
  4. L5 dendritic SwiGLU: Replaces the feedforward block, gated by dendrites
Figure 1. Cortical columns replacing transformer blocks in the Rust port. Schematic: cortical columns of Verace Neocortex in cross-section, with the layers that stand in for a transformer block. The Rust port implements them and passes a smoke test, but no training result is recorded.
Open the simulator on its own pageA gate that passes only surprise: an interactive toy model of the principle. You can also try it below

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 σ2\sigma^2. 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

  1. 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 σ2\sigma^2.

  2. L2/3 windowed Hebbian association

    The attention replacement. It recalls context over a backward window of 16 positions at cost O(T⋅w⋅d)O(T \cdot w \cdot d), uses anti-Hebbian lateral inhibition, and keeps 15% of activations through k-winners-take-all.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. AutoScale and self-repair

    In the V11 Rust crate, every 10K steps, AutoScale rules kill, merge or split columns from gate means, σ2\sigma^2 and cosine similarity. A repair routine rolls back to the best checkpoint when weights or loss diverge.

  12. 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 ΔW=−ηεσ2h⊤/N\Delta W = -\eta \frac{\varepsilon}{\sigma^2} h^{\top} / N, scaled by plasticity, and σ2\sigma^2 is learned through softplus with the chain rule. The error is averaged over the feature dimension rather than summed, to keep σ2\sigma^2 from diverging.
Predictive coding inference loop
Without gradients, all columns are re-run for up to pc_max_steps plus conflict extras. At each step the top-down context is the workspace broadcast plus the lateral message plus the prediction from column i+1i+1. The loop stops after the minimum number of steps once the relative error change is below 1%.
Windowed Hebbian associative recall
Each position computes at=Wassocxta_t = W_{assoc} x_t, with WassocW_{assoc} initialised to identity. A context term weights values vjv_j over j∈[t−w,t]j \in [t-w, t] by softplus(wdist(xt−xj))\mathrm{softplus}(w_{dist}(x_t - x_j)), 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 X⊤X/NX^{\top}X/N. The lateral weights track Y⊤Y/N−IY^{\top}Y/N - I and are subtracted, pushing the output covariance toward identity, a principal-subspace code. A binary mask prunes weights that stay below prune_threshold and regrows 5% of pruned weights at 0.01 when prediction error is high.
BCM threshold and metaplasticity
The sliding threshold follows θ←(1−1/τ)θ+(1/τ) y2‾\theta \leftarrow (1 - 1/\tau)\theta + (1/\tau)\,\overline{y^2}, initialised at 1.0, and the Hebbian rule is Δw∝y(y−θ)x\Delta w \propto y(y - \theta)x. An EMA of weight-change magnitude with τ=500\tau = 500 sets the multiplier 1/(1+m)1/(1 + m). The Hebbian rate is further scaled by 1+min⁡(σ2,10)1 + \min(\sigma^2, 10), so uncertain columns learn faster, and error modulation enters with weight 0.5.
Neuromodulated plasticity gate
The lab's Theorem C sets plasticity to DA⋅ACh⋅(0.5+0.5 NE)⋅(0.5+0.5 s)\mathrm{DA} \cdot \mathrm{ACh} \cdot (0.5 + 0.5\,\mathrm{NE}) \cdot (0.5 + 0.5\,s), where ss 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 σ(g)f(x)\sigma(g) f(x) to its input, with raw gate gg initialised to −2-2, 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_ratio fraction 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 σ2=softplus(Wσh)+10−6\sigma^2 = \mathrm{softplus}(W_{\sigma} h) + 10^{-6}, with the bias set so that σ2\sigma^2 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 [−3,8][-3, 8].
Grid-cell position encoding
Position is pt=meanh σ(sh)sin⁡(2πt softplus(fh)+ϕh)p_t = \mathrm{mean}_h\, \sigma(s_h) \sin(2\pi t\, \mathrm{softplus}(f_h) + \phi_h), with frequencies drawn at random and phases initialised to zero. The head scale starts at 0.5 and the boundary gate at σ(−2)\sigma(-2), and the result is tiled or padded to the model width.
Nested oscillation coupling
Gamma amplitude is Aγ=1+tanh⁡(κ1)cos⁡ϕθ+tanh⁡(κ2)cos⁡ϕδ−tanh⁡(κ3)(1+cos⁡ϕα)/2A_{\gamma} = 1 + \tanh(\kappa_1)\cos\phi_{\theta} + \tanh(\kappa_2)\cos\phi_{\delta} - \tanh(\kappa_3)(1 + \cos\phi_{\alpha})/2. 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 S←σ(b)S+softmax(score(h))⊗WwritehS \leftarrow \sigma(b) S + \mathrm{softmax}(\mathrm{score}(h)) \otimes W_{write} h, with decay about 0.9975 per token, a memory of about 277 tokens. A Tsodyks-Markram trace tracks facilitation uu and resources xx and releases uxu x. An 8-slot phonological loop decays by about 0.982 per token and amplifies its most recent slot.
TRN bimodal relay gating
Relevance is r=σ(⟨Wqx,Wkδ⟩/dtrn)r = \sigma(\langle W_q x, W_k \delta \rangle / \sqrt{d_{trn}}), interpolated toward 1 by a learned gate. The auxiliary loss r(1−r)r(1 - r) pushes each gate toward a binary decision.
D1 and D2 dopamine competition
Each pathway's receptor activation is σ(k(DA−EC50))\sigma(k(\mathrm{DA} - \mathrm{EC}_{50})) 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 p←min⁡(1,p+(1−0.999)(1+min⁡(e,5)))p \leftarrow \min(1, p + (1 - 0.999)(1 + \min(e, 5))), and wake efficiency is max⁡(1−p,0.1)\max(1 - p, 0.1). The learning rate is base rate times (0.5+ACh)(0.5+NE)(0.5 + \mathrm{ACh})(0.5 + \mathrm{NE}) 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 WassocW_{assoc} 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 ∂L/∂W=(softmax(z)−y)⊤h/N\partial L / \partial W = (\mathrm{softmax}(z) - y)^{\top} h / N, 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_lr times 100, because the per-token error is of order 1/V1/V.
Drift-diffusion token decoding
Evidence accumulates over logits with noise 0.3(1+min⁡(σ2,5))0.3(1 + \min(\sigma^2, 5)) against the threshold θ=3(1−0.3min⁡(DA,1))e−n/τ\theta = 3(1 - 0.3\min(\mathrm{DA}, 1)) e^{-n/\tau}, with τ\tau twice the total steps. The step count is 1+min⁡(3c,15)1 + \min(3c, 15) for conflict cc, 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 σ2>5\sigma^2 > 5 and its gate exceeds 0.8. A further rule of that crate's autoscale module locates the capacity bottleneck by σ2\sigma^2 depth band, splitting shallow and middle columns for local capacity and growing fresh deep columns for discourse integration. A split sets Wa=12W+ξaW_a = \frac{1}{2}W + \xi_a and Wb=12W+ξbW_b = \frac{1}{2}W + \xi_b, 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.

  1. 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 σ2\sigma^2. It does not measure learning.

  2. 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 σ2\sigma^2 diverge.

  3. 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.

  4. 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 1/V1/V and would otherwise be too small.

  5. 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.

  6. Validation runner is not yet implemented

    The validation code defines metrics including validation loss and the σ2\sigma^2 ratio between validation and training data, but its run function returns default values.

  7. Gradient clipping limit stored but unused

    The AdamW wrapper for the hybrid mode keeps a max_grad_norm value that its step function does not apply.

  8. 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.

  9. 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 σ2\sigma^2 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 σ2\sigma^2 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_weight times discourse σ2\sigma^2 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 12λ∑iFi(θi−θi∗)2\frac{1}{2}\lambda \sum_i F_i(\theta_i - \theta_i^{*})^2 weighted by Fisher information that protects important weights from forgetting (Kirkpatrick 2017). The configuration default is λ=100\lambda = 100.
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.