Engrams for GLM-5.3: Why You Can't Transcode Experts into Lookup Tables

Created · Updated

October 17, 2026 · Milo (session model: anthropic/claude-fable-5.1; reasoning setting not recorded; four background research workers on xai/grok-4.7) · one DGX Station GB300 · companion to GB300 GLM-5.3 Testing, Pin Hot Experts and GB300 DeepSeek Flash 4.1 Testing

NOT A RECIPE James asked whether some of GLM-5.3's experts could be converted into Engram lookup tables so the single-GB300 vLLM lane streams fewer bytes from Grace. The answer is no, three times over. The conversion is not an operation anyone has published (an expert is a function of the hidden state; an Engram row is a function of token ids). DeepSeek's own Engram result shrinks expert inventory, not the expert bytes read per token. And on our box the arithmetic does not close: two V4.1-sized tables (189 GiB) do not fit beside the 380 GiB expert pin, and deleting the first 16 MoE layers would free 81 GiB for a modeled ≤3.8 ms of a 40 ms step. What survives is a CPU-only measurement that costs minutes.
expert payload (NVFP4)337.5 GiB75 layers × 256 experts, identity, matches ledger
C2C miss bytes18 of 40.1 msK=1 decode step, Nsight, measured
one Engram module94.6 GiBDSV4.1-Flash, pinned, measured
Engram gather cost0.04 msof 14.6 ms, DSV4.1 lane, measured
Grace headroom114 GiB494 − 380, arithmetic, before OS
16 layers → tables≤3.84 msmodeled, uniform split of the 18 ms
Contents
  1. The idea, and why it is seductive
  2. What Engram actually is
  3. Why an expert cannot be transcoded
  4. DeepSeek's win does not cut the bytes we stream
  5. The arithmetic on our box
  6. What people have actually retrofitted
  7. The serving side, for completeness
  8. The cousin idea: memoize MoE outputs by n-gram
  9. What we would measure before believing any of it
  10. The honest comparators
  11. Verdict and reopen triggers

The idea, and why it is seductive

Two models live on the same DGX Station GB300, and they pay for host memory in completely different currencies.

The big GLM-5.3 (744B, NVFP4) does not fit in 250.7 GiB of HBM, so all 75 MoE layers of routed experts are pinned in Grace RAM and read over NVLink-C2C through a per-layer slot cache. Every decode step the GPU streams whole experts that missed the cache: 18 MiB of 4-bit weights plus 2.25 MiB of scales, each. Nsight puts that at 18 ms of a 40.1 ms K=1 step, 46.6% of the budget. It is the reason the lane sits at 54.7 tok/s C1 and the reason every lever we have tried since September has been about which experts live where.

DeepSeek-V4.1-Flash, on the :30006 lane, also keeps ~190 GiB of parameters in Grace: its two Engram modules, 196B parameters of hashed n-gram embeddings. Those cost 0.04 ms of a 14.6 ms step. Same RAM, same link, four hundred times cheaper per step. The difference is shape: an Engram lookup is 48 rows of 264 bytes at addresses known before the forward pass starts; an expert miss is 20 MiB of contiguous weights the GPU has to pull before it can multiply.

So the question writes itself. Parameters in table form are nearly free in Grace. Parameters in expert form are bandwidth-bound. GLM-5.3 has 725B parameters in expert form. Could some of them be moved into table form, and would that let the lane stream less?

I spent a research round on it: four background workers against primary sources (the Engram paper, the V4.1-Flash tech report, the Qwen3.8-Flash-Next report, the GLM-5.3 config and card, vLLM source on both our pinned build and upstream main, and every retrofit or lookup-table paper we could find through October 2026). This post is the teaching version of the answer. The physics intuition is right. The premise about where the parameters come from is wrong, and the arithmetic does not rescue it.

What Engram actually is

Engram is DeepSeek's "conditional memory" module (Cheng et al., arXiv:2601.07372, January 2026, revised July). MoE is conditional computation: route the token to a few experts and run them. Engram is the complementary axis, conditional memory: look up a static vector for a fixed local pattern and add it to the residual stream, O(1), no matmul.

V4.1-Flash's modules: n-gram orders {2, 3, 4}, 8 heads, 256 dims per head (2048 per order), ~16M rows per head at distinct primes, FP8 rows plus ue8m0 block scales. That is 384M rows × 264 B = 94.4 GiB per module computed, 94.6 GiB per module as we measured it pinned. Qwen3.8-Flash-Next adopted the same primitive (they call it "N-gram Embedding": 51B parameters, one module at layer 2, 20M bigram/trigram rows) — also trained in from step zero.

Why an expert cannot be transcoded

This is the part that kills the idea before any arithmetic.

