An Index — kept by Alek
DeepSeek-AI  ·  Peking University  ·  12 Jan 2026 A technical index  ·  12 entries

Engram.

Conditional memory via scalable lookup

A transformer has no instruction for look it up. It has one for compute it, and so it burns layers of attention and FFN reconstructing “Alexander the Great” from three subword fragments, every time. Engram adds the missing primitive: a hash-addressed embedding table read in O(1), placed inside the residual stream, gated by context. This page takes it apart — the addressing arithmetic, the allocation law, the measured effects.

Paper
Conditional Memory via Scalable Lookup: A New Axis of Sparsity for Large Language Models
Authors
Cheng, Zeng, Dai, Q. Chen, B. Wang, Xie, Huang, Yu, Hao, Li, H. Zhang, H. Zhang, Zhao, Liang
Code
github.com/deepseek-ai/Engram
Largest model
Engram-40B — 39.5B total / 3.8B activated
Headline
MMLU +3.0 · BBH +5.0 · Multi-query NIAH 84.2 → 97.0
Claim under test
Memory is a sparsity axis, not an add-on
N° 01Premise

Retrieval simulated as computation

Language modelling runs two workloads through one mechanism. Compositional reasoning — multi-step inference, arithmetic, code — genuinely needs deep, input-dependent computation. Static recall — named entities, idioms, formulaic collocations — does not. It needs a table.

Transformers only have the first mechanism, so they emulate the second. The canonical demonstration comes from PatchScope: decode the residual stream at the token Wales layer by layer and watch six blocks of attention and FFN assemble a single entity that a lookup would have returned in one step.

LayerLatent state translation (PatchScope)Resolved entity
1–2Country in the United KingdomWales
3Country in EuropeWales
4Title held by female sovereigns in their own right or by queens consortPrincess of Wales (unspecific)
5Title given to the wife of the Prince of Wales (and later King)Princess of Wales (unspecific)
6Diana, Princess of Wales (1961–1997), the first wife of Prince Charles, Prince of Wales, famous for her beauty and humanitarian workDiana, Princess of Wales
Table 3. Six sequential blocks consumed to resolve one static multi-token entity. Sequential depth is the scarcest resource in a transformer; here it is spent on an operation with no reasoning content. Reproduced from Ghandeharioun et al. (2024).

The wasted depth is the target. Engram's thesis is that if the model can address that entity directly, the freed layers become available for work that actually requires them — which is why the paper's largest gains land on BBH (+5.0) and ARC-Challenge (+3.7), not on the trivia benchmarks you would expect a memory module to move.

N° 02Two axes

Conditional computation, conditional memory

MoE is conditional computation: a router reads the hidden state and activates a sparse subset of experts. Engram is conditional memory: a hash of the input tokens addresses a sparse subset of embedding rows. Both raise total parameters without raising per-token FLOPs. They differ in the one property that determines where the parameters are allowed to live.

PropertyMoE — conditional computationEngram — conditional memory
Selected unitExpert FFN (top-k of N)Embedding row (1 per hash head)
Address derived fromHidden state h_t — a runtime valueInput token IDs — known in advance
Address known atLayer execution timeBefore the forward pass begins
Work per activationTwo matmuls per expertOne gather. O(1), no arithmetic
Parameters may liveHBM only — needed mid-flightHost DRAM, NVMe — prefetchable
Access distributionBalanced by construction (aux-loss / bias)Zipfian — cacheable by frequency
Fails atCheap static recallAnything context-dependent

The third row is the load-bearing one. Because an Engram address is a pure function of input_ids, the table can sit off-accelerator and still arrive on time — the property Section 11 turns into a 100B-parameter layer in host memory at a 2.8% throughput cost.

Where the parameters go

Fix total parameters P_tot and activated parameters P_act. The inactive remainder P_sparse = P_tot − P_act is free capacity — it scales the model without scaling the compute. The allocation ratio ρ splits it:

P_sparseMoE = ρ · P_sparse     P_Engram = (1 − ρ) · P_sparse    ρ = 1 ⇒ pure MoE

Section 06 shows this has an interior optimum. That is the paper's central empirical claim: pure MoE is not the right allocation.

N° 03Addressing

