← The living map spec / 06-compute

6. Computational design

This document describes the current design only. The reasons for each choice, and the alternatives rejected, are in decisions.md. All numbers are order-of-magnitude estimates; the milestone that measures each one is listed in §10. Tolerances for reductions, solves, sampling and messages come from the information budget in 12-information-budget.md.

1. Cost drivers

A naive implementation fails for these reasons. Every section below exists to remove one of them.

Driver Naive cost (fly CNS, full detail) Addressed in
Memory traffic ~15 GB of state traversed per 25 µs step ≈ 600 TB per simulated second; bandwidth-bound §2, §4; messages: 12 §7
Serial depth of regulation burn-in ~10⁵ simulated seconds ≈ 4×10⁹ sequential steps per candidate Φ §5; adaptive precision: 12 §4.3
Burn-in nested in optimizer and ensemble ~10²⁶–10²⁷ FLOP §5, §6, §7; Fisher-weighted allocation: 12 §3–4
Gradients of chaotic long-time statistics Exponentially growing, meaningless gradients §6; data-rate gate: 12 §6
Gradients through body contact Non-smooth, biased §6
Extracellular diffusion on EM geometry Petavoxel grids §3 (homogenization)
Recomputation across experiments and team members Same burn-ins and reductions recomputed many times §8

2. Data model and memory layout

The core abstraction separates what never changes during a run from what does, as MuJoCo separates mjModel from mjData:

Object Contents Lifetime
Organism Connectome, morphologies, cell types, transcriptome priors, provenance Organism release (immutable, content-hashed)
Model Compiled arrays: tree topology, compartment geometry, synapse index tables (CSR), mechanism groups, fidelity level per cell type Built once per (Organism, fidelity configuration)
Params Φ (per-type regulatory programs), latent edges, global physics; a JAX pytree Changes every optimizer step
State Voltages, gates, concentrations, vesicle pools, body state, RNG counters Per replica, per time step

Layout rules:

3. Fidelity lattice

Every component has named fidelity levels. A configuration picks a level per component per cell type (or region).

Component Levels (cheap → reference)
Neuron electrical N0 graded point neuron → N1 reduced, impedance-preserving (~10–50 compartments) → N2 full EM morphology
Channel gating G0 deterministic → G1 stochastic (Markov / Langevin)
Chemical synapses S0 lumped deterministic → S1 lumped stochastic → S2 per-site stochastic
Extracellular diffusion D0 well-mixed neuropil compartments → D1 homogenized coarse grid → D2 EM-geometry voxels
Body B0 recorded replay → B1 reduced mechanics (resistive force theory, MJX) → B2 continuum body + CFD

Three mechanisms use the same lattice:

  1. Validation of reductions: each lower level is checked against the level above (on the worm, against full reference). "Within tolerance" means within the reduction's share of the task's information budget Δ ≤ τ_T (12-information-budget.md §1–2).
  2. Fidelity probes (§9): online error estimates in production runs.
  3. Multilevel Monte Carlo (§7): most samples from cheap levels, corrections from expensive ones.

Reduction is not ablation. Moving down the lattice approximates a physical process numerically. The Necessity Map (03-evaluation.md) removes a process entirely to test whether it is scientifically needed. Reductions may be used whenever their measured error is within tolerance; they do not wait for the Necessity Map.

Reduction details:

4. Execution model

4.1 Whole brain per device

At the production fidelity (N1/G0/S1/D1), a fly CNS instance is small:

Component Count State Size (fp32)
Compartments ~1.7×10⁵ neurons × ~30 ≈ 5×10⁶ ~40 variables each ~0.8 GB
Lumped synapse groups ~10⁷ (estimate) ~5–10 states each ~0.2–0.4 GB
Diffusion grid, indicator, body — — < 0.5 GB
Total State ~1.5–2 GB

The unit of parallelism is the replica, not a slice of the brain. Each GPU runs whole brains; replicas, candidate Φs and experimental conditions spread across GPUs with no communication during the forward pass.

4.2 Replica-batched kernels

Synaptic scatter and tree solves are dominated by reading index and topology arrays from Model, not by arithmetic. When R replicas share a GPU, each kernel loads those arrays once and applies them to all R replicas' State. Index traffic is divided by R and arithmetic intensity rises accordingly. Replicas that need different Models (different fidelity configurations) are batched separately.

