Skip to content

Appendices: scope seeded truncated sampling to the pinned sampler; trim run chronology and the pending list - #130

Merged
SamMausberg merged 13 commits into
mainfrom
paper/appendix-trim
Oct 1, 2026
Merged

SamMausberg merged 13 commits into
mainfrom
paper/appendix-trim

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Based on main after #129 merged (2f1b274). Two appendix fixes from an outside read of the paper, both checked by the integrator, plus a length-neutral main-text scope for Codex's P1 (2962631). The rebase onto main resolved one conflict, in the pending list: #129's backbone-served entry is kept, shortened to one line like the others.

1. Seeded truncated sampling (App B, App D tables)

At the pin bd66ce34, top_k_top_p_min_p_sampling_from_probs_torch (python/sglang/srt/layers/sampler.py, lines 746-800) does three things in order:

  1. It sorts the probabilities.
  2. With a seed, it calls multinomial_with_seed on the sorted row. That function hashes each column by its index in that row (col_indices = torch.arange(m), lines 899-902).
  3. It maps the winner back through probs_idx.

So a token's Gumbel noise depends on its rank, not its id. The function also refuses min-p with a seed (assert, line 776). The full-vocabulary seeded path (_sample_from_logprobs, lines 594-611, and the untruncated seeded path) keys by token index.

The old text said top-k needs only membership plus the tie semantics at the k-th position. That is too weak for seeded equality with the stock sampler. Changes:

  • App B, "Truncated sampling" (new label app:truncated).
    • With token-keyed noise, the certified top-k race gives equality in law with top-k sampling. Once the engine's tie semantics at the k-th position are matched, it also gives pathwise equality with a token-keyed dense race over the same set.
    • It does not give seeded equality with the pinned sampler's truncated path. That needs the complete order within the certified set, meaning strictly separated enclosures of the FP32 probabilities the sampler sorts for every pair whose ranks could differ, plus torch.sort's order on equal probabilities.
    • Min-p with a seed is refused.
    • The full-vocabulary seeded path keys by token index, and that is what the certified race of Section 5 covers.
    • The paragraph's last sentence is scoped to a dense race keyed the same way.
  • Consumer table (App D.3). "Exact top-k" now needs the order within the set. The seeded rows are split into the full-vocabulary token-keyed race and the stock seeded top-k/top-p path (rank-keyed; analysis only).
  • Engine code-path table (App D.6). The sampler row says that the token-keyed field applies to full-vocabulary seeded sampling, and that the truncated path keys by sorted position and refuses seeded min-p.
  • Citation. New source sglangsampler: a permalink to the pinned file, lines 746-800. It is added to paper/references.bib, sources/references_full.bib, sources/source_manifest.json (count 224) and a sources/citation_audit.md row recording the lines read.

The main text is not changed. Flagged to main for the author: contract.tex:83 says seeded noise is keyed by (seed, absolute position, token), which holds only without top-k/top-p.

2. Less run chronology; findings first; a short pending list

  • D.4 opens with one sentence per established finding, each with its register entry. The findings: the tie rule and the head GEMM cause no divergence; plain vs MTP part inside layer 0's recurrence from identical inputs and state; the concurrency pair parts at batch-dependent kernels; MTP vs plain runs at 3.5-4.0 per 1,000 with identical pools, always at a tie or within two BF16 spacings; and history dependence through the prefix cache.
  • P4 (E.5). The declared served test is stated once: arms, metric, decision rule, output probe and void rule. The two void attempts become one sentence: at most 127 of 128 admitted, and the amendments declared after each (655,360-token pool, 132 pinned slots, admission preflight). The causes then judged likely are dropped. The prompt-check correction after the first run stays, as a disclosed deviation from the declaration.
  • Smaller cuts:
    • the deterministic patch's switch history;
    • "these runs predate pinned pools" (rephrased as a scope);
    • the ordering candidate, shortened and still labelled untested;
    • "which failed at launch" on the pending kernel trace;
    • the one-step chain's "was not rerun";
    • "declared while the first confirmation session was running" (now "declared before any arm was timed on it").
  • G.3 pending results. Every entry is one line, with its evidence path in parentheses, and the list fits on one page. What each result decides stays beside its marker in the text. The detail of the remaining pinned pairs now lives once, in D.4's "Open questions", which D11 points to.

No result or pending marker is removed, and D numbering is unchanged. The only numbers dropped are details of the void P4 attempts: the first run's 360,448-token pool and the second's 40% cache use.

