Autoregressive Generation
A forward pass becomes a sequence: the cost of the loop, why checking is cheaper than producing, and how to stop and stream without corrupting the text.
In a recorded GPT-2 CPU experiment, 64 greedy decode steps with no KV cache took 11.49 seconds. After generation, I supplied the known 64 tokens alongside the 17-token prompt to the same model in one 81-token forward pass. That pass took a median 0.419 seconds across five timed calls, and the argmax at each of the 64 prediction positions agreed with the token chosen by the serial run. The 81st position was computed but was not needed to check any of those 64 decisions.
In this experiment, the no-cache generation run took about 27 times as long as the single-pass check. That is a comparison between two deliberately different workloads, not a measured speedup for an inference engine or a speculative decoder. Its underlying lesson is structural: ordinary autoregressive generation must choose the next token before it knows the following prefix, whereas a causal transformer can score many positions in parallel when their token inputs are already known. A KV-cached generator narrows the cost difference; how much is an open measurement for Chapter 10.
This chapter puts the Chapter 4 forward pass inside a generation loop, records how repeated full-prefix computation scales, and explains why parallel verification is possible. It then follows two operational obligations to their actual implementations: stopping at the right place and streaming a faithful text prefix. A correct token choice is necessary but not sufficient for a correct response: EOS handling, stop-string hold-back, incremental detokenisation, and callback delivery can change what a client receives.
Where this sits
Chapter 1 introduced the loop, Chapter 3 defined token selection, and Chapter 4 exposed the forward computation. Here those parts form a concrete interface: generate receives token ids, a callback for next-token logits, a decoding function, a token limit, optional EOS and stop strings, and an optional selection hook. It records chosen token ids, step timings, emitted text, and one of the implemented stop reasons: eos, stop_string, or max_tokens. It does not yet implement timeouts, cancellation, or a full request-level sampling configuration.
The Inference Lab increment consists of this loop contract, StopStrings, and IncrementalDecoder. The matcher operates on decoded text and holds back possible stop-string prefixes. The decoder reconstructs UTF-8 text from growing token prefixes in the cases covered by the tests. These are small, testable reference mechanisms—not yet a complete, production-safe streaming implementation. We will make both their guarantees and their missing edge cases explicit.
This boundary matters beyond model serving. A completion-style agent may use Observation: to terminate its action text, while a UI expects a monotone stream of readable characters. If an engine leaks the beginning of a stop marker, drops buffered text on EOS, or sends a final suffix only in its returned object, an agent or client observes a protocol failure that can easily be mistaken for a model failure. The rest of the book needs this interface to be observable and testable.
The loop
Let \(s_t\) be the token sequence after \(t\) steps, starting from the prompt \(s_0\). One iteration is
The mathematical state is the accepted token prefix, together with the model and decoding policy that define the next-token distribution. The operational state can additionally hold KV tensors, position information, RNG state, emitted-text offsets, stop-string hold-back, and resource limits. A correctly maintained KV cache avoids recomputing earlier keys and values while preserving the intended causal computation to an agreed numerical tolerance; equality is not automatic across kernels or precisions. Nor can the prefix grow indefinitely: GPT-2’s positional limit must eventually be enforced or the execution policy changed. Chapter 10 tests caching, while this chapter focuses on a no-cache baseline.
What the naive loop costs
In examples/ch05/real_generation.py, each decode step sends the entire known prefix to GPT-2, obtains logits for all positions, and selects the next token from the final row. No KV cache is reused. For \(n\) new tokens starting from \(P\) prompt tokens, the total number of input positions processed is a sum over those repeatedly growing prefixes:
| New tokens | Median total time | Positions processed | If each token once | Waste factor | ms per position |
|---|---|---|---|---|---|
| 8 | 0.97 s | 164 | 24 | 6.8 | 5.9 |
| 16 | 1.98 s | 392 | 32 | 12.2 | 5.0 |
| 32 | 4.25 s | 1,040 | 48 | 21.7 | 4.1 |
| 64 | 11.16 s | 3,104 | 80 | 38.8 | 3.6 |
| 128 | 28.54 s | 10,304 | 144 | 71.6 | 2.8 |
Each time entry is the median of two total-duration runs; the full timings are in research/ch05/results.json. The ms per position column is derived by dividing total elapsed time by a count of processed input positions. It is a useful summary of this experiment, not a measurement of equal-cost token positions. The denominator omits distinctions such as attention’s growing matrix sizes, output projection, Python overhead, and allocator effects.
The recomputation factor rises from 6.8 at eight new tokens to 71.6 at 128. Algebraically it grows with output length if the supported context can also grow; GPT-2 itself has a finite context limit. The no-cache loop processes \(O(nP+n^2)\) token positions. That is a statement about the number of repeated position computations, not a complete FLOP bound: recomputing full \(T\times T\) attention for every growing prefix contributes a sum of quadratic attention terms, which can be cubic in \(n\). A cached loop reduces repeated projections, but attention against the growing cache still has context-dependent cost. These distinctions are important when Chapters 10 and 11 turn counts into time and bandwidth estimates.
The processed-position count grew about 63-fold from eight to 128 output tokens, while the two-run median elapsed time grew about 29-fold. The quotient shown in the last column declined from 5.9 to 2.8 ms per processed position. That pattern is consistent with better utilisation when larger matrices are passed to the CPU, as Chapter 4 also suggested, but this run did not isolate CPU utilisation or memory traffic. It would be a mistake to infer from the quotient that each position becomes uniformly cheaper. The cost model must distinguish growing sequence shapes, dense attention, and fixed overhead before explaining timings causally.
Nothing in the table measures a KV-cached implementation. Dividing the naive time by the recomputation factor would be invalid: cache maintenance, memory traffic, one-token matrix shapes, and attention over the retained prefix change the cost structure. The cached comparison remains NOT_RUN for this chapter and is an explicit gate for Chapter 10.
Latency profile of one generation
A separate 64-token latency run, following one discarded warm-up forward pass, recorded the elapsed forward-and-select time for each decode step. Its total was 14.54 seconds, not the 11.49 seconds from the separate serial-versus-parallel verification run. The two runs should not be silently combined into one benchmark:
| Quantity | Value |
|---|---|
| Time to first token (forward pass over 17 positions) | 125 ms |
| Median inter-token time | 187 ms |
| 95th percentile inter-token time | 413 ms |
| Maximum | 460 ms |
| Median, first half of steps | 147 ms |
| Median, second half of steps | 284 ms |
| Fitted drift | 4.3 ms per step |
| Overall rate | 4.4 tokens/s |
The later steps were slower: the median excluding the first token rose from 147 ms in the first half to 284 ms in the second, and a linear fit to the inter-token samples had a slope of about 4.3 ms per step. The 413 ms p95 therefore combines position-dependent growth with ordinary runtime variation. Calling it mostly drift is plausible from the plotted sequence, but the experiment did not decompose trend, scheduler effects, and noise. It would be too strong to say that the high percentile is not variance at all.
A percentile remains a valid summary of the observed inter-token intervals, even when those intervals trend upward; it simply cannot tell us why the tail is slow. For comparisons, report step index or context length alongside p50 and p95, and keep prefill/first-token timing separate from later decode intervals. KV caching removes repeated prefix projections, but single-token attention still reads an expanding set of keys and values; a flat inter-token profile is a hypothesis to test, not a guaranteed result. Finally, the table’s 125 ms first-step compute time is not end-to-end service TTFT: tokenisation, queueing, dispatch and delivery were not included.
Why checking is cheaper than producing
The verification experiment generated 64 tokens by greedy, no-cache decoding. It then supplied the known 17-token prompt plus all 64 generated tokens in one causal forward pass and compared the argmax at indices corresponding to the 64 actual prediction positions. Only 80 input positions were needed for those comparisons; including the final generated token made the measured pass 81 positions long. This detail should be retained if the harness is later optimised.
| Time | |
|---|---|
| Generate 64 tokens serially (no cache) | 11.49 s |
| One forward pass over the 81-token sequence (median of 5) | 0.419 s |
| Ratio | 27× |
| Positions where the argmax equals the generated token | 64 of 64 |
All 64 comparisons had the same argmax token id. Causal masking makes the prediction at a position independent of later token values, so it is legitimate to score a known sequence in parallel. The result does not prove that the entire logits vectors were bit-identical between the two execution shapes, nor that cached or fused implementations would be bit-identical. In this experiment the discrete greedy choices matched; Chapter 4’s separate masked-prefix test examined an exact-zero earlier-logit difference under one fixed execution path.
The practical distinction is between proposing tokens and verifying token probabilities. Greedy generation must resolve each accepted next token before continuing along the exact selected path. If a cheap draft model or heuristic proposes several tokens, a causal target model can score those proposed positions together. A greedy verifier may retain the longest prefix whose proposed ids match the target’s argmax choices. For sampling, simply comparing argmax ids is wrong: exact speculative sampling uses a carefully defined acceptance and correction distribution so that the target distribution is preserved. Blockwise parallel decoding (Stern et al., 2018) and speculative decoding (Leviathan et al., 2023) formalise these approaches. Known prompt tokens are already available and can be processed as prefill, whereas accepted new tokens are produced in decode.
The 27× ratio compares serial generation without a cache against one warmed, batched forward pass on one CPU and one prompt. It is neither the speedup of speculative decoding nor the expected ratio for a production server. The full-sequence check also computes an unused last-position row. The warranted conclusions are narrower but useful: the verification harness reproduced 64 greedy choices, a causal forward pass scored known positions in parallel, and the next optimisation question is whether generating and checking proposed blocks beats a correctly cached baseline. No such speedup is measured here.
Stopping
At a service boundary, completion, caller limits, and external interruption need separate reasons. This chapter groups the principal cases into four categories, while the implemented generate loop supports only the first three. Timeout and cancellation are interface requirements, not yet working branches in this function.
| Reason | Who decides | Nature |
|---|---|---|
| End-of-sequence token | The model | A token the model chooses to emit |
| Token limit | The request | A resource limit |
| Stop string | The decoding policy | A condition on the decoded text |
| Timeout or cancellation | The service | An external signal |
The code checks EOS, stop strings and the token limit during normal generation. A service can request cancellation between steps, but a synchronous forward call that cannot be interrupted might still run until that call returns. The cancellation delay is up to the remaining step time, plus scheduling and cleanup—not at least one full step. The current function has no cancellation/timeout input and can return only eos, stop_string or max_tokens. Chapter 30 will have to add and test the external states instead of merely mentioning them in a glossary.
How often does a model choose to end?
The GPT-2 EOS experiment examined six chosen prompts, each for at most 64 greedy selections. Those prompts included a document ending and a chat-shaped text, but GPT-2 is a base language model, not an instruction-following assistant. The question tested was specific: did id 50256 become the greedy next token before the request limit?
| Prompt style | Stop reason | Maximum P(EOS) over the run | Best rank of EOS |
|---|---|---|---|
| Document ending (“All rights reserved.”) | max_tokens | 0.117 | 2 |
| Chat transcript | max_tokens | 0.007 | 2 |
| Question and answer | max_tokens | 0.021 | 2 |
| List | max_tokens | 0.012 | 3 |
| Story opening | max_tokens | 0.002 | 40 |
| Code | max_tokens | 0.004 | 3 |
For the six observed traces, <|endoftext|> (id 50256) was never the highest-ranked choice in any of 384 steps. In the document-ending trace its probability reached about 0.117 and rank 2, yet greedy selection did not choose it; all six traces terminated at max_tokens. This is an observation about the recorded prompts and decoding rule, not an EOS frequency estimate for GPT-2 prompts in general.
GPT-2 was trained to predict text tokens, including its end-of-text marker; it was not trained as a contemporary assistant to conclude chat turns on command. That distinction is more precise than saying it was never trained to conclude anything. EOS is a token id, not an ordinary decoded text suffix, and this implementation checks it before detokenisation. generated_ids nevertheless retains the EOS id when it is selected; text omits its decoded representation. One caveat is a live code defect: if a stop-string prefix is pending at EOS, the current generate implementation breaks without flushing the pending text, so the returned text can be truncated. That must be fixed and tested before promising lossless finalisation.
Stop strings
A stop string is a condition on the decoded output text, not on a fixed token-id sequence. The same visible marker may have different token segmentations depending on preceding context, so matching one pre-tokenised id pattern is insufficient as a general stopping strategy. The examples measured with the pinned GPT-2 tokeniser make the failure concrete:
| Surface text | GPT-2 tokens |
|---|---|
END |
END |
\nEND |
\n · END |
Observation: |
Obs · ervation · : |
Observation: (leading space) |
Obs · ervation · : |
</s> |
</ · s · > |
Tokenisation is context dependent: END, \nEND, and Observation: yield different id sequences, and visually identical double newlines can arise from token 628 or tokens 198 and 198. A matcher looking only for [628] misses the second form. Matching decoded text avoids that specific ambiguity, although the engine must still define normalisation, special-token handling, and whether stop text is included in stored token ids or returned output.
For a general text-level stop policy, the matcher must inspect decoded output and avoid exposing tentative characters. Suppose END is the marker and the decoder yields E, N, and D in three updates. Sending E and N immediately makes it impossible to remove the complete marker from a client’s already visible stream. A correct streaming contract must buffer possible marker prefixes and release them only after they cannot complete a stop string.
StopStrings holds back the longest suffix of pending text that is a proper prefix of any configured stop string. After E it waits; after EX it releases both characters; after END it stops without emitting the marker. At most max(len(stop)) - 1 characters of candidate prefix need be buffered under this strategy, but the corresponding delay in time depends on token arrivals and decoding. The unit tests cover simple split markers, rejection of a false prefix, earliest completed matches, and end-of-limit flushing. They do not yet cover every overlapping-marker combination, Unicode normalisation policy, or every arbitrary chunking.
The desired invariant is that, given the same fully decoded character sequence and stop policy, the final retained text should not depend on how that sequence was split into deltas. The existing tests demonstrate selected cases but do not constitute a proof of chunk-invariance. For example, with stops ["ABCDE", "BC"], feeding ABCDE in one delta matches the marker at index 0 and emits nothing, while feeding ABC then DE stops on BC early and emits A. This is a chunk-invariance counterexample in the current matcher, not merely an untested edge. A precedence policy and buffering rule must be specified and implemented before the reference can claim this property. Exercise 2 captures it as a regression test.
Streaming
Streaming should not alter token selection or the final intended output. It changes when portions of the decoded response become observable, and introduces buffering, finalisation, cancellation, and delivery questions that a single batch decode can hide. A stream emitted by a callback is also not proof that a network client actually received those bytes.
A GPT-2 token can contain a UTF-8 fragment, so separately decoding each id can introduce � replacement characters even when the complete id sequence decodes correctly. The experiment uses 推論 café 😀: nine GPT-2 tokens, of which eight individual-token decodes contain replacement characters. The reference IncrementalDecoder reconstructs the growing prefix at every push and withholds some output, rather than permanently committing each invalid fragment.
| Method | Recorded result and scope |
|---|---|
| Decode individual GPT-2 token ids and concatenate | Eight of nine individual decodes contain �; concatenation differs from the source text |
Use IncrementalDecoder on the same nine ids, then flush |
Concatenation equals 推論 café 😀 with no replacement characters; the recorded report counts six empty deltas across pushes plus the final flush |
The per-token method corrupted the multi-token Japanese characters and emoji in this example; the café portion happened to decode as complete characters. The prefix-redecode strategy avoided that failure on this input but is not a general proof of UTF-8 correctness. In particular, IncrementalDecoder infers incompleteness merely from whether the decoded prefix ends with �. That test also delays a legitimate U+FFFD character or a replacement resulting from malformed bytes, and it cannot distinguish a deliberate replacement from an unfinished byte sequence. Further, the reference re-decodes all ids on every push, giving quadratic cumulative work under a linear decode-cost assumption. A production implementation should use an incremental byte-state decoder with an explicit invalid-sequence policy and tests for malformed UTF-8, literal U+FFFD, boundaries at the prompt, and final flush. This remains a useful teaching fixture, but not an unconditional guarantee that every input streams correctly.
Two interfaces must therefore be measured separately. A model token is not necessarily a stream event: a decoder may hold incomplete bytes, a stop matcher may hold tentative text, and a transport may coalesce callbacks. Model-side decode intervals should not be reported as client-observed character latency. Likewise, generated_ids, text, and on_text events have different meanings: the ids include the chosen EOS token when present, the returned text excludes stop markers, and callback delivery may lag or omit a flushed tail in the current code. A reliable request record should include tokenizer revision, selection policy, full generated ids, final visible text, and an event trace when streaming is exercised.
The loop as code
The core generate loop is intentionally short; the extract below is explanatory pseudocode, not the full function or an executable Python example. In the repository, generate accepts an optional select(logits, step) callback and records both forward and selection times. The code also has finalisation logic after this body—and that finalisation is where two defects are visible: pending stop-text is not released at EOS, and tail text flushed on max_tokens is added to the returned string without calling on_text. The example should be read together with those known limitations:
for step in range(max_new_tokens):
logits = next_logits(ids) # the seam: any engine plugs in here
best = argmax(logits)
ids.append(best)
steps.append({"step": step + 1, "token_id": best, "seconds": ..., "positions_processed": len(ids) - 1})
if best == eos_token_id:
reason = "eos"; break # EOS is checked before it can be emitted
out, stopped = stopper.feed(decoder.push(best))
emit(out)
if stopped:
reason = "stop_string"; break
The seam next_logits(ids) allows a toy, a no-cache model, or a wrapper with additional state to supply scores, although this function itself passes the full id prefix on every call. EOS is checked before text decoding, and step records include positions_processed, forward_seconds, and select_seconds. The optional selection callback also permits non-greedy rules, but SamplingConfig and its seed from Chapter 3 are not automatically wired into this function. The older generation_loop.py remains a simple toy fixture with a different result shape. Neither example yet demonstrates end-to-end network streaming or correct finalisation in all cases.
What the numbers do not show
- A single pinned GPT-2 small model, greedy decoding for real-model measurements. This does not characterise instruction-tuned models, production stop policies, or stochastic acceptance.
- No KV-cache benchmark. Both the recomputation factors and the 27× comparison describe a deliberately naive loop. Cached-generation performance remains NOT_RUN in this chapter.
- One prompt for scaling, latency and verification, with separate timing runs. The code implies some position dependence; the precise fitted drift and timings are not transferable.
- Two scaling repetitions per length. The medians indicate behaviour on this machine rather than a robust performance distribution.
- Partial streaming verification. GPT-2 tokenisation and a synthetic byte-token model were exercised, not a network transport or arbitrary Unicode/invalid-byte inputs.
- Unfixed end-of-run issues. EOS can discard stop-string hold-back, and
on_textomits text flushed at the token limit. The tests do not cover these cases. - No implemented cancellation or timeout. Their semantics are requirements for Chapter 30, not findings.
- One CPU thread and no production serving. Absolute throughput, scheduling, batching, and GPU behaviour are not measured.
Inference Lab increment
The Chapter 5 Lab increment exposes a deliberately narrow reference API and an evidence-bearing cost model. The promised streaming contract is not yet fully satisfied; the implementation notes below name the remaining repairs explicitly:
generate(next_logits, decode, prompt_ids, max_new_tokens, eos_token_id=None, stop_strings=(), on_text=None, select=None): a no-cache loop returningstop_reason,generated_ids,text, per-step timings andtotal_seconds. Theselecthook is optional; Chapter 3’s configuration is not connected by default.StopStrings: a text-level prefix-holding matcher, exercised by example tests; overlapping patterns and chunk-invariance still need systematic testing.IncrementalDecoder: a prefix-redecode reference that handles the measured GPT-2 Unicode example but uses a replacement-character heuristic rather than a general incremental UTF-8 state machine.positions_naiveandpositions_cached: counts of processed input positions, not time estimates for an actual cached runtime.
Together with Chapters 1–4, these components make it possible to design a record identifying the model artefact, tokenizer, sampling rule, forward implementation, timing and stop outcome. The Chapter 5 return value itself does not yet assemble all those earlier metadata fields or persist a sampling seed. Before it becomes a reference contract for Chapter 6, the engine should (1) flush safe held-back text on EOS, (2) send final flushed text through on_text, (3) establish chunk-invariance and Unicode properties, and (4) specify cancellation and prompt-boundary behaviour. The performance baseline stays useful as it is; correctness at the API boundary is the next publication gate.
What you should now be able to do
- Write the serial next-token decision rule, and explain why a known or speculatively proposed continuation can be scored in parallel.
- Derive the no-cache position-recomputation factor and distinguish it from FLOPs, cached cost, and wall-clock speedup.
- Explain the 64-of-64 greedy verification result without asserting bit-identical logits or a 27× production speedup.
- Report implemented stop reasons separately from cancellation/timeout requirements.
- Specify stop-string precedence and test hold-back against arbitrary chunk splits and overlapping patterns.
- Describe why independently decoding byte-level tokens corrupts Unicode and where the prefix-redecode reference still fails.
- Explain why measured first-step compute time is not end-to-end TTFT, and how latency drift affects p95 interpretation.
- Distinguish generated token ids, final returned text, and
on_textcallback events when validating streaming.
Key terms
- Autoregressive generation: choosing accepted tokens sequentially, conditioned on the accepted prefix.
- Prefix: the supplied and accepted token ids that condition the next distribution, subject to the model’s context policy.
- Stop reason: the recorded termination cause; this implementation supports
eos,stop_stringandmax_tokensonly. - EOS token: a model vocabulary id that can mark a sequence boundary; selecting it does not require emitting its decoded surface form.
- Stop string: a text-level pattern used by the decoding policy to truncate output.
- Hold-back: keeping a possible stop-string prefix private until it can be emitted or rejected.
- Incremental decoder: a decoder that produces stable text deltas from a token stream; the present implementation approximates this with full-prefix decoding.
- Position-recomputation factor: number of processed input positions in the no-cache loop divided by the once-per-position idealisation.
- TTFT: request-to-first-visible-token latency under a specified service boundary; not equivalent to this chapter’s first-step computation time.
- Inter-token latency drift: a systematic trend in step duration as the accepted prefix grows.
- Parallel verification: scoring known draft tokens in one causal forward pass; acceptance semantics differ between greedy and stochastic decoding.
Reader exercises
- Add a
timeoutstop reason and a cancellation check between forward calls. Trigger cancellation midway through a slow forward step and separate request arrival, check time, and termination time. Which delay is unavoidable without interruptible kernels? - Write a chunk-invariance property test for
StopStrings. Include random splits, two overlapping stop patterns, and the case where an earlier partial match competes with a later full match. Define an explicit precedence rule before testing. - Write an EOS regression test for
generatethat holds backENfor stop stringEND, then selects EOS. The final returned text should retainEN. Does the current implementation pass? Fix the finalisation path. - Write a callback regression test where generation ends at
max_tokenswith held-back suffixEN. Compare''.join(on_text_deltas)withresult['text']. Repair the callback delivery so they match. - Exercise
IncrementalDecoderwith literal U+FFFD, malformed UTF-8, an emoji split over byte tokens, and a prompt ending in a partial byte sequence. Define error handling rather than assuming every�means “wait”. - Repeat the parallel-check experiment after sampling at temperature 1.0. Explain why argmax matching is not an acceptance test for samples, and derive the distribution-preserving acceptance rule from the speculative-decoding paper.
- Run the EOS experiment on a cached instruction-tuned model, if available. Record the tokenizer’s EOS id, prompt format, and decoding settings before comparing outcomes.
- Refit step time versus position and compare it with both the projection FLOPs and dense-attention FLOPs in Chapter 4. Does a linear fit explain the entire trace?
- Implement a linear-time byte-state incremental decoder and benchmark it against full-prefix decoding over longer multilingual outputs. Include a finish/flush test.
References
Primary research (three papers):
- Blockwise Parallel Decoding for Deep Autoregressive Models — Stern, Shazeer and Uszkoreit (NeurIPS 2018). Explains proposing and verifying token blocks under greedy decoding rather than confusing a full-sequence check with generation.
- Fast Inference from Transformers via Speculative Decoding — Leviathan, Kalman and Matias (ICML 2023). Gives the sampling-preserving acceptance and correction rule and an explicit target/draft cost model.
- The Curious Case of Neural Text Degeneration — Holtzman et al. (ICLR 2020). Grounds the separation between decoding policy, repetition, and the quality of generated text.
Technical specifications and implementation references:
- Attention Is All You Need — causal masking and parallel self-attention in the original transformer architecture (not a description of the particular GPT-2 benchmark).
- Hugging Face generation strategies — library-specific stopping and decoding options; version-dependent behaviour must be checked against the installed release.
- Python incremental codecs — byte-state incremental decoding and explicit treatment of incomplete byte sequences.
Evidence in this chapter
| Claim | Evidence status / scope |
|---|---|
| A causal model can score known tokens in parallel, while normal accepted-token selection has a serial dependency | Established mechanism; causal architecture and decoding literature |
| Blockwise and speculative methods can propose blocks and verify them without changing the target policy when their acceptance rules are correct | Established research, not implemented or benchmarked here |
| Serial no-cache 64-token run: 11.49 s; warmed 81-token pass: median 0.419 s; 64/64 greedy argmax ids agree | Book result: one CPU, one prompt, no KV cache; logits equality not checked |
| No-cache recomputation factor rises from 6.8 to 71.6 at output lengths 8 to 128 | Book arithmetic over input-position counts; not a measured cached speedup |
| Total time per processed position fell from 5.9 to 2.8 ms in the scaling experiment | Book result, two runs per length; explanation remains hypothesis |
| Separate 64-token latency run: first-step compute 125 ms, inter-token p95 413 ms, fitted drift 4.3 ms/step, total 14.54 s | Book result, one run; not end-to-end TTFT or a decomposition of drift versus noise |
| EOS id 50256 was never chosen in 384 greedy steps across six prompts | Book result on GPT-2 small; no claim about instruction-tuned models |
| Stop text can have multiple token-id segmentations | Established mechanism plus book tokeniser examples |
| Eight of nine individual GPT-2 token decodes in the multilingual test contain replacement characters | Book result; prefix-redecode succeeds on this one test case |
IncrementalDecoder handles arbitrary Unicode and malformed bytes safely |
NOT_ESTABLISHED; replacement-character heuristic has identified limitations |
| Chunk-invariance for overlapping stop strings | KNOWN IMPLEMENTATION GAP; different delta splits can select different stop markers |
| EOS finalisation preserves pending stop-string text; callbacks receive all final text | KNOWN IMPLEMENTATION GAPS, requiring regression tests and code fixes |
| Real KV-cached generation, network streaming, timeout/cancellation and sampled verification | NOT_RUN / not measured in this chapter |