routed expertEngram row
inputh ∈ R^6144, the post-attention hidden state — a function of the entire prefixa hashed suffix n-gram of token ids — a function of the last 2–4 tokens
computesW2 · silu(W1 h) ⊙ (W3 h), 37.7M parametersa stored vector, gated by h but not computed from it
domaincontinuous, unboundedfinite, enumerable before the forward pass
can be precomputed into a table?no — there is no finite set of inputs to precompute overit is the table

There is exactly one paper that turns trained experts into exact lookup tables: Mixture of Lookup Experts (arXiv:2503.15798, ICML 2025). It works because MoLE changes the architecture before training so that experts take the embedding-layer output as input instead of the hidden state. The input domain is then the vocabulary, a finite set, and FFN_j(Embedding(i)) can be precomputed for every i. A GLM-5.3 expert was trained on h. Two prefixes that share a 4-token suffix can need different expert outputs, and the expert gives them different outputs. A token-keyed table cannot, by construction. The best a table can do is store the per-n-gram mean of the expert's output and hope the residual is small. Nobody has published that residual for any frontier MoE, and the Engram paper's own gate ablation is a warning that an ungated prior hurts.

DeepSeek's win does not cut the bytes we stream

Even granting a magic conversion, the Engram result does not do what the physics argument needs.

The paper's "sparsity allocation" law holds total parameters and activated parameters fixed and varies ρ, the fraction of the inactive sparse budget kept as experts. Validation loss is U-shaped; the optimum moves ~20–25% of the sparse budget into Engram. The 27B demonstration cuts routed experts from 72 to 55 and spends the freed parameters on 5.7B of tables. Top-6 is unchanged. Activated parameters are unchanged. The expert GEMM volume per token is unchanged. What shrinks is how many experts exist in storage, not how many are read when a token routes.

Our 18 ms is not a tax on unused inventory. It is the bytes of the experts that were routed to and missed the 7,360-slot HBM cache. Inventory shrink only helps that number indirectly, by letting the same slots cover a larger fraction of a smaller set (7,360 / 19,200 = 0.38 coverage today; a 72→55-style cut would make it 0.50 — and coverage is not hit rate, and the full-trace LRU ceiling at this budget is already 0.802). That is a cache-footprint experiment wearing an Engram costume, and it requires deleting experts, which is a quality decision James has not made.

Qwen's version of the same sweep (Qwen3.8-Flash-Next report, Table 8) is worth knowing: a fixed-budget swap of 10 / 25 / 50% of parameters from experts into n-gram tables lowered loss but showed no clear downstream win. They stopped treating n-gram as a substitute for experts, kept all 512, and scaled the table on top. Two labs, same primitive, and neither one shipped a model with fewer active expert bytes because of it.

The arithmetic on our box

The routed-expert payload is an identity, not an estimate: 75 MoE layers × 256 experts × (3 × 6144 × 2048) parameters / 2 bytes-per-pair = 337.5 GiB, which is exactly what the lane measured. FP8 scales at one per 16 weights add 42.2 GiB (the ledger's "45 GB"). Per MoE layer: 5.06 GiB. Per expert on the wire: 18 MiB + 2.25 MiB.

first N MoE layers → tablesbackbone layersexpert bytes freedC2C saved (modeled)share of 40.1 ms step
43–620.25 GiB0.96 ms2.4%
83–1040.5 GiB1.92 ms4.8%
123–1460.75 GiB2.88 ms7.2%
163–1881.0 GiB3.84 ms9.6%
193–2196.2 GiB4.56 ms11.4% — pays for one module
383–40192.4 GiB9.12 ms22.7% — pays for two; half the MoE stack

Modeled: the 18 ms is split uniformly by N/75. No layer-resolved miss profile exists for this lane; if early layers are hotter than average (plausible, unmeasured), the real saving is smaller. Do not convert these to tok/s — the 40.1 ms budget is K=1 and the 54.7 tok/s is MTP K=2. A second modeled read that also credits the freed slots to the remaining layers’ hit rate reaches 6.9–9.9 ms for N=16 (at hit 0.44 / 0.61, capped at the 0.802 LRU ceiling); that is an upper sketch resting on a residency→hit-rate curve nobody has measured, and it still requires deleting 16 layers and training a table that does not exist.

Now the other side of the ledger. A V4.1-sized module is 94.6 GiB pinned. Grace is 494 GiB with no swap. After the expert pin the arithmetic headroom is 114.3 GiB, before the OS, the vLLM process, page tables and shared memory — and the lane has already host-OOMed once at a sloppy pin.

Grace RAM, 494 GiB — big GLM-5.3 lane, all 75 MoE layers of routed experts pinned Routed-expert NVFP4 payload 337.5 GiB Headroom 114.3 GiB FP8 scales 42.2 GiB one V4.1 Engram module, 94.6 GiB → two modules, 189.2 GiB — overflows by 75 GiB → 0 100 200 300 400 494 Conclusion: two V4.1-sized tables cannot sit beside the expert pin. One fits only on paper — before the OS, the vLLM process and page tables. Experts 337.5 GiB = 75 × 256 × 3 × 6144 × 2048 / 2 (identity); scales = params / 16. Module = 384M rows × 264 B (94.6 GiB measured). Deleting the first 16 MoE layers frees 81.0 GiB — 13.6 GiB short of one module. Nineteen layers pay for one; thirty-eight for two.

Grace budget on the big GLM-5.3 lane. The bar is to scale (494 GiB → 820 px). Two V4.1-sized Engram modules overflow by 75 GiB even with zero process overhead; one module fits only on paper.

Put the two tables together: to make room for one module you delete 19 MoE layers (a quarter of the stack) for a modeled 11% step-time saving, and you have not yet trained the table that is supposed to replace what those layers did. The Engram paper's own ρ→0 arm says an Engram-dominated allocation "loses conditional computation capacity." Thirty-eight deleted layers is that regime.

And the published placement lands in the wrong place anyway. The paper's best single injection is layer 2; V4.1 uses 1 and 14. GLM-5.3's layers 0–2 are dense. The first streamed expert layer is index 3. Copying either placement onto GLM does not touch a streamed parameter.

What people have actually retrofitted

The question I most wanted answered: has anyone added an Engram-style memory to an already-trained model, or removed experts and compensated with one? Ranked by closeness to "convert this checkpoint's experts":

workwhat it didscaledeletes experts?
STAPLE (Oct 2026)Continued-trains OLMo-2 with token-indexed tables added as a residual beside the kept FFN up-projection. Their Engram-style upcycle arm (layers 2 and 7, hashed 2/3-grams) lost to the simpler token residual. Replacing the up-projection (STEM) stays below the dense baseline even after 100B tokens.1B, 7Bno
TF-Engram (Jul 2026)Train-free: mines phrases from an external corpus, encodes them, injects into a frozen model. Ten-benchmark average 57.6 → 59.4.Qwen3-0.6Bno (dense)
Cross-model memory transfer (Aug 2026)Freezes an Engram table trained with model A, attaches to frozen model B, trains only a reader.≤9Bno
BadEngram (Sep 2026)Grafts an 8,191-row Engram onto a frozen 7B as a backdoor. Proves a frozen backbone accepts a residual from a trained graft; reports attack success, not MMLU.7Bno
Memory Decoder (2025)Separate 0.5B transformer imitating a kNN retriever, interpolated at the logits. +28% inference cost.Qwen2.5, Llamano
DSV4.1-Flash, Qwen3.8-Flash-NextTrained the tables in from step zero (45T tokens; a new pretrain respectively).552B+196B; 125B+51Bn/a

Nothing on that list deletes an expert. Nothing is within an order of magnitude of 744B. The only retrofit with a real downstream win (STAPLE) keeps every FFN weight and found the Engram shape worse than a plainer one. If GLM-5.3 ever carries n-gram memory, it will be because Z.ai trained it in; the public config has no engram, ngram or ple field, and the card says 5.3 shares its base with 5.2 — every gain is post-training.

On training cost, for the record: the one experiment that fits one GB300 is a probe — freeze the backbone, stage the first K MoE layers in HBM (8 layers = 36 GiB), train a table to mimic their outputs, measure the residual. It does not produce a checkpoint that can drop those experts. Anything that unfreezes a 744B backbone needs BF16 master weights (1.49 TB) plus optimizer state; our eight DGX Sparks total 1.02 TB. GLM-5 was pretrained on 28.5T tokens; V4.1-Flash on 45T. That is not a one-person lab's afternoon.

The serving side, for completeness

Assume the checkpoint existed. vLLM's Engram is pure Python + Triton (no csrc): FP8 rows gathered from pinned host memory over UVA on a side stream, prefetched before the consuming layer, gated into DeepSeek V4.1's hyper-connection residual of shape [T, hc_mult, H], with token history read from the DSA sliding-window metadata. The allowlist in vllm/config/engram.py is three architecture strings: DeepseekV41ForCausalLM and the two Qwen4Exp* classes. Qwen did not reuse the DeepSeek module; PR #54371 was a parallel PLE stack (+1712/−495 lines) sharing only the config object. GlmMoeDsaForCausalLM is an alias of DeepseekV32ForCausalLM with a plain residual. Our pinned v0.28.0 image contains zero Engram files; it lands with the V4.1 support in the 0.30 line.

A graft is on the order of 1–2k lines and 2–4 weeks after the MRV2 rebase the lane already treats as its expensive open lever — a new token-history source, a gate for a non-mHC residual, the weight mapper (the engram.embed.scale regex is the silent one), and a re-validation of the slot-cache hook under piecewise CUDA graphs. It is the cheapest part of the whole proposal, and it is moot without the checkpoint.

The cousin idea: memoize MoE outputs by n-gram

If you cannot retrain, the next thought is an inference-time cache: key the MoE layer's output (or a cold expert's output) on the hashed token n-gram, serve the cached vector on a hit, run the real experts on a miss. "Engram-like," but learned from the model's own outputs instead of trained.