Checks

  • latexmk -pdf: 0 warnings, 79 pages (81 on main), main text ends on p10, References on p11.
  • scripts/check_paper_references.py: clean, including the new bib entry against the full bib and the manifest.
  • I read the changed pages (App B, D.3, D.4, E.5, G.2-G.3).
  • The host-identity hook passes.

@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-01T15:31:13.442323Z 31810b8 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: 252e525c7f

ℹ️ 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_sampling.tex Outdated
Two further conditions complete the random-number contract of Section~\ref{sec:decisions}. Equality in distribution, as opposed to seeded equality, needs i.i.d.\ noise with the correct marginal that is independent of the proposal draw, the acceptance uniform and the scores; a residual race (Appendix~\ref{app:residual}) also needs independence from the acceptance event. And a hash with $2^{32}$ levels makes the law exact only for the idealized continuous field; the stock seeded sampler shares that approximation.

\paragraph{Truncated sampling} The Gumbel-max identity has a top-$k$ form that samples $k$ tokens without replacement~\cite{kool2019}. Top-$k$ sampling applies the ladder to membership (drop $i$ when $hi_i$ is below the $k$-th largest $lo$) and races over the certified set; equality then also needs the engine's tie semantics at the $k$-th position. Min-$p$ admits $i$ when $z_i\ge z_{\max}+T\log(\text{min-}p)$, which intervals decide without a partition function. Top-$p$ admission depends on the mass above each token relative to the partition function $Z$, so it needs partition bounds and is usually cheaper to hand to the ordinary path. Fused samplers take the other route and make the dense path cheap: FlashInfer samples top-$k$, top-$p$ and min-$p$ without sorting and implements chain speculative sampling~\cite{flashinfer,flashinfersamplingblog}, and SonicSampler fuses the post-logit sampling and verification kernels over a bounded top-128 pool and describes top-$p$ under that pool as theoretically lossy~\cite{sonic}. The closest precedent for sampling from bounded scores, Mussmann, Levy and Ermon's lazy Gumbel sampling, draws noise only for a retrieved top set and, with an approximate top set, widens the cutoff by the approximation error~\cite{mussmann2017,mussmann2016}; the certified race differs in bounding every row with a dense cheap pass and in keying the noise by token, which gives pathwise equality with the dense race.
\paragraph{Truncated sampling}\label{app:truncated} The Gumbel-max identity has a top-$k$ form that samples $k$ tokens without replacement~\cite{kool2019}. Top-$k$ sampling applies the ladder to membership (drop $i$ when $hi_i$ is below the $k$-th largest $lo$) and races over the certified set. With noise keyed by token, as in the full-vocabulary race, this gives equality in distribution with top-$k$ sampling from the reference scores and, once the engine's tie semantics at the $k$-th position are matched, pathwise equality with a token-keyed dense race over the same set. It does not give seeded equality with SGLang's sampler at the pin. That sampler's seeded top-$k$, top-$p$ and min-$p$ path sorts the probabilities, keys each token's Gumbel noise by the token's position in the sorted row rather than by its index, and maps the winner back to a token through the sort's permutation, so the noise a token receives depends on its rank~\cite{sglangsampler}. Seeded equality with that path therefore needs, beyond membership, the complete order within the certified set: enclosures of the FP32 probabilities the sampler sorts that are strictly separated for every pair of members whose ranks could otherwise differ, and \code{torch.sort}'s order where probabilities are equal. The pinned sampler also refuses min-$p$ with a seed. Its full-vocabulary seeded path keys the noise by token index, and that is the case the certified race of Section~\ref{sec:decisions} covers. Min-$p$ admits $i$ when $z_i\ge z_{\max}+T\log(\text{min-}p)$, which intervals decide without a partition function. Top-$p$ admission depends on the mass above each token relative to the partition function $Z$, so it needs partition bounds and is usually cheaper to hand to the ordinary path. Fused samplers take the other route and make the dense path cheap: FlashInfer samples top-$k$, top-$p$ and min-$p$ without sorting and implements chain speculative sampling~\cite{flashinfer,flashinfersamplingblog}, and SonicSampler fuses the post-logit sampling and verification kernels over a bounded top-128 pool and describes top-$p$ under that pool as theoretically lossy~\cite{sonic}. The closest precedent for sampling from bounded scores, Mussmann, Levy and Ermon's lazy Gumbel sampling, draws noise only for a retrieved top set and, with an approximate top set, widens the cutoff by the approximation error~\cite{mussmann2017,mussmann2016}; the certified race differs in bounding every row with a dense cheap pass and in keying the noise by token, which gives pathwise equality with a dense race keyed the same way, not with the stock sampler's rank-keyed truncated path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scope the main seeded-sampler contract too

