Tiered Memory
An exact episodic ring in front of a centroid bank, with Nerode merging — fuse memories only when queries can't tell them apart.
Tiered Memory
The topline architecture: a semantic/episodic split in the lineage of the Compressive Transformer and Infini-attention (see Related Work), plus a merging criterion borrowed from automata theory — merge memories the readers cannot distinguish (a Nerode congruence over keys), not merely nearby keys.
Mechanics: an exact episodic ring of the last e raw (k, v) pairs per
(layer, kv-head); evictions demote into a K-Means Memory-style centroid
bank; one softmax reads the union (ring entries at mass 1). Every nerode
tokens, centroid pairs merge when their score profiles against a probe
buffer of recent queries agree within tau at every probe and their value
means agree within tv RMS — keys differing only in directions queries
never probe merge here, but never under Euclidean distance.
How we know this
| impl | spec | max_dlogit |
|---|---|---|
| sliding | sliding:256 | 0.000000 |
| kmeans-exact | kmeans:l=0 | 0.000000 |
| tiered-exact | tiered:e=1024;l=0;nerode=0 | 0.000000 |
| sink-exact | sink:s=16;w=256 | 0.000000 |
Findings
- The ring fixes short-range fidelity. On the standard probe the standing-best configuration agrees with causal attention on 68 of 70 positions — the best of any compressing configuration measured (full table in K-Means Memory) — and merging causes no short-range damage.
- Ring size is a copy-loop dial: sharp recency attention over a long window lets generation lock onto its own tail. A long ring (e=64) produced seed-dependent repetition collapses on 2048-token streams; e=16 never collapsed. The episodic channel must never search its own output.
- Aggressive merging reproduces the reindex lesson from
K-Means Memory: pooled mass's log-mass score advantage outcompetes
fresh content.
tau=0.2, tv=0.05is the working regime. A merged-mass suppression score (max instead of sum on merge) confirmed the collapse mechanism and widens the safe window, but doesn't advance the standing best. - Surprise-gated insertion (
g>0) spends capacity on novelty, not arrival order: a demoted token births a centroid only if its distance to the nearest centroid exceedsg× the running mean assignment distance. (A training-free cousin of DMC's learned append-vs-accumulate policy — see Positioning.) The gate only works behind the ring: gating all inserts from token 0 anchors the distance EMA on garbage, which is why the same idea failed as a k-means birth policy. - Gate and Nerode merging are substitutes, not complements — a full 2×2 ablation confirmed each mechanism alone rescues the baseline's worst seed, but "both" is numerically identical to gate-only wherever the gate is active: gating prevents duplicate centroids, so merges drop to ~0. Pick one — nerode-only for the analysis story (and the novelty claim), gate-only for cheapest operation.
- The gate carries a 4× smaller bank: at m=32 (64× compression at 2048 tokens) the gated configuration holds a stream floor of 0.40/0.35/0.38 where ungated k-means at the same budget collapsed in the original experiment runs.
Against the eviction baseline
The literature's canonical streaming baseline is attention sinks + a recent
window (StreamingLLM), re-implemented here as sink:s,w:
How we know this
| impl | seed | first | last | min |
|---|---|---|---|---|
| tiered-nerode-s1 | 1 | 0.58 | 0.50 | 0.38 |
| tiered-nerode-s2 | 2 | 0.49 | 0.50 | 0.49 |
| tiered-nerode-s3 | 3 | 0.54 | 0.52 | 0.38 |
| sink4-124-s1 | 1 | 0.56 | 0.22 | 0.22 |
| sink4-124-s2 | 2 | 0.54 | 0.28 | 0.28 |
| sink4-124-s3 | 3 | 0.57 | 0.40 | 0.32 |
| kmeans128-s1 | 1 | 0.63 | 0.52 | 0.31 |
| kmeans128-s2 | 2 | 0.55 | 0.49 | 0.43 |
| kmeans128-s3 | 3 | 0.48 | 0.53 | 0.35 |
| kmeans64-s1 | 1 | 0.58 | 0.50 | 0.36 |
| kmeans64-s2 | 2 | 0.43 | 0.36 | 0.29 |
| kmeans64-s3 | 3 | 0.52 | 0.50 | 0.44 |
| tiered32-gate-s1 | 1 | 0.60 | 0.45 | 0.40 |
| tiered32-gate-s2 | 2 | 0.60 | 0.43 | 0.35 |
| tiered32-gate-s3 | 3 | 0.45 | 0.54 | 0.38 |
| lattice-best-s1 | 1 | 0.55 | 0.60 | 0.52 |
| lattice-best-s2 | 2 | 0.55 | 0.56 | 0.54 |
| lattice-best-s3 | 3 | 0.39 | 0.67 | 0.39 |
Standing best
tiered:m=64,e=16,nerode=64,tau=0.2,tv=0.05 — at half the centroid
budget of kmeans:m=128 it matches or beats it on stream health and never
collapses: 3-seed minimum distinct ratio
0.38/0.49/0.38 vs k-means m=128's
0.31/0.43/0.35 and m=64's
0.36/0.29/0.44. verifiedHow we know this
| impl | seed | first | last | min |
|---|---|---|---|---|
| tiered-nerode-s1 | 1 | 0.58 | 0.50 | 0.38 |
| tiered-nerode-s2 | 2 | 0.49 | 0.50 | 0.49 |
| tiered-nerode-s3 | 3 | 0.54 | 0.52 | 0.38 |
| sink4-124-s1 | 1 | 0.56 | 0.22 | 0.22 |
| sink4-124-s2 | 2 | 0.54 | 0.28 | 0.28 |
| sink4-124-s3 | 3 | 0.57 | 0.40 | 0.32 |
| kmeans128-s1 | 1 | 0.63 | 0.52 | 0.31 |
| kmeans128-s2 | 2 | 0.55 | 0.49 | 0.43 |
| kmeans128-s3 | 3 | 0.48 | 0.53 | 0.35 |
| kmeans64-s1 | 1 | 0.58 | 0.50 | 0.36 |
| kmeans64-s2 | 2 | 0.43 | 0.36 | 0.29 |
| kmeans64-s3 | 3 | 0.52 | 0.50 | 0.44 |
| tiered32-gate-s1 | 1 | 0.60 | 0.45 | 0.40 |
| tiered32-gate-s2 | 2 | 0.60 | 0.43 | 0.35 |
| tiered32-gate-s3 | 3 | 0.45 | 0.54 | 0.38 |
| lattice-best-s1 | 1 | 0.55 | 0.60 | 0.52 |
| lattice-best-s2 | 2 | 0.55 | 0.56 | 0.54 |
| lattice-best-s3 | 3 | 0.39 | 0.67 | 0.39 |
Merging frees slots, so merge aggression converts directly into birth capacity for new content — 64 centroids that act like 128. Frozen, this retrofit already beats every prior configuration on validation CE (2.0644 vs frozen exact's 2.6080 at 2× context): the exact ring supplies the sharp local attention that cluster reads blur, without the RoPE-extrapolation penalty. Training in the Loop takes it further.