Skip to reading
Macalinao StudioLEARNReading room

FIELD NOTES / COLLEGE

Memory at work

A cache retains work from the current sequence. It does not retrain the model.

About 4 minutes · reading supplement · Read the high-school path

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.

Two kinds of stored information

A new token reuses cached keys and values; reading that state still costs time and memory.

  1. Weights: learned settings
  2. Prompt: prefill
  3. KV: retained state
  4. New token: decode

Weights: learned settings

Understand

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.

Build the cache estimate.

Two layers, two KV heads, four values per head, one hundred tokens, two bytes per value.

6,400 B
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.

Follow

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.

Distinguish

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.

Connect

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.

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.

Question 1 / 30Does ordinary prompt processing have to change model weights?
Read the supporting passage: Weights →

Question 2 / 30A model refers to an earlier sentence. Which explanation does not require retraining?
Read the supporting passage: Weights →

Question 3 / 30What does a conventional KV cache retain?
Read the supporting passage: Cache →

Question 4 / 30Which quantities are reused from earlier tokens during cached decoding?
Read the supporting passage: Cache →

Question 5 / 30What is prefill in this explanation?
Read the supporting passage: Prefill →

Question 6 / 30Before one-token-at-a-time continuation, how is the supplied prompt processed?
Read the supporting passage: Prefill →

Question 7 / 30What happens as a new token extends a conventional cache?
Read the supporting passage: Decode →

Question 8 / 30Why does a growing conversation often require more KV storage?
Read the supporting passage: Decode →

Question 9 / 30Does cache reuse make attention to past state free?
Read the supporting passage: Cost →

Question 10 / 30The past keys and values already exist. What work can remain?
Read the supporting passage: Cost →

Question 11 / 30In a uniform cache estimate, what happens when retained token count doubles?
Read the supporting passage: Tokens →

Question 12 / 30Hold batch size, heads, layers, dimensions and precision fixed; change T to 2T.
Read the supporting passage: Tokens →

Question 13 / 30Why can simultaneous sequences use more cache memory?
Read the supporting passage: Batch →

Question 14 / 30Hold each sequence length fixed and double an unshared batch. What happens to its cache estimate?
Read the supporting passage: Batch →

Question 15 / 30Which memory categories should be separated?
Read the supporting passage: Budget →

Question 16 / 30A GPU has enough space for weight files alone. What still needs budgeting?
Read the supporting passage: Budget →

Question 17 / 30What does the leading 2 count in M = 2LBTHkvdb?
Read the supporting passage: Formula →

Question 18 / 30Why does the conventional KV formula include a factor of two?
Read the supporting passage: Formula →

Question 19 / 30For L=2, B=1, T=100, Hkv=2, d=4, b=2, what is M?
Read the supporting passage: Toy →

Question 20 / 30Evaluate 2 × 2 × 1 × 100 × 2 × 4 × 2 bytes.
Read the supporting passage: Toy →

Question 21 / 30If only query-head count doubles while Hkv is fixed, must KV storage double?
Read the supporting passage: Gqa →

Question 22 / 30In grouped-query attention, the stored KV dimensions are unchanged. What follows?
Read the supporting passage: Gqa →

Question 23 / 30If bytes per cache element fall from two to one, what happens to the values-only estimate?
Read the supporting passage: Bytes →

Question 24 / 30With all cache dimensions fixed, change b from 2 to 1.
Read the supporting passage: Bytes →

Question 25 / 30Can the same uniform KV formula be applied unchanged to every latent-attention design?
Read the supporting passage: Architecture →

Question 26 / 30A model stores compressed latent state instead of conventional uniform keys and values. What must you inspect?
Read the supporting passage: Architecture →

Question 27 / 30Why distinguish allocated cache capacity from live occupancy?
Read the supporting passage: Occupancy →

Question 28 / 30A runtime reserves a large buffer but uses only some token positions. Which statement is accurate?
Read the supporting passage: Occupancy →

Question 29 / 30When is reusing another prefix cache valid?
Read the supporting passage: Prefix →

Question 30 / 30Two requests look similar. What must match before reusing cached computation?
Read the supporting passage: Prefix →

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.

Sources and further investigation

Source review: October 28, 2026. Model-release claims are attributed to their publishers.