For any fixed-seed request with top-k or top-p enabled, this paragraph now correctly establishes that the stock sampler is rank-keyed, but the central contract still says the stock noise is token-keyed and that every certified token equals the stock seeded token (paper/sections/contract.tex:13,83 and paper/sections/head.tex:36-41). Consequently, the paper still promises seeded/pathwise equality for a common truncated-sampling configuration that its own appendix shows the current certified race cannot reproduce. Restrict those main claims to full-vocabulary sampling or carry the rank-order certification into the stated contract.

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 6aaf11a (head c62fb5e). The main-text seeded-sampler contract is now scoped to untruncated sampling in all three places: Section 2.1 ("Without top-k or top-p the seeded sampler is already a race"), the sampling row of the assumptions table ("Untruncated seeded noise is a function of (seed, absolute position, token)"), and Section 4's fixed-noise paragraph ("with a seed and no truncation every committed token is the stock seeded sampler's token"). Appendix B, Truncated sampling, gives the rank-keyed truncated path and what seeded equality with it would need. The edit is length-neutral: the main text still ends on p10 with References on p11.

SamMausberg added a commit that referenced this pull request Oct 1, 2026
Codex P1 on #130: Section 2.1, the sampling row of the assumptions table
and Section 4's fixed-noise paragraph state that stock seeded noise is
token-keyed and that certified tokens equal the stock seeded sampler's.
At the pin that holds only without top-k or top-p, which key the stock
noise by sorted rank (Appendix B, Truncated sampling). Three scope phrases,
no other change; the main text still ends on p10 with References on p11.
@SamMausberg
SamMausberg changed the base branch from paper/appendix-v4cache to main October 1, 2026 14:59
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: c62fb5ec6a

ℹ️ 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 added a commit that referenced this pull request Oct 1, 2026
Codex P1 on #130: Section 2.1, the sampling row of the assumptions table
and Section 4's fixed-noise paragraph state that stock seeded noise is
token-keyed and that certified tokens equal the stock seeded sampler's.
At the pin that holds only without top-k or top-p, which key the stock
noise by sorted rank (Appendix B, Truncated sampling). Three scope phrases,
no other change; the main text still ends on p10 with References on p11.
@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: 77e3203ade

ℹ️ 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".

"urls": [
"https://github.com/sgl-project/sglang/blob/bd66ce343e4f6e2f2b75d7e820fe4d0718a8d824/python/sglang/srt/layers/sampler.py#L746-L800"
],
"accessed": "2026-10-01",

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 Advance the audit date for the new source

This source is recorded as accessed and verified on 2026-10-01, but the manifest's top-level audit_date and the audit declaration in sources/citation_audit.md still say 2026-09-30. Consequently, consumers relying on the declared audit cutoff cannot tell that the newly cited sampler source is covered by the audit; update both audit dates when adding this row.

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 a987427. The manifest's audit_date is now 2026-10-01, and its scope says that sglangsampler was added on 1 October 2026 after reading the pinned file. sources/citation_audit.md keeps its original 30 September date for the 34 audited entries and its header now names the one later entry checked on 1 October. The paper and its PDF are unaffected.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 77e3203: Codex is still running on this head. I will confirm or withdraw once it finishes.)