From token IDs to 16 table addresses

Everything upstream of the embedding lookup is integer arithmetic on input_ids — no weights, no gradients, no data dependence on the hidden state. Four stages: canonicalise, window, mix, reduce.

STAGE 1 — CANONICALISE STAGE 2 — SUFFIX WINDOW STAGE 3 — MULTIPLICATIVE-XOR MIX STAGE 4 — REDUCE mod Mₙ,ₖ input_ids x_t 19737 ␣Alexander 270 ␣the 9327 ␣Great RAW · |V| = 129,280 P : V → V′ 15695 · 237 · 2049 NFKC→NFD→strip→lower CANONICAL · |V′| = 98,628 −23.7% CLASSES n = 2 suffix 2-gram ( x′_{t−1} , x′_t ) n = 3 suffix 3-gram ( x′_{t−2} , x′_{t−1} , x′_t ) CAUSAL · LEFT-PADDED WITH pad_id 4-GRAMS TESTED, NOT KEPT — §09 WHY SUFFIX, NOT WINDOW the key ends at t, so a hit marks pattern completion mix = (x′_t · m₀) ⊕ (x′_{t−1} · m₁) ⊕ … SIGNED 64-BIT · m_k ODD · NO OVERFLOW MULTIPLIERS — LAYER 2, seed 0 76867402669959 · 37272333609899 22753931226247 PROPERTIES odd m_k ⇒ multiplication invertible mod 2⁶⁴ ⊕ across positions ⇒ avalanche on any token order matters: m_k is position-indexed layer-seeded: seed + 10007·ℓ ⇒ decorrelated z_{t,n,k} = mix mod M_{n,k} k=1 M = 646403 → E₂,₁[z] k=2 M = 646411 → E₂,₂[z] ⋮ ⋮ ⋮ k=8 M = 646523 → E₂,₈[z] 8 HEADS × 2 ORDERS = 16 ROWS DISTINCT PRIMES, NEVER REUSED 32 consecutive primes from 646,403 cover both layers; coprime moduli mean a collision in one head is independent of the others — 16 votes, not 1
Figure A. The retrieval path, with real values. Multipliers and prime moduli are reproduced from engram_demo_v1.py at seed 0 for the paper's layer 2 placement; canonical IDs are from the actual DeepSeek-V3 tokenizer. Nothing here depends on the hidden state.

03.1 — Tokenizer compression

Collapsing a lossless vocabulary into a semantic one

A BPE vocabulary is built for lossless reconstruction, so it splits one concept across many IDs: Apple, ␣apple, APPLE. For a hash key that is pure waste — each variant addresses a different, separately-trained row. Engram first applies a precomputed surjective map P : V → V′ built from textual normalisation.

normalizers.Sequence([
  NFKC(),                      # compatibility composition
  NFD(), StripAccents(),        # decompose, drop diacritics
  Lowercase(),
  Replace(Regex(r"[ \t\r\n]+"), " "),   # collapse whitespace runs
  Replace(Regex(r"^ $"), SENTINEL),     # protect a lone space …
  Strip(), Replace(SENTINEL, " "),      # … from Strip()
])
# byte-fallback tokens (decode to U+FFFD) bypass this and key on
# their raw token string, so they stay distinct.

Note the sentinel dance: Strip() would erase a token that is exactly one space — a very high-frequency token — so it is swapped for a private-use character and swapped back.

RankMergedCanonicalRaw surface forms
1163'␣'\t \n \r ␣ ␣␣ \n\n ␣␣␣ …
254'a'A a ␣a ␣A á ä ã ą ␣à â …
340'o'O o ␣o ␣O ó ö ô õ ő ò …
435'e'E e ␣e ␣E é è ␣é ę ě ê …
530'i'I i ␣I ␣i í ì î ī ï ␣î …
Table 6, reproduced. Running the paper's normaliser over the real DeepSeek-V3 vocabulary returns these exact merge counts. The 465 reserved IDs that decode to the empty string form a larger class and are excluded, as in the paper.
129,280
Raw vocabulary |V|
98,628
Canonical |V′|
23.4%
Reduction (paper)

