# You could have invented transformers from memory

- **ID:** 1388
- **Kind:** post
- **URL:** https://alexwang.ai/posts/associative-memory/
- **Authors:** Alex Wang (researcher, San Francisco, PhD CS Stanford — long-context architectures for sequence modeling and memory, ex-research scientist at Cartesia)
- **Venue:** Alex Wang's blog (alexwang.ai, published 2026-10-15)
- **Published:** 2026
- **Source:** blog
- **Language:** en
- **Access:** free
- **Added:** 2026-10-16
- **Verified:** 2026-10-16
- **Page:** https://papers.projxon.ai/entries/1388

## Summary

A pedagogical explainer (not a research result) deriving linear maps, MLPs, and self-attention as associative key-value memory stores from first principles. The unifying quantity is the interference-to-signal ratio — interference from other stored memories vs the target's signal — and capacity is the number of memories before interference matches signal (random unit keys, query with a stored key). At d_k=64: outer-product linear store ≈64; optimal linear (least-squares/whitened keys) ≈128; ReLU MLP ≈128; squared ReLU / SwiGLU ≈2d_k²/3 ≈2,700–2,900; cubed ReLU ≈2d_k³/15 ≈35,000; self-attention with β=√d_k ≈e^{2√d_k−2} ≈1.2 million; β ∝ log M allows an essentially unbounded store (>2M in experiments). Derivations: interference terms add like a random walk (√M); σ(s)=ReLU(s)^p gives capacity M≈d_k^p; the exponential is a weighted sum of all powers, so capacity grows exponentially in the sharpness β: M≈e^{2β(1−β/d_k)} for β≪d_k; normalizing weights for numerical stability yields exactly f(x)=Vᵀsoftmax(βKx). Unlike MLPs, self-attention is non-parametric: keys/values come from context tokens, so the store grows with context length. Notes that the original transformer's v2/v3 described the feedforward layer as "a kind of attention" (passage removed from later versions) and tried replacing FFNs with learned-key-value attention at similar quality. The long-context section compares β∝log M tricks (Su 2021 entropy scaling, Scalable-Softmax, Qwen LogN-Scaling, Qwen2.5-1M YaRN scaling), driving the interference ratio to ~10⁻⁴ at 2M memories. Author-stated caveat: the count is random-vector recall of a single layer, ignoring training data; companion pointers to bits-per-parameter memorization work (Morris et al. ~3.6 bits/param; Allen-Zhu & Li ~2 bits factual knowledge/param). Includes interactive demos (sliders for M and β with live interference/signal visualization). Asides: a gradient-descent step is a memory write (Irie, Csordás & Schmidhuber); transformers' MLPs store facts in superposition.

## Research notes

- Discovery: Hudson shared the bare blog link directly 2026-10-16; post read in full; published 2026-10-15 per the page. Relevance: (1) pedagogical explainer, not a research result — label as such; (2) conceptual anchor for his memory-scaling line: queued #48 xHC (residual-stream expansion explicitly framed as memory scaling), #11 MSAR, #15 MGVR, #41 ScalingDepth, #870 DepthBench, #43 MAI-Base-2, #52 Nemotron long-context transduction, #849 ThunderSyncRL — the post gives the cleanest intuition for why memory scaling matters and where each component's capacity comes from (linear ≈d_k, MLP ≈thousands via power-law suppression, attention ≈unbounded); (3) the "gradient descent step writes a memory" aside connects to his training-dynamics interests (#901 mode-hopping); (4) the references list name-checks Gated DeltaNet (his known stack line — Gated DeltaNet isn't faster than a Transformer until ≥16k context) and the full memory-research map (dense associative memory → Mamba/Titans → product-key/UltraMem → RETRO/kNN-LM → ROME/MEMIT → KVzip/gist tokens). Caveats: idealized random-key analysis; no training-data accounting. Cluster: memory capacity, associative memory, long-context scaling, transformer interpretability. No code released; all math hand-derived with interactive figures.
- License: n/a

## Similar entries

- [The Surprising Effectiveness of Shared Memory in Looped Transformers](https://papers.projxon.ai/entries/1255) (paper, #1255)
- [Agent Memory Repo (Cognition) — open spec for persistent agent memory](https://papers.projxon.ai/entries/1269) (code, #1269)
- [Block Delta Memory (BDM): Sparse Recurrent Memory with Dense Execution](https://papers.projxon.ai/entries/1060) (code, #1060)
- [Balancing Memory Pathways: Analyzing and Improving Memory Utilization in Hybrid LMs](https://papers.projxon.ai/entries/1282) (paper, #1282)
- [Memory Caching: RNNs with Growing Memory](https://papers.projxon.ai/entries/461) (paper, #461)
- [LiFT: Loop Flow Transformers](https://papers.projxon.ai/entries/1274) (paper, #1274)
