Eligibility traces for Cognia inner layers
Date: August 3, 2026
Status: implemented experimental mechanism
Implementation: Core/Mind/NeuralGraph.cu, Core/Mind/Mind.cu
Regression: Cognia/tests/15/
1. Problem
The sequential trainer originally learned only the output readout. Recurrent and intermediate layers produced context, but their weights remained fixed during language training. Output error therefore could not improve the representation of history inside the network.
Full backpropagation through time (BPTT) would require retaining an unrolled graph of states, activations, and derivatives across many tokens. That does not fit Cognia's local, online, biologically inspired runtime. An eligibility trace offers an online approximation: a synapse locally remembers that it was active in the past, and a later error determines whether that trace changes the weight.
2. Three learning factors
An inner weight update is the product of three pieces of information:
- presynaptic activity — what entered the synapse;
- local postsynaptic sensitivity — whether the target neuron could respond;
- learning signal — whether a later output error asks for more or less influence.
For an edge e: i → j, the runtime updates its trace after every token:
e_ij(t) = λ · e_ij(t-1) + pre_i(t) · φ'(post_j(t))
φ'(a) ≈ max(0, 1 - a²)
λ = 0.95 controls memory duration. Older activity decays exponentially, while
several previous tokens can still receive credit for the current result. A gated
edge uses its actual effective input including the gate; a neuron in a select
port uses its normalized route activation.
3. Output error
The language readout computes softmax probabilities. Each output class receives a directional error:
L_k = target_k - probability_k
The readout continues to learn with its exact local softmax cross-entropy update. The eligibility mechanism does not replace it and does not train edges leading directly into the readout a second time.
4. Carrying the learning signal inward
Output error travels across GPU edges in the reverse direction. One reverse step approximately computes:
L_i += weight_ij · L_j / normalization(in_degree_j)
The current implementation performs three reverse steps and sums signals from all reached depths. This is bounded credit transport through the current forward weights, not a complete temporal unrolling. No separate backward graph or full history of every neuron activation is retained.
5. Inner-weight update
A plastic inner edge changes according to:
Δw_ij = ηelig · rate_ij · gain_j / normalization(in_degree_j)
· e_ij(t) · L_j(t)
The default ηelig = 0.05 multiplies the declared per-edge rate, typically 0.01
for plasticity:learnable. The effective base step is therefore approximately
0.0005 before activity, normalization, and learning signal are included. The
resulting weight is clamped to [-1, 1].
Only edges with a non-zero plasticity rule are updated. Consequently:
plasticity:none,fixed, andfrozenremain unchanged;- the readout retains its separate softmax update;
- plastic edges in inner and recurrent layers can receive credit;
- the trace is temporary training state, not a checkpointed model parameter.
6. Sequence boundaries and lifecycle
At the beginning of each sentence or document sequence, resetActivity() also
clears eligibility traces. Credit therefore cannot leak between unrelated
documents. Traces are also cleared when topology changes because edge indices no
longer carry their previous identities after a structural rewrite.
Applied-update statistics accumulate separately during training. At completion, the trainer reports the number of inner edges that actually changed and the sum of their absolute deltas.
7. Enabling the mechanism
The mechanism is opt-in and requires a sequential softmax readout:
cognia_train model.cognia data.seq 5 Network `
--sequential --softmax --eligibility
A training plan uses the eligibility flag:
stage language readout dataset input/train.seq checkpoint output/model.bin epochs 5 softmax eligibility
Without the flag, older examples retain their previous behavior. Lazy activation also avoids clearing a large trace buffer during ordinary inference.
8. Measured technical validation
Example 10 bootstrap, one epoch:
- 681 next-token transitions;
- 2,248 inner edges actually changed;
- total absolute weight delta
0.014303394; - the checkpoint was saved successfully.
Regression 15 uses a network with separate plastic inner edges and a fixed readout. The test requires a non-zero number of changed inner edges; it currently changes 12 edges. The complete Cognia test suite remains green.
9. What this result does not prove yet
A non-zero weight change proves a working credit path, not automatically a better language model. The mechanism is approximate and has several limitations:
- three reverse steps cannot reach arbitrarily deep networks;
- it is not the exact BPTT gradient;
- long-term credit decays exponentially according to
λ; - traversing all edges during reverse steps increases per-token cost;
- an excessive learning rate can damage an already useful inner state;
- the current checkpoint cannot resume in the middle of a sequence while preserving that sequence's trace.
The required next experiment is an A/B comparison on the same train/test split with traces disabled and enabled. Primary metrics are held-out perplexity, next-token accuracy, repetition count, stability of longer dependencies, and epoch runtime. Only that experiment can establish whether inner learning yields a practical language improvement.