The effect is not merely compression. Inside the sentence By the way, I am a fan of the Milky Way. the tokenizer emits ␣way (1722) and ␣Way (13823) as unrelated IDs; P sends both to canonical 1461. The 2-gram key for “the way” and the key for “…y Way” now share statistics that the raw vocabulary kept apart. Removing this step is one of the three ablations that hurt most (§09).

03.2 — Multi-head hashing

Why eight heads and why prime moduli

The space of 3-grams over a 98k vocabulary is ~9.6 × 1014 keys. No table enumerates that, so Engram hashes into a fixed number of slots and accepts collisions — then makes them survivable. Each order n gets K = 8 heads, each with its own prime modulus, none reused across heads, orders, or layers.

z_{t,n,k} = φ_{n,k}( g_{t,n} ) ,   e_{t,n,k} = E_{n,k}[ z_{t,n,k} ]    (1)
e_t = _{n=2..N} _{k=1..K} e_{t,n,k}  ∈  ℝ^d_mem    (2)

Two keys that collide in head k almost certainly do not collide in the other seven, because the moduli are coprime and the multipliers are independent. The concatenation in (2) means the fusion layer sees eight near-independent readings of the same key; a single corrupted one is recoverable. Prime — rather than power-of-two — moduli avoid the classic failure where mod 2^b keeps only the low bits and discards the avalanche the XOR just produced.

Table packing

All 16 head-tables are one nn.Embedding. Each head's index is shifted by the cumulative size of its predecessors, so the 16 addresses become one contiguous gather — a single kernel, one memory transaction pattern, no per-head dispatch.

offsets = cumsum([0, M₂,₁, M₂,₂, …, M₃,₇])
rows    = embedding[ z + offsets ]   # [B,L,16,d_head]
e_t     = rows.flatten(-2)         # [B,L,d_mem]

Layer decorrelation

Multipliers are drawn per layer from seed + 10007·ℓ, forced odd (2r+1) so multiplication stays a bijection mod 264, and bounded so x′·m cannot overflow int64. The Engram at layer 2 and the Engram at layer 15 therefore see the same n-gram at completely different addresses — they are independent memories, not two reads of one.

Layer / orderk=1k=2k=3k=4k=5k=6k=7k=8
ℓ = 2, n = 2646403646411646421646423646433646453646519646523
ℓ = 2, n = 3646537646543646549646571646573646577646609646619
ℓ = 15, n = 2646631646637646643646669646687646721646757646771
ℓ = 15, n = 3646781646823646831646837646843646859646873646879

32 distinct primes, searched upward from engram_vocab_size − 1 = 646,399 with a shared seen-set across layers. Reproduced by running the repository's find_next_prime loop. These are the demo configuration's table sizes; Engram-27B uses 2,262,400 slots per head.

N° 04Fusion

Gating a static prior against live context

The retrieved vector e_t is context-free by construction. It is the same 1280 numbers whenever those three canonical tokens co-occur — correct for “Alexander the Great”, wrong when the n-gram is a hash collision or a polysemous fragment. Engram therefore never adds e_t to the residual stream directly. It scores it first.

INPUTS PROJECTIONS SCORE GATE, THEN APPLY MIX, THEN RETURN h_t^(m) — QUERY BRANCH m OF 4 · d = 2560 POST-ATTENTION HIDDEN STATE e_t — KEY AND VALUE 16 ROWS · d_mem = 1280 STATIC · NO CONTEXT YET RMSNorm( h_t ) q̂ RMSNorm( W_K^(m) e_t ) PER-BRANCH — 4 DISTINCT W_K v_t = W_V e_t SHARED ACROSS ALL 4 BRANCHES ⟨ q̂ , k̂ ⟩ / √d SCALED COSINE α_t^(m) = σ( · ) ONE SCALAR, PER TOKEN ṽ_t = α_t^(m) · v_t α → 0 SUPPRESSES THE MEMORY SiLU( Conv1D( RMSNorm(Ṽ) ) ) + Ṽ DEPTHWISE · CAUSAL · w = 4 DILATION 3 · ZERO-INIT Y H^(ℓ) ← H^(ℓ) + Y THEN ATTENTION, THEN MoE NEXT BLOCK
Figure B. The fusion path for one of the four mHC branches. The hidden state supplies only the query — memory supplies both key and value — so the gate measures agreement between what was retrieved and what the context expects.
k_t = W_K e_t ,   v_t = W_V e_t    (3)

