Repository navigation
bf16_paths: neither BF16 miss at the served gross positions is shown to be specific to SGLang - #222
Conversation
… SGLang kernel variants hf_paths.py reads 579ae7ce/439 and a4db11ff/333 along the prefill and decode paths in transformers' Qwen3.5 in BF16 (torch or flash-linear-attention GDN kernels; cached state in BF16 or FP32), and sglang_variants.py reads them on the unpatched SGLang pin under one-family kernel swaps. Readings set in the docstrings before the run; hold.sh runs both in one shared hold.
Open upstream issue #38975 and PRs #38977/#40362 report that the packed GDN decode kernel and the gating kernel round sigmoid(beta) through BF16. The beta_fp32 variant runs the default flags on the pin with both lines changed (engine/sglang/patches/upstream-bf16/0001), so the hold can tell whether that rounding explains the decode/prefill disagreement.
…d steps The prefill trace stopped one position short when the prefill ended at the target (KeyError at 439 in the first hold), and the sglang venv has no pip: install flash-linear-attention 0.5.2 with uv. hold.sh takes a step (all, hf, sglang) so the transformers runs can be repeated without the server variants.
…readout perturb.py repeats paths.py's FP32 forward with every decoder layer's output multiplied by (1 + u), u ~ U[-2^-9, 2^-9], over 8 seeds, to measure how far rounding of BF16 size moves the two positions by itself (readings set in the docstring). summary.py tabulates every source and path against FP32. hold.sh takes several steps (hf, sglang, perturb).
The two positions were found because SGLang erred there, so they cannot compare error rates between implementations. rates.py decodes and prefills 12 workload prompts on stock SGLang, reads the same text with transformers BF16 (FP32 and BF16 cached state) and scores every path's top-1 against an FP32 forward, before and after the first end of text. perturb.py --site gdn puts the BF16-sized noise on the GDN core's inputs instead of the residual stream. Readings set in the docstrings.
…ared decision transformers' torch GDN keeps the recurrence in FP32, so the rate comparison also reads the same text with flash-linear-attention's kernels (FP32 state), and rates.decide applies the rule declared before the run against the worse of the two. CPU tests for the readouts and the rule.
Hold 3's rates sample never reached an end-of-text token, the regime of both events. rates.py takes the output length and an end-of-text filter on the benchmark's recorded outputs; hold.sh's rates_eot step decodes 768 tokens of 12 such prompts and compares against both transformers GDN implementations with an FP32 state. Secondary readouts: finer regret thresholds and the logprob error on FP32's top-1.
a4db11ff/333 is ill-conditioned in BF16: transformers BF16 misses FP32 there by up to 16.7 nats and FP32 flips its own top-1 under noise of one BF16 rounding. At 579ae7ce/439 only SGLang misses, but no single kernel family carries it, and on 15,360 unselected positions per path (5,426 after the end of text) SGLang is as accurate as transformers; both declared rate rules came back inconclusive (0 vs 0, 1 vs 1). No upstream issue follows from this.
|
@codex review |
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: 1e8903a4ab
ℹ️ 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".
| from experiments.benchcert.paths import MODEL, REVISION, TRACE | ||
| from experiments.bf16_paths.hf_paths import entry | ||
|
|
||
| EPS = 2.0**-9 |
There was a problem hiding this comment.
Perturb by the full BF16 rounding bound
For normalized BF16 round-to-nearest with eight significant bits, the relative rounding-error bound is approximately 2^-8, not 2^-9; values just above a power of two can incur nearly the larger error. Consequently, the committed perturbation evidence samples only half the advertised range, so the observation that 579ae7ce stays stable does not establish stability under a full BF16-sized rounding perturbation. Increase the bound and regenerate the perturbation evidence before using it to classify that position.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed: round-to-nearest BF16 has a relative error bound of 2^-8, and 2^-9 sampled only half of it. Fixed in 94460d6 (EPS = 2^-8, docstring and README corrected). Both perturbations were rerun at 2^-8 (hold 5) and the evidence regenerated in 41829e3: 579ae7ce's 1756 now stays within 0.52 nats of FP32 (-10.04 to -9.27; 68189 on top in all 8 seeds), and a4db11ff's 18299 falls as low as -11.65 in FP32 itself with the top-1 flipping in 4 of 8 seeds. The classification of both positions is unchanged; the 2^-9 runs are kept outside git as superseded and named so in the README.
| sglang_events = events_above(counts, 'sglang/decode') + events_above(counts, 'sglang/prefill') | ||
| by_comparator = { | ||
| name: events_above(counts, f'{name}/decode') + events_above(counts, f'{name}/prefill') | ||
| for name in COMPARATORS |
There was a problem hiding this comment.
Do not count paired paths as independent events
When a bad position appears in both decode and prefill, these lines count it twice before applying the exact binomial test, even though the two observations share the same prompt, position, weights, and much of the computation. This can manufacture a significant verdict: three affected positions duplicated across both paths become 6-versus-0 events and yield p=0.015625, whereas the three independent positions yield p=0.125. Deduplicate or block events by prompt/position, or use a paired/block-aware test, before deriving the sglang-specific verdict.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed: the two paths share the prompt, position and most of the arithmetic. Fixed in 94460d6: rates.summary records, per source, the positions missed by more than 2 nats on either path, and decide counts each position once (positions_missed_above_2_nats in the JSON; new test test_rates_summary_counts_a_position_missed_on_both_paths_once). Regenerated in 41829e3; neither verdict changes (0 vs 0; then one position, 6af1e245/247, for SGLang and both transformers runs). The README says this correction came after the runs.
… position once Codex on #222: round-to-nearest BF16 has a relative error bound of 2^-8, not 2^-9, so the perturbation now draws u from [-2^-8, 2^-8] (the 2^-9 runs are superseded). The rate decision counted a position missed on both the decode and the prefill path twice; it now counts positions, once each.
…ons counted once Regenerated at 94460d6: positions.json with the 2^-8 perturbation runs (hold 5; 579ae7ce's 1756 stays within 0.52 nats, a4db11ff's 18299 falls as low as -11.65 in FP32 itself), rates.json and rates_eot.json with the decision on missed positions counted once (verdicts unchanged: 0 vs 0, 1 vs 1).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41829e3353
ℹ️ 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".
| scripts/gpu_lock.sh -s experiments/bf16_paths/hold.sh rates_eot | ||
| # Hold 5 (repo 94460d6): both perturbations again at the full rounding bound, 2^-8 (the runs of | ||
| # holds 2 and 3 used 2^-9 and are superseded). | ||
| scripts/gpu_lock.sh -s experiments/bf16_paths/hold.sh perturb perturb_gdn |
There was a problem hiding this comment.
Make the full-bound rerun command executable
When the documented holds are run in order using the default BF16_PATHS_OUT, holds 2 and 3 create perturb.json and perturb_gdn.json, so this hold-5 command exits with status 65 at hold.sh's existing-output guard before either full-bound run starts. Document the required removal/archive step or use a separate output directory so the listed command actually reproduces the committed perturbation evidence.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 86852c1: the README's command list now shows the step taken before hold 5 (the 2^-9 outputs moved to superseded_eps2m9/, since hold.sh refuses to overwrite an output) and notes that into a fresh output directory at 94460d6 or later holds 2 and 3 already perturb at 2^-8, so hold 5 is not needed for a reproduction.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86852c1149
ℹ️ 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".
| noise = torch.rand(hidden.shape, generator=generator, dtype=hidden.dtype) | ||
| perturbed = hidden * (1 + (2 * noise - 1) * EPS) |
There was a problem hiding this comment.
Do not treat random perturbations as a rounding bound
When none of the eight random directions happens to expose a sensitive direction, this uniform sampling cannot establish that a position is stable under BF16 rounding: most sampled elements have errors smaller than EPS, and the finite samples do not cover all correlated in-bound rounding patterns. The full EPS fixes the previously reported scale issue, but these lines are fresh evidence that the rerun remains only a positive sensitivity probe, so using its 0.52-nat observed maximum to classify 579ae7ce as “not” ill-conditioned is unsupported; either test actual BF16 round-trips/provide a worst-case bound or qualify the negative conclusion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed: eight random draws per site are a sensitivity probe, not a bound. Fixed in 418ad12: the README now says 579ae7ce/439 showed no sensitivity in 16 draws (1756 within 0.52 nats), that a random probe cannot bound stability over every correlated in-bound rounding pattern, so this supports rather than proves good conditioning, and that the transformers runs (real BF16 roundings, four configurations) point the same way; the Result item and the Limits bullet are qualified the same way, and perturb.py's docstring states the limit. The verdict does not rest on this probe: it rests on the selection-free rates, which were inconclusive, so no issue follows either way.
…d (Codex on #222) Eight random draws per site can show that a position is sensitive but cannot bound its stability over every in-bound rounding pattern; the README and perturb.py's docstring now say so, and qualify the reading of 579ae7ce/439. Docstring only: the perturbation evidence (generated at 94460d6) is unchanged.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 418ad12362
ℹ️ 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".
| a power of two come close to it), so each run perturbs the residual stream at least as much | ||
| as storing it in BF16 after every layer would, at every position of the prefix |
There was a problem hiding this comment.
Remove the lower-bound claim for random perturbations
The stated fix still leaves this pointwise lower-bound claim: a uniform draw in [-2^-8, 2^-8] usually has magnitude below the BF16 error bound and can be smaller than the actual rounding error for the fixed activation, so a run does not perturb every element “at least as much” as BF16 storage would. The later random-probe disclaimer addresses directional coverage but does not make this amplitude claim true; retaining it overstates what the residual experiment establishes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed: a uniform draw within the bound is neither an upper nor a lower bound on a fixed value's rounding error. Fixed in 8f0021d: the docstring now says each run perturbs by relative errors of the same order as BF16 storage and that the draw bounds no particular rounding. The README already describes the noise as uniform within the bound and the runs as a sensitivity probe, not a bound.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f0021d1d6
ℹ️ 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".
| per path (12 workload prompts decoded for 512 tokens, then 12 prompts decoded for 768 tokens so | ||
| that 5,426 positions lie after the end of text), SGLang's mean logprob error on FP32's top token | ||
| (0.0039-0.0054 nats per path and sample) lies within transformers' range (0.0042-0.0057), and | ||
| SGLang misses FP32's top by more than 0.5 nats at 3 positions against 2 and 1 for the two |
There was a problem hiding this comment.
Deduplicate the shared half-nat miss
For the reported rates_eot data, SGLang's decode and prefill entries both exceed 0.5 nats at the same 0ae071b513acf1ae position 551, while only prefill exceeds it at 6af1e245439490c5 position 247. Thus there are two distinct positions, not three; 3 is the number of path-position observations. Since the surrounding result explicitly reports positions and deduplicates paths for its decision, either report 2 against 2 and 1 here or label these as path-position observations.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in b394831: by position, SGLang misses by more than 0.5 nats at 2 distinct positions (0ae071b5/551 on both paths, 6af1e245/247 on prefill), and transformers' torch GDN run misses at the same 2 (fla at 1 of them); the README now says this, and the per-path table stays labelled per path.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b39483154a
ℹ️ 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".
| comparator = max(by_comparator, key=lambda name: by_comparator[name]) | ||
| hf_events = by_comparator[comparator] | ||
| total = sglang_events + hf_events | ||
| p_value = sum(math.comb(total, k) for k in range(sglang_events, total + 1)) / 2**total |
There was a problem hiding this comment.
Base the exact test on discordant positions
Because SGLang and transformers are evaluated at the same prompt/position pairs, summing their event counts treats paired observations as independent and counts a position missed by both implementations twice. This already makes the committed rates_eot p-value 0.75 even though its sole event is shared and there are no discordant pairs, for which a paired exact test yields 1.0; in other samples it can change the verdict (for example, six SGLang misses with one shared comparator miss produces 0.0625 here versus 0.03125 from the five SGLang-only discordances). Preserve the position sets through decide and compute the exact test from SGLang-only versus comparator-only positions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in c44ef32: summary passes the missed-position sets to decide, which runs the paired exact test on SGLang-only against comparator-only positions (sglang_only, comparator_only, paired_exact_p_one_sided in the JSON) and keeps the declared count thresholds; new test test_decision_pairs_positions_both_miss covers your 6-with-1-shared example (p = 1/32) and the shared-only case (p = 1). Rate evidence regenerated at c44ef32 (b43d550): the rates_eot p is now 1.0 (its one miss is shared), and both verdicts stay inconclusive. README updated (c386c13).
SGLang and transformers are read at the same positions, so the decision now tests SGLang-only against comparator-only missed positions (McNemar's exact test) instead of summing the two counts. Neither verdict changes; the rate evidence is regenerated from this commit.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9935ab68f2
ℹ️ 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".
| for state in $states; do | ||
| ! missing "$r/hf_bf16_${state}state.jsonl.gz" || | ||
| timeout --foreground 1200 python -m experiments.bf16_paths.rates hf --out "$r" --state-dtype "$state" || fail |
There was a problem hiding this comment.
Rebuild dependent traces after regenerating SGLang
When a stale marker is caused by a missing sglang.jsonl.gz, this section regenerates SGLang's greedy text but preserves any existing transformers traces here and the FP32 trace later. If the regenerated decode differs—for example after intentionally moving the file aside to rerun under updated code or dependencies—the preserved files describe the old text, while sources() validates only prompt IDs and trace lengths, so the resulting evidence can silently compare different token contexts. Invalidate the downstream HF/FP32 files whenever SGLang is rebuilt, or record and verify the exact output token IDs before keeping them.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 029f1a2: hf and fp32 rows now record text_sha256 (SHA-256 of the prompt and output ids they were computed on); sources() and summary refuse a row whose hash differs from sglang.jsonl.gz (test test_rates_refuses_traces_of_other_text), and hold.sh moves existing transformers and FP32 traces into a superseded-/ directory before it regenerates the SGLang text. The committed raw rows predate the hash and are not checked; each rates directory was produced once, in order (sglang, then hf, then fp32).
) hf and fp32 rows record a SHA-256 of the prompt and output ids they were computed on, sources() and summary refuse a row whose hash differs from sglang.jsonl.gz, and hold.sh moves existing traces aside before it regenerates the SGLang text. The committed raw rows predate the hash and are not checked; each rates directory was produced once, in order.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 029f1a2994
ℹ️ 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".
| recorded = row.get('text_sha256') | ||
| if recorded is not None and recorded != text_sha( |
There was a problem hiding this comment.
Reject traces that lack a text hash
When a legacy HF or FP32 row is combined with a regenerated sglang.jsonl.gz having the same prompt and output length but different output tokens, recorded is None, so this check accepts the stale row and summary() compares distributions from different token contexts. Fresh evidence after the prior regeneration fix is this explicit missing-hash bypass; require the hash or otherwise validate the exact token sequence before consuming these raw traces.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 148847a: a transformers or FP32 row without a text hash is refused unless --accept-unhashed, and the output lists every row accepted that way (unhashed_rows_accepted). The README's regeneration commands pass the flag for holds 3 and 4 only, with the reason (each directory produced once, in order: prompts, SGLang, transformers, FP32). Tests: test_rates_refuses_unhashed_traces_unless_accepted. Evidence regenerated (fa70220); verdicts unchanged.
| if missing "$r/prompts.jsonl"; then | ||
| python -m experiments.bf16_paths.rates prompts --out "$r" "$@" || { fail; return 0; } | ||
| fi |
There was a problem hiding this comment.
Invalidate downstream outputs when prompts are regenerated
When prompts.jsonl is moved aside using the supported redo workflow and regenerates to a different sample, these lines replace only the prompt manifest; the following guard keeps the existing SGLang, HF, and FP32 traces and the step can be marked complete. The resulting readout still measures the old prompt sample rather than the newly selected one, so recreating the manifest should also invalidate its dependent outputs or verify that the manifest matches sglang.jsonl.gz.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 148847a: sources() refuses an sglang.jsonl.gz whose prompts and prompt ids differ from the current prompts.jsonl (test_rates_refuses_sglang_text_of_another_manifest), and hold.sh's set_aside moves SGLang's text and every transformers and FP32 trace into superseded-/ when it recreates the manifest (and the traces when it recreates the text).
…alidate on regeneration (Codex on #222) Rows without a text hash are refused unless --accept-unhashed, which the README uses for holds 3 and 4 (produced once, in order) and the output lists; sources() refuses an sglang.jsonl.gz decoded from another prompts.jsonl; hold.sh moves SGLang's text and every trace aside when it recreates the manifest, and the traces when it recreates the text.
…verdicts unchanged)
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa7022026b
ℹ️ 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".
| for state in $states; do | ||
| ! missing "$r/hf_bf16_${state}state.jsonl.gz" || | ||
| timeout --foreground 1200 python -m experiments.bf16_paths.rates hf --out "$r" --state-dtype "$state" || fail |
There was a problem hiding this comment.
Invalidate FP32 when regenerating an HF trace
When the supported redo workflow moves aside one hf_bf16_*.jsonl.gz file, this loop regenerates it but preserves the existing fp32.jsonl.gz. That FP32 file stores logprobs only for tokens present in the BF16 top-20 sets when it was created; if the regenerated HF trace introduces a new top-1 token, rates.summary rejects the supposedly completed hold because FP32 lacks that token's logprob. Set aside FP32 before rebuilding any missing HF trace so the documented evidence command remains reproducible.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in dad71b8: before the transformers runs, run_rates sets fp32.jsonl.gz aside whenever any of the step's traces (each state dtype, and fla) is missing and will be rebuilt, so FP32 is recomputed over the new union. With this the rates dependency chain is closed: a new manifest sets aside SGLang's text and all traces, a new text the traces, a new trace FP32. Stub-tested (FP32 kept while every trace exists, moved when one is missing); shellcheck and hold_lint pass.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…in's sections, then upstream-bf16)
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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: REQUEST CHANGES at 5748d8b This was a full review. The investigation holds up:
Two numbers in the README's prose are wrong. Both are one-phrase fixes. Blocking
Optional
What I checked
|
…' (not within its range); three of sixteen readings exceed 1 nat Reviewer, #222 issuecomment-5962740297: 0.0039 is below transformers' lowest 0.0042, and the torch 576-token prefill exceeds 1 nat in both state configurations (positions.json).
|
@codex review |
|
Checks at 5748d8b (the pending items from my review above). All pass; the two blocking wording items stand.
|
|
Verdict: APPROVE at 82523e2 (provisional on Codex, requested 23:14 on this head) I re-checked only the delta from 5748d8b: one commit,
My optional items 3-6 were not taken. That is fine; none is blocking. My earlier checks at 5748d8b still apply, since nothing else changed: the regenerated evidence was byte-identical, |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
…es and the upstream patches BF16 (#222, evidence/bf16_paths): the served benchmark read both gross positions as ill-conditioned in BF16. #222 supports that for a4db11ff/333 only. At 579ae7ce/439, the paper's 8.9-nat position, transformers in BF16 keeps FP32's top token in all 16 readings, FP32 under one-rounding noise moves 1756 by at most 0.52 nats, and no single SGLang kernel swap removes the miss: an SGLang outlier at a selected position, whose frequency the unselected positions cannot compare with transformers'. The abstract and §4.5 add "unlike transformers'"; App E.5, the served README (two places) and a new notes subsection give the reading; register entry bf16-paths in both registers. Low-concurrency probes (#220, evidence/speed_lowc): one notes paragraph (split-KV verify dropped by its rule; FA4's head-dim-256 compile failure and backport; one-session served FA4 probes, exactness not classified; fused GDN chain passed its rule but not built), H6, "What did not work", register entry speed-lowc, and the missing index rows. Upstream (#226): one notes paragraph and register entry upstream-patches (the FA4 test as a comment on sgl-project/sglang#35757; the sgl-kernel sm_90a build fix open as sgl-project/sglang#42263). The two FP8 lines say the CUTLASS GEMM "fails" rather than "aborts", consistent with the engine README. Reviewer's optional item from #227: "calls of up to 30-64 positions" in the abstract and §4.5 (largest certified calls at each point). Paid for in §4.5's paragraph with no claim dropped; the main text still ends at the foot of p10.
The served certified-head benchmark (#190) found two positions where stock SGLang's BF16 prefill and decode paths disagree with each other, and one of them with FP32, by 9 to 15 nats (
evidence/certified_head/served/README.md, "Reference paths and FP32"). Sam pre-approved one upstream issue on this, on condition that the error is shown to be specific to SGLang rather than BF16 ill-conditioning any implementation would show. This PR is the investigation; its answer is that neither error is shown to be specific to SGLang, so no issue follows.Findings (measured;
evidence/bf16_paths/README.md)a4db11ff/333 is ill-conditioned in BF16. transformers 5.12.1 in BF16 misses FP32 there by up to 16.7 nats (its torch GDN prefill of the whole output puts FP32's top token at -17.16), and FP32 itself, under relative noise within the BF16 rounding bound (2^-8) on the residual stream or on the GDN inputs, flips its top-1 in 4 of 8 seeds and puts that token as low as -11.65.579ae7ce/439 only SGLang misses: transformers BF16 (torch and flash-linear-attention GDN, BF16 or FP32 cached state; 16 readings) keeps FP32's top-1 on top, and in 16 random draws of rounding-sized noise FP32 kept the contested token within 0.52 nats (a probe, not a bound). But on the unpatched pin no single kernel swap removes the miss: one-family swaps (Triton GDN prefill, FlashInfer GDN decode, Triton attention, no CUDA graphs) and the beta-in-FP32 lines of open upstream PRs #38977/#40362 move it between -8.9 and -0.32 without restoring FP32, and the beta change breaksa4db11ff's decode instead.rates.pybefore each run was inconclusive both times (0 vs 0, 1 vs 1; missed positions, each counted once).So
579ae7ce/439 remains an SGLang outlier at one selected position; the samples cannot separate its rate from transformers' own large misses, and SGLang's typical BF16 accuracy matches transformers'.Changes
experiments/bf16_paths/:hf_paths.py(transformers along the same paths),sglang_variants.py(the unpatched pin under one-family swaps, reusingbench's Server andpaths.stock_target),perturb.py(FP32 under BF16-sized noise),rates.py(selection-free comparison and the declared decision),summary.py(readout),hold.sh(shared-lane holds, steps selectable).engine/sglang/patches/upstream-bf16/0001: a diagnostic patch with the two beta lines (variantbeta_fp32), and its section inengine/sglang/README.md.evidence/bf16_paths/: README,positions.json,rates.json,rates_eot.json; rows inexperiments/README.mdandevidence/README.md.tests/test_bf16_paths.py: CPU tests of the readouts and the decision rule.Validation
python -m pytest tests/test_bf16_paths.py: 23 passed.pre-commit run --fileson every touched file: passed (codespell run by hand on the evidence README, which the hooks exclude).uv pip install --no-deps --target ~/vp-data/upstream/bf16/pydeps, used only throughPYTHONPATHin the hold).Not done
No per-layer localization of the
579ae7cemiss: with no single swap removing it and no rate difference to explain, it would not change the decision. No upstream issue or comment; the beta result shows sensitivity in both directions, not an accuracy gain, so it does not add to #38975.Review
decidenow tests SGLang-only against comparator-only positions (c44ef32); evidence regenerated, verdicts unchanged (c386c13).outside_top20andcomplete(c136288); all positions were inside in the committed data.Review round (main, for the reviewer's issuecomment-5962740297)