Review of the exact head 77e3203, rebased on main after #129: 1f816bc (sampling scope), a6f8b2d (trim and G.3), 2962631 (main-text scope) and the PDFs.

  • The sampler facts are right at the pin bd66ce343e (python/sglang/srt/layers/sampler.py).

    • top_k_top_p_min_p_sampling_from_probs_torch sorts the probabilities. With a seed it calls multinomial_with_seed on the sorted row, whose noise hashes col_indices = torch.arange(m) (L899-902), so the noise is keyed by rank. It maps the winner back through probs_idx.
    • It asserts on min-p with a seed (L776).
    • _sample_from_logprobs (L594-611) keys by token index on the full vocabulary.

    The App B text (equality in law, pathwise equality only with a token-keyed dense race, and seeded equality with the stock truncated path needing the full order within the set plus torch.sort's tie order) follows from that. So do the split D.3 rows and the scoped D.6 row.

  • The main-text edit (Codex P1 on 252e525, answered) is accurate and length-neutral. The three phrases scope the contract to untruncated seeded sampling ("Without top-k or top-p", "Untruncated seeded noise", "with a seed and no truncation"). The main text still ends on p10, and References start on p11.

  • The trim removes no result or marker.

    • Over paper/sections, the set of \ev/\pend/\evitem/\devitem keys is unchanged (205 distinct), and \pend uses stay at 97 (\ev uses rise from 232 to 238, from the findings-first D.4).
    • The deleted text is run chronology and the void-attempt explanations then judged likely, which Moonshot P4b: explain the 127-request plateau; amend to a running limit of 129 #123 has since shown were wrong.
    • The rewritten P4 paragraph keeps the full declared design: arms, metric, decision rule, output probe and void rule, plus the disclosed prompt-check correction.
  • Citation. sglangsampler is consistent across both bibs, the manifest and citation_audit.md, and check_paper_references.py is clean.

  • Rebuild in place. latexmk -g on one core finished with 0 warnings, wrote 79 pages, and its text is identical to the committed PDF. The committed PDF is restored.

Note. P4's third void attempt and its explanation (#123) are not on main yet. When #123 merges, "Two attempts have been void" needs the same update.

SamMausberg added a commit that referenced this pull request Oct 1, 2026
Codex P2 on #130: the manifest's audit_date and the citation audit's
declared date still said 30 September while sglangsampler was read and
added on 1 October. The manifest's audit_date is now 2026-10-01 and its
scope names the addition; the audit's header keeps its original date and
names the one later entry.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on a987427: Codex is still running on this head. I will confirm or withdraw once it finishes.)

a987427 changes only sources/source_manifest.json (audit_date 2026-10-01, with the scope naming sglangsampler's addition) and sources/citation_audit.md (the 30 September audit date kept, with the one later entry named), for the Codex P2 on 77e3203. No paper file changed, so my rebuild check of 77e3203 stands. check_paper_references.py is clean, and pre-commit passes on both files.

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

SamMausberg added a commit that referenced this pull request Oct 1, 2026
Codex P1 on #130: Section 2.1, the sampling row of the assumptions table
and Section 4's fixed-noise paragraph state that stock seeded noise is
token-keyed and that certified tokens equal the stock seeded sampler's.
At the pin that holds only without top-k or top-p, which key the stock
noise by sorted rank (Appendix B, Truncated sampling). Three scope phrases,
no other change; the main text still ends on p10 with References on p11.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Codex P2 on #130: the manifest's audit_date and the citation audit's
declared date still said 30 September while sglangsampler was read and
added on 1 October. The manifest's audit_date is now 2026-10-01 and its
scope names the addition; the audit's header keeps its original date and
names the one later entry.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 2b71cd6: Codex is still running on this head. I will confirm or withdraw once it finishes.)

Re-review after the rebase onto main (after #132, #123 and #128).

Everything else stands from my reviews of 77e3203 and a987427.

@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: 2b71cd6c46

ℹ️ 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
\path{srt/models/qwen3_5_text.py} & The Qwen3.5 head is tied to \code{embed\_tokens}, which is not a \code{ParallelLMHead}, so SGLang's quantized-head paths do not apply; a low-precision copy must be separate, and the BF16 head stays resident for re-scoring and fallback.\\
\path{srt/models/qwen3_5_mtp.py} & \code{set\_embed\_and\_head} skips the head when embeddings are tied, so a reduced draft head from \code{-{}-speculative-token-map} does not reach the MTP drafter while indices are still remapped (Appendix~\ref{app:levers}).\\
\path{srt/layers/sampler.py} & Unseeded sampling is an exponential race; seeded sampling is a Gumbel race keyed by (seed, position, token) in FP64 (\code{multinomial\_with\_seed}). The certified race uses the same field.\\
\path{srt/layers/sampler.py} & Unseeded sampling is an exponential race; seeded sampling over the full vocabulary is a Gumbel race keyed by (seed, position, token) in FP64 (\code{multinomial\_with\_seed}), and the certified race uses the same field. The seeded top-$k$, top-$p$ and min-$p$ path keys the same hash by position in the sorted probabilities instead, and refuses min-$p$ with a seed~\cite{sglangsampler}.\\

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 Exclude min-p from the rank-keyed seeded path

When a request combines a seed with min-p, the pinned sampler asserts before sampling, so there is no seeded min-p path that keys noise by sorted position. Listing min-p alongside seeded top-k and top-p both misstates the engine behavior and contradicts the end of this same sentence; retain the refusal but restrict the rank-keyed-path claim to top-k/top-p.

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 fe34665 (head 919613d). The rank-keyed seeded path is now top-k and top-p only, in both App B and the code-path table. The refusal of min-p with a seed is kept as its own statement.

Comment thread paper/sections/app_stack.tex Outdated
The second question has a better answer. A decoder that keeps a dense anchor and the recent actual FP32 operands of each step, and replays them in the reference kernel's order, reproduces every state word bit for bit by induction, while reading the dense state once per step and writing it once every $m$ steps. That reduces information movement, not information, and it is what replay-based rollback already does~\cite{replayssm,gdncode}. The paragraphs below treat it as a lever with a pre-registered test (P4), and the opposite idea, sharing exact computation across requests (P5).

\paragraph{Writing the recurrent state less often (P4, hypothesis)} Rounding-preserving live replay is exact and cuts dense-state traffic per step from $2D$ (read and write) to $D+D/m$ when the state is flushed every $m$ steps, 0.625 of the original at $m=4$, for a few percent more storage (derived). If the recurrent kernel is a fraction $f$ of a decode step, a kernel twice as fast gives at most $1/(1-f/2)$, removing it entirely $1/(1-f)$, and the $m=4$ traffic cut alone $1/(1-0.375f)$. The measured share at $B=128$ and a 418-token mean context is $f=0.416$ (Table~\ref{tab:profile-plain}), which gives $1.26\times$, $1.71\times$ and $1.18\times$ (derived from a measured share). The pre-registered test has two parts. A kernel check compares every state word and GDN output of the replayed and dense paths, one layer at a time, and one differing word rejects bit-exactness (below). The served timing decodes 512 tokens greedily at batch 128 from 2,048-token prompts with FP32 state and no speculation, with the threshold at $1.10\times$; through the server only the output probe below checks exactness. The served timing's design, metric and decision rule were declared before its first run~\ev{p4-declared}. Dense decoding and replay at $m=4$ run as four server pairs in the order A B B A A B B A with identical memory pools, and the primary metric, amended before the run started, is the server's decode rate at exactly 128 running requests in the measured phase. The scheduler logs one generation throughput per 40 decode passes; a window counts when it shows 128 running requests, the previous decode line also shows 128, no prefill batch lies between the two (a window containing a prefill pass mixes prefill time into its rate), and both lines fall inside the AIPerf profiling phase (first request start to last request end), which excludes the AIPerf warm-up wave and the ramp and drain. Windows carry equal token counts (128 per pass, no speculation), so the rate is the harmonic mean of the window rates; fewer than 8 such windows in any arm voids the run. The metric measures decode only, which is what the lever changes; client throughput, which includes the 2,048-token prefills, is reported beside it. The four log ratios give a 95\% $t$ interval, and the claim is rejected if its upper end is below $1.10$, supported if its lower end reaches $1.10$, and inconclusive otherwise; a supported result is a served decode throughput at 128 running requests, not an end-to-end speedup. A server output probe compares greedy tokens and top-20 log-probabilities at concurrency 1 with dense decoding: a difference refutes end-to-end exactness, and a pass does not establish it; a second dense server is the noise control, and if it differs too the probe is undecided. The verdict states both results, and if the probe refutes exactness, P4's exact claim is not supported whatever the throughput interval. A run that fails its completeness, workload, pool, environment or provenance checks is void and repeated, and its numbers are not reported. One of those checks was corrected after the first run and before its verdict was computed or looked at: the check of the sent prompts compared the benchmark's request ids, which differ from the declared ones for this workload even when the right texts are sent, and it now compares the prompt texts' hashes exactly, a check no weaker than the declared one; the first run failed the old check in all eight arms and passes the corrected one. That run is void all the same: in every arm at most 127 requests were admitted, so the validator stopped before any ratio was computed and no verdict exists; the cause then judged likely was SGLang's admission budget, which reserves each request's full 512 output tokens. A rerun was declared before it started, with a pinned attention cache of 655,360 tokens in both arms instead of 360,448, a required admission preflight that stops the job unless 128 requests run in the measured phase, the one-layer kernel steps reused from the first run because they cannot depend on a server's pools, and the output probe and the paired timing run again. That second attempt was void at its preflight: both arms again peaked at 127 running requests, with the attention cache at 40\% use, so the cache was not the limit. Likely, from the log, the recurrent-state slots were: the 128th request stayed queued with 127 slots in use and the free slot not schedulable, while prompts were admitted five at a time under chunked prefill. Before any further run, both arms were amended to pin 132 recurrent-state slots, four of headroom, with the other pools unchanged, and the preflight now runs on its own before the full job is queued. No result of either attempt is reported. SGLang's own replay path qualifies only if it passes the bit-exactness check. The replay kernel is committed as an engine patch with a one-layer test that compares every output and state word against the stock decode kernel (\code{tests/test\_gdn\_exact\_replay.py}~\ev{moonshot-patches}).
\paragraph{Writing the recurrent state less often (P4, hypothesis)} Rounding-preserving live replay is exact and cuts dense-state traffic per step from $2D$ (read and write) to $D+D/m$ when the state is flushed every $m$ steps, 0.625 of the original at $m=4$, for a few percent more storage (derived). If the recurrent kernel is a fraction $f$ of a decode step, a kernel twice as fast gives at most $1/(1-f/2)$, removing it entirely $1/(1-f)$, and the $m=4$ traffic cut alone $1/(1-0.375f)$. The measured share at $B=128$ and a 418-token mean context is $f=0.416$ (Table~\ref{tab:profile-plain}), which gives $1.26\times$, $1.71\times$ and $1.18\times$ (derived from a measured share). The pre-registered test has two parts. A kernel check compares every state word and GDN output of the replayed and dense paths, one layer at a time, and one differing word rejects bit-exactness (below). The served timing decodes 512 tokens greedily at batch 128 from 2,048-token prompts with FP32 state and no speculation, with the threshold at $1.10\times$; through the server only the output probe below checks exactness. The served timing's design, metric and decision rule were declared before its first run, and every later change before the run it governs~\ev{p4-declared}. Dense decoding and replay at $m=4$ run as four server pairs in the order A B B A A B B A with identical memory pools. The primary metric is the server's decode rate at exactly 128 running requests: the harmonic mean of the scheduler's generation-throughput windows (one per 40 decode passes) that show 128 running requests on that line and the previous one, with no prefill batch between them, inside the AIPerf profiling phase, which excludes warm-up, ramp and drain; fewer than 8 such windows in any arm voids the run. It measures decode only, which is what the lever changes, and client throughput, which includes the 2,048-token prefills, is reported beside it. The four log ratios give a 95\% $t$ interval, and the claim is rejected if its upper end is below $1.10$, supported if its lower end reaches $1.10$, and inconclusive otherwise; a supported result is a served decode throughput at 128 running requests, not an end-to-end speedup. A server output probe compares greedy tokens and top-20 log-probabilities at concurrency 1 with dense decoding, with a second dense server as the noise control: a difference refutes end-to-end exactness, a pass does not establish it, and a refuted probe leaves P4's exact claim unsupported whatever the throughput interval. A run that fails its completeness, workload, pool, environment or provenance checks is void and its numbers are not reported. One check was corrected after the first run and before any verdict was computed: the sent prompts are now matched by the hashes of their texts, because the benchmark's request ids differ from the declared ones for this workload, a check no weaker than the declared one. Two attempts have been void, because in every arm at most 127 of the 128 requests were admitted; the amendments declared after each, a pinned attention cache of 655,360 tokens, 132 pinned recurrent-state slots and an admission preflight that must show 128 running requests, are recorded with the declaration. No served result exists. SGLang's own replay path qualifies only if it passes the bit-exactness check. The replay kernel is committed as an engine patch with a one-layer test that compares every output and state word against the stock decode kernel (\code{tests/test\_gdn\_exact\_replay.py}~\ev{moonshot-patches}).

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 Restore the noise-control outcome

When the replay-vs-dense probe differs and the second dense server also differs, the control shows that the probe cannot attribute the difference to replay. The prior decision rule explicitly classified this case as undecided, but the shortened text now says that a difference refutes exactness without specifying how the control changes that verdict, allowing ordinary dense-server noise to reject P4; preserve the undecided outcome for a differing control.

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 fe34665 (head 919613d). The declared undecided case is restored. A difference refutes end-to-end exactness unless the second dense server also differs from the first, in which case the probe is undecided. A pass does not establish exactness.

Comment thread sources/citation_audit.md Outdated
# Citation audit of `paper/paper.tex`

Audit date: 30 September 2026. Scope: all 34 `\bibitem` entries in `paper/paper.tex`
Audit date: 30 September 2026; one later entry (`sglangsampler`) was added and checked on 1 October 2026. Scope: all 34 `\bibitem` entries in `paper/paper.tex`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Update the audit scope to 35 entries

Adding sglangsampler increases the audit table from 34 to 35 source rows, but the scope declaration still claims that all 34 entries are covered. Readers using this declaration to determine audit completeness now receive a stale count; update it alongside the newly added entry.

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 fe34665 (head 919613d). The scope now reads: the 34 \bibitem entries of the original paper/paper.tex, plus the later entry, 35 rows in all.

SamMausberg added a commit that referenced this pull request Oct 1, 2026
…ded case; audit row count

Codex on #130 (2b71cd6):
- P2: the pinned sampler refuses seeded min-p, so the rank-keyed seeded
  path is top-k/top-p only (App B and the code-path table).
- P2: the trimmed P4 paragraph dropped the declared undecided outcome of
  the output probe; a difference refutes exactness unless the second dense
  server also differs, in which case the probe is undecided.
- P3: the citation audit covers 35 rows (the 34 original entries plus
  sglangsampler).
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 919613d: Codex is still running on this head. I will confirm or withdraw once it finishes.)