α_t = σ( RMSNorm(h_t) RMSNorm(k_t) / √d )    (4)

Y = SiLU( Conv1D( RMSNorm(Ṽ) ) ) + Ṽ ,   Ṽ = α_t · v_t    (5)

The gate is one number

Not a vector, not a per-dimension mask — a single scalar per token per branch. That is a strong constraint: the module may decide how much of a memory to admit, never which parts. It buys interpretability (§10 reads α directly as “a static pattern completed here”) and it keeps the fusion cheap.

RMSNorm on both sides before the dot product makes α a scaled cosine similarity rather than a magnitude comparison, which is what keeps gradients stable when the query and the memory live at very different scales early in training.

Four branches, one table

The backbone is Manifold-Constrained Hyper-Connections with M = 4 parallel residual streams. Engram shares the embedding table and W_V across all four, but gives each branch its own W_K^(m). So one retrieval is admitted at four different strengths — each branch decides independently whether it wants that memory.

The five projections (W_V + four W_K) fuse into a single FP8 GEMM. Removing branch-specific gating is the single most damaging ablation in §09.

Where to inject it

Placement is a genuine trade-off, and the paper resolves it empirically rather than by argument.

  • Earlier is better for offloading work. The point is to spare the backbone from reconstructing local patterns; do it after the backbone already has, and there is nothing left to spare.
  • Later is better for gating. α needs a query that has seen global context. At layer 1 the hidden state has been through no attention at all, and the four mHC branches have not yet diverged enough to gate differently.
  • Layer 2 wins the single-injection sweep (val loss 1.770). One round of attention is enough context; layer 1 is worse, and everything deeper degrades monotonically.
  • Two smaller modules beat one large one. Splitting the same 1.6B budget across layers 2 and 6 reaches 1.768 — early intervention plus late-stage contextual gating. Engram-27B uses layers 2 and 15.
  • And it happens to serve the hardware. A deeper second placement gives the prefetcher more compute to hide PCIe latency behind (§11).
N° 05Inspector

The addressing, running

Below is the real arithmetic — the DeepSeek-V3 tokenizer's IDs, the canonical map P, the seed-0 multipliers, and the prime moduli computed by the repository's own prime search. Pick a token to see the 16 addresses its suffix n-grams resolve to.

Engram layer

Key construction

Edit any canonical ID by one digit and watch every one of the 16 addresses move. Changed rows mark in red.

Resolved addresses

Head Order Modulus MAddress z Position in table

Verified against the reference implementation. Multipliers come from np.random.default_rng(0 + 10007·ℓ); the mix is computed in signed 64-bit (BigInt here, int64 there) and never overflows because each m_k is bounded by (2⁶³−1)/|V′|/2. The paper places Engram at layers 2 and 15; the shipped demo file uses layer_ids = [1, 15], and the moduli shown here follow the paper.

32
Slots read per token
16 heads × 2 layers
72.4M
Slots in Engram-27B
2,262,400 × 16 × 2
1 : 2.26M
Fraction of table
touched per token
2,560
Floats gathered
per token, all layers

Derived from Table 5 and Eq. 2: d_mem = 1280 is the concatenation of 2 orders × 8 heads × 80 dims, so 2,262,400 × 80 × 16 × 2 = 5.79B parameters — the paper's 5.7B Engram module. Engram-40B triples the slot count to 7,239,680 per head for 18.5B.

N° 06Allocation law

The U-curve: pure MoE is the wrong allocation

Hold P_tot and P_act fixed — same parameter count, same FLOPs per token — and sweep ρ, moving capacity from routed experts to embedding slots. If memory were merely a cheaper substitute for compute, loss would rise monotonically as ρ falls. It does not.

Figure 3, left — schematic with measured anchors. The three marked points are values stated in the paper; the connecting curve is interpolated to show the shape, not measured. Only the 6×10²⁰ FLOPs budget is drawn — the 2×10²⁰ run sits on a different loss range but produces the same U with the optimum in the same place (ρ ≈ 75–80%).
Allocation ρVal lossReading
100% — pure MoE1.724899 routed experts, no memory
≈ 80% — optimum1.7109Δ = −0.0139
≈ 40%≈ parity43 experts still matches pure MoE