4.3 Temporal blocking

Neurons interact only through synapses and gap junctions, so one neuron can be integrated for many steps in fast on-chip memory:

4.4 Time stepping

4.5 Partitioned runs (reference fidelity only)

N2 fly runs don't fit on one device. They partition the connectome with a min-cut on synaptic coupling. Spiking synapses synchronize at the minimum axonal plus synaptic delay (exact, as in NEST). Graded synapses and gap junctions use waveform relaxation across devices, communicating once per window, with the same message compression as §4.3.

4.6 Kernels and numerics

5. Regulation solver (developmental burn-in)

5.1 What is computed

The developmental outcome is defined in 04-physics.md, L7: the adult regulatory state is the endpoint of the regulatory dynamics, started from z(t₀) ~ p₀,c and run along the developmental schedule in the closed loop. The solver never redefines that outcome. It computes it in one of two modes:

Direct simulation of days of regulation, with activity resolved, is the reference used to validate both modes on the worm (§5.9).

5.2 Endpoint mode: the slice equation

For rules with constant gain and no leak (L7 Case 1), each neuron's state stays on its slice z_i = z_i(t₀) + G_c a_i. The unknowns are the slice coordinates a ∈ ℝ^{Nk}: k per neuron, not n. The equation is

e(a) = s* − E_closed-loop[ σ( z(t₀) + G a ) ] = 0

This replaces the ill-posed equation E[sensor(θ)] = setpoint, which has a manifold of solutions per neuron and a singular Jacobian. The equivalent square system in z is

F(z) = [ s* − E[σ(z)] ;  Nᵀ (z − z(t₀)) ] = 0,      N spans null(Gᵀ)

Its Jacobian is nonsingular if and only if the loop gain J G is nonsingular, where J = ∂E[σ]/∂z. (If [−J; Nᵀ] v = 0, then v = G b for some b, and J G b = 0.)

Other rule forms:

Algorithm. Pseudo-transient continuation on a, starting at a = 0 (the initial state):

a_{m+1} = a_m + (I/Δt_m + Ĵ G)⁻¹ e(a_m)
Δt_m grows as the residual falls (switched evolution relaxation)

For small Δt each step follows the regulatory flow, and for large Δt it becomes Newton's method. The solver therefore tends to converge to the equilibrium the trajectory reaches from the initial state, not to an arbitrary root. Ĵ G is a k×k block per neuron, estimated with k Jacobian–vector products using common random numbers.

Precision schedule. The Monte Carlo error of e(a_m) is held at a fixed fraction θ of the residual, so sampling grows as the residual falls and early iterations are cheap. This schedule is measured in the solver's own loop-gain-scaled metric and is kept below a fraction of the stability margin, so that noise cannot carry the iteration to another branch (12-information-budget.md §4.3).

Certification. An endpoint is accepted only if all of the following hold; otherwise that type switches to transient mode:

  1. The residual is within tolerance relative to the Monte Carlo error of E[σ]. The tolerance is the solve's share of the information budget, ½ eᵀ F_e e plus the expected noise term, with F_e the Fisher information of the dataset with respect to sensor errors (12-information-budget.md §4.1). Checks 2 and 3 are not relaxed by Fisher weighting.
  2. Every eigenvalue of the estimated loop gain has real part above a margin λ_min > 0. This is checked per neuron, and for the network by Arnoldi iteration for the least stable modes.
  3. The basin check passes: for a random ≥1% of neurons per type, and for every worm run, the endpoint agrees with transient-mode integration from a = 0.

A root that fails check 2 satisfies the sensor equations but is not a developmental outcome, because the dynamics move away from it.

5.3 Per-neuron decomposition (default)

  1. Run the closed-loop network briefly; record every neuron's input waveforms and sensory traces.
  2. Solve each neuron's slice equation (k unknowns) against its recorded inputs, holding the network fixed. These are ~1.7×10⁵ independent single-cell problems, batched by cell type.
  3. Re-run the network with the new states to refresh inputs. Repeat until the inputs stop changing.