Three things are wrong with it as a bytes lever, and only one of them is the function-class problem again.

  1. It is a partial function. Unseen n-grams — most of a Zipf tail — still need the real experts, so the experts stay pinned. Not one byte leaves the streaming set.
  2. A hit only saves a miss the slot cache would have paid. Frequent n-grams are the tokens whose experts are most likely already resident in HBM. The intersection between "n-gram frequent enough to cache" and "expert that would have missed" is exactly the quantity that decides whether this does anything, and it is unmeasured.
  3. Ungated. Engram's gate exists so the memory can be suppressed when context disagrees with the prior. An ungated cache of observed outputs is the paper's own worst ablation, minus the training. Polysemy is the test case: the same 3-gram in two contexts that should not share a layer output, averaged into one centroid.

Geva et al.'s "FFN layers are key-value memories" is often cited here. Read it carefully: the key is an inner product with the hidden state x, not a token hash, and "lower layers capture shallow patterns" is not "lower layers are token-determined." After one attention layer, nothing is.

What we would measure before believing any of it

None of this changes serving. The first one is minutes of CPU.

#measurementcostwhat it decides
M3n-gram coverage, CPU only. On 200k–1M tokens of real agent traffic, the fraction of tokens whose suffix 2/3/4-gram has count ≥2, ≥8, ≥32.minutes, no GPUIf coverage at ≥8 is small next to the measured agent-traffic miss rate (1 − 0.41 = 0.59), the memoization variant is dead before any GPU work.
M4Within-bucket stability. Hook the MoE residual addend (routed + shared) at layers 3–18 with controls at 20/40/77; per n-gram bucket with support ≥8, mean cosine to centroid and variance explained — and the same on the pre-MoE hidden state: if h is not stable in a bucket, y cannot be.1–5 min of prefill at 3.4k tok/s; statistics only (naive vector dumps would be 183 GiB)A high cosine is a screen, not a logprob. It only earns a quality gate.
M1Layer-resolved C2C miss bytes, layers 3–18 vs 19–77, on agent and probe mixes.one lane-down profiling bootThe only number that can make the N-layer table above real or kill it. Sharpens every residency lever, not just this one.
M2Host residual after exact-pin: pinned bytes, RSS, MemAvailable, lane idle.read-only snapshotWhether "114 GiB headroom" is memory or arithmetic.

If anything is ever built, the gate is the lane's standing one: teacher-forced logprobs against the incumbent including a long prefix (the slot-cache hook's bar is max |Δlogp| = 0.0 on 3,071 tokens; any nonzero delta is "measured, not promoted"), needle 18/18 to 211K, the task ladder, MTP acceptance per class, plus two cache-specific slices — a forced-miss slice that must equal the incumbent, and a polysemy slice. Deleting experts to make room for a table is pruning-plus-compensation and needs James's explicit yes.

The honest comparators

The physics goal — fewer streamed bytes per step — has levers that do not require a training run. The retrofit has to beat these, and it cannot, because it does not touch the 18 ms unless experts are deleted.

leverattacks the 18 ms?status
Sub-4-bit cold-expert tieryes, proportionally on misseslegal under the September 30 quality policy; gate runs on the box; QMoE precedent is a top-1 Switch Transformer, transfer unverified
KV → expert slots (HiSparse capacity trade)yes, via hit ratethe one ≥10% modeled lever from the October 16 round; behind the MRV2 rebase
Explicit expert prune (REAP class)yes, ≈ f of misses for fraction fneeds James's yes; near-lossless on coder models at 50% in the paper, never run on GLM-5.3
Cross-layer expert bank (vLLM #56177 idea)only via fewer unique bytesoffline sim first, bar ≥ +0.02 hit
Engram retrofitno — adds bytes unless experts are deletedresearch probe at most

Verdict and reopen triggers

What I keep from the round is the teaching point: DeepSeek did not make their tables cheap by putting them in host memory. They made them cheap by training parameters that are addressable before the forward pass. Host placement is the consequence, not the trick. You cannot get the consequence by moving someone else's parameters.

Credits

Sources