Measured at C = 6×10²⁰, P_tot ≈ 9.9B, P_act = 993M. The optimum sits at ρ ≈ 75–80% in both compute regimes — stable enough to use as a design rule.

Why both ends lose

ρ → 100%. No dedicated store for static patterns, so the model rebuilds them through depth — the waste from §01, now priced.

ρ → 0%. No conditional computation left. A table cannot compose, cannot condition on context, cannot do arithmetic. Memory does not substitute for compute; it complements it.

The interior minimum is the whole argument. It says the two axes are structurally different rather than two ways of buying the same thing — and that frontier MoE models are sitting at a corner of the design space rather than inside it.

Released from the budget, memory keeps paying

Relax the parameter cap and the second scaling question appears: with a fixed 3B MoE backbone (568M activated, 100B tokens), how far does adding slots go? Sweeping M from 2.58×10⁵ to 1.0×10⁷ — up to ~13B added parameters — validation loss falls log-linearly across the entire range, with no sign of saturation.

The comparison that matters is OverEncoding, which also uses hashed n-gram embeddings but averages them into the input embedding at layer 0. Same memory budget, distinctly worse slope. How the memory is fused matters as much as how much of it there is.

Figure 3, right — schematic. Axis ranges are the paper's; the trends reproduce the reported log-linear behaviour and the relative ordering. Point values are not tabulated in the paper.
N° 07Pre-training

Iso-parameter, iso-FLOPs, 262B tokens

Engram-27B is MoE-27B with 17 routed experts removed and the freed parameters spent on a 5.7B embedding module — ρ = 74.3%. Identical backbone, identical data in identical order, identical activated parameters. The only difference is where the sparse capacity sits.

BenchmarkShots Dense-4BMoE-27B Engram-27BΔ vs MoEEngram-40B
Configuration
Total parameters4.1B26.7B26.7B39.5B
Activated (excl. token embed)3.8B3.8B3.8B3.8B
Experts — shared + routed (top-k)2+72 (6)2+55 (6)2+55 (6)
Engram parameters5.7B18.5B
Language modelling — loss, lower is better
Pile (test)2.0911.9601.950−0.0101.942
Validation set1.7681.6341.622−0.0121.610
Knowledge & reasoning
MMLU548.657.460.4+3.060.6
MMLU-Redux550.760.664.0+3.464.5
MMLU-Pro521.128.330.1+1.831.3
CMMLU547.957.961.9+4.063.4
C-Eval546.958.062.7+4.763.3
AGIEval029.138.641.8+3.245.9
ARC-Easy2576.886.589.0+2.590.1
ARC-Challenge2559.370.173.8+3.776.4
TriviaQA533.048.850.7+1.951.8
TriviaQA-ZH562.874.876.3+1.577.9
PopQA1515.119.219.4+0.221.2
CCPM072.279.687.1+7.587.7
BBH342.850.955.9+5.057.5
HellaSwag064.371.872.7+0.973.1
PIQA063.871.973.5+1.676.5
WinoGrande564.067.667.8+0.268.1
Reading comprehension
DROP (F1)141.655.759.0+3.360.7
RACE-Middle572.480.982.8+1.983.3
RACE-High566.075.478.2+2.879.2
C3057.760.163.6+3.561.8
Code & mathematics
HumanEval (pass@1)026.837.840.8+3.038.4
MBPP (pass@1)335.446.648.2+1.646.2
CruxEval-i027.630.732.2+1.536.2
CruxEval-o028.734.135.0+0.935.3
GSM8K835.558.460.6+2.262.6
MGSM827.046.849.4+2.652.4
MATH415.228.330.7+2.430.6

Table 1. All four models trained on the same 262B tokens. The Δ column compares the two iso-parameter, iso-FLOPs 26.7B models. Engram-40B keeps the activated budget fixed and only grows the table; it does not dominate on every task, which the authors attribute to under-training — the loss gap was still widening at the end of the run.

The surprising column