Convergence condition. Split J = J_d + J_o, where J_d is block-diagonal (each neuron's sensors with respect to its own state, inputs held fixed) and J_o carries network coupling. To first order the outer iteration is block Jacobi on the slice equation. It converges if and only if

ρ( (J_d G)⁻¹ J_o G ) < 1

where ρ is the spectral radius, estimated during the run by power iteration with Jacobian–vector products. If the estimate exceeds 0.9, the solver switches to the joint solver (§5.6) without waiting for stagnation. Implicit-function gradients use the same structure: per-neuron k×k solves plus a few Krylov iterations for the coupling.

5.4 Stratified averaging with Markov state models

Sensor averages must cover the animal's behavioral states (e.g. worm forward runs, reversals, turns), which switch over tens of seconds. Long time-averaging windows would make this the most expensive step. Borrowing from molecular dynamics, where Markov state models (as used in Folding@home) avoid long trajectories:

This replaces "run long enough to visit every state many times" with "run short windows in every state", which parallelizes. It is valid if the state decomposition is Markovian at the chosen lag time, which is checked with standard implied-timescale tests and with a residual conditional-mutual-information test of predictive sufficiency.

Sensitivities. The loop gain needs the derivative of the average, and regulation can shift behavior as well as activity within each state:

∂E[σ]/∂z = Σ_s π_s ∂σ̄_s/∂z + Σ_s σ̄_s ∂π_s/∂z
∂π = π (∂T) Z,      Z = (I − T + 1π)⁻¹   (fundamental matrix)

The second term, from shifts in state occupancy, is estimated with likelihood-ratio weights on the transition counts.

5.5 Validity conditions: when endpoint mode and implicit differentiation apply

# Condition Diagnostic If violated
V1 Loop gain well-conditioned σ_min(Ĵ G) above its Monte Carlo error by a factor ≥ 10; condition number below κ_max (set at M4) Transient mode; report proximity to a bifurcation
V2 Selected equilibrium stable All eigenvalues of Ĵ G have real part > λ_min Reject root; transient mode
V3 Equilibrium is the one reached from the initial state Basin check (§5.2) Transient mode for that type; cache results by trajectory
V4 Regulation slow relative to activity mixing ε = τ_mix/τ_reg < ε_max (default 0.1) Simulate the offending (fast-path) coordinates in time together with activity
V5 No active bounds No regulated quantity at its saturation limit at the endpoint Transient mode with complementarity at the bounds
V6 Conservation structure known Rule is Case 1, leak with a known left null space, or flat-parameterized involutive Transient mode
V7 Leak memory short relative to age 1/λ_min(D) < 0.1 × developmental duration Transient mode (the adult state is not an equilibrium)
V8 Quantity of interest is an endpoint Not a trajectory (F3, F7 time courses) Transient mode

Implicit differentiation (§6) is valid exactly when V1–V7 hold at the endpoint. Each run records which conditions held, for each type.

5.6 Joint solver (fallback)

If decomposition fails its convergence condition (§5.3), or input changes stop decreasing between outer iterations, switch to a joint solver on all slice coordinates together: averaged sensors from parallel replicas, stochastic pseudo-transient Newton–Krylov steps (heterogeneous multiscale method), common random numbers and control variates across iterations.

5.7 Transient mode

Integrate the averaged slow dynamics dz/dt = G(z) e(z) − D(z − z^ref) along the developmental schedule (wiring, body and rearing environment as functions of age), from z(t₀) ~ p₀,c.

5.8 Amortized surrogate

A per-cell-type surrogate (neural operator) maps (Φ_c, initial state, input-waveform statistics, morphology features) to the slice coordinates a*, trained on solves the pipeline already performs. It warm-starts or replaces inner solves. Every prediction is certified like any endpoint (§5.2: residual, stability and, on the sampled subset, basin); if a* moves beyond tolerance, the true solve is used and added to the training set. The surrogate touches only the slow inner loop, never network physics.

5.9 Ground truth on the worm

The worm is cheap enough to run direct day-long regulation simulations with activity resolved. Every solver mode above is validated against them before use on the fly:

The A0 demonstrator (prototypes/a0-regulatory) is the first, synthetic, instance of these checks.

6. Gradients and optimization

7. Uncertainty at scale

8. Content-addressed compute cache

Expensive intermediate results are cached and reused across the team, keyed by a hash of every input that affects them:

Artifact Key
N1 reductions, transfer impedances Organism release, neuron ID, reduction settings, declared parameter domain Θ_dom (passive membrane, capacitance, axial resistivity, linearization operating points), code version
Burn-in endpoints Model hash, Params hash (including p₀,c), initial-state samples or their seeds, developmental-schedule samples, rearing distribution, solver mode and settings, RNG seed, reproducibility class, certified information cost Δ and benchmark version
Conditioned state posteriors and forecasts (proposed) Model and posterior hashes, conditioning-data hash and observation cutoff, history-state representation/version, particle or initial-state identities, assimilation policy, intervention, forecast horizon, observation model, solver settings, RNG seed, reproducibility class; contract in 11-prediction-and-history.md
Markov state models Model hash, Params hash, clustering settings, reproducibility class
Surrogate training pairs Cell type, Φ_c, initial-state statistics, input statistics hash
Benchmark scores Model version, benchmark version (task specifications of 03-evaluation.md)

Exactness. A cache hit is bitwise identical to recomputation only within one reproducibility class (§4.6). Across classes, a hit is statistically equivalent: it agrees within the tolerances recorded for that artifact type, and is labeled as such. The workflow layer (07-platform.md) consults the cache before scheduling any job.

Warm starts from nearby cache entries (e.g. the closest previous Φ) can change the answer when the regulation dynamics have several stable equilibria: a solver started near another branch can converge to it. A warm start is therefore allowed only if the result is certified as the endpoint reached from the specified initial state (§5.2, checks 1–3). Otherwise the solve restarts from a = 0. When certification holds, warm starts change only convergence speed, not the answer.

9. Error control

All error estimates below are reported in the information currency of 12-information-budget.md: the change in the predicted dataset distribution, Δ in nats, compared with the task's budget τ_T.

Local probes. Every production run embeds shadow neurons: higher-fidelity copies of a random ~1% of neurons, driven by the same inputs as their twins, with outputs not fed back. Divergence between shadow and twin gives an online estimate of local reduction error per cell type, under the inputs that the reduced network supplied. Types whose error exceeds tolerance are moved up the lattice (§3) in the next run.

Local error is not the error of the result: recurrence can amplify or suppress it, and closed-loop behavior can shift. Two further checks propagate local error to the quantities reported:

Every published result carries its measured local error, the propagated error estimate, and the date and outcome of the latest coupled comparison for that configuration.

10. Budget and assumptions

All numbers in this section are feasibility hypotheses, not guarantees. Each has a milestone that tests it and a criterion that would change the plan. Benchmarks measure complete inference workloads (burn-in, gradients, ensembles, closed-loop evaluation) end to end, not isolated kernels.

Worm (reference fidelity throughout): ~10¹²–10¹³ FLOP per simulated second (~10¹³–10¹⁴ with continuum body and full Stokes fluid). Direct burn-in and full ensembles are expected to be affordable; this is tested at M4.

Fly CNS (production fidelity), illustrative:

Item Estimate Tested in Plan changes if
State per brain ~1.5–2 GB M0 (reduction sizes, lumped synapse counts) > 1 device memory: partitioned production runs (§4.5), revisit D9
Forward wall time per simulated second per GPU ~0.3–1 s with temporal blocking and replica batching M1 (roofline profiler), then end-to-end at P0.5 > 5 s: re-plan fly fidelity configuration
Network simulated time per outer iteration ~10³ s (decomposed regulation, stratified averaging) M4 (worm), P0.5 (larva) > 10⁴ s: surrogate-first burn-in or per-type direct fits for the fly
Serial outer iterations ~10²–3×10² M4 > 10³: revisit D11
Share of types needing transient mode (§5.5) Unknown; assumed small M2b, M4 > 20%: budget transient mode as the default
Saving from information-budget allocation and adaptive precision in the regulation solve Unknown; depends on the tail of the Fisher weights A0 extension, M2b, M4 < 2×: keep uniform allocation (12-information-budget.md §8)
Imaging capacity vs. entropy production (data-rate gate) Unknown M2 Gate fails for trajectory tasks: freeze them as distributional
Hardware for a full fit ~64–256 GPUs End-to-end benchmark at P0.5 —
Wall time for a full fit ~days End-to-end benchmark at P0.5 > 1 month: reduce scope before P2

Assumptions that could break the budget: