Files
ailed-experiments-rp/results/frozen.md
T

319 lines
17 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Frozen-weights probe: does memory have a job once learning is out of the picture?
Task 7b. Task 7 measured memory beating memoryless 2.99x at `lr=1e-3` and watched
that margin decay to 1.06x at `lr=1e-2`, so mean error cannot tell state and fast
weights apart. This file removes learning instead of retuning it: train, freeze every
parameter, keep stepping the world. Nothing after the freeze can be attributed to an
optimiser step.
**Verdict: a clean null, twice over. Memory is not doing the work, and neither model
builds an internal regime variable.**
1. Under frozen weights `grp_k0` beats `rp_only` 2.50x on steady error, on 8/8 seeds.
**That entire margin is the GRP's extra 4160 parameters, not its state.** The same
architecture with the state ablated — every parameter kept, an empty memory handed
in each step — measures 2.170e-05 against `grp_k0`'s 2.101e-05. Memory is worth
1.06x, on 4 seeds out of 8. Its recovery curve is indistinguishable at every lag.
2. The regime is decodable from `M` at 0.332 against a measured chance of 0.273. It is
decodable from the memoryless RP's `h` at 0.342 against 0.274. **`M` knows no more
about the regime than the feedforward representation it is built from** — slightly
less — and the same +0.05 appears in a state-free network, so it is a read-off of
the current configuration, not a memory.
3. The mechanism is visible: the gate sits at `g = 0.500 ± 0.029`, never above 0.9,
never below 0.1, on any seed. It is at its initialisation. The GRP as trained here
is not gating anything.
Environment: `experiments/`, `ailed/` unmodified, no default in `particles.py` or
`regime.py` changed. 8 seeds (0-7), 8000 training steps then 4000 frozen steps,
`lr=1e-3`, `bptt=20`, `hidden=32`, `omega=10`, `kappa=0`, `window=20`. Noise floor
`noise² = 4.0e-06`. 40 runs total.
```
uv run python frozen.py --out results/frozen.json
uv run python frozen.py --conditions grp_k0 --ablate-state --out results/frozen_nostate.json
uv run python frozen.py --freeze-affect --no-probes --out results/frozen_affect.json
```
## 0. The freeze audit
Both guards the brief asked for, asserted in code on every run, not checked by eye.
| check | how | result |
|---|---|---|
| no parameter moved | `parameters_to_vector` snapshot before/after the frozen phase, `torch.equal` | **bit-identical on 40/40 runs** |
| nothing could move | `requires_grad=False` on every parameter *and* the whole phase under `torch.no_grad()`, no optimiser constructed | asserted |
| memory kept updating | `min_t max_i |M_t − M_{t−1}|` over the frozen phase | **2.587e-04**, over every grp run |
| the assertion can fail | `test_frozen_phase_detects_a_parameter_change` nudges `out.bias` by 1e-6 after the snapshot | raises, as required |
| `h` is the organism's `h` | `org.grp(h, M_prev, arousal)` must equal the M the organism returned; `org.out(h)` must equal the pred it returned | `torch.equal`, every step of every run |
Mean per-step memory movement is 1.06e-02, four orders above the detection threshold,
so the GRP is running as a GRP throughout. `_train` is a verbatim copy of
`regime.run`'s loop; `test_train_copy_is_identical_to_regime_run` asserts it
reproduces `regime.run`'s metrics exactly, so the frozen phase starts from the
organism Task 7 measured.
Parameter counts, which turn out to be the whole story: `rp_only` **1442**,
`grp_k0` **5602**. The RP is identical in both (1376); the GRP adds a 64→32 gate and
a 64→32 candidate layer, 4160 parameters, 3.9x the total.
## 1. Part A — frozen recovery
Metrics come from `regime._metrics` applied to the frozen phase, so they are
comparable with Task 7's; as there, they are computed on the second half of the phase.
### 1a. The headline, and the control that dissolves it
Frozen-phase `steady`, means over seeds 0-7. `grp_k0_nostate` is `grp_k0` with an
empty memory dict handed to `Organism.forward` every step, in training and in the
frozen phase: identical architecture, identical 5602 parameters, `M_prev` always zero.
It is the capacity-matched feedforward control.
```
condition steady sd min max max/min n_params
------------------------------------------------------------------------------
rp_only 5.257e-05 2.924e-05 2.644e-05 1.054e-04 3.99 1442
grp_k0_nostate 2.170e-05 5.155e-06 1.531e-05 2.733e-05 1.78 5602
grp_k0 2.101e-05 6.430e-06 1.426e-05 3.515e-05 2.46 5602
```
Decomposed per seed, which is what carries it:
```
mean median seeds won
capacity rp_only / nostate 2.51x 1.94x 8/8
state nostate / grp_k0 1.06x 1.00x 4/8
```
Per-seed `nostate / grp_k0`: 1.49 0.92 1.33 0.92 0.90 1.08 0.78 1.10. Four above one,
four below. **Removing the state costs nothing.** The same decomposition in the
trained phase gives capacity 3.06x on 8/8 seeds and state 1.25x on 4/8.
Per-seed frozen `steady`:
```
condition s0 s1 s2 s3 s4 s5 s6 s7
--------------------------------------------------------------------------------------------
rp_only 4.298e-05 3.808e-05 3.098e-05 3.205e-05 1.054e-04 5.585e-05 8.881e-05 2.644e-05
grp_k0_nostate 2.588e-05 1.531e-05 2.665e-05 1.992e-05 1.736e-05 2.545e-05 2.733e-05 1.573e-05
grp_k0 1.742e-05 1.656e-05 2.006e-05 2.170e-05 1.931e-05 2.365e-05 3.515e-05 1.426e-05
```
Note also that the across-seed spread — Task 7's "memory buys reliability" reading —
goes the same way. `grp_k0_nostate` has the *tightest* spread of the three (1.78x
max/min, against `grp_k0`'s 2.46x). Reliability is capacity here too.
### 1b. The recovery shape: the prediction under test fails
Raw `recovery[k]`, frozen phase, means over seeds:
```
condition rec@0 rec@5 rec@10 rec@19 steady
-------------------------------------------------------------------
rp_only 5.506e-05 7.311e-05 8.078e-05 6.563e-05 5.257e-05
grp_k0_nostate 2.708e-05 3.749e-05 4.246e-05 2.769e-05 2.170e-05
grp_k0 2.756e-05 3.824e-05 4.311e-05 2.756e-05 2.101e-05
```
`grp_k0` and `grp_k0_nostate` agree to within 2% at every lag. The state changes the
post-switch trajectory not at all.
The brief's prediction was that frozen `rp_only` steps up at each switch and never
comes back down, while frozen `grp_k0` rises and decays. Normalising each seed by its
own steady error before averaging — the only way to compare shapes across conditions
whose floors differ 2.5x:
```
condition @0 @2 @4 @6 @8 @10 @12 @14 @16 @18 @19 peak decay
----------------------------------------------------------------------------------------
rp_only 1.16 1.35 1.49 1.66 1.68 1.59 1.52 1.43 1.38 1.34 1.30 1.69@7 57%
grp_k0_nostate 1.31 1.40 1.54 1.92 2.09 2.06 1.87 1.64 1.46 1.35 1.31 2.13@9 73%
grp_k0 1.42 1.47 1.69 2.06 2.22 2.18 1.97 1.72 1.51 1.40 1.35 2.24@9 72%
```
("decay" is the fraction of the peak excess over steady that is gone by `@19`.)
**The frozen memoryless RP does come back down** — 57% of the way, with no parameter
having moved and no per-entity state to move. And `grp_k0`'s *relative* excursion is
larger, not smaller: it peaks at 2.24x its own floor against the RP's 1.69x, and peaks
two steps later.
The reason is that `recovery[k]` under frozen weights is not measuring the model. At a
switch the particle configuration is equilibrated to the old regime; the new coupling
matrix then drives it somewhere else over the next 10-20 steps. That transient belongs
to the world, and a fixed function of the configuration inherits it. **Under frozen
weights `recovery[k]` measures the world's post-switch transient, not adaptation**, and
the state-ablation row proves it directly: same curve with the state and without it.
### 1c. The RP is not quite static — controlled for
`CONDITIONS["rp_only"]` uses `ctx="affect"`, so `(valence, arousal)` feeds the CPPN.
Affect is updated from `loss.item()` every step and freezing weights does not freeze
it. **A frozen `rp_only` therefore is not a fixed function of the current observation**
as the brief assumed: it retains a 2-d state. Re-running the frozen phase with affect
also pinned at its end-of-training value:
```
condition affect live affect pinned
-------------------------------------------
rp_only 5.257e-05 4.906e-05
grp_k0 2.101e-05 2.057e-05
ratio 2.50x 2.26x (8/8 seeds either way)
```
Removing the RP's last adaptive channel does not rescue the prediction — the RP's
decay gets *stronger* (74% of the excess, up from 57%), confirming the decay is the
world's, not affect's.
## 2. Part B — what does the state know?
Linear decode from a per-entity representation to the world's regime id. Test split is
the last 30% of the frozen phase, taken as a suffix in time so the probe cannot
memorise adjacent steps: 2800 training steps × 16 entities = 44 800 samples, 1200 test
steps, ~20 switches per seed.
Chance is measured, not assumed. Two nulls, each refitting the probe from scratch:
`shuffle` permutes the step labels (keeping a step's 16 entities together), `shift`
circularly shifts the label sequence, which also preserves each regime's 40-80 step
block structure and is therefore the stricter of the two — a probe that merely tracks
slow drift still scores at the `shift` level. Both land near 0.27, above the naive
1/4 = 0.25, which is exactly why the brief asked for it to be measured.
```
representation acc shuffle shift gap seeds > chance
---------------------------------------------------------------------------------
rp_only h, least squares 0.342 0.289 0.274 +0.067 8/8
rp_only h, logistic 0.341 0.289 0.276 +0.065 8/8
rp_only h, entity-centred0.341 0.289 0.274 +0.067 8/8
grp_k0 h, least squares 0.338 0.292 0.274 +0.065 7/8
grp_k0 h, logistic 0.344 0.299 0.275 +0.069 7/8
grp_k0 M, least squares 0.332 0.287 0.273 +0.058 7/8
grp_k0 M, logistic 0.332 0.293 0.276 +0.056 7/8
grp_k0 M, entity-centred0.333 0.287 0.273 +0.060 7/8
grp_k0_nostate M, least squares 0.325 0.288 0.275 +0.050 --
```
**The claim under test fails.** The regime is weakly decodable from `M` — and equally
weakly decodable from the memoryless RP's `h`, and from the `h` inside the very same
GRP organism, which is the comparison that holds the weights fixed. `M` is
consistently the *worst* of the three. The GRP's state has not built a regime variable;
it has not even preserved as much regime information as the layer feeding it.
The last row settles what the +0.05 is: the state-ablated GRP, whose `M` is a fixed
function of the current `h` with nothing carried between steps, decodes at 0.325. The
signal is an instantaneous read-off of the particle configuration — the field the
regime is currently imposing is visible in `r` right now — not something a memory
accumulated.
Three ways the null was stressed, none of which changes it:
- **Estimator.** Multinomial logistic (LBFGS, strong Wolfe) matches least squares to
within 0.006 everywhere. Not a least-squares artefact.
- **Entity identity.** `M` is dominated by stable per-entity structure (the particle's
type). Subtracting each entity's own train-split mean, in case a regime code hides
under that offset, moves accuracy by ≤0.002.
- **Target.** The regime id is an arbitrary label over four random coupling matrices;
what entity *i* actually needs is its own row `k[t_i, :]` of the current one. Probing
each of the three signed entries as a 3-class problem, against measured chance:
```
representation acc chance gap above chance
-------------------------------------------------------
rp_only h 0.514 0.488 +0.025 20/24
grp_k0 h 0.517 0.484 +0.033 22/24
grp_k0 M 0.506 0.482 +0.024 21/24
```
Same picture on the target the domain actually rewards: `M` last, `h` no worse.
### Adaptation latency
Reported for completeness and not interpretable. Decoding the regime per step by
averaging the 16 entities' probe scores, the mean number of steps from a switch to the
first correct decode is 12.0 for `M` and 10.7 for `rp_only`'s `h` — but 40 of 164
switches never decode correctly before the next switch arrives. **A latency measured
off a probe running 5 points above chance is measuring the probe's noise.** The honest
statement is that neither representation supports reliable regime decoding, so neither
has a measurable adaptation latency by this route.
## 3. What the state is doing instead
The gate, measured over every frozen step and entity:
```
condition mean g sd frac g>0.9 frac g<0.1
---------------------------------------------------------
grp_k0 0.500 0.029 0.000 0.000
grp_k0_nostate 0.509 0.025 0.000 0.000
```
`g = σ(W_g[h‖M] − κa)` with `κ = 0`. A mean of 0.500 with sd 0.029 and no saturation
in either direction, on every seed, means the gate's pre-activation is sitting at zero:
it is at its initialisation and 8000 training steps have not moved it. The update
`M ← (1−g)M̃ + gM` degenerates to a fixed 50/50 blend — a two-step exponential moving
average of `tanh(W_c[h‖M])`, with no input dependence. **Nothing is being decided about
what to keep.**
Persistence confirms there is no long integration to point at. Lag-1 autocorrelation
and the lag at which it falls below 1/e, per channel:
```
condition rep lag-1 tau
--------------------------------------
rp_only h 0.964 18.1
grp_k0 h 0.960 14.0
grp_k0 M 0.980 13.6
grp_k0_nostate M 0.959 13.1
```
`M` is marginally smoother at lag 1 than the `h` it is built from, and *less* persistent
over the 1/e horizon than the memoryless RP's own `h`. Representations in this domain
are slow because the world is slow, not because anything is integrating them.
## 4. Which one understands the domain?
**Neither, and the question does not currently have a mechanism to attach to.**
There is no evidence in this experiment that either model has come to represent which
regime the world is in. The regime is weakly present in both models' representations at
about +0.05 over a measured chance of 0.27, and it is present in exactly the same
amount in a network with no state at all, which identifies it as an instantaneous
read-off of the visible configuration rather than an internal variable either organism
built.
What the frozen probe does establish, and it is worth having:
- **The margin is real and it is not a learning-rate artefact.** With every weight
bit-frozen, the gated architecture predicts 2.5x better than the plain relational
perceptron, on 8 seeds out of 8. Task 7's `lr` objection is answered: no optimiser
step is available to either model here.
- **The margin is not memory.** It is 4160 extra feedforward parameters. Ablating the
state while keeping them preserves the entire effect (1.06x, 4/8 seeds) and leaves
the recovery curve unchanged at every lag.
- **The GRP's gate is untrained.** It sits at 0.5 with no input dependence, which is a
sufficient mechanistic explanation for both nulls and is a fact about this setup, not
about the architecture.
The last point is the actionable one. This is a measured null about *this* domain and
*this* training budget, not an impossibility result. The gate never learned to gate,
and §1b explains why it had no reason to: the post-switch error is dominated by the
world's own configuration transient, which no amount of state can shorten. A domain
where regime identity is worth something to a per-entity state — where the transient is
short and the ambiguity is long — would give the gate a job. This one does not, which
is the same conclusion §6(c) of `headroom.md` reached from the other direction.
## 5. Consequences for A1
- **Do not claim A1 as a memory result on this domain.** The frozen-weights version of
the comparison, which is the strongest form available, attributes the margin to
capacity. Any A1 comparison of `rp_only` to `grp_k0` is confounded 3.9x on parameter
count and needs `grp_k0_nostate` alongside it, in the trained setting too, where the
same decomposition gives capacity 3.06x on 8/8 seeds and state 1.25x on 4/8.
- **Task 7's requirement 2 inherits this.** The 2.99x at `lr=1e-3` and the
frozen-*regime* reliability argument in `headroom.md` §5 were both measured without a
capacity control. Neither is safe to quote as a memory claim as it stands. The
frozen-regime runs should be re-run with `grp_k0_nostate` before §5's "memory reaches
the floor every time" sentence is carried into the paper.
- **`recovery[k]` is not an adaptation measurement in this domain.** It tracks the
world's post-switch transient, and a stateless frozen model reproduces its shape. Any
A1 claim phrased on recovery curves needs a different observable.