A memory module should move TriviaQA and PopQA. It moves them least (+1.9, +0.2). The largest gains are on CCPM +7.5, BBH +5.0, C-Eval +4.7, ARC-Challenge +3.7 — composition-heavy tasks with no obvious lookup component. Under the paper's account this is exactly right: the benefit is not the facts stored, it is the depth returned to the backbone. §09 tests that claim directly.

N° 08Long context

Attention, relieved of local work

Attention heads that spend themselves binding adjacent subwords into entities are not available for retrieval across 32k tokens. If Engram absorbs the local dependencies, the prediction is that long-range behaviour improves — even though Engram itself has a receptive field of three tokens.

The evaluation is unusually careful about a confound the authors flag themselves: long-context ability tracks general model quality, so comparing at equal steps conflates architecture with base capability. They therefore include an iso-loss checkpoint — Engram at 46k steps has the same pre-training loss as MoE at 50k — and give all variants the identical YaRN extension run (32,768 tokens, 5,000 steps, 30B tokens).

Model (steps, pre-train loss) LongPPL (32k) ↓ RULER (32k) ↑
BookPaperCodeL-CoT SMKMVMQVTCWEFWEQA
MoE-27B (50k, 1.63) 4.382.912.4914.16 100.088.092.784.277.04.573.034.5
Engram-27B (41k, 1.66) — 82% FLOPs 4.372.922.5014.26 99.688.393.089.583.23.899.644.0
Engram-27B (46k, 1.63) — iso-loss 4.192.842.4513.59 97.689.095.597.087.24.398.637.5
Engram-27B (50k, 1.62) — iso-FLOPs 4.142.822.4413.41 99.389.396.597.089.05.999.340.5

Table 2. S / MK / MV / MQ — single, multi-key, multi-value and multi-query needle-in-a-haystack. VT — multi-hop variable tracking. CWE / FWE — common and frequent word extraction. QA — long-document question answering.

84.2 → 97.0
Multi-query NIAH
at iso-loss
77.0 → 87.2
Variable tracking
at iso-loss
73.0 → 98.6
Frequent-word extraction
at iso-loss

The 82%-compute row is the sharper result: an Engram checkpoint stopped 9,000 steps early, at visibly worse pre-training loss, already matches the fully-trained MoE on LongPPL and beats it on RULER. Two honest caveats: single-needle accuracy is marginally lower (99.3 vs 100.0 — a saturated metric), and CWE stays broken for both models at 4.5 vs 5.9. Whatever common-word extraction needs, neither architecture has it.

N° 09Mechanism

Evidence that Engram buys depth

The claim from §01 — that lookups return sequential depth to the backbone — is testable with interpretability tools rather than benchmarks. Three independent probes agree.

1 — Predictions converge earlier

LogitLens projects every intermediate hidden state through the final LM head and measures KL divergence against the model's own final distribution: how prediction-ready is layer ? Both Engram variants sit systematically below the MoE baseline, with the widest gap in the early blocks — precisely where the entity-composition work of Table 3 would otherwise happen.

2 — Shallow layers behave like deep ones

Centered Kernel Alignment compares representations across models. Build the pairwise CKA matrix over Few-NERD entity-final tokens, then take the similarity-weighted centroid of the top-5 matching MoE layers for each Engram layer. The alignment curve lifts clearly off the diagonal: Engram layer 5 ≈ MoE layer 12.

Same conclusion from a different instrument — the network is not merely more accurate, it is further along at the same depth.

Figure 4 — schematic. Reproduces the reported qualitative behaviour and the one quantitative anchor stated in the text (layer 5 → ≈12). Per-layer values are not tabulated in the paper.

3 — Turn it off and see what breaks

Suppress the Engram output entirely at inference, leaving the backbone untouched, and measure what survives. This deliberately induces a train/inference mismatch, so the authors read only the two extremes of the spectrum — but the dichotomy is stark.

Figure 6. Retained performance as a percentage of the intact model. Reading comprehension is grounded in the context window and barely notices; factual recall collapses. Engram holds the parametric knowledge; the backbone holds the reasoning.