fe34665 fixes Codex's three comments on 2b71cd6, and each has a reply:

  • Sampler scope. The rank-keyed seeded path is now scoped to top-k and top-p in App B and D.6, and seeded min-p is stated separately as refused (the assert at sampler.py L776). This matches the pinned code.
  • P4 output probe. The undecided case is restored: "a difference refutes end-to-end exactness unless the control also differs from the first dense server, in which case the probe is undecided". That is the declared rule.
  • Citation audit. citation_audit.md counts "35 rows in all".

Rebuild in place at 919613d: latexmk -g on one core finished with 0 warnings, wrote 79 pages, and its text is identical to the committed PDF. References start on p11, and check_paper_references.py is clean.

@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: 919613de6f

ℹ️ 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/contract.tex Outdated

\subsection{What the Engine Computes}\label{sec:stock}
Qwen3.5-4B ties its output head to its input embedding: $W\in\BF^{V\times D}$ with $V=248{,}320$ and $D=2{,}560$, where $\BF$ denotes the BF16 numbers. At the pinned commit SGLang computes the head as \code{torch.matmul} of the BF16 head inputs with $W^\top$, a cuBLAS GEMM that accumulates in FP32, rounds each output to BF16 and chooses its kernel by the batch shape $M$. The logits are widened exactly to FP32, and greedy decoding and greedy verification take \code{torch.argmax}, which returns the smallest maximal index. BF16 keeps eight significant bits, so logits in $[16,32)$ are $0.125$ apart, and two real logits closer than about one spacing can round to the same value, leaving the index to decide. The seeded sampler is already a race: after an FP32 softmax and logarithm it returns $\argmax_i(\log p_i+G_i)$ in FP64, with Gumbel noise $G_i$ computed from a 32-bit hash of (seed, position, token), a \emph{counter-keyed field} that can be recomputed for any token in any order. It exists only with \code{-{}-enable-deterministic-inference}, whose batch-invariant \code{mm} runs, at the pin's defaults on this GPU, DeepGEMM's deterministic BF16 GEMM (one FP32 \code{wgmma} accumulator, no split-$K$, round-to-nearest output); with a seed the stock head is that kernel. Table~\ref{tab:terms} fixes the terms used below.
Qwen3.5-4B ties its output head to its input embedding: $W\in\BF^{V\times D}$ with $V=248{,}320$ and $D=2{,}560$, where $\BF$ denotes the BF16 numbers. At the pinned commit SGLang computes the head as \code{torch.matmul} of the BF16 head inputs with $W^\top$, a cuBLAS GEMM that accumulates in FP32, rounds each output to BF16 and chooses its kernel by the batch shape $M$. The logits are widened exactly to FP32, and greedy decoding and greedy verification take \code{torch.argmax}, which returns the smallest maximal index. BF16 keeps eight significant bits, so logits in $[16,32)$ are $0.125$ apart, and two real logits closer than about one spacing can round to the same value, leaving the index to decide. Without top-$k$ or top-$p$ the seeded sampler is already a race: after an FP32 softmax and logarithm it returns $\argmax_i(\log p_i+G_i)$ in FP64, with Gumbel noise $G_i$ computed from a 32-bit hash of (seed, position, token), a \emph{counter-keyed field} that can be recomputed for any token in any order. It exists only with \code{-{}-enable-deterministic-inference}, whose batch-invariant \code{mm} runs, at the pin's defaults on this GPU, DeepGEMM's deterministic BF16 GEMM (one FP32 \code{wgmma} accumulator, no split-$K$, round-to-nearest output); with a seed the stock head is that kernel. Table~\ref{tab:terms} fixes the terms used below.

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 Exclude min-p from the seeded-race condition

