Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ All notable changes to `nerve-wml` follow [Keep a Changelog](https://keepachange
- **Plan A.3** — Hyperparameter wiring (3 tasks, n_steps=32, lr=0.05, n_osc ∈ {32,64})
- **Plan A.4** — AKOrN comparison (3 tasks, minimal vs full topology, separation metrics)
- **Plan B** — Paper revisions (8 tasks, §Method, §Results, new citations, abstract figures)
- **Plan C** — Biological substrate (11 tasks, BioFieldWML Phase 1–2, CL1 sleep-every validation, Palacios SNN-PC scheduler)
- **Plan C** — Biological substrate (11 tasks, BioFieldWML Phase 1–2, CL1 sleep-every validation, Lee SNN-PC scheduler)

### Reinforcement campaigns (9 confirmed, 1 audit)

Expand Down Expand Up @@ -69,7 +69,7 @@ All notable changes to `nerve-wml` follow [Keep a Changelog](https://keepachange
### Biological substrate integration

- **BioFieldWML Phase 1**: MockBioCultureClient scheduler with sleep-every ≥ 1 validation, episode-bound Add(layer) accumulator.
- **BioFieldWML Phase 2**: Palacios SNN-PC (predictive coding via spiking neurons) integrated as optional substitution-compatible estimator for Kuramoto-style cell populations.
- **BioFieldWML Phase 2**: Lee SNN-PC (Lee et al. 2024, Frontiers Comp. Neurosci., DOI 10.3389/fncom.2024.1338280 — predictive coding via spiking neurons) integrated as optional substitution-compatible estimator for Kuramoto-style cell populations.
- **Testing**: 458 fast tests + 35+ slow statistical tests covering unit (L1), info-theoretic (L2), integration (L3), golden (L4) strata. No real CL1/FinalSpark API key used (MockBioCultureClient only).

### Citations added to refs.bib
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Protocol.
| §Information Tx Test (6) PRH refinement | `papers/paper1/main.tex` | New "Global vs Local alignment" paragraph engages `platoscave2026` + `aristotelianprh2026`; nerve-wml's mutual-kNN measurement claimed as *local* (null-calibrated 18.8× random), not global |
| GTM re-grounding | `papers/paper1/main.tex` | Replaces sole reliance on Bastos & Friston 2012 with Bastos 2020 predictive routing + Friston 2025 + Ruffini 2025 laminar Comparator |
| HNN positioning (closes #13) | `papers/paper1/main.tex` "Surrogate-gradient SNN" thread | Cites Liu et al. 2024 (NSR) and positions nerve-wml in the *weak-coupling* corner of the HNN taxonomy |
| BioFieldWML plan versioned | `docs/superpowers/plans/2026-05-19-bio-substrate-wml.md` | Plan for a 4th conformant substrate alongside MLP / LIF / Transformer; 5 (b)-classified mechanisms encapsulated inside `step()` (Tomé STDP, Pignatelli IE, Palacios SNN-PC, Bellitto WSCL, Tucker-Friston E/I); cross-refs dream-of-kiki `biophysical-stratification` spec |
| BioFieldWML plan versioned | `docs/superpowers/plans/2026-05-19-bio-substrate-wml.md` | Plan for a 4th conformant substrate alongside MLP / LIF / Transformer; 5 (b)-classified mechanisms encapsulated inside `step()` (Tomé STDP, Pignatelli IE, Lee SNN-PC, Bellitto WSCL, Tucker-Friston E/I); cross-refs dream-of-kiki `biophysical-stratification` spec |

Headline measurements and claims A/B remain unchanged — this update is
documentation and planning only, not new experimental findings.
Expand Down
2 changes: 1 addition & 1 deletion docs/substrate-paradigms.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ substrate.
| **In-silico MLP baseline** | `track_w/mlp_wml.py::MlpWML` | Dense linear + nonlinearity | Standard backprop on `codebook` + readout heads | Track W foundation |
| **In-silico LIF (rate-coded)** | `track_w/lif_wml.py::LifWML` | Leaky integrate-and-fire over `T` micro-ticks, rate decode | Surrogate-gradient backprop | Track W foundation |
| **In-silico Transformer** | `track_w/transformer_wml.py::TransformerWML` | Multi-head attention over codebook history | Standard backprop | Track W foundation |
| **BioField PC-VMP** | `track_w/bio_field_wml.py::BioFieldWML` | Spiking field with `μ/σ` belief + `PRED γ` / `ERROR θ` Neuroletter roles | Predictive coding via variational message passing (Palacios SNN-PC, arXiv:2409.05386) | nerve-wml Phase 2 (PR #24, 2026-05-20) |
| **BioField PC-VMP** | `track_w/bio_field_wml.py::BioFieldWML` | Spiking field with `μ/σ` belief + `PRED γ` / `ERROR θ` Neuroletter roles | Predictive coding via variational message passing (Lee et al. 2024 SNN-PC, DOI 10.3389/fncom.2024.1338280) | nerve-wml Phase 2 (PR #24, 2026-05-20) |
| **Wet biology** | `track_w/bio_wml.py::BioWML` | Remote biological neural culture via `BioCultureClient` (stim/read-back) | Codebook + emit heads via backprop on decoded spike codes | Track W bio-substrate plan, mock in CI |

## Cross-repo bridges
Expand Down
18 changes: 14 additions & 4 deletions docs/superpowers/plans/2026-05-19-bio-substrate-wml.md
Original file line number Diff line number Diff line change
Expand Up @@ -1861,13 +1861,23 @@ and that untagged neurons are unaffected.

---

### Ref B-3 — Palacios et al. 2024 (arXiv:2409.05386)
### Ref B-3 — Lee et al. 2024 (Frontiers in Computational Neuroscience)

**SNN-PC survey — Fristonian extension (variational message
passing, per-neuron spike-time prediction).**
**SNN-PC — feedforward gist signaling with spiking predictive coding.**

**Full citation.**
Lee, Dora, Mejias, Bohte & Pennartz, *"Predictive coding with spiking
neurons and feedforward gist signaling"*, Frontiers in Computational
Neuroscience 18:1338280, 2024. DOI 10.3389/fncom.2024.1338280.

**Note on arXiv:2409.05386.**
That arXiv ID corresponds to a *survey* paper (N'dri, Gebhardt,
Teulière, Zeldenrust, Rao, Triesch, Ororbia & al., *"Predictive Coding
with Spiking Neural Networks: a Survey"*, 2024) — useful as background
reading but not the source of the VMP mechanism used here.

**Mechanism.**
Palacios 2024 extends predictive coding (PC) to spiking networks:
Lee et al. 2024 extend predictive coding (PC) to spiking networks:
each neuron maintains a belief over *when* peers will spike and
minimises variational free energy via local variational message
passing (VMP). Prediction errors are Poisson-rate residuals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ The elegant coupling is therefore **SpikingKikiWML ⊑ BioCultureClient**:
wrap a `SpikingKikiWML` in an adapter that satisfies the
`BioCultureClient` Protocol. BioFieldWML then consumes spikingkiki
spike trains exactly as it consumes Mock / CL1 / FinalSpark cultures.
The Palacios SNN-PC VMP update becomes a Predictive-Coding learning
The Lee SNN-PC VMP update (Lee et al. 2024, Frontiers Comp. Neurosci.,
DOI 10.3389/fncom.2024.1338280) becomes a Predictive-Coding learning
signal **on the silicon culture**, with no change to BioFieldWML
itself.

Expand Down Expand Up @@ -125,11 +126,11 @@ client = SpikingKikiBioClient(substrate=sk)
bio = BioFieldWML(id=1, bio_client=client, ...)

# Now bio.step(nerve, t) drives sk via roundtrip(), reads spikes,
# runs the Palacios VMP belief update, emits PRED/γ or ERR/θ
# runs the Lee VMP belief update (Lee et al. 2024), emits PRED/γ or ERR/θ
# Neuroletters as it does with any other BioCultureClient.
```

The Palacios VMP update is **the learning signal** on spikingkiki:
The Lee SNN-PC VMP update is **the learning signal** on spikingkiki:
high posterior σ on a neuron group = ERROR / θ Neuroletter, which
downstream learners can use to update spikingkiki's `codebook` or
`input_proj` (out of scope for this design — it's the next step).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ Per-tick t over T = `n_micro_ticks`:
through `input_proj`.
2. Compute Q, K, V via mmapped matmuls. To stay spike-native, accumulate
into a leaky integrator on each head dimension rather than a softmax.
3. **Attention via belief accumulation** (Palacios SNN-PC compatible):
3. **Attention via belief accumulation** (Lee SNN-PC compatible,
Lee et al. 2024 DOI 10.3389/fncom.2024.1338280):
each output position holds a (μ, σ) belief; spikes drive the residual.
On the final micro-tick, emit the top-1 token from
`argmax_z μ_attn(z)`.
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_bio_wml_pc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Unit tests for BioFieldWML Phase 2 — Palacios SNN-PC VMP.
"""Unit tests for BioFieldWML Phase 2 — Lee SNN-PC VMP.

Reference: Palacios et al. 2024 (arXiv:2409.05386), variational message
passing in spiking predictive-coding networks. See
docs/superpowers/plans/2026-05-19-bio-substrate-wml.md §"Ref B-3".
Reference: Lee, Dora, Mejias, Bohte & Pennartz 2024, "Predictive coding
with spiking neurons and feedforward gist signaling", Frontiers in
Computational Neuroscience 18:1338280, DOI 10.3389/fncom.2024.1338280.
See docs/superpowers/plans/2026-05-19-bio-substrate-wml.md §"Ref B-3".

Invariants verified
-------------------
Expand Down
22 changes: 12 additions & 10 deletions track_w/bio_field_wml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Phase 1 (Bellitto, 2024 — Wake-Sleep Continual Learning):
Internal wake/sleep scheduler. Sleep calls are silent (N-1).

Phase 2 (Palacios et al. 2024 — arXiv:2409.05386):
Phase 2 (Lee et al. 2024 — Frontiers in Computational Neuroscience,
DOI 10.3389/fncom.2024.1338280):
Variational message passing (VMP) for spiking predictive coding.
Each neuron maintains a belief (μ, σ) over expected spike counts
from a ``BioCultureClient``. On wake calls, a closed-form Gaussian
Expand All @@ -17,7 +18,7 @@
by construction.

See docs/superpowers/plans/2026-05-19-bio-substrate-wml.md
§"Ref B-3" (Palacios SNN-PC) for the design input.
§"Ref B-3" (Lee SNN-PC) for the design input.

Wake/sleep convention (documented for TDD tests)
-------------------------------------------------
Expand Down Expand Up @@ -49,7 +50,7 @@


class BioFieldWML(nn.Module):
"""Wake/sleep-scheduled WML substrate with Palacios SNN-PC VMP.
"""Wake/sleep-scheduled WML substrate with Lee SNN-PC VMP.

Parameters
----------
Expand Down Expand Up @@ -122,7 +123,7 @@ def __init__(
self._call_count = 0
self._bio_client = bio_client

# Palacios SNN-PC belief state.
# Lee SNN-PC belief state (Lee et al. 2024, Frontiers Comp. Neurosci.).
# μ: per-neuron expected spike count (rate prediction).
# σ: per-neuron rate uncertainty (standard deviation).
# Initialised to vague prior (μ=0, σ=1) — uninformative.
Expand All @@ -144,7 +145,7 @@ def __init__(
torch.set_rng_state(saved_rng)

# ------------------------------------------------------------------
# Palacios SNN-PC — variational message passing
# Lee SNN-PC — variational message passing (Lee et al. 2024)
# ------------------------------------------------------------------

def _measure_spikes(self, t: float) -> Tensor:
Expand Down Expand Up @@ -186,17 +187,18 @@ def _vmp_update(
) -> tuple[Tensor, Tensor, Tensor]:
"""Closed-form Gaussian variational message-passing update.

Approximates the Poisson-rate likelihood (Palacios 2024) with a
Laplace-approximated Gaussian where σ²_obs = max(observed, 1) so
the update has a closed form:
Approximates the Poisson-rate likelihood (Lee et al. 2024,
DOI 10.3389/fncom.2024.1338280) with a Laplace-approximated
Gaussian where σ²_obs = max(observed, 1) so the update has a
closed form:

μ_post = (σ²_obs · μ_prior + σ²_prior · obs) /
(σ²_obs + σ²_prior)
σ²_post = (σ²_prior · σ²_obs) /
(σ²_obs + σ²_prior)

The prediction error is ``observed − μ_prior`` (Poisson rate
residual, Palacios eq. 5).
residual; cf. Lee et al. 2024 eq. 5 analogue).

Mutates ``self._mu`` and ``self._sigma`` in-place and returns
the new (μ, σ) plus the residual error (all detached, no grad).
Expand Down Expand Up @@ -275,7 +277,7 @@ def step(self, nerve: Nerve, t: float) -> None:
))
return

# WAKE — Phase 2 Palacios SNN-PC VMP path.
# WAKE — Phase 2 Lee SNN-PC VMP path (Lee et al. 2024).
observed = self._measure_spikes(t)
mu_post, sigma_post, error = self._vmp_update(observed, t)

Expand Down
7 changes: 4 additions & 3 deletions track_w/spiking_kiki_bio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
The adapter wraps a ``SpikingKikiWML`` and satisfies the
``BioCultureClient`` Protocol (track_w.bio_clients) without modifying
either substrate. BioFieldWML then consumes spikingkiki spike trains
exactly as it consumes Mock / CL1 / FinalSpark cultures. The Palacios
SNN-PC VMP update becomes a predictive-coding learning signal on the
silicon culture.
exactly as it consumes Mock / CL1 / FinalSpark cultures. The Lee
SNN-PC VMP update (Lee et al. 2024, Frontiers Comp. Neurosci.,
DOI 10.3389/fncom.2024.1338280) becomes a predictive-coding learning
signal on the silicon culture.

Spatial bucketing: contiguous groups (simpler, tied to .npz layout).
Temporal bucketing: ``n_micro_ticks`` ticks divided into ``n_bins``
Expand Down
Loading