Verace Neocortex: simulation and tools
A pure-NumPy cortical transformer, morphological tokenizer, synthetic cognitive datasets and an ODE simulator of NCT training dynamics.
- Stochastic resonance gate: Stayed near 0.117 and never opened
- Training steps: Gates began opening around step 1700
- Tripartite ACh gate: Opened first and was the strongest, at 0.88
- Mechanism gate: Pushed open by utility, starts near 0.119
Overview
This part of Verace Neocortex holds the research tooling around the model, which the lab's papers and code call the NeuroCortex Transformer (NCT). It has five parts: a pure-NumPy implementation of the model with its own autograd engine, a dual-route morphological tokenizer, generators for a synthetic cognitive dataset, a simulation framework, and architecture diagram generators. The simulation framework models NCT V10.2 training as coupled ordinary differential equations. It addresses one question: whether the 24 biologically motivated mechanism gates open, stay stable and add value. It answers that question cheaply, without running full training.
The model chains predictive coding, a six-signal neuromodulator, oscillatory phase binding, cortical-column consensus, excitatory-inhibitory attention, Hebbian fast weights and a k-winners-take-all feed-forward layer inside each block. The simulator dynamics.py Euler-steps a scalar surrogate of training. It tracks the learning rate, MSE, the precision , the 24 gates, four neuromodulators, working memory, oscillations, the inhibitory triad and homeostasis, with noise added. Around it sit Latin hypercube Monte Carlo sampling with Spearman sensitivity, adaptive grid search, a what-if scenario engine and a paired-seed comparison of old and new algorithms.
The Run 13 research report covers about 500 or more simulations of a 49-theorem model with bounded in [0.3, 4.0]. In the lab's simulations, 200 Monte Carlo samples showed zero divergence and 16 of 24 gates opened at the default configuration. Ablating all 24 gates cost +0.21 NTP, and an aggressive recipe reached NTP 3.94 against 3.96 for the default. The StochasticResonance gate never opened. The lab's stochastic resonance analysis traced this to noise that did not depend on the signal, and it derived a signal-dependent replacement (Thm 48).
The NumPy model, autograd engine, optimizer, tokenizer, dataset generators and simulation framework are implemented. The training script runs on random token batches. No training run of the NumPy model is recorded in this part. Every measured figure comes from the scalar ODE surrogate, not from training the network. The five biophysical replacements and the stochastic resonance fix are derived analytically and simulated, and the analysis states that the fix was applied in the implementation. No measurement of its effect is recorded. The V11 local learning rules and the wake-sleep loop appear only in the architecture diagram generator, as design.
Status
Experiments. The code is implemented and the research report records Run 13 simulation results from the ODE surrogate. No training of the NumPy network is recorded.
Simulator
A gate rises from 0 to 1 around a threshold. Two hundred made-up inputs are passed through it: set how steep it is, where its threshold lies and how spread out the inputs are.
- the inputs (made up): those the gate passes in colour
- dashed: a hard step at the same threshold
- Inputs passed
- 48%
- Inputs left undecided
- 59%
- Width of the undecided band
- 1.46
- Mean output of the gate
- 0.48
Make the gate steeper and it tends to a hard step: fewer inputs are left undecided. Move the threshold through the inputs.
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
Pure-NumPy NCT model
NCTModelstacksNCTBlocklayers with tied embeddings.NCTConfigdefaults to d=512, L=12, 6 excitatory and 2 inhibitory heads, K=4 columns, P=4 phases and M=6 neuromodulatory signals.Autograd and nn library
tensor.pyis a reverse-mode autograd engine on NumPy.nn.pyaddsModule,Parameter, Xavier-initialisedLinear,Embedding,RMSNormand invertedDropout.GPT-like baseline
baseline.pyis a standard comparison model for TinyStories: pre-norm RMSNorm, RoPE, dense SwiGLU, all-excitatory attention and tied embeddings. Its defaults are d=128, L=6, H=8, d_ff=512 and V=50257.Dual-route morphological tokenizer
NCTTokenizermaps frequent whole words to single tokens, decomposes other words into morphemes and falls back to UTF-8 bytes. It adds case-marker tokens and saves and loads in an HF-compatible format.Cognitive dataset generators
Template generators produce synthetic documents for seven cognitive demand categories, including entity tracking, temporal ordering, inhibitory control, uncertainty calibration and multi-step reasoning. Each document carries metadata naming the NCT modules it targets.
ODE training-dynamics surrogate
NCTDynamicalSystemindynamics.pyEuler-steps scalar coupled subsystems of NCT V10.2 training. Noise is added so that the simulator can expose instabilities.Monte Carlo sensitivity engine
monte_carlo.pysamples parameter configurations by Latin hypercube, uniform or perturbation sampling and simulates each one. It reports Spearman sensitivities, the top configurations and 2D divergence maps.Parameter space registry
parameter_space.pydefines 33 tunable parameters with ranges, defaults, scale type, sensitivity tier and coupling class.Grid search and scenario engines
grid_search.pyruns one-at-a-time sweeps, pairwise grids and adaptive zoom refinement.scenarios.pyruns ablations, coupling studies, the phase diagram, the gate opening cascade, counterfactuals and scale predictions.Algorithm comparison and algebra
algorithmic_mathematics.pyderives and simulates five biophysical replacements.run_algorithm_comparison.pycompares the new and old versions over 100 paired-seed samples.Plotting and CLI
run.pydispatches the Monte Carlo, grid search, scenario, sensitivity and full pipelines.visualize.pydraws tornado plots, heatmaps, gate trajectories, ablation bars and stability maps.Architecture diagram generators
generate_unified.pyandgenerate_hybrid.pyemit Excalidraw JSON for the V11 architecture and for the hybrid continuous-training decision flow.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Interaction-coupled mechanism gate dynamics
- Each of the 24 gates receives a push , where is the critical period factor and the auxiliary fraction. The update is on
gate_raw, clipped to [-10, 10]. The cost is 0.01, or 1.0 for the disabled gates 5, 6 and 10, and each gate starts at . - Sigmoid-bounded Friston precision learning
- The log-precision is with , so that . With free energy , the gradient is , and moves by times the summed gradient. This drives toward MSE.
- Asymmetric sigma2 boundary penalty
- The KL term is , whose gradient is zero inside the free zone [0.3, 4.0]. It replaces an older symmetric pull toward . The code's sigmoid range (0.1, 5) is wider than the [0.3, 4.0] that the research report describes as bounded by construction.
- Astrocyte calcium transient detector
- Per layer, , and . This is the highpass filter with : steady gradients give a gain of 1, and the code cites De Pitta 2009 for the detector. It replaces a dual-EMA detector (0.03/0.002) whose gain was .
- D1/D2 dual-pathway Boltzmann modulation
- and with , using tonic dopamine. The modulation is and the output is . This replaces the symmetric curve.
- VIP to SST disinhibitory gating
- The disinhibition is , so that and the output is , where is the top-down correction. Both gates start at , which gives near-identity behaviour (about 0.944) at initialisation. VIP is applied before SST, following Pfeffer 2013.
- Baddeley phonological loop buffer
- K=8 slots decay by per token. Rehearsal adds about 0.27 times the attention weight times the readout. Writes are gated by importance with bias -2, which gives about a 12% write rate. The predicted capacity is about 5 items with 4-token rehearsal.
- Surprise-gated predictive coding
- The prediction error is , with surprise and gate , where
tau_initis 1.0. The output is , so predictable tokens are replaced by their prediction. The first layer uses a surprise of 1. - Six-signal neuromodulator
- An MLP from d to 256 to 6 reads the context . It outputs attention temperature (0.5 to 2.0), FFN sparsity (0.1 to 1.0), layer gate (0 to 1), residual scale (0.1 to 2.0), inhibition strength (0 to 1) and plasticity rate (0.001 to 0.1). The output bias starts at 0.
- Oscillatory phase-coherence binding
- Each token has a soft membership over P=4 phases. Each phase runs attention without RoPE, using the bias with the product floored at 1e-4. The phase outputs are weighted by and summed.
- Cortical column agreement consensus
- K=4 views of size d/K pass through one shared canonical circuit. Each column's agreement is its mean cosine similarity with the other columns, and the weights are . The mean pairwise cosine is fed back to the neuromodulator as confidence.
- Composite auxiliary loss
- The NTP cross-entropy is summed with weighted auxiliary terms. The predictive coding term is the MSE between each layer's prediction and the detached next-layer output. The other terms are and . A column diversity penalty on the squared cosine similarity of the column output projections is added with
lambda_div= 0.01. - Dynamic reverse-mode autograd
- Each operation computes its output and registers a closure that accumulates into the parents'
.grad, reducing gradients correctly under broadcasting.backward()walks the graph iteratively in reverse topological order. A global_NO_GRAD_DEPTHcounter disables graph building. - AdamW with warmup-cosine schedule
- AdamW uses betas 0.9/0.999, eps 1e-8 and weight decay 0.1, with bias correction and decoupled decay. The learning rate rises linearly over 2000 warmup steps, then decays along a cosine to 1e-5.
train.pyclips the global gradient norm to 1.0 and saves .npz checkpoints every 500 steps. - Latin hypercube sampling
- Each dimension of the parameter space receives exactly one sample per 1/n stratum. This gives better marginal coverage than uniform random sampling for the Monte Carlo runs.
- Spearman rank sensitivity
- Parameter importance is the rank correlation between sampled parameter values and outcome metrics. Pairs containing NaNs are dropped, and a parameter with fewer than 10 valid samples gets 0.
- Adaptive grid zoom refinement
- Each round is a full factorial grid with n points per dimension. The next round centres on the best result with its width multiplied by
zoom_factor0.3, clipped to the original bounds. - Ablation by utility zeroing
- A mechanism is ablated by setting its gate's base utility to 0 instead of forcing the gate closed. The gate then receives no loss benefit and is never pushed open.
- Paired-seed old/new algorithm comparison
- Both variants run with identical seeds, a common-random-numbers form of variance reduction. Only the five overridden subsystems differ, over 100 samples, and the report prints mean and standard deviation deltas.
- Scored greedy affix stripping
- Suffixes are tried longest first, and each candidate is scored as root quality times 1000 plus the root length if the root is known, or the suffix length otherwise. Stripping stops early at a known root, with
MAX_SUFFIXES=3,MAX_PREFIXES=2 andMIN_ROOT_LEN=3. A false-decomposition list and morphophonemic normalisation (runn to run, mak to make, happi to happy) refine the roots. - Difficulty-scaled entity curriculum
- A difficulty sets the number of entities to (3 to 8) and the gap to tokens (50 to 500). Templates then rescale the gap by with a floor of 30, and documents are wrapped to at least 1500 tokens.
- Tokenizer vocabulary build
build_vocab.pybuilds the vocabulary from WikiText-103 with options max_roots 8000, max_whole_words 5000 and minimum frequencies 5/3. It tests losslessness against GPT-2 BPE and retokenises the corpus into int32 .bin files. Ids 0 to 5 are special tokens, followed by 256 byte tokens.
Results
From the lab's own experiments and records. They have not been independently replicated.
Zero divergence across the parameter space
In the Run 13 simulations, 200 Monte Carlo samples across the full parameter space showed zero divergence.
16 of 24 gates open at default
The research report records 16 of 24 gates opening reliably: 4 closed by design (utility 0) and 4 weak. TripartiteAChGate opened first, at step 1688, and was the strongest at 0.88.
Precision converges slowly under tighter bounds
In the simulations, approached the MSE more slowly with the [0.3, 4.0] bounds. The ratio was 2.22 at 7.5K steps and 1.34 at 50K.
Default trajectory over 7500 steps
Simulated NTP fell from 10.000 to 4.108 by step 500 and reached 4.027 at step 7500. Gates began opening around step 1700, and tonic dopamine dropped from 0.50 to 0.21, which the report reads as a shift from exploration to exploitation (Thm 47).
Ablating all gates costs 0.21 NTP
The scenario engine found that ablating all 24 gates raised NTP by 0.21. The NMDA slots and the phonological loop were the most essential.
Working memory and inhibitory equilibria
The NMDA level filled to 26%, the silent trace to 24% and the phonological loop to 3%. The inhibitory triad settled at SST 0.65, VIP 0.68, Apical 0.41 and Chandelier 0.11.
Aggressive recipe is the best counterfactual
lr=6e-4, gate_mult=30 and clip=3.5 gave NTP 3.94 against 3.96 for the default and opened 20 gates, according to the simulation records.
Critical periods close near step 5500
The report records critical periods closing by about step 5500, at a factor of 0.10.
Stochastic resonance gate never opens
Across training runs 9, 10, 11, 12 and 13, the StochasticResonance gate stayed near 0.117, and in simulation it was the only gate that never opened. The lab's analysis attributed this to noise that did not depend on the signal and derived a signal-dependent replacement. Its effect has not been measured.
Concepts
- Mechanism gates
- Each of the 24 biologically motivated mechanisms is scaled by a learned gate that starts near 0.119. The gate opens only when the mechanism lowers the loss more than it costs.
- Scalar ODE surrogate
- Instead of training the network, the simulator represents each subsystem by a few scalar state variables and integrates their coupled equations with Euler steps. This makes hundreds of runs cheap.
- NTP loss
- The next-token prediction cross-entropy, the main training loss the simulator tracks alongside MSE and .
- Friston sigma2 precision
- is the learned variance of the prediction error, so its inverse is the precision. Minimising drives toward the MSE.
- Sigmoid-bounded sigma2 (Thm 28g)
- The Run 13 configuration bounds in [0.3, 4.0], which the research report states holds by construction.
- Stochastic resonance
- Adding noise lets a subthreshold signal cross a nonlinear threshold more often, which improves detection. Gammaitoni et al. 1998 name three required ingredients: a threshold, a subthreshold signal and noise matched to the gap between them.
- Uniform noise gives no learning signal
- The old module computed with . The lab's analysis shows that near a smooth minimum , so gradient descent removes the noise and the gate closes.
- Kramers escape argument
- Citing Gerstner et al., Neuronal Dynamics, the analysis gives the escape rate as with , and the optimal noise as about . The analysis argues that noise on subthreshold dimensions raises the chance of crossing the threshold and lowers the expected loss.
- Signal-dependent stochastic resonance (Thm 48)
- The proposed fix scales the noise by a subthreshold indicator instead of applying it uniformly. The analysis derives that the gate gradient then favours opening.
- Tsodyks-Markram activity-silent trace (Thm 35)
- A two-variable facilitation and depression trace replaces the additive working-memory trace. It is self-limiting and has stable eigenvalues.
- Baddeley phonological loop (Thm 36)
- A slot buffer with decay, content-addressable read, rehearsal and selective write. It replaces a blind cyclic write.
- D1/D2 inverted-U (Thm 37)
- Two sigmoid receptor curves with EC50 0.65 and 0.25 give an asymmetric inverted-U response to dopamine. The model follows Durstewitz and Seamans 2008.
- VIP-SST disinhibitory motif (Thm 38/46)
- VIP interneurons read the top-down correction and reduce SST suppression of it, giving a monotonic, bounded transfer function. The motif follows Pfeffer et al. 2013 on inhibition of inhibition.
- Astrocyte transient detection (Thm 12)
- A calcium highpass detector reacts to the rate of change of gradient norms and rejects their constant level. It replaces a dual-EMA bandpass.
- Inhibitory triad
- The SST, VIP, Apical and Chandelier components of cortical inhibition, which the simulator tracks as coupled state variables.
- Working memory hierarchy
- Four levels (NMDA active slots, activity-silent trace, phonological loop and D1/D2 gating) that develop progressively during simulated training.
- Critical periods
- A factor in the gate and learning dynamics that decays during training, locking learned representations once it closes.
- Dual-route tokenization
- Following the Coltheart DRC model, frequent words take a lexical route to one token and other words a sublexical morpheme route, with byte fallback. Case is carried by <cap> and <allcap> tokens, so the vocabulary stays lowercase and lossless.
- Gamma-theta token alignment
- A design target in which one token matches one gamma cycle and one morpheme, and a word spans one theta cycle of 3 to 7 tokens. The validation suite tests that most words have 1 to 3 tokens and nearly all have at most 7.
- Cognitive demand categories
- Seven demand types (entity tracking, temporal ordering, inhibitory control, uncertainty, conflict, attention and reasoning chains), each mapped to named NCT modules in the dataset metadata.
- Wake-sleep training loop
- Appears only in the V11 diagram generator, as design. Sleep pressure grows by per step, and sleep triggers at 0.7 or after 100 wake steps, followed by replay, weight downscaling by 0.99, noisy dreams and k-means consolidation into 8 clusters.
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.