When a request enables min-p with a seed but leaves top-k and top-p disabled, this condition still claims that the stock sampler runs the token-keyed race, even though the pinned sampler rejects seeded min-p, as the newly added Appendix B text states. Describe this as the fully untruncated path, or explicitly exclude min-p too, so the main engine contract does not promise behavior for a configuration that asserts before sampling.

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 bf4ae34 (head 652c62e). Section 2.1 now reads "With no top-k, top-p or min-p the seeded sampler is already a race". The assumptions-table row ("Untruncated seeded noise") and Section 4 ("with a seed and no truncation") use the same scope. The main text still ends on p10, with References on p11.

SamMausberg added a commit that referenced this pull request Oct 1, 2026
Codex P2 on #130 (919613d): the pinned sampler refuses a seed with min-p,
so Section 2.1's condition now reads "with no top-k, top-p or min-p";
the table row's "untruncated" and Section 4's "no truncation" follow it.
Main text still ends on p10.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

SamMausberg added a commit that referenced this pull request Oct 1, 2026
…pler

At the pin, SGLang's seeded top-k/top-p/min-p path sorts the
probabilities and keys each token's Gumbel noise by its position in the
sorted row (multinomial_with_seed hashes arange(m) over that row), then
maps back through the sort's permutation; min-p with a seed is refused.
Membership and the k-th tie are therefore not enough for seeded equality
with the stock truncated sampler: it also needs the complete order within
the certified set and torch.sort's order on ties. The token-keyed race
gives equality in distribution and pathwise equality with a token-keyed
dense race, which is what the full-vocabulary seeded path uses.

