Repository navigation
Appendix D: integrate the state-safety results (#59) - #74
Conversation
Figure 5 is now drawn from first_difference_by_module.csv instead of typed counts; the counts are unchanged. Appendix D.4 adds the fresh-server repeats: batch 1 is bitwise reproducible, and at concurrency 32 24 of 320 outputs diverge at ties, 0.35 per 1,000. The tap-changed prompts are now explained by history dependence through the prefix cache, with the deterministic stock reproduction: logprobs change for 2 of 12 prompts with the cache on and none with it off. KV-level confirmation stays pending. Appendix D.5 reports the completed H5 tests. Truncation (157/157, 240/240) and stop tokens at every index of an MTP verify cycle (160/160, 240/240) reproduce the untruncated output bitwise, and warm against cold continuations match except at ties. A new register entry "targeted" covers them; state-targeted narrows to the remaining tests; and the H5 status row is updated.
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. |
|
Verdict: REQUEST CHANGES Reviewed head 7d2777f: one commit on a6a1850 that integrates #59 into Appendix D. Everything checks out except one claim, which goes further than the evidence. Checked and correct
BlockingB1. The five tap-changed prompts are "traced" to the prefix cache, but that link has not been confirmed (
Codex was still running when I posted. I'll check its comments with the fix. |
Address review B1 on #74. The stock reproduction shows the effect on other prompts. For the five tapped prompts there is only the attention signature and a code reading, and the KV-level confirmation is pending. The text now says "consistent with" and "a likely stock explanation".
|
B1 is fixed in a71fff9. The neutrality sentence now reads "the five exceptions are consistent with history dependence through the prefix cache, discussed below". The paragraph opens with "have a likely stock explanation" and adds that "the tapped prompts themselves show only the attention signature, and the mechanism is a code reading" before the 12-prompt stock reproduction. The pending KV-level confirmation sentence is unchanged. Build: 72 pages, 0 warnings, main text ends on page 10. |
# Conflicts: # paper/paper.pdf
|
Verdict: APPROVE Re-reviewed head a71fff9 (one commit on 7d2777f). B1 is fixed.
Merge note. #75 has merged (13368f4) and also changed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d2777fea3
ℹ️ 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}), 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}. So is an explanation of the five prompts whose output the tap itself changed: in each, the tapped run differs from output index 2 on, and the first differing module there is layer 3's attention output while its QKV projection and every earlier module agree, so the attention read different KV~\ev{state-tap}. The untested hypothesis is that inserting the prompt into the prefix cache repoints the running request's prefix KV to an equal-valued but not bitwise-equal copy computed in another request's prefill, and that the tap's per-forward synchronization changes whether decode step 2 reads the repointed copy. | ||
| \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} The five prompts whose output the tap itself changed have a stock explanation~\ev{state-tap,targeted}. In each, the tapped run differs from output index 2 on, and the first differing module there is layer 3's attention output while its QKV projection and every earlier module agree, so the attention read different 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 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); with the prefix cache off all 12 are bitwise identical. 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, and under overlap scheduling on timing. The values involved are valid, no case changed more than a near-tie decision, and it is not state corruption; the confirmation at the level of the cached KV is \pend{state-mech}. |
There was a problem hiding this comment.
Keep the five tap exceptions pending
The cited history experiment establishes that prefix-cache history can alter outputs, but it does not trace all five tap-induced exceptions to that mechanism: targeted.json reports differences for only two of the 12 history prompts, the cache-disabled control was run only for plain decoding, and the cached-KV comparison is explicitly still pending later in this paragraph. When explaining the five tapped prompts or the MTP case, this should remain a hypothesis until those prompts are individually reproduced or their entering KV is confirmed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a71fff9. The five prompts are now "consistent with history dependence through the prefix cache", with "a likely stock explanation". The text adds that the tapped prompts show only the attention signature and that the mechanism is a code reading. The KV-level confirmation stays pending (state-mech).
| \paragraph{What SGLang does, and how it is tested (H5)} During verification SGLang computes the recurrent state and the convolution window after every draft position into per-position buffers and leaves the live state untouched; after acceptance a fused scatter copies the buffers of the last accepted position (for a tree, the last accepted node) into the request's slot (code reading at the pin). The emitted prefix includes the bonus token while the materialized state does not; the bonus token is the first input of the next cycle. Prefix reuse checkpoints the recurrent state every 256 tokens of sequence length into a ping-pong pair of slots, including checkpoints that fall inside a verify cycle, and a freshly allocated slot is cleared by the next forward on the same stream, after any in-flight verification by its previous owner. The MTP draft layer is a full-attention layer, and under greedy verification every committed token is the target's argmax, so an error in draft-side state could lower acceptance but not change the output. | ||
|
|
||
| Each point where a speculative cycle touches this state is tested against a reference that isolates it. Truncation by \code{max\_new\_tokens} and stop tokens at every index inside a verify cycle must reproduce the untruncated run bitwise on the same server. Checkpoints taken during speculative decoding, including in the cycle that finished the request, are restored for a continuation and compared with a cold prefill of the same prefix. Requests aborted mid-stream with a recurrent pool of exactly four slots force the next request onto the freed slot while the aborted request's last verification may still be in flight. Chunked prefill at 200 and 256 tokens is compared with an unchunked prefill. And the log-probability drift of every MTP run against plain decoding is bucketed by the draft position that the previous cycle rejected. Small debug runs of each test passed their checks; the outcome of each full test is \pend{state-targeted}. | ||
| Each point where a speculative cycle touches this state is tested against a reference that isolates it. Truncation by \code{max\_new\_tokens} and stop tokens at every index inside a verify cycle must reproduce the untruncated run bitwise on the same server. Checkpoints taken during speculative decoding, including in the cycle that finished the request, are restored for a continuation and compared with a cold prefill of the same prefix. Requests aborted mid-stream with a recurrent pool of exactly four slots force the next request onto the freed slot while the aborted request's last verification may still be in flight. Chunked prefill at 200 and 256 tokens is compared with an unchunked prefill. And the log-probability drift of every MTP run against plain decoding is bucketed by the draft position that the previous cycle rejected. The first two tests are complete~\ev{targeted}, for MTP with three and five draft steps, top-$k$ 1, the prefix cache, overlap scheduler and CUDA graphs on, one request in flight and the first 40 prompts. Truncation leaves every truncated run bitwise equal to the untruncated run's prefix: 157 of 157 with three steps, keeping 1 to 4 tokens of the final cycle, and 240 of 240 with five steps, keeping 1 to 6. A stop token at every index of a verify cycle also reproduces the untruncated prefix bitwise, in 160 of 160 and 240 of 240 cases. In 120 and 200 of them the stop falls inside the draft block, so drafts after it were accepted and folded into the recurrent state before the stop was detected, and none of that state reaches the output. Extending each stopped conversation with a new user turn, served warm from the restored checkpoint and cold after a flush, gives identical continuations in 139 of 160 and 210 of 240 cases; the rest diverge at exact ties (19 and 30) or within one BF16 step (2), consistent with the warm path's different prefill computation and with the history dependence above. The same two tests for the tree and for plain decoding, checkpoint reuse, aborts with slot reuse, chunked prefill, run-to-run repeats and the drift by rejection position are \pend{state-targeted}. |
There was a problem hiding this comment.
Report token-prefix equality instead of bitwise equality
The targeted harness marks truncation and stop cases identical solely by comparing output_ids with the reference prefix (targeted.py lines 115 and 177); it does not compare log-probabilities, logits, or recurrent-state bits. Therefore these runs establish matching greedy token prefixes, not bitwise reproduction or that post-stop state had no observable numerical effect—a state/logit difference that preserves the argmax would pass every reported case. Either narrow these claims to token equality or add a bitwise state/logit comparison.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 64880c6 and 9a69a75. targeted.py compares output_ids only, so the truncation and stop results are now "token-identical" to the untruncated prefix. The text says log-probabilities and state are not compared, and "none of it changed an output token" replaces the state claim. The H5 register row has the same wording. The history control is scoped to "plain decoding with the prefix cache off" and to "identical in tokens and log-probabilities", which is what that test compares.
|
Verdict: APPROVE Approving head ad8c346. It merges main at 13368f4 (#75) into the approved a71fff9.
|
|
Verdict: REQUEST CHANGES I am withdrawing my approval of ad8c346. Codex's second P2 on 7d2777f still applies, and I missed it. Codex was still running when I first reviewed, and I approved a71fff9 and ad8c346 without going back to its comments. B2. The H5 tests compare tokens, not bits (
B3. The prefix-cache-off control ran for plain decoding only (
Codex's first P2 (keeping the five tap exceptions pending) was addressed in a71fff9. The same token-only wording is in the merged state README (#59), which I also approved without catching it. The state workstream is fixing it in a separate PR. |
Address the Codex review of #74. targeted.py compares only output token IDs with the reference prefix, not log-probabilities or state, so the results are now token-identical, not bitwise; the same goes for the H5 status row. The prefix-cache-off history result is stated as identical in tokens and log-probabilities, which is what that test compares.
Address review B3 on #74: only plain decoding ran with the prefix cache off (history__plain_noradix).
The deterministic-mode run predates the patch's environment switch, which is off by default, and had the change on (state README).
|
Verdict: APPROVE Approving head c94128e (64880c6, 9a69a75 and c94128e on ad8c346).
Nit (not blocking). "gives identical continuations in 139 of 160" compares tokens too. "Token-identical" would match the state README's wording. |
Integrates the state-safety results merged in #59 into Appendix D, the status table and the evidence register. The main text is unchanged.
What the appendix now says
evidence/state_safety/first_difference_by_module.csvthrough pgfplots (\datafigure) instead of typed counts. The counts and the layout are unchanged: 167 at layer 0's GDN recurrence; gated RMSNorm in 13 GDN layers; 6 at layer 3's attention; 5 at layer 0's MLP in a batched prefill.noise_floor.csv):targeted.json). This replaces the untested hypothesis about the five prompts the tap changed. It gives the code path at the pin: after prefill the request's KV is repointed to the tree's copy, which is equal in value but not bitwise. The deterministic stock reproduction: with the cache on, plain and MTP s3 keep every token but change log-probabilities for 2 of 12 prompts (from output index 2, and 5); for plain decoding with the cache off all 12 are identical in tokens and log-probabilities. KV-level confirmation stays pending (state-mech).targeted;state-mechnow listsfirst_difference_by_module.csvandanalyze_all.sh.state-targetednarrows to the remaining tests.Every number was checked against
targeted.json,noise_floor.csvand the state README.Validation
latexmk -pdfbuilds 72 pages with no LaTeX or BibTeX warnings. The main text ends on page 10. The rebuiltpaper.pdfis committed, and I compared the redrawn Figure 5 with the previous one and looked at the changed pages.python scripts/check_paper_references.pypasses: no uncited or missing keys, and every register path exists on origin/main.paper/; there are no other changed files.