40 local caches, 4 global cache pairs
Every layer makes its own local KV. Only L3, L9, L15, and L21 produce persistent global KV and indexer K.
A 40-layer model that separates the work of building memory from the work of reading it. Four global KV stores serve the whole backbone, while a huge phrase memory adds capacity through sparse lookups.
Based on the technical report, model card, and released configuration and inference code. Shapes are logical, before parallelism. This page numbers layers 1–40; the release uses indices 0–39.
Both halves are causal: a token can read only its own position and earlier positions. All 40 blocks have MoE, local sliding-window attention, and four residual streams. CSA2 gives the global branch a much smaller set of cache producers.
2 SWA-only layers
3 groups of Full + 5 Reuse
Global compression 2:1
Full + 3 Reuse, then
4 groups of Reindex + 3 Reuse
Global compression 1:1
Click a layer to highlight its KV and index producers and update the computation diagram below.
Every layer makes its own local KV. Only L3, L9, L15, and L21 produce persistent global KV and indexer K.
The hidden-state path remains sequential. Layer 30 also reads global memory derived from layer 20.
A Reindex layer keeps the same global memory but chooses new positions. A Reuse layer keeps the latest selection too.
Optimized serving skips most decoder work for the prompt. Each generated token and each teacher-forced training token runs all 40 layers.
Choose a layer, then select an operation to inspect its weights, precision, and backward dependencies. Solid heavy borders mark matrix multiplies or attention; dashed boxes show shared state or communication.
T counts current query/local positions; G counts new global source positions; S counts retained global entries. R = 6T counts routed token-expert assignments. During optimized decoder prefill, the global projection can process the full encoder prompt while the query/local path processes 128 replay positions. Encoder pooling emits only completed pairs, including any carried partial pair. Batch/document boundaries are suppressed here; causal masks preserve them. Deployment can fuse several logical operations into one kernel.
Traced from inference/model.py. Its
small default ModelArgs describe a debug model; the dimensions here come from the released config.json.
CED changes where decoder global KV comes from. It is projected from the last encoder output H20, so the global memory of an old prompt position can exist without computing that position through L21–40.
Prefill computes H20 for the full prompt, projects decoder global KV, then runs the decoder on the last 128 positions.
Layer 30 depends on both the sequential path through L21–29 and the encoder-derived global memory.
20N + 20 min(N, 128)
Counts token-layer executions, treating layers equally. Projection costs, sparse indexing, attention work, and hardware scheduling determine actual FLOPs and latency.
The 128-token decoder replay is approximate. Every decoder layer generates its own local KV from its own incoming hidden state.
Local dependencies accumulate across depth, so exact reconstruction can require about 20 × 128 = 2,560 recent positions. Bounded replay processes only 128, truncating local attention at the replay boundary while preserving access to global memory. The report finds negligible quality degradation and simulates this replay during post-training.
Report §2.2 and §3.2.2. The released minimal inference example runs the full stack; bounded replay describes the optimized serving system.
Each attention layer reads its local window plus at most 512 selected global entries. Main queries are always layer-specific. The three modes decide who makes the global memory and who chooses its positions.
| Mode | Examples | Global KV + indexer K | Indexer query + Top-K | Main query + local KV |
|---|---|---|---|---|
| Full | L3, L9, L15, L21 | Generate new memory | Compute fresh selection | Compute independently |
| Reindex | L25, L29, L33, L37 | Reuse L21 memory | Own query; fresh selection | Compute independently |
| Reuse | 30 layers, including L30 | Reuse the group's memory | Reuse latest Top-K; no indexer query | Compute independently |
L3–8, L9–14, and L15–20 each have a separate global store at ratio 2:1. A learned channel-wise softmax pools each pair; groups do not overlap.
L21 projects H20 at ratio 1:1. All 20 decoder layers share this store. Four deeper indexers update which entries their groups read.
Score causally visible positions. Select Top-512 for L21 and score each 8-position block by its maximum.
Keep up to 2,048 blocks × 8 positions. The pool is larger than the final attention selection.
Each Reindex layer rescores only the candidate pool with its own indexer query, then selects its own Top-512.
The first search still grows with context length. Later decoder searches are bounded by the fixed candidate pool. Reuse layers perform no search. The candidate restriction is introduced during post-training and applied during inference.
Relative to V4 CSA, the compressor removes overlap and learned absolute position embeddings. Indexer K is projected from the main KV latent before RoPE. The core attention still gathers local and selected global latents, with a per-head attention sink.
Report §2.3 and the released compressor, indexer, and attention implementations.
An ordinary embedding maps a token ID to a learned vector. Engram maps recent 2-, 3-, and 4-token groups to learned vectors. The current hidden state decides how much of that memory to add to each residual stream.
Concatenate 8 hash-head vectors for each of 3 orders. A learned projection produces four keys and one shared value.
Updated stream = H + 0.60 × V
The actual model computes a gate separately for each stream from normalized hidden/key compatibility. Words here are illustrative tokens; the release hashes compressed tokenizer IDs using multiple heads and distinct prime table sizes. The slider demonstrates gating and does not run the model.
Only a few rows are accessed per token. The huge table adds learned pattern capacity with small projections instead of evaluating all table parameters.
Lookup addresses depend only on token IDs. Embeddings can be prefetched before a stage runs, overlapping transfers with GPU computation.
The same short phrase can appear in different contexts. Gating allows its retrieved vectors to contribute differently to the current hidden state.
Engram entries persist across requests as model parameters. Training updates selected rows; inference reads them. KV caches instead hold request-specific activations.
Modules sit at L2 and L15 (release indices 1 and 14), with 8 hash heads per order and about 16M entries per head. The V4.1 variant omits the original Engram short causal convolution and uses momentum plus Sinkhorn balancing for table updates. Table storage and lookup bandwidth remain substantial; the report does not give an isolated Engram accuracy ablation.
The backbone stores most of its weights in routed expert matrices. Engram adds a second form of sparsity: token-addressed table rows. Both activate a small subset of their stored capacity at each position.
40 layers × 384 experts × 3 SwiGLU matrices. Each expert has gate/up/down matrices between model width 5120 and expert width 2304.
A token selects 6/384 of the routed bank, plus one shared expert in every layer. Main attention, norms, projections, embeddings, and output head add the remaining backbone weights.
The released config specifies two row totals and 256 channels per row. This tally counts table elements, separately from projection and gating parameters.
At one FP8 byte per element, raw tables occupy about 183.11 GiB, before scales. Only 48 rows are selected per text token across the two modules.
The report's 552B and 196B are headline counts rather than a complete checkpoint tensor audit. Its 8B prefill / 16B decode figures describe the optimized execution path. Parameter counts, active arithmetic, stored weight bytes, training optimizer state, and KV memory are different quantities.
The three encoder producers each retain one entry per pair of tokens; the decoder producer retains one per token. That is about 2.5 global entries per context token across the model.
2.5 × (256 + 32 + 64 + 4) = 890 bytes per context token
Global values include their quantization scales. Local values count payload only.
Before parallel replication or sharding. Excludes local quantization scales, allocator/page padding, sparse-index and candidate buffers, compressor state, and activations used for training.
The main format has one scale per 16 channels. The indexer uses one scale per 32 channels. Both keys and values of main attention use the stored latent.
The independent-cache comparison uses the same 38 CSA2 layers, widths, compression ratios, and precision, with a separate global store at every layer.
CSA2 sharing and FP4 main KV jointly reduce the actual long-context serving footprint. At 1M tokens, global KV is 890 MiB in the logical model.
Global KV stays in persistent storage. Encoder SWA state uses a short-lived memory pool; decoder SWA is rebuilt from the prompt tail. Bounded replay recovers missing local state.
Model card and report Figure 1; §2.4.4 and §3.2. The minimal reference simulates cache quantization in dequantized tensors; its allocated buffers do not directly demonstrate packed-cache memory usage.
CED and CSA2 target long-context compute and cache storage. These additions address residual traffic, numerical formats, vision, and generation throughput.
Each sublayer predicts input, output, and residual mixing coefficients. The input mix used now comes from the previous sublayer, removing a reduction dependency from the critical path.
Mega-mHC fuses residual update, input mixing, coefficient prediction, pre-norm, and FP8 conversion. The report halves mHC activation traffic relative to its original implementation; this is a residual-module saving.
The final stream merge consumes the carried mixing coefficients too.
Quantize the full 512-channel latent after RoPE into E2M1, with one E4M3 scale per 16 channels and no second-level global scale.
Attention dequantizes cached values before using them. Main KV QAT is introduced during post-training. Local SWA KV stays FP8 because it is more sensitive to quantization.
A 32-layer, width-1024 ViT uses 16 heads, 2D RoPE, RMSNorm, and SwiGLU. Linear patch embedding keeps the projection compatible with Muon.
At that resolution, 9,216 patch tokens become 1,024 language-model visual tokens. Image and text expert routing have separate load-balancing correction biases.
Three drafter blocks produce base logits for five draft positions in parallel. A lightweight Markov head models token dependencies; a confidence head estimates acceptance probabilities.
The scheduler adapts verification length to expected system throughput. DSpark is trained after backbone pre-training, then kept aligned during post-training without sending its objective's gradients into the backbone.
Report §2.4 and §2.1.1.
The report pre-trains on 45T multimodal tokens, using sparse attention from the start at 64K context. Context expands to 1M at 34T tokens. Teacher-forced execution keeps the full 40-layer graph; shared activations introduce distributed responsibilities.
Shared KV, indexer keys, and selections can cross pipeline stages. Per-microbatch state tracks their consumers through forward, recomputation, and backward, retaining them until the last consumer finishes.
Dedicated process groups own table row partitions. Prefetch begins before stage microbatches. Lookup gradients are buffered and returned to their owning ranks after backbone backward; optimizer states are further sharded.
Backbone linear matrices use Muon, with head-wise treatment for Q/K. Engram tables, token embeddings, and prediction heads use momentum plus Sinkhorn balancing. RMSNorm and other non-matrix parameters use AdamW.
| Piece | Reusable foundation | V4.1 integration work |
|---|---|---|
| Attention kernel | Gather local + selected global latents and normalize with the sink | Support packed FP4 reads and the chosen layout; expose shared KV and supplied selections |
| Compressor / indexer | Projection, normalization, pooling, and Top-K primitives | Ratio 2 encoder / ratio 1 global decoder; new indexer K source, three modes, hierarchical candidates |
| MoE / residuals | Routed and shared experts; Sinkhorn and residual combination math | Modality-specific routing biases; carried Single-Pass mHC input coefficients |
| Model / distributed runtime | Common decoder, linear, normalization, and sharding infrastructure | CED source relationships, shared-state ownership and gradients, new checkpoint mappings |
| Engram / vision / drafter | Embedding, ViT, and transformer building blocks | New table lookup integration, DeepSeek vision configuration, and DSpark algorithm |
The existing TorchTitan V4 attention wrapper selects CSA for ratio 4, HCA for other compressed ratios, and local-only attention for ratio 1. V4.1 requires indexed global attention at both ratios 2 and 1, so the model needs new control flow and configuration wiring.
Report §3.1 and TorchTitan V4 implementation. The reuse table is an implementation assessment.
Source review: October 26, 2026. Calculations use one context and one logical model copy. Global KV includes specified quantization scales; local KV counts FP8 payload. The CED work plot is an equal-layer execution illustration, not a performance benchmark. Engram addressing and gating controls are schematic examples, not model inference.