Rewrites App B's truncated-sampling paragraph, splits the consumer table's
seeded rows (full vocabulary vs stock top-k/top-p), and scopes the sampler
row of the engine code-path table. Cites the pinned sampler.py (new source
sglangsampler, added to the paper bib, the full bib, the manifest and the
citation audit).
…per pending entry

- D.4 opens with the established findings, each with its register entry.
- P4 (E.5): the declared served test in one pass; the two void attempts
  and the amendments declared after them in two sentences, without the
  causes then judged likely; the post-run prompt-check correction kept as
  a disclosed deviation.
- Smaller cuts of how runs unfolded: the deterministic-mode patch switch,
  the pre-pinning remark, the ordering candidate, the failed kernel-trace
  launch, the one-step chain and the sensitivity workload's timing.
- G.3: every pending entry on one line with its evidence path; what each
  result decides stays beside its marker in the text.
Codex P1 on #130: Section 2.1, the sampling row of the assumptions table
and Section 4's fixed-noise paragraph state that stock seeded noise is
token-keyed and that certified tokens equal the stock seeded sampler's.
At the pin that holds only without top-k or top-p, which key the stock
noise by sorted rank (Appendix B, Truncated sampling). Three scope phrases,
no other change; the main text still ends on p10 with References on p11.
Codex P2 on #130: the manifest's audit_date and the citation audit's
declared date still said 30 September while sglangsampler was read and
added on 1 October. The manifest's audit_date is now 2026-10-01 and its
scope names the addition; the audit's header keeps its original date and
names the one later entry.
…ded case; audit row count

Codex on #130 (2b71cd6):
- P2: the pinned sampler refuses seeded min-p, so the rank-keyed seeded
  path is top-k/top-p only (App B and the code-path table).
- P2: the trimmed P4 paragraph dropped the declared undecided outcome of
  the output probe; a difference refutes exactness unless the second dense
  server also differs, in which case the probe is undecided.
- P3: the citation audit covers 35 rows (the 34 original entries plus
  sglangsampler).
Codex P2 on #130 (919613d): the pinned sampler refuses a seed with min-p,
so Section 2.1's condition now reads "with no top-k, top-p or min-p";
the table row's "untruncated" and Section 4's "no truncation" follow it.
Main text still ends on p10.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 652c62e: Codex is still running on this head. I will confirm or withdraw once it finishes.)

bf4ae34 fixes the Codex P2 on 919613d, and the thread has a reply. Section 2.1 now reads "With no top-k, top-p or min-p the seeded sampler is already a race", which matches the pinned sampler (seeded min-p is refused at sampler.py L776).

Rebuild in place: latexmk -g on one core finished with 0 warnings, wrote 79 pages, and its text is identical to the committed PDF. The main text still ends on p10, with References starting on p11.

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

SamMausberg added a commit that referenced this pull request Oct 1, 2026
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 31810b8: Codex is still running on this head. I will confirm or withdraw once it finishes.)

Rebased onto main 6135d9d (#139), with only paper.pdf conflicting. This PR's own diff is line for line the one I approved before the rebase. Rebuild in place: latexmk -g on one core finished with 0 warnings and its text is identical to the committed PDF. References start on p11, and the PDF now carries #139's γ displays from main.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 31810b8ff0

ℹ️ 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".

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