Repository navigation
Appendix D: state the full prefix-cache history evidence (#86) - #87
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| \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}} |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
# Conflicts: # paper/paper.pdf
|
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.
The merge is pure. Re-doing 672a8bd into 234ae84 locally, 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. |
|
@codex review |
There was a problem hiding this comment.
💡 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".
| \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. |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Verdict: APPROVE Re-reviewed c271d6c, which differs from 9897205 by one line of 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. |
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_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.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.prefill_cache_hits), so the repoint is the only way KV reaches another request.targeted.json,history__*.pairs):mt_bench-0056andhumaneval-0008change, under plain decoding and MTP-3. The other four do not change.state-tapliststap_signature.json.state-mechadds the cache-level check for the history-dependent prompts and the MTP prefix-cache-off control.Validation
latexmk -pdfbuilds 74 pages with no warnings. The main text ends on page 10. The rebuiltpaper.pdfis committed, and I looked at both changed pages.python scripts/check_paper_references.pypasses;tap_signature.jsonexists on origin/main.