DeepSeek V4.1 Flash: redesigning the cost of context
Trace a modern Transformer from prompt to cache to answer, calculate resource tradeoffs, and judge evidence critically.
Preparation: Attention, causal masks, caching and fractions; college adds matrix shapes and asymptotic cost.
Plan 25–40 minutes with the activities; this is a study estimate, not a timed requirement. Both paths have complete narration. Your notes and progress are kept separately for each level.
FULL LOCAL NARRATION
Follow the complete explanation.
Narration includes worked solutions. Pause at each practice prompt before continuing. Formula notation has a spoken explanation; all teaching text remains readable.
A language model first reads the prompt, called prefill, then produces new tokens, called decode. An agent repeatedly receives tool results, so reading and retaining old context can dominate its work. A key-value cache stores intermediate attention information so the model does not have to rebuild everything at each output token. Think of reusable working notes: making the notes, keeping them and moving them all have costs. DeepSeek V4.1 Flash changes several parts together to reduce these costs. It remains a Transformer that generates text one token at a time from text and image inputs. Separate prefill computation, decode computation, runtime cache capacity and persistent cache I/O. Optimizing one does not guarantee proportional improvements in the others. The report describes 552 billion backbone parameters plus 196 billion conditional-memory parameters in Engram. It reports 8 billion active parameters per token in prefill and 16 billion in decode. Active parameter count is a compute-related quantity, not the total weight storage requirement. The 890-byte-per-token figure describes global KV storage, excluding local sliding-window state, weights, activations and serving overhead.
Worked example. At one million tokens, 890 bytes per token gives 890 million bytes, or 0.89 decimal gigabytes, of global cache. This is a derived calculation from the authors’ reported rate. It is not the memory needed to run the model. Doubling the number of equal-length requests doubles this component before any sharing.
M_global = N × 890 bytes
Read this calculation together with its stated assumptions.
Try it yourself. A student says the whole model fits in 0.89 gigabytes. What did they leave out?
Pause and write your answer before listening to the solution.
Reveal worked solution
They counted only the global cache for one request. Model weights, local caches, temporary activations and deployment overhead are additional. Sparse activation does not make the inactive weights disappear.
Source location: report sections 1; 2.1; 6, pages 4–8, 37. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 02 / 07
Read the prompt once through the causal encoder
The network has forty layers arranged as a twenty-layer causal encoder followed by a twenty-layer decoder. Causal means that a position cannot read future tokens. The decoder’s global cache is projected from the encoder’s final representations. Most prompt tokens therefore need the encoder computation without a full pass through the decoder. The decoder still needs its own recent local state, prepared using a short replay. During generation, both halves participate. This is not the usual bidirectional encoder used in a translation diagram. For decoder layer l, the global cache and compression weights come from the final encoder state: C_l = H_20 W_KV,l and Z_l = H_20 W_Z,l at cache-producing layers. Local sliding-window keys and values still depend on the layer’s own hidden states. The paper’s schematic work count is N L/2 + W L/2 rather than N L, for long prompts with window W. This isolates layer-token processing; it is not an exact FLOP or latency model. CED is inspired by YoCo, so the case study illustrates cumulative research rather than an invention without predecessors.
Worked example. For N = 10,000 prompt tokens, L = 40 layers and W = 128, the simplified baseline has 400,000 layer-token units. The encoder plus decoder replay has 202,560. Dividing gives 0.5064, close to half. At short prompts the replay matters more. Different operations have different costs, so do not convert this ratio directly into a stopwatch prediction.
R_work = (N + min(N, W)) / (2N), W = 128
Read this calculation together with its stated assumptions.
Try it yourself. Why does the decoder still run during prefill if the encoder provides its global cache?
Pause and write your answer before listening to the solution.
Reveal worked solution
Its sliding-window state is layer-local and must be prepared. Bounded replay supplies an approximate recent state. Global-cache projection does not remove all decoder work.
Source location: report sections 2.2; 3.2.2, pages 9, 20. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 03 / 07
Share memories, but keep asking new questions
Compressed Sparse Attention 2, or CSA2, separates three jobs: storing memory, finding useful entries, and asking a question of those entries. Full mode creates a global cache and a fresh selection. Reindex mode shares the cache but makes a new selection. Reuse mode shares both. Every mode still computes a new main query and local sliding-window state. Sharing reference material does not mean copying the previous layer’s answer. The mode is assigned to a layer in advance; it is not an expert router choosing a mode for each word. Cache reuse saves storage; index reuse saves selection computation. Those are different resources. The eighteen global-attention encoder layers use compression ratio two in three groups, each containing one Full and five Reuse layers. The twenty decoder layers use ratio one: one Full group followed by four Reindex groups, each followed by three Reuse layers. Ratio one is an uncompressed sequence setting, while sparse selection and cross-layer reuse still apply. The first two encoder layers use local attention only.
Worked example. Imagine six layers needing the same eight memory entries. Six private copies would hold forty-eight entries; one shared copy holds eight. This toy count ignores query storage, local state, precision and metadata. Changing a query can change attention weights even when selected entries are unchanged. In the real design, storage savings must be counted across all cache-producing groups.
Toy cache entries: 6 × 8 = 48; shared = 8
Read this calculation together with its stated assumptions.
Try it yourself. Does Reuse mode mean that the attention output is reused unchanged?
Pause and write your answer before listening to the solution.
Reveal worked solution
No. The layer computes its own query and attends to shared global entries alongside its own local state. Shared keys, values and indices do not imply identical outputs.
Source location: report sections 2.3.1; 4.2.1; Figure 4, pages 10–11, 22. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 04 / 07
Search a shortlist without pretending search is free
Finding useful memory can itself become expensive. The first decoder indexer searches the visible context and builds a candidate pool. Later reindexing layers search inside that pool. The final selected entries can differ between layers. Think of first choosing promising shelves in a library and then choosing books from those shelves. A useful book on an excluded shelf cannot be recovered by a later search confined to the shortlist. This makes accuracy tests as important as arithmetic savings. The reported pool has up to 2,048 blocks of eight positions, or 16,384 candidates. Each sparse attention selection uses 512 entries. Block scores use the maximum position score in each block. With four later decoder reindexers, a simplified count is N + 4 min(N,16384), compared with 5N if all five indexers scan the full range. The first scan remains linear in N. Constant bounded work applies to the later indexers, not the entire model. Candidate restriction is introduced during post-training and used at inference.
Worked example. At one million visible positions, five complete scans score five million positions. One full scan plus four pools of 16,384 scores 1,065,536 positions. The ratio is about 0.2131. This counts scored positions, excluding block selection, top-k algorithms and attention arithmetic. It is not a measured speedup.
R_index = [N + 4 min(N,16384)] / (5N)
Read this calculation together with its stated assumptions.
Try it yourself. What happens if the first selection excludes the block containing the only relevant evidence?
Pause and write your answer before listening to the solution.
Reveal worked solution
Later indexers cannot select that evidence from a pool that omits it. Stress tests should include rare facts, adversarial distractors and evidence placed far away. The paper acknowledges sparse-selection robustness limits.
Source location: report sections 2.3.2; Figure 5, pages 11–12. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 05 / 07
Smaller numbers and reconstructable local state
Two separate ideas reduce storage. First, the main global cache stores lower-precision numbers. Second, the persistent cache does not keep all local sliding-window states for long periods; missing recent state can be reconstructed with a short replay. Reconstruction is approximate. These choices exchange some numerical detail or recomputation for less storage and data movement. The report finds small quality changes in its tested settings, which is evidence about those tests rather than a promise for every future input. Main KV uses four-bit E2M1 values with one eight-bit E4M3 scale per sixteen channels, omitting the second global scale. Payload plus scale is 4.5 bits per channel before alignment or other overhead, not exactly four. Indexer quantization uses MXFP4; local SWA cache remains FP8. Quantization-aware training adapts to the cache format. Bounded replay uses W recent tokens instead of the full layer-expanded dependency range. The resulting states are not mathematically identical to full reconstruction. The reported roughly fourfold global and eightfold persistent cache reductions have different denominators and must not be multiplied into a thirty-twofold claim.
Worked example. For sixteen main-cache channels, values take sixty-four bits and the group scale takes eight, making seventy-two bits or nine bytes. Sixteen eight-bit values alone would take sixteen bytes; this simplified payload comparison excludes the baseline’s own scaling overhead. For forty layers and a window of 128, the schematic full dependency range is 5,120 tokens versus a bounded replay of 128.
16 × 4 + 8 = 72 bits = 9 bytes
Read this calculation together with its stated assumptions.
Try it yourself. Can a successful replay test prove that approximate replay always gives the same answer?
Pause and write your answer before listening to the solution.
Reveal worked solution
No. The states differ by design. Test answer quality and stability at different cache-hit boundaries, including difficult long-context cases. Equality of all outputs is neither shown nor implied.
Source location: report sections 2.4.4; 3.2.1–3.2.2, pages 14, 19–20. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 06 / 07
Architecture, learned memory and the training system
The model’s progress also depends on the surrounding system. Mixture of experts routes tokens to a small subset of expert networks. Engram supplies learned conditional memory addressed by short token patterns. It is not a web search or a user-editable evidence database. DSpark proposes several draft tokens and schedules their verification to improve throughput. Single-Pass mHC rearranges residual-stream mixing so deployment kernels move less data. A vision encoder turns images into features for the text-generating backbone. These mechanisms solve different problems and should not all be called attention improvements. Each MoE layer has one shared expert and 384 routed experts, of which six are selected per token. Engram adds 196 billion parameters with hashed two-, three- and four-gram lookup and contextual gating. DSpark uses a three-block drafter, five draft positions, a lightweight Markov head and confidence-based verification scheduling. Single-Pass mHC consumes input-mixing coefficients from the preceding block, enabling fused memory traffic. The report claims 45 trillion multimodal pretraining tokens. It explicitly describes SFT, reinforcement learning and on-policy distillation as established algorithms; the post-training changes emphasize data synthesis, environments and scale.
Worked example. An image feature grid with ninety-six positions on each side has 9,216 positions. A three-by-three pixel unshuffle rearranges local features into channels and reduces the grid to thirty-two by thirty-two, or 1,024 positions: nine times fewer. This is a feature-layout calculation, not a claim that every image detail survives equally well or that the whole model becomes nine times faster.
(96 × 96) / (3 × 3) = 1024 positions
Read this calculation together with its stated assumptions.
Try it yourself. Classify these: shared attention cache, verified draft tokens, synthetic training tasks, hashed learned memory.
Pause and write your answer before listening to the solution.
Reveal worked solution
They are respectively an attention/cache architecture choice, a decoding strategy, a data-pipeline choice, and a conditional-memory mechanism. Their effects need different ablations and measurements.
Source location: report sections 2.1.1; 2.4.1–2.4.3; 4.2; 5, pages 8, 12–14, 22, 25–32. Numerical examples are teaching calculations unless explicitly described as reported results.
Section 07 / 07
What would count as industry progress?
An improvement moves the industry forward when it expands useful capability for a realistic budget. A smaller cache could support more simultaneous learners, longer documents or less data transfer. Those are potential benefits to measure, not guaranteed classroom outcomes. Compare systems on the same tasks, with the same tools, context and time limits. Record failures as well as average scores. The authors’ benchmark results are reported evidence; this lesson does not independently reproduce the large model. No model weights are loaded by Workbench. Use a controlled evaluation matrix: fixed prompts and scaffold, matched reasoning budget, cold and warm cache cases, quality, latency percentiles, throughput, peak accelerator memory, persistent-cache bytes and transfer volume. Ablate cache sharing, quantization and replay separately where feasible. Benchmark saturation can hide differences on difficult tasks. Appendix B.2 shows that more reasoning increases trajectory length consistently but agent success can plateau or dip. Do not attribute the whole benchmark improvement to CSA2 when architecture, data, training and harness also changed.
Worked example. Suppose a hypothetical system cuts cache bytes in half but succeeds on only eighty of one hundred tasks where the baseline succeeds on ninety. Storage improved, while success fell by ten percentage points. Whether that trade is acceptable depends on the task; a single efficiency number cannot decide it. For this paper, explicitly test rare-evidence retrieval and cache-resumption boundaries, the robustness limits the authors identify.
Read this calculation together with its stated assumptions.
Try it yourself. Design one fair comparison and one failure test before claiming this architecture is better for an educational assistant.
Pause and write your answer before listening to the solution.
Reveal worked solution
Hold the lesson questions, tool access, model settings and hardware fixed; measure answer quality and latency with warm and cold caches. Add a long context containing one crucial fact among distractors, then resume at several cache boundaries. Report the quality-cost tradeoff and uncertainty rather than promising universal superiority.
Source location: report sections 5.3; 6; Appendix B.2; Figure 11, pages 32–37, 48–49. Numerical examples are teaching calculations unless explicitly described as reported results.
WORKBENCH / PREDICT → TEST → EXPLAIN
Inspect exact numerical data
These are computed teaching fixtures. No remote AI model or GPU is called by the experiment.
CHECK YOUR UNDERSTANDING
Commit to an explanation.
Keep your learning record.
LONGER INFERENCE LESSONS
Follow the mechanism in depth
Worked examples, local narration and connected learning modes at your level.
Report reviewed October 21, 2026. Claims are attributed to the authors; experiments are transparent teaching calculations, not a reproduction of the model.
Sources and scope
Original worked examples and teaching text, grounded in these primary references. Numerical fixtures explain mechanisms; model quality and hardware performance require separate measurements. Both levels share key examples, with different explanations and checkpoints.
Credit the research, understand the released weights, and locate DeepInfer in the larger system.
Additional reading · original lesson audio remains unchanged.
Read the full explanation · 599 words + college extension
Locate the contribution
Architecturedefines
Checkpointrecords
Runtimeexecutes
Serviceconnects
DeepSeek releases research, weights and substantial inference technology. DeepInfer is part of the execution system.
Architecture: operations
Checkpoint: parameters
Runtime: execution
Service: coordination
Architecture: operations
A model release contains several kinds of progress
When a new language model appears, it is tempting to describe every improvement as a new Transformer. A more useful explanation separates architecture, trained weights, numerical representation, and execution software. An architecture changes how information is processed. A checkpoint records learned parameters at a particular stage. A quantized artifact changes how some values are stored. An inference framework decides how compatible computation is carried out on hardware. Improvements in any of these can matter, but they are different contributions.
Use the DeepSeek classroom as a map of those questions. The layer view introduces information flow. The memory and expert scenes examine architectural mechanisms. The release scene asks what a checkpoint comparison actually measures. The runtime scene moves outward to the system that executes the model. A higher benchmark score does not, by itself, prove a new architecture; the evidence must connect the reported result to the change being discussed.
What DeepInfer adds to the explanation
DeepSeek describes DeepInfer as its production inference framework and has released code supporting offline inference for V4.1 Flash. Its README identifies optimized kernels, parallel execution, speculative verification, scheduling, and other runtime features. It also states that the release does not supply every component of a complete hosted service. A KV cache system and some deployment-level coordination remain outside that complete-service package. These boundaries are part of the release’s meaning, not a reason to overlook its value.
Think of scheduling as arranging work so that independent operations spend less time waiting. In the lesson’s toy example, CPU preparation takes six milliseconds and device work takes twenty. Serial execution totals twenty-six milliseconds. Perfect overlap would take twenty, assuming independence and no additional costs. The possible ratio is 26/20, or 1.3. This is an explanatory upper-bound example, not a benchmark of DeepInfer. Real dependencies, synchronization, transfers, and contention determine what overlap is achievable.
Why open releases deserve visible credit
DeepSeek deserves credit for making model weights, research explanations, and substantial inference technology available for others to study and build upon. Weights let another team investigate learned behavior without paying the full cost of the original training. Technical reports provide a basis for understanding design choices. Executable software exposes practical decisions that a diagram alone cannot communicate. Together, these releases support education, comparison, adaptation, and further engineering.
Credit does not require treating every claim as settled. A reader can appreciate a contribution while checking benchmarks, limitations, and the scope of the release. Attribution should also extend upstream: DeepInfer’s README acknowledges earlier inference projects that influenced its development. Technical progress is cumulative. A lesson that names both the releasing team and its foundations gives a more faithful account than one that presents a single organization as inventing every component from nothing.
Follow a claim back to the right artifact
A third-party checkpoint carrying DeepSeek in its name is not automatically an official DeepSeek release. Identify the publisher and the upstream checkpoint, then ask what was changed. A behavior modification, a numerical conversion, and a new inference backend answer different questions. Published performance from one setup cannot simply be transferred to another setup with different weights, hardware, prompts, or runtime options.
For your reading exercise, choose one claim from each mode. In Signal Room, label whether it concerns architecture or a conceptual animation. In Workbench, identify the assumptions behind the calculation. In Field Notes, open the primary source and decide whether it supports the exact statement. Finish by writing a short attribution: who developed the original model, who released the artifact being discussed, and what software executes it. This turns the case study into a method you can reuse whenever the next model arrives. The aim is to understand why a change matters, not merely to memorize a release name.
College extension · make the assumptions explicit
Distinguish algorithmic equivalence from end-to-end equivalence. An optimized kernel may aim to compute the same operation with different memory traffic, subject to numerical behavior. A modified checkpoint changes the function being evaluated. A sampling or verification change can affect the output distribution unless it preserves the required procedure. A benchmark comparison should record these boundaries before attributing its result to one optimization. The runtime’s supported accelerators also matter: architecture-specific kernels are not automatically portable to every consumer GPU.
Sources and further investigation
Source review: October 28, 2026. Model-release claims are attributed to their publishers.