Skip to content

Appendix D: state the full prefix-cache history evidence (#86) - #87

Merged
SamMausberg merged 4 commits into
mainfrom
paper/appendix-history
Oct 1, 2026
Merged

SamMausberg merged 4 commits into
mainfrom
paper/appendix-history

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Brings Appendix D's "History dependence through the prefix cache" paragraph up to the evidence merged in #86, replacing the interim narrowing in #83. It follows the reviewed wording of the state README section of the same name. The main text is unchanged.

What the paragraph now says

  • Tap-changed prompts (tap_check.json). The tap changed five prompts, all first differing in log-probabilities at output index 2. Three change tokens, at near ties: the top-two gap at the first changed token is 0 or 0.125 in both runs.
  • Module signature (tap_signature.json). Untapped runs record no module outputs, so the signature comes from two tapped sessions (v1 and v3) that served the same 167 prompts in the same order at batch 1. They differ for four of the five, in plain decoding and MTP-3. In all eight comparisons the first differing module is layer 3's attention, at output index 2 for plain decoding and at a verify step at output index 3 or 5 for MTP, with identical QKV projection and earlier modules. At the same batch shape that points to different cached KV.
  • Mechanism, by code reading. The prefix-cache insertion repoints the request's KV. No prefill in these runs reused a cached prefix (0 cached tokens; prefill_cache_hits), so the repoint is the only way KV reaches another request.
  • History test (targeted.json, history__*.pairs):
    • The 12 prompts include all five tap-changed prompts. Only mt_bench-0056 and humaneval-0008 change, under plain decoding and MTP-3. The other four do not change.
    • Prefix cache off: all 12 are identical for plain decoding; the MTP control is pending.
  • Conclusions, at their strength. Dependence on which request computed the prefix is shown for two prompts. For the other four the mechanism is "likely" the same but what decides it is unknown. The ordering/timing candidate is labelled "reasoning and untested". No token changed in the history test, and the tap changed only near-tie decisions.
  • Register. state-tap lists tap_signature.json. state-mech adds the cache-level check for the history-dependent prompts and the MTP prefix-cache-off control.

Validation

  • latexmk -pdf builds 74 pages with no warnings. The main text ends on page 10. The rebuilt paper.pdf is committed, and I looked at both changed pages.
  • python scripts/check_paper_references.py passes; tap_signature.json exists on origin/main.

With #86 merged, the paragraph now gives the full evidence:
- The tap changed five prompts, three of them in tokens, at near ties:
  the top-two gap is 0 or 0.125 in both runs.
- The module signature comes from two tapped sessions that served the
  same 167 prompts in the same order. They differ for four prompts, at
  layer 3's attention, in all eight comparisons.
- No prefill reused a cached prefix, so the repoint is the only path.
- The 12-prompt test includes all five tap-changed prompts, and only
  mt_bench-0056 and humaneval-0008 change. The other four do not change
  under plain decoding or MTP-3.
- For those four the mechanism is likely the same but undecided. The
  ordering/timing idea is labelled as untested reasoning.

state-tap lists tap_signature.json, and state-mech adds the MTP
prefix-cache-off control.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T05:09:00.338214Z c271d6c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d20bad5f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread paper/sections/app_register.tex Outdated
\evitem{state-mech}{First differing module outputs and divergence classes under both error models (Figure~\ref{fig:divergence}, Table~\ref{tab:divergence})}{\nolinkurl{evidence/state_safety/mechanism_plain_c1_vs_mtp_s3_c1.json}, \nolinkurl{mechanism_plain_c1_vs_c32.json}, \nolinkurl{first_difference_by_module.csv}, \nolinkurl{divergences.csv}}{\nolinkurl{experiments/state_safety/mechanism.py}, \nolinkurl{analyze_all.sh}, \nolinkurl{compare.py}}
\evitem{state-noise}{Divergence rates, BF16 top-two ties, same-server and fresh-server repeats and the deterministic-mode checks; the server settings of every run}{\nolinkurl{evidence/state_safety/noise_floor.csv}, \nolinkurl{noise_floor.json}, \nolinkurl{run_meta.json}}{\nolinkurl{experiments/state_safety/run_all.sh}, \nolinkurl{compare.py}}
\evitem{state-tap}{Positive controls of the bit-exact tap; the method and the open tap-changed prompts}{\nolinkurl{evidence/state_safety/tap_control_down9.json}, \nolinkurl{tap_control_core13_decode.json}, \nolinkurl{tap_control_core13.json}, \nolinkurl{tap_check.json}, \nolinkurl{README.md}}{\nolinkurl{experiments/state_safety/mechanism.py}}
\evitem{state-tap}{Positive controls of the bit-exact tap; the method and the open tap-changed prompts}{\nolinkurl{evidence/state_safety/tap_control_down9.json}, \nolinkurl{tap_control_core13_decode.json}, \nolinkurl{tap_control_core13.json}, \nolinkurl{tap_check.json}, \nolinkurl{tap_signature.json}, \nolinkurl{README.md}}{\nolinkurl{experiments/state_safety/mechanism.py}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge List the generator for tap_signature.json

Add experiments/state_safety/tap_signature.py to the producer list for the newly registered tap_signature.json. That artifact is generated when analyze_all.sh invokes tap_signature.py; mechanism.py only supplies imported helpers. Since this register explicitly promises the program that produced each evidence file, the current row sends readers to the wrong entry point and makes the new evidence harder to reproduce.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 234ae84. The state-tap entry's producers are now experiments/state_safety/mechanism.py, analyze_all.sh (which writes tap_check.json) and tap_signature.py (which analyze_all.sh runs for tap_signature.json). The description now names the tap-changed prompts and their module signature in two tapped sessions.

Address the Codex comment on #87. analyze_all.sh writes tap_check.json
and runs tap_signature.py for tap_signature.json; mechanism.py supplies
the helpers. The state-tap entry now lists all three, and its
description names the tap-changed prompts and their signature.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Reviewed 0d20bad and 234ae84, and the final head 9897205, which merges main 672a8bd (#85) into them.

Every claim in the rewritten paragraph matches the evidence merged in #86. I reproduced each of these files byte-identical when reviewing #86.

  • tap_check.json. The tap changes five prompts, each first differing at output index 2. Three change tokens, and the top-2 gap at the first changed token is 0 or 0.125 in both runs.
  • tap_signature.json.
    • The v1 and v3 tapped sessions served the same 167 prompts in the same order at batch 1, and they differ for the other four prompts in both plain and MTP-3.
    • In all 8 comparisons, the first differing module is model.layers.3.attn: at output index 2 in plain, and at a verify step at index 3 or 5 under MTP.
    • The server.log of each of the four tapped sessions shows 0 of 169 prefills with cached tokens.
  • The 12-prompt history test (targeted.json, history__*.pairs). It includes all five tap-changed prompts. Only mt_bench-0056 and humaneval-0008 change, with log-probabilities only, from index 2 (and 5 for MTP's mt_bench-0056). Plain with the cache off is 12/12 identical, and the history runs have 0 of 38 prefills with cached tokens. The other four don't change under plain or MTP-3.
  • Reasoning is kept apart from measurement.
    • "By the code" marks the claim that the cache reuses a prefix only at a stored recurrent state.
    • "Likely" for the four is tied to the same-batch-shape signature.
    • What decides which KV copy a step reads is stated as unknown.
    • The ordering and timing candidate is labelled reasoning and untested.
  • Register.
    • state-tap lists tap_signature.json with the producers mechanism.py, analyze_all.sh and tap_signature.py, which addresses Codex's P2 on 0d20bad.
    • state-mech adds the MTP cache-off control.
    • All paths exist on main.

The merge is pure. Re-doing 672a8bd into 234ae84 locally, paper/paper.pdf is the only conflict and every other path is identical to 9897205. Against main, the tex hunks are identical to 234ae84's.

Build at 9897205. I rebuilt from source: 74 pages, no warnings, and the text matches the committed PDF. The main text ends on page 10, with References at the top of page 11. Page 1 carries #85's footnote, and the checker passes.

Codex and commits. Codex finished on 0d20bad, and its one P2 is fixed and answered. It has not run on 234ae84 or 9897205. All commits are Sam's, with no AI attribution.

Suggestion (not blocking): "while its QKV projection and every earlier module agree" is slightly broader than what was measured. tap_signature.py leaves out the GDN core, its gated norm and the logits, because v1 did not hash them per token. Downstream outputs of those modules are compared, so the conclusion stands. Still, "every earlier module output that both tap versions hash", the README's wording, would say exactly what was compared.

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9897205417

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread paper/sections/app_exactness.tex Outdated
\paragraph{How often} In plain decoding at concurrency 1 against 32, 167 of 320 prompts diverge within 256 tokens, 3.42 divergences per 1,000 compared tokens, with a largest margin at the divergence of 0.375 nats. Repeating either configuration on the same server reproduces every token of all 320 prompts, and every log-probability except those of one 128-token prompt, which differ from its prefill onward in both repeats. A fresh server at batch 1 reproduces the first pass bitwise on all 320 prompts, that one included, so its difference on the same server comes from what the prefix cache already held (below). A fresh server at concurrency 32 reproduces 296 of the 320 outputs; the other 24 diverge at exact ties, 0.35 per 1,000 compared tokens, because request arrival, and with it batch composition, differs between sessions~\ev{state-noise}. Plain decoding at batch 1 has an exact BF16 tie between its top two logits at 11.3 of every 1,000 positions and a nonzero gap of at most 0.125 at another 22.2, and no run committed a token that was not its own top-1~\ev{state-noise}. SGLang's deterministic mode, which replaces the default matrix multiplication with a batch-invariant one (DeepGEMM's deterministic BF16 GEMM at the pin's defaults on this GPU, a persistent Triton kernel otherwise)~\cite{sglangdeterministic} and, with the FlashInfer backend, also switches sampling to PyTorch and disables the prefix cache, made plain decoding batch-invariant in an 8-prompt, 128-token check (concurrency 1 against 8: identical tokens and bitwise-identical log-probabilities) but not MTP speculation (2 of 8 prompts diverged). Passing the deterministic KV split to FlashInfer's target-verify plan, as an engine patch (\path{engine/sglang/patches/state/0002-verify-kv-split-deterministic.patch}, now behind an environment switch that is off by default; the run predates the switch and had the change on), left 28 of 96 MTP prompts diverging between concurrency 1 and 32, 1.55 per 1,000 compared tokens, all at exact ties~\ev{state-noise}. A plausible reason, not tested, is that the draft is not batch-invariant, so accepted lengths, and with them a position's offset inside its verify block, differ between batch sizes.

\paragraph{Open questions} The remaining configuration pairs (MTP with one, three and five steps and a tree at both concurrencies, prefix cache and overlap scheduler off, deterministic mode and the FP32 head in full) and the cache-level check are \pend{state-mech}. \paragraph{History dependence through the prefix cache} Of the five prompts whose output the tap itself changed, one has a stock explanation~\ev{state-tap,targeted}. They are recorded in \path{tap_check.json}: in all five the first log-probability difference is at output index 2, and two of them keep every token. Untapped runs record no module outputs, so the module-level signature comes from two tapped runs, which also differ for four of the five: in each of those, the first differing module is layer 3's attention output while its QKV projection and every earlier module agree, which at the same batch shape points to different cached KV. At the pin, after a request's prefill, SGLang inserts its prefix into the prefix cache, matches it again and repoints the request's KV slots to the tree's copies, freeing its own. For tokens the tree already held, such as a chat-template prefix shared with an earlier request, the request then attends over the earlier request's copy of that KV, valid values for the same tokens at the same positions but computed in a prefill of another shape and not bitwise equal; under the overlap scheduler decode step 1 is already in flight with the request's own KV, so the switch shows from output index 2 (code reading at the pin). A deterministic reproduction of the effect on stock SGLang serves each of 12 prompts on an empty cache and again right after the earlier prompt that shares the longest prefix with it. With the prefix cache on, plain decoding and MTP with three steps keep every token but change log-probabilities for 2 of the 12 prompts, from output index 2 (and 5 for one MTP prompt); for plain decoding with the prefix cache off all 12 are identical in tokens and log-probabilities. Of the five tap-changed prompts, only \code{mt\_bench-0056} is among those this test shows changing, without the tap; whether the same mechanism explains the other four is open. So with the prefix cache on, a request's output at a fixed configuration and batch shape depends on which earlier request computed its shared prefix. The values involved are valid, no token changed in this test, and it is not state corruption; the confirmation at the level of the cached KV is \pend{state-mech}.
\paragraph{Open questions} The remaining configuration pairs (MTP with one, three and five steps and a tree at both concurrencies, prefix cache and overlap scheduler off, deterministic mode and the FP32 head in full) and the cache-level check are \pend{state-mech}. \paragraph{History dependence through the prefix cache} Five prompts change output under the tap~\ev{state-tap}. In all five the tapped run first differs from the untapped one in log-probabilities at output index 2, and three of them change tokens, at near ties: at the first changed token the top-two gap is 0 or 0.125 in both runs (\path{tap_check.json}). Untapped runs record no module outputs, so the module-level signature comes from two tapped sessions with different tap versions, which served the same 167 prompts in the same order at batch 1 and also differ for four of the five, in plain decoding and with MTP at three steps (\path{tap_signature.json}). In all eight comparisons the first differing module output is layer 3's attention, at output index 2 for plain decoding and at a verify step at output index 3 or 5 for MTP, while its QKV projection and every earlier module agree, which at the same batch shape points to different cached KV.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Qualify the module-agreement claim

For these eight v1/v3 comparisons, tap_signature.py explicitly excludes linear_attn.attn, linear_attn.norm, and gdn_ outputs before selecting the first difference (experiments/state_safety/tap_signature.py:29,43-46), so the evidence establishes only that every comparable earlier output agrees—not every earlier module. An excluded upstream GDN output could differ first, which weakens the inference that different cached KV is necessarily what first reaches layer 3; retain the qualifier used in evidence/state_safety/README.md that this applies to outputs hashed by both tap versions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c271d6c. The sentence now reads "while its QKV projection and every earlier module output that both tap versions hash agree, which at the same batch shape points to different cached KV." It adds: "The comparison leaves out the GDN recurrence and attention outputs, the gated norm and the logits, which the two versions do not hash comparably, so one of those could differ first." This matches _NOT_COMPARABLE in tap_signature.py and the README wording.

Address the Codex P2 on #87, which the reviewer had raised as optional.
tap_signature.py drops the GDN recurrence and attention outputs, the
gated norm and the logits before finding the first difference, because
the two tap versions do not hash them comparably. The claim is now that
every earlier module output both versions hash agrees, with the
excluded outputs named and the caveat that one of them could differ
first.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: c271d6cf1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed c271d6c, which differs from 9897205 by one line of app_exactness.tex plus the PDF.

Codex's P2 on 9897205 is fixed. The sentence now says "every earlier module output that both tap versions hash agree". A new sentence names what the comparison leaves out and says that one of those could differ first. The Codex thread has a reply. Codex's manual run on c271d6c finished with no new comments.

Build. I rebuilt from source: 73 pages (the reflow saved one), no warnings, and the text matches the committed PDF. The main text ends on page 10, and the checker passes. The commit is Sam's, with no AI attribution.

Suggestion (not blocking): the list of excluded outputs is one item short. _NOT_COMPARABLE covers linear_attn.attn, linear_attn.norm, logits and the gdn_ prefix, and in the v3 slots that prefix matches both gdn_core (the recurrence) and gdn_conv (the causal convolution). Neither exists in v1. "The GDN convolution, recurrence and attention outputs, the gated norm and the logits" would list them all. That can go in the next appendix PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant