FIELD NOTES / COLLEGE
Memory at work
A cache retains work from the current sequence. It does not retrain the model.
Listen to this reading.
Local Kokoro Heart narration · college. Covers the essay, worked example, college extension, and practice explanations. Quiz choices and source URLs are not read aloud. The text below is the transcript.
A new token reuses cached keys and values; reading that state still costs time and memory.
- Weights: learned settings
- Prompt: prefill
- KV: retained state
- New token: decode
Weights: learned settings
The workshop and the work in progress
A useful way to distinguish model weights from a cache is to imagine a workshop. The tools and their settings are available for many jobs. The current project also occupies space: notes, measurements, and partly completed work. Weights are the learned settings reused across requests. Cached attention state belongs to a particular sequence or reusable prefix. The analogy stops short of literal memory or understanding; it simply separates persistent parameters from temporary computation.
When a decoder processes a prompt, it performs a prefill pass over the input. When it continues the answer, it generates tokens through decoding steps. In ordinary causal attention, earlier token positions cannot attend to later positions. This allows previously computed keys and values to remain useful as the sequence grows. A KV cache stores those representations so the system can reuse them rather than recomputing all earlier projections at every step.
Worked example
Build the cache estimate.
Two layers, two KV heads, four values per head, one hundred tokens, two bytes per value.
Trace the calculation
Keys and values × layers × KV heads × head size × tokens × bytes: 2 × 2 × 2 × 4 × 100 × 2 = 6,400 bytes. This toy formula excludes other memory and does not describe every architecture.
Reusing work is not making it free
A new query still needs to interact with the relevant cached information. Reading the cache takes bandwidth, and a longer sequence can require more attention work. The cache also occupies memory. Caching changes the balance between recomputation and retained state; it does not remove every cost associated with a long conversation. This explains why a model can generate a short answer quickly yet struggle with a very long prompt or many concurrent users.
Suppose a toy model has two layers, two key/value heads per layer, four values per head, and a sequence of one hundred tokens. Storing both keys and values at two bytes per value requires 2 × 2 × 2 × 4 × 100 × 2 = 6,400 bytes. The first factor accounts for keys and values. This deliberately small example ignores allocator overhead and other state. Doubling the sequence length doubles this simple cache estimate; doubling independent sequences does the same.
Architectures change what needs to be retained
Grouped-query attention allows multiple query heads to share fewer key/value heads. That changes the number of cached heads while allowing distinct queries. Latent attention can retain a compact representation and use architecture-specific transformations to recover or compute what attention needs. Sliding windows can limit which recent positions remain relevant to a particular attention layer. These are distinct mechanisms, not interchangeable names for compression.
Do not apply one cache formula to every modern model without checking its architecture. Some systems contain multiple types of attention, shared memory, compressed representations, or other persistent state. A published bytes-per-token figure may cover only one component. Ask whether it includes all layers, scales, local windows, batches, and additional model-specific structures. A precise label such as “global cache component” is more useful than a large unqualified claim about total memory.
Measure the experience, not only a rate
Latency is the time a user waits for an event, such as the first token or the complete answer. Throughput is the amount of work completed over time, often across several requests. Batching can improve aggregate throughput while changing an individual user’s waiting time. Faster arithmetic does not guarantee lower latency when communication, cache reads, or scheduling dominate the workload.
Using the cache calculation above, vary sequence length while keeping other quantities fixed, then vary concurrency. Explain which quantities should change and which should remain constant. Finally, consider an answer that is twice as long. Even if each decoding step has the same cost, more steps take more time. A responsible performance report states the model revision, numerical format, hardware, prompt and output lengths, concurrency, and the metric being measured. Those details turn a speed claim into something another person can interpret and attempt to reproduce.
College extension · make the assumptions explicit
For a conventional cache with uniform layers, an estimate is M = 2LBTHkv db, where L is layer count, B batch size, T retained tokens, Hkv key/value head count, d head dimension and b bytes per element. The result is bytes. It is not a universal equation for latent or heterogeneous architectures. Separate allocated capacity from live occupancy, and separate weight memory from KV state and temporary buffers. Prefix sharing can reduce duplication when supported, but cache validity depends on matching the computation that produced it.
Reason through the practice.
Use these short explanations alongside the main reading. Each coach question links to the relevant explanation.
Weights
Weights are learned settings; activations and cached sequence state change with the input during ordinary inference.
Cache
The cache retains attention keys and values from processed tokens. It avoids recomputing those projections for the same past positions.
Prefill
Prefill processes the supplied prompt. Decoding then extends the sequence, typically one generated token at a time.
Decode
With a growing cache and fixed other settings, retaining more token positions increases sequence-state memory.
Cost
Caching avoids repeated computation of stored keys and values, but reading that state and using it still costs time and memory bandwidth.
Tokens
The conventional cache estimate is linear in retained token count under fixed dimensions and precision.
Batch
For separate unshared sequences, conventional KV storage scales with batch size. Prefix sharing changes assumptions when supported.
Budget
Weight storage, KV state and temporary working memory are separate costs. File size alone is not a complete runtime budget.
Formula
The leading two counts key and value arrays. L is layers, B batch, T tokens, Hkv KV heads, d head dimension and b bytes per element.
Toy
Multiply all dimensions and bytes per element, including both keys and values: the result is 6,400 bytes.
Gqa
The formula depends on KV-head count, not query-head count by itself. This assumes the other stored dimensions and cache design stay fixed.
Bytes
The conventional values-only estimate is linear in bytes per element. Metadata and other implementation costs can change total savings.
Architecture
The conventional formula is not universal. Latent or heterogeneous architectures can store different state and require a matching estimate.
Occupancy
Capacity is the space reserved; occupancy is the portion holding live state. Serving systems may preallocate capacity or manage blocks.
Prefix
Prefix reuse requires compatible computation, including the relevant model state and token sequence. Similar-looking text alone is insufficient.
Read · recall · revisit
Make the idea your own.
College · 15 questions per practice set, drawn from 30 authored questions. Each set covers every concept once. Read the supporting passages whenever you need them.
Progress stays in this browser on this site. It is not sent to a server or shared between devices. High school and college have separate records. Clearing browser data removes it.
15 questions per set. Enable JavaScript for rotating practice; the complete bank is listed below without it.
These checks cover the selected answers, not your overall understanding. A correct answer suggests a review tomorrow; a missed answer suggests reviewing its passage now. This simple reminder is not a validated learning schedule.
Clear this level’s current set and all coach attempts? Lesson progress and the other level will stay unchanged.
Sources and further investigation
Source review: October 28, 2026. Model-release claims are attributed to their publishers.