Review

Review the generation contract, model-policy-cache separation, prefill and decode shapes, position state, cache memory, numerical equivalence evidence, token traces, and dependency-ordered audit.

Generation repeats one contract:

prefixfinal logitspolicynext tokenextended prefix.\text{prefix}\rightarrow\text{final logits} \rightarrow\text{policy}\rightarrow\text{next token} \rightarrow\text{extended prefix}.

Stop when the policy selects <eos>, when another input would exceed context, or when another declared rule applies. Record the stopping reason.

Separate Model, Policy, and Cache

  • The model and checkpoint determine logits.
  • The decoding policy determines how a token is selected from logits.
  • The KV cache changes which stable computations are reused.

A correct cache preserves logits within tolerance. A different policy may select a different token from the same logits.

Reconstruct Prefill and Decode

Prefill processes PP prompt positions and creates PP key and value records per layer and head. Decode consumes one new input token, creates one new query, key, and value, appends K/V, and calculates one new logits row.

At cached length tt:

qt,kt,vt:(B,h,1,dh),K,V:(B,h,t+1,dh).q_t,k_t,v_t:(B,h,1,d_h), \qquad K,V:(B,h,t+1,d_h).

The current query attends across the full valid cache. Previous queries are not needed for the next standard attention output.

Reconstruct Position State

The next zero-based position equals the number of consumed input tokens. A prompt of length PP uses positions 0 through P1P-1; its first fed-back token uses position PP.

The frozen model accepts four input positions. Its fourth logits row can predict a fifth returned token, but the fifth token cannot become another input.

Reconstruct Cache Memory

Standard multi-head K/V payload contains

2LBhTdh2LBhTd_h

scalars. For the frozen model, this is 16T16T scalars or 64T64T float32 bytes. At T=4T=4, the payload is 256 bytes, excluding metadata, weights, and temporary values.

Caching saves repeated prefix projections and block computation. The new query still attends across all cached positions, so dense attention work per new token grows with context length.

Reconstruct the Equivalence Evidence

All 16 prefixes of the four controlled sequences pass:

  • maximum absolute logit error: 4.7684×1064.7684\times10^{-6};
  • acceptance tolerance: 10510^{-5};
  • wrong-position error: 23.0252;
  • wrong-layer-cache error: 3.6990.

Greedy generation returns <bos> A B D <eos>. Seeded top-3 sampling returns <bos> Y X Y <eos>. These token traces test deterministic execution and random state; they do not measure language quality.

Audit in Dependency Order

  1. checkpoint, vocabulary, model mode, and uncached logits;
  2. per-layer K/V values, axes, append, and length;
  3. position index and request ownership;
  4. cached-versus-full intermediate and final values;
  5. policy settings and random state;
  6. EOS, context, and batched stopping behavior.

Chapter 9 assumes this computation is correct and asks what controlled observations and interventions can reveal about it.

Pause and reflect

What can you now explain without looking back, and what should you revisit? The note stays with this review.

Review

Not marked done.