TriviaQA retains 29%, PopQA 44%, MGSM 44% — against C3 at 93% and RACE-Middle at 89%. Note that MATH (36%) and MGSM (44%) fall on the knowledge side, suggesting the memory is also carrying formulaic mathematical surface patterns, not only entities.

Component ablations

All at a fixed 1.6B Engram budget on a 12-layer 3B MoE backbone (0.56B activated, 100B tokens). Reference configuration: {2,3}-grams at layers 2 and 6, 1.768 against a bare MoE baseline of 1.808.

VariantVal lossEffect
3B MoE baseline1.808no memory
Reference — layers 2 + 61.768Δ = −0.040
Single injection, layer 21.770best single placement
w/o multi-branch gating≈1.783largest regression
w/o context-aware gating≈1.780static memory admitted unfiltered
w/o tokenizer compression≈1.778keys fragment across case/space
+ 4-grams≈1.773dilutes the 2/3-gram budget
w/o short conv≈1.771marginal

Three components carry the design: branch-specific fusion, context-aware gating, and tokenizer compression. Remove any one and most of the 0.040 advantage goes with it. The depthwise convolution is nearly free to drop.

Adding 4-grams hurts at this budget — longer keys are rarer, so slots spent on them see fewer updates than slots spent on 2- and 3-grams. The authors explicitly leave open that this reverses at larger table sizes.

Values marked ≈ are read from the Figure 5 markers rather than a table; the paper reports them graphically. The ordering and the three-way conclusion are stated in the text.

N° 10Gating

What the gate actually fires on

Because α_t is a single scalar, it can be read straight off the model. Engram operates on suffix n-grams, so a high value at token t means the phrase ending at t was recognised — the gate marks pattern completion, not pattern onset.

α0.0 1.0

Figure 7 — schematic reproduction. The sentences are the paper's; the highlighted spans are the ones it reports the gate activating on. Per-token α values are published only as a heatmap image, so the intensities here are illustrative of the described pattern rather than measured. Engram-27B computes eight gates per token (4 mHC branches × 2 layers); the paper visualises the branch most correlated with semantic matching.

The categories it selects

  • Multi-token named entitiesAlexander the Great, the Milky Way, Princess of Wales.
  • Formulaic collocationsBy the way. Zero factual content, perfectly predictable, ideal table material.
  • Cross-lingual, with no special handling — Chinese idioms and historical figures fire the same way. The mechanism is a hash over token IDs; it has no notion of language.

Note the useful negative: the gate is quiet over function words and compositional spans. It is not a general-purpose “add memory” signal — it is a static-pattern detector, which is what Eq. 4 was designed to produce.

Why suffix framing matters

A 3-gram key at position t is (x′_{t−2}, x′_{t−1}, x′_t). Nothing to the right is visible, so the module stays strictly causal and is usable in autoregressive decoding without modification.

It also means the memory cannot help until the pattern has been observed — Engram assists the token after “Bucephalus” is complete, not the one that predicts it. What it contributes is a clean, already-composed representation of the phrase for everything downstream, which is exactly the representation the backbone was spending six layers to build.

N° 11Systems

Storage decoupled from compute

This is the property that makes the architecture interesting to build on rather than merely to benchmark. An MoE router cannot tell you which expert a token needs until the hidden state reaches that layer, so expert weights must already be in HBM. An Engram address is a function of input_ids alone — it is computable before the first block runs.

Training

Sharded tables, All-to-All

Embedding tables are sharded across accelerators. The forward pass gathers active rows with an All-to-All; the backward pass dispatches gradients back the same way. Total memory capacity scales linearly with device count, so the table size is bounded by the cluster rather than by any single GPU.

The embeddings get their own optimiser: Adam at 5× the base learning rate with no weight decay, while the backbone runs Muon. Sparse rows are visited rarely, so they need a larger step when they are; decay would erode the long tail between visits. The convolution is zero-initialised so the module is an exact identity at step 0.

Inference

Prefetch, and hide it behind the first blocks

Tables move to host DRAM. The moment a sequence is known, all addresses are known, so the host can start the PCIe transfer while the GPU is still executing block 0 — communication overlapped with computation rather than serialised behind it. This is why Engram sits at layer 2 and not layer 0: layer 0 leaves nothing to hide the latency behind, which is precisely the flaw the paper identifies in OverEncoding and SCONE.

