suchirsalhan's picture
Add H-Net dynamic-chunking artefacts
5deafcd verified
|
Raw History Blame Contribute Delete
8.31 kB
# Experiment 25 — activation patching on learned chunk representations
**Are the units a dynamic chunker invents genuinely functional computational units, or compression artefacts?**
Run: `python experiments/exp25_chunk_patching.py` (~8 min, 1 GPU).
Artifacts: `patches.csv` (52,025 patches), `summary.json`; site-redraw replicate in `patches_siteseed1.csv` / `summary_siteseed1.json`.
Adapter: `interp/runner.py`. Estimators: `interp/patching.py`, unmodified.
## Headline
**No.** At this scale the learned chunks are not privileged loci of information. Replacing a whole
chunk state at its boundaries and replacing the same number of bytes starting mid-chunk are, within
across-seed spread, the same intervention. Aligned-minus-misaligned averaged over depth:
| condition | aligned (damage, nats/byte) | misaligned | **contrast (A−M)** | contrast − Gaussian null |
|---|---|---|---|---|
| A (no parity) | −0.0091 | −0.0114 | **+0.0023 ± 0.0039** | +0.0028 ± 0.0049 |
| B (parity, per-sent) | −0.0071 | −0.0184 | **+0.0114 ± 0.0072** | +0.0070 ± 0.0070 |
| Apc (no parity, per-cp) | −0.0094 | −0.0081 | **−0.0013 ± 0.0020** | +0.0024 ± 0.0036 |
| Bpc (parity, per-cp) | −0.0085 | −0.0103 | **+0.0017 ± 0.0064** | +0.0009 ± 0.0019 |
`±` is the spread **across the 3 seeds**, never pooled over items. Every value is a mean over
layers 0–6; the per-layer table is in `summary.json` under `results.mono`.
`0/28` (family × layer) cells have |mean| > 2 across-seed SD under an independent draw of patch
sites; `1/28` do under the first draw (B/L0), and that one cell does not survive the redraw. Of 84
item-level permutation tests (one per family × layer × seed), 6.0% fall below p = 0.05 — the rate
you get by construction.
## Why the effects are this small: the chunk pathway itself
Without a positive control the number "0.01 nats" is uninterpretable. Two ablations, whole-sentence,
nats/byte, averaged over the 12 checkpoints:
| intervention | Δ NLL |
|---|---|
| base NLL | 1.417 |
| **zero the entire main-network contribution to the decoder** | **+0.344** (24% of the loss) |
| **replace every chunk state (26 of them) with an unrelated sentence's** | **+0.243** |
| that ceiling divided by the mean chunk count | +0.0093 |
| **replace ONE chunk state (aligned, layer 0)** | **+0.0176** |
The chunk pathway is genuinely load-bearing — deleting it costs a quarter of the model's
predictive performance. But a single chunk's causal contribution is within ~2× of the aggregate
effect divided by the number of chunks. The information is **additive and diffuse across chunks**,
not concentrated in the unit that the router carved out. That is the negative result, and it is
the same result whether the edit respects a boundary or not.
## Depth
Effect magnitude decays monotonically with depth in every family — layer 0 (states entering the
main net) ≈ 0.018 nats damage, layer 6 (final main block) ≈ 0.004 — i.e. a chunk's identity is
most consequential where it enters the stack and is progressively mixed away. The
aligned-vs-misaligned contrast shows no depth structure: it is flat and inside seed spread at
every layer.
**Limitation.** Only `ckpt_last.pt` (step 6000) was retained for these 27 runs, so this is depth at
the FINAL step only. The layer × training-time version — where the interesting question (when do
units become causally functional?) lives — needs intermediate weights that do not exist and would
require re-running training with `keep_ckpt` on.
## A vs B
Condition B (parity-trained, per-sentence β) is the only family with a consistently positive
contrast, present at all 7 layers and in both site draws (+0.0114 ± 0.0072 and +0.0098 ± 0.0114).
Its misaligned edits do ~2.6× the damage of its aligned edits. **This is suggestive and it is not
significant**: the across-seed SD is comparable to the mean, it does not survive subtraction of the
statistics-matched Gaussian null in the replicate (+0.0025 ± 0.0016), and the matched per-codepoint
pair (Apc vs Bpc) does not reproduce the ordering (−0.0013 vs +0.0017). With 3 seeds it is an
anecdote. Reported because the pre-registration says both answers are results, not because it
supports the parity hypothesis.
## Cross-lingual (secondary)
`patching.ChunkPatchStudy` run unchanged, donor = English, recipients de / hi / zh / ta, layer 0,
content-matched (parallel FLORES+ row) against the content-mismatched-donor null:
- aligned-minus-null across all 16 (family × language) cells: mean **−0.0006**, range −0.0083…+0.0072,
mean across-seed SD 0.0059. **1/16** cells exceed 2 SD — chance.
- Donating an English chunk into a Hindi or Tamil forward pass does nothing distinguishable from
donating an unrelated English chunk.
Caveat inherent to the design: the donor chunk is taken at the same *chunk index*, not the same
*content*, so cross-lingual chunk k is not the translation of recipient chunk k. This is
`patching.py`'s pre-registered design and it makes the cross-lingual leg a weak test.
## Controls that passed
- **Identity (the load-bearing assertion).** Patching a chunk with its own vector is a bit-exact
no-op — `max |Δ NLL| = 0.0` — via **both** injection paths, at layers 0, 3 and 6, on all 12
checkpoints. The bytes path only degenerates to the chunks path when the byte range coincides
with a chunk span, so this tests the overlap arithmetic itself. The driver raises if it is
non-zero.
- **Forward fidelity.** `runner._forward` (which threads an injection point through the main stack)
agrees with `HNet.forward` to `max |Δ logits| = 0.0` when unpatched, so the depth sweep cannot
silently diverge from the trained model's own computation.
- **Statistics-matched Gaussian donor** (right per-dimension mean/SD at that layer, no content),
run in both aligned and misaligned form, so the reported contrast has its own null contrast.
Overall `contrast − null` = +0.0033, mean |value| 0.0034, mean across-seed SD 0.0055.
- **Perturbation mass.** A misaligned byte range does not carry the same total overlap weight as
the chunk it displaces: mean mass 1.18 vs 1.00. Restricting to misaligned patches with mass in
[0.9, 1.1] does not change any conclusion (mass-matched contrasts in `summary.json`).
- **Site-redraw replicate.** Independent draw of which chunk is patched: contrasts correlate
r = 0.64 across the 28 cells with 89% sign agreement and mean |difference| 0.0031 — comparable to
the effects themselves. Item-sampling noise is not negligible at this effect size.
## What was built
`interp/runner.py` — the adapter `interp/patching.py` asks for, closing the `[GAP]` flagged in
`interp/README.md` §5.3:
- `encode(lang, sent_idx)` / `nll(lang, sent_idx, patch=None)` against `scratch/ckpt/<run>/ckpt_last.pt`
on the trainer's byte-identical FLORES+ probe (`probe/probe_text.jsonl`), one sentence per forward
pass, fp32, no padding.
- Both injection paths: `{"chunks": {j: v}}` (aligned) and `{"bytes": ((b0,b1), v)}` (misaligned),
the latter via `model.apply_byte_patch`, which writes into every overlapping chunk state in
proportion to overlap.
- **Injection at arbitrary depth** of the main network (layer 0 = chunk states entering it;
layer *l* = output of main block *l*−1), with donor vectors drawn from the donor's forward pass at
the same layer. This is new; `HNet.forward` could only inject at the main net's input.
- Positive-control ablations `{"kill_main": True}` and `{"all": matrix}`.
`experiments/exp23_interp_validation.py` still passes **49/49** (15.9 s).
## Other limitations
- 16.2 M-parameter models, 6000 steps, one hierarchy stage. A causal null at this scale is not a
causal null at scale; it is evidence that unit-localisation is not automatic.
- Probe = 96 English FLORES+ sentences with ≥ 6 chunks, truncated at 512 bytes, mean 26 chunks each.
- The architecture caps the achievable effect: the byte-level encoder residual reaches the decoder
directly (`decoder(h + res_gate * up)`), so 76% of the model's prediction quality is untouchable
by any chunk-state patch. An H-Net without that residual would be a sharper test.
- Seed spread is estimated from 3 points, so "± SD" is indicative, not an interval.