Volume per step scales with activated slots (32 rows/token), not with table size. A 100B-parameter table and a 1B-parameter table move the same bytes per token.

Table 4. NVIDIA H800, 512 sequences, lengths ~ Uniform(100, 1024), nano-vLLM harness. A 100B-parameter Engram layer in the second block, entire table resident in host DRAM.
ConfigurationTok/sPenalty
4B dense — baseline9,031.62
+ 100B Engram, CPU offload8,858.28−1.9%
8B dense — baseline6,315.52
+ 100B Engram, CPU offload6,140.02−2.8%

Dense backbones were used deliberately, to keep MoE expert-parallel traffic out of the measurement.

This is a pessimistic number. Every single retrieval was forced across PCIe with no caching at all. Natural-language n-grams are Zipfian, so a real deployment would keep the hot head of the distribution in HBM and let only the long tail reach DRAM or NVMe — a three-tier hierarchy the paper describes but does not implement here.

Configuration reference — Engram-27B / 40B

BackboneValue
Layers / dimension30 / 2560
AttentionMLA, 32 heads, RoPE θ=10000
Residual topologymHC, expansion 4
Leading dense layers1
Load balancingloss-free (bias)
Sequence length4096
Batch / steps1280 / 50,000
Optimiser / LRMuon / 4e-4, step decay
Weight decay0.1
Engram27B40B
d_mem12801280
Slots per head2,262,4007,239,680
Heads per order88
N-gram orders{2, 3}{2, 3}
Layers[2, 15][2, 15]
Parameters5.7B18.5B
OptimiserAdamAdam
LR multiplier×5×5
Weight decay0.00.0
Conv initzerozero

Table 5. Slots-per-head is listed in the paper as “Engram vocab size”; the reading above is the one consistent with the reported 5.7B / 18.5B parameter counts at d_mem = 1280.

N° 12Edges

What it is not, and what is unresolved

Engram is frequently described as giving a model “a second brain” or fixing “LLM amnesia.” It does neither. Being precise about the boundaries is the fastest way to understand the mechanism.

Not retrieval-augmentation

There is no document store, no query encoder, no nearest-neighbour search. The table holds learned parameters addressed by a hash of literal token IDs. Nothing is retrieved about the content; a row is fetched because of the arithmetic on three integers.

Not editable memory

Rows are trained by gradient descent like any other weight. You cannot write a new fact into slot z and expect coherent behaviour — the row means whatever training made it mean, entangled with every colliding key. This is parametric memory that happens to be sparse, not a knowledge base.

Not long-range

The receptive field is three tokens. The long-context gains in §08 are entirely indirect: attention is freed, not extended.

Open questions the paper leaves

  • Collision behaviour at scale is uncharacterised. Eight heads make collisions survivable, but there is no measurement of how often two semantically unrelated n-grams share a slot, or what that costs.
  • 4-grams are unresolved, not refuted. They lose at a 1.6B budget. The authors explicitly decline to rule out that they win at 18.5B.
  • Two layers, chosen by a 12-layer sweep. The [2, 15] placement for a 30-layer model is extrapolated from ablations on a smaller backbone plus a latency-hiding constraint. Three modules? Four?
  • 262B tokens is short. Engram-40B was still improving relative to baselines at the end of training — the reported numbers are a lower bound, and the shape of the allocation law at trillion-token scale is unknown.
  • The Zipfian cache hierarchy is described, not built. The 2.8% figure comes from forcing every access over PCIe; the tiered design that would improve it remains future work.
  • Nothing here is post-trained. All results are base-model evaluations. How a heavily-parametric-memory model behaves under RLHF or reasoning-style RL is untested.

The claim worth keeping

Strip away the benchmark table and one structural result remains: under a fixed parameter and FLOP budget, moving roughly a fifth to a quarter of your sparse capacity out of routed experts and into a hash-addressed table makes the model better — and it makes it better most on the tasks that look least like lookup. If that holds at frontier scale, then every pure-MoE model currently in production is sitting at the boundary of the design space rather than inside it, and “where should the parameters live” becomes a question with a non-degenerate answer.