Skip to content

Repair: the FlashInfer GDN verify kernel dominates wide-block verification; Stage A with the Triton kernel - #89

Merged
SamMausberg merged 9 commits into
mainfrom
repair/verifier
Oct 1, 2026
Merged

SamMausberg merged 9 commits into
mainfrom
repair/verifier

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Decomposition of SGLang's wide-block DFlash verify pass and Stage A rerun with the faster stock GDN verify kernel. Session experiments/repair/runs/decomposition.sh (exclusive lock, 2026-10-01 04:49-05:12 UTC, same panel and flags as Stage A, foreign CPU load below 0.5 cores).

Measured

B V(B), FlashInfer GDN verify (default) same, per-position states dropped V(B), Triton GDN verify
16 4.78 4.53 4.55
64 15.62 14.36 7.58
256 44.82 40.73 19.18

(ms, forced full acceptance.) The per-position FP32 state writes cost 0.26, 1.26 and 4.10 ms (5.3, 8.1, 9.1% of V), close to their bytes. Most of the excess is FlashInfer's gated_delta_rule_mtp itself: SGLang's Triton verify kernel (--linear-attn-verify-backend triton, a stock option) makes the whole pass 2.06x faster at B = 64 and 2.34x at B = 256, consistent with the prediction recorded before the run (the FlashInfer kernel walks the positions sequentially in 512 CTAs per layer at one request). Stock DFlash-16 with the Triton kernel: 7.302 ms per cycle, 7.603 tokens (1,041 tokens/s pooled vs 1,029).

Stage A with the Triton verify kernel (baseline on the same kernel; f = 2.39%, target 5.54x decode)

B ideal free drafter perfect blocks with DFlash drafting P3 S_b estimate P3 S_b ceiling
16 3.30 / 3.12 2.10 / 2.05 1.71 / 1.69 2.23 / 2.17
64 7.98 / 6.84 5.81 / 5.21 4.30 / 3.99 6.17 / 5.49
256 12.72 / 9.94 10.73 / 8.71 7.11 / 6.21 11.28 / 9.06

(decode / end to end, derived from the measured V(B) and baseline.)

  • The Stage A verdicts depend on the verify kernel. With the Triton kernel, perfect B-token blocks reach the 5x target from B = 64 even paying DFlash's drafting cost, and P3's two-pass design passes Stage A at B = 256. With the default FlashInfer kernel neither does; with its measured state writes (4.10 ms against 2.33 ms needed), P3's ceiling with a state-free audit and an uncharged boundary replay would pass at B = 256.
  • P2 therefore turns on drafting, not verification: blocks of 64 or more tokens must be accepted almost entirely, and the repair mechanisms tested (one-step recycling; exact Jacobi at about one token per pass) do not produce them. P3 stays refuted by Stage B (Repair Stage B: the anchored residual evaluator fails at the operator level #58).

Files

  • evidence/repair/stage_a_timing.json: adds the no-state, Triton-verify and Triton-baseline runs.
  • evidence/repair/stage_a_oracle.{json,csv}: FlashInfer kernel, measured state writes at B = 16, 64, 256 (byte bound at 32, 128).
  • evidence/repair/stage_a_oracle_triton.{json,csv}: Triton kernel (state writes bounded by bytes).
  • experiments/repair/stage_a.py: --verifier and --suffix.
  • evidence/repair/README.md: new section and updated Stage A bullets; commands.

The session's Nsight Systems runs failed at launch (an option nsys launch does not accept); the fix is on the P9 branch and a B = 256 trace is queued. Exactness: the Triton and FlashInfer verify kernels are both stock SGLang kernels and differ only numerically; this PR makes no output-equality claim between them.

…Triton verify kernel

Dropping the per-position GDN states saves 0.26, 1.26 and 4.10 ms of the
verify pass at B = 16, 64, 256; switching the GDN verify kernel from
FlashInfer's to SGLang's Triton kernel makes the pass 2.06x faster at B = 64
and 2.34x at B = 256 (V(256) 19.2 ms). With the Triton kernel and the DFlash
baseline on the same kernel, perfect blocks reach the 5x target from B = 64
and P3's two-pass design passes Stage A at B = 256; P3 stays refuted by
Stage B.
@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-01T06:36:49.300104Z 643c8f8 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: 3866100c32

ℹ️ 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 on lines +95 to +98
'--verifier',
choices=['flashinfer', 'triton'],
default='flashinfer',
help='GDN verify kernel of the forced-acceptance rows (the baseline should use the same)',

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 Validate the baseline verifier before deriving speedups

When --verifier triton is used without also changing the default --baseline fresh_b16 (or when any baseline from the wrong backend is selected), the forced rows are filtered to Triton while C_D, A_D, and f are silently taken from the FlashInfer baseline. The command completes and emits plausible but invalid cross-backend speedups, even though the help text says the baseline should match; reject a baseline whose verifier_of(base) differs from args.verifier.

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 877e81f: stage_a.py exits when the baseline run's verify kernel (from its launch command) differs from --verifier; fresh_b16 with --verifier triton is now rejected.

Comment thread evidence/repair/README.md
Comment on lines +83 to +86
`stage_a_timing.json` (runs `force_nostate_b*`, `force_tritonverify_b*`, `fresh_tritonverify_b16`),
`stage_a_oracle.{json,csv}` (FlashInfer verify kernel, now with measured state writes at
B = 16, 64, 256) and `stage_a_oracle_triton.{json,csv}` (Triton verify kernel). Session
`experiments/repair/runs/decomposition.sh` under the exclusive lock, 2026-10-01 04:49-05:12

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 Record the decomposition engine revision

The newly documented decomposition session was run at engine SHA 5d8e00e3e121 with repair patch 0002, as recorded in every new stage_a_timing.json row, but the README still declares that the setting “throughout” is the 0001-only engine at 101e52731b. This associates the new measurements with the wrong executable revision and makes the stated reproduction setup inaccurate; distinguish the decomposition session's engine and patch set here or update the introductory scope.

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 877e81f: the README header names both builds (101e52731b, patch 0001, for Stage A and earlier runs; 5d8e00e3e1, patches 0001 and 0002, for the decomposition), the decomposition section repeats it, and each run's run.json records its engine commit.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed head 3866100, one commit on main f62cdaa.

What reproduces. Every evidence file reproduces byte-identical from ~/vp-data/repair/runs/{timing1,nsys1} with the README's commands: analyze_timing.py gives stage_a_timing.json, and the two stage_a.py invocations give stage_a_oracle{,_triton}.{json,csv}.

  • The README numbers match those files:
    • the V(B) table;
    • the write costs 0.255, 1.258 and 4.095 ms (5.3, 8.1, 9.1%);
    • the ratios 2.06x and 2.34x;
    • the Triton Stage A table;
    • 7.302 ms per cycle and 7.603 tokens.
  • The 5.18x figure is right: floor + (V − 4.095 ms) + commit gives 5.74 in decode and 5.18 end to end. It is not a column in any file, though; see suggestion S1.
  • The engine builds behind the two sessions (timing1 at 101e52731b, nsys1 at 5d8e00e3e1) differ only by patch 0002's env-gated branch in gdn_flashinfer.py. I checked the diff. So, with the env unset, the default code path is the same.

Blocking

B1. Triton results need the label "pending exactness classification". This is integrator check (1). --linear-attn-verify-backend is not in bench/arms.py NEUTRAL_FLAGS, so the Triton GDN verify kernel counts as a numerics change against the reference configuration. The runs show it: stock DFlash-16 commits 7.675 tokens per cycle with the FlashInfer kernel and 7.603 with the Triton kernel, so the outputs changed.

Every Triton-based figure needs "pending exactness classification":

  • the 2.06x and 2.34x verify ratios;
  • the ~1% baseline gain;
  • the Triton Stage A table and its JSON (add an exactness field);
  • the bullets "perfect blocks reach the 5x target at B = 64" and "P3's two-pass design reaches it at B = 256";
  • "with SGLang's Triton verify kernel it would, from B = 64";
  • the top bullet's "With SGLang's Triton verify kernel P3 passes Stage A at B = 256";
  • "P2 therefore turns on drafting".

No exact-stack claim may rest on these until a comparison against plain decoding at c = 1, in the #37 convention, exists. "A stock option" is true, but it is not the reference configuration, so say that too.

B2. The B = 16 baseline change (1,029 → 1,041 tokens/s) has no repeats. Integrator check (2).

  • These are single runs from different sessions (timing1, and nsys1 at 04:49–05:12).
  • The gain splits into a cycle period 2.1% shorter (7,457 → 7,302 µs) and 0.9% fewer tokens per cycle (7.675 → 7.603), and the second part comes from changed outputs.
  • Within each run, the cycle period's p10–p90 spread is about ±1%.

Either add same-session repeats, for example A/B alternated, and report the spread; or say that it is one cross-session comparison inside plausible run-to-run variance, and that acceptance moved because the outputs changed. The Triton Stage A table rests on this baseline, so the same caveat applies there.

B3. The Triton Stage A table needs "derived" in the README. Integrator check (3). The PR body says it, and the JSON's kind says it, but the README table and its bullets do not. P3 staying refuted by Stage B is kept, which is correct.

B4. The decomposition compares across sessions, and the README doesn't say so. The write costs and the Triton ratios subtract nsys1-session runs from the FlashInfer V(B) of the earlier timing1 session; nsys1 had no FlashInfer control. The code path is the same, as noted above, but the README presents these as "two runs" of one session. Either state that the comparison is cross-session and give a bound on drift, or add a same-session FlashInfer forced run at least at B = 16 and 256. B = 16 matters most: its 0.26 ms is 5.3% of V.

B5. Codex P2 on stage_a.py:98 (unaddressed). --verifier triton with the default --baseline fresh_b16 silently mixes kernels: C_D, A_D and f come from the FlashInfer baseline. Reject a baseline whose verifier_of(base) differs from --verifier, and add a test, or at least a check that fails loudly.

B6. Codex P2 on README.md:86 (unaddressed). The README's scope still says engine 101e52731b "throughout". The decomposition runs are at 5d8e00e3e1, which is patches 0001 plus 0002. Name both builds.

B7. "As predicted" needs a committed record. Integrator check (5). The only record of the prediction is in the workstream notes outside the repository, which committed files may not cite. It isn't under version control, so its "01:00" header can't be checked; the file's mtime is 05:16, after the run.

Its content also differs from the claim. It predicted:

  • the FlashInfer kernel's share of V(B) under nsys, about 60% of V(64) and 75–85% of V(256);
  • that dropping the state writes saves "a few ms";
  • that a chunked exact GDN verify would be the fix.

It did not predict the Triton speedup. The nsys runs failed, so the share prediction is untested. The Triton swap only bounds the FlashInfer kernel's excess from below: at least 8.0 ms (51%) of V(64) and 25.6 ms (57%) of V(256).

What is committed before the run is the plan to test Triton (decomposition.sh, c8e91f5, 03:29), not a prediction of the outcome. Replace "as predicted" with the code-reading explanation, labelled as code reading, and say the nsys share measurement is queued.

Integrator check (4)

The 4.10 ms is the FlashInfer kernel's measured write cost: V(256) 44.82 − 40.73 ms, set against the 2.33 ms needed. The new section's bullet says so. The top bullet ("measured, they are 4.10 ms") sits in the FlashInfer Stage A context but doesn't name the kernel; please add "(FlashInfer verify kernel)" there.

Paper follow-up (not blocking this PR)

Appendix F cites the byte-bound estimate "2.90 and 2.78", "5.20 end to end", and the decomposition as queued. After this PR, the committed CSV gives 2.89 and 2.77 with measured writes, and 5.18. The appendix needs a follow-up once this merges, so I'm routing it to the appendix editor.

Suggestions

  • S1. Record the 5.18x as a column, for example S_b_ceiling_without_state_writes_e2e, so the README figure is in a committed file.
  • S2. Name the two failed nsys runs' directories (force_nsys_b*) as excluded in the README, so nobody feeds them to analyze_timing.py.

…-session drift, build per run

- Label every Triton-verify figure pending an exactness classification (the
  kernel switch changes DFlash's acceptance, 7.675 to 7.603 tokens per cycle).
- Say the 1,029 vs 1,041 tokens/s baselines are single runs from two sessions,
  within plausible variance; mark the Triton Stage A table derived.
- Bound the cross-session drift with the untouched draft phase (2.0-2.6%) and
  queue a same-session control; name the engine build of each session.
- Replace the forward-looking attribution with the code reading, labelled, and
  say the kernel-share trace is queued; exclude the failed nsys directories.
- stage_a.py rejects a baseline whose verify kernel differs from --verifier
  and records S_b_ceiling_stateless_audit_e2e (5.18x at B = 256).
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Re-reviewed 877e81f. Nearly everything is fixed; two small items remain.

Fixed.

  • B1. The Triton ratios, the baseline, the Triton table and JSON, and the header bullets are labelled pending, with the reason (7.675 → 7.603 tokens per cycle).
  • B2. The baseline comparison is stated as single runs from two sessions, "not established".
  • B3. The Triton table is labelled "derived".
  • B4. There is a cross-session caveat, and a same-session control is queued.
  • B5. stage_a.py now rejects a baseline on the wrong kernel. I ran --baseline fresh_b16 --verifier triton and it exits 1 with "baseline fresh_b16 uses the flashinfer verify kernel, not triton".
  • B6. Both builds are named.
  • B7. "As predicted" is gone, and the kernel structure is labelled code reading.
  • Check (4). The 4.10 ms is now tagged "FlashInfer verify kernel, cross-session".
  • S1 and S2. S_b_ceiling_stateless_audit_e2e gives 5.18 at B = 256, and the failed nsys directories are listed as excluded.
  • All four oracle files still reproduce byte-identical.

Blocking

R1. One drift figure doesn't match the evidence. The caveat says the draft phase is "3.148 against 3.212 ms at B = 256" and "2.0-2.6% shorter". In stage_a_timing.json, force_b256's draft median is 3,206.8 µs (3.207 ms; the mean is 3.225). Against force_nostate_b256's 3,147.6 that is 1.8% shorter; against force_tritonverify_b256's 3,130.7 it is 2.4%. The B = 16 figures (2.335 against 2.397, 2.6%) are right. Please correct it to 3.207 and "1.8–2.6%", or name the statistic if 3.212 comes from somewhere else.

R2. One bullet built on the Triton result still lacks the label. "P2 therefore turns on drafting: a 5x gain needs blocks of 64 or more tokens accepted almost entirely" follows from the Triton table: with the FlashInfer kernel, perfect blocks don't reach 5x below B = 256. It needs "(with the Triton verify kernel; pending exactness classification)", or similar.

Codex: both P2s from 3866100 are fixed in code and README, but their threads have no reply, and Codex has not run on 877e81f.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed e219016.

  • R1 is fixed. The caveat now reads 1.8–2.6%. It gives 2.335 and 2.339 ms against 2.397 at B = 16, and 3.148 and 3.131 against 3.207 at B = 256. These match the draft-phase medians in stage_a_timing.json for force_nostate_b* and force_tritonverify_b* against force_b*.
  • R2 is fixed. The drafting bullet now opens "With the Triton kernel (pending exactness classification)".

Integrator checks (1)–(6), at this head:

Check Result
(1) Every Triton-based figure is labelled pending exactness classification, with the evidence that outputs differ.
(2) The 1,029 → 1,041 tokens/s difference is stated as single cross-session runs; the baseline gain is "not established".
(3) The Triton Stage A table is labelled derived, and P3 stays refuted by Stage B.
(4) The 4.10 ms is the FlashInfer kernel's write cost, measured cross-session.
(5) "As predicted" is gone. The kernel structure is labelled code reading, and the share trace is queued.
(6) Both Codex P2s from 3866100 are fixed (in 877e81f) and their threads answered. Codex has not run on 877e81f or e219016.

Checks.

  • The evidence reproduces byte-identical: stage_a_timing.json and all four oracle files.
  • stage_a.py rejects a baseline on the wrong verify kernel.
  • pre-commit passes.
  • Both commits are Sam's, with no AI attribution.

Follow-up after merge: Appendix F's Stage A figures (2.90/2.78, 5.20, and the decomposition marked queued) need updating. I've told the appendix editor.

@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: e2190160ff

ℹ️ 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 experiments/repair/stage_a.py Outdated
cmd = list(row.get('command') or [])
if '--linear-attn-verify-backend' in cmd:
return str(cmd[cmd.index('--linear-attn-verify-backend') + 1])
return 'flashinfer'

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 Infer the fallback verifier from the decode backend

When timing data is produced with serve_probe.py --arg linear-attn-decode-backend=triton and no explicit verify override, this fallback labels the run as FlashInfer even though the verifier inherits the decode backend. As a result, --verifier triton rejects or excludes the matching baseline and forced rows, while --verifier flashinfer can silently derive mislabeled results; parse --linear-attn-decode-backend before falling back to FlashInfer.

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 1a21360: verifier_of resolves the verify kernel as SGLang does at the pin (layers/attention/linear/utils.py): an explicit --linear-attn-verify-backend wins, otherwise FlashInfer when the decode backend (--linear-attn-decode-backend, else --linear-attn-backend, else its default, triton) is FlashInfer, and Triton otherwise. tests/test_repair_stage_a.py covers the cases. Every committed row in stage_a_timing.json keeps its label (10 flashinfer, 4 triton), and both stage_a_oracle files regenerate byte for byte.

An explicit --linear-attn-verify-backend wins; otherwise the verifier is
FlashInfer when the decode backend (--linear-attn-decode-backend, else
--linear-attn-backend, else Triton) is FlashInfer, and Triton otherwise. Every
committed row keeps its label and the oracle files regenerate unchanged.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed 1a21360, the fix for Codex's P2 on e219016.

verifier_of now matches SGLang at the pin. I read layers/attention/linear/utils.py at bd66ce343e, resolve_linear_attn_backends. Decode is linear_attn_decode_backend or linear_attn_backend. Verify is the explicit --linear-attn-verify-backend if set; otherwise it follows decode when decode is FlashInfer, and is Triton when it is not. verifier_of reproduces that order.

Checks.

  • tests/test_repair_stage_a.py passes.
  • Both oracle files, and their _triton versions, regenerate byte-identical, so no committed label changed.
  • All 14 runs pass the decode backend explicitly as a separate token (--linear-attn-decode-backend flashinfer), and the 4 Triton runs add --linear-attn-verify-backend triton.
  • pre-commit passes, and the commit is Sam's with no AI attribution.
  • Codex's thread on e219016 has a reply. Codex has not run on 1a21360.

Suggestion (not blocking): flag_value reads only the space-separated form. A --flag=value spelling would fall through to the default, so handling it, or failing loudly on it, would make the resolver robust to future launch commands.

My approval at e219016 carries forward. Integrator checks (1)–(6) are unchanged by this delta.

@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: 1a21360b27

ℹ️ 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 experiments/repair/stage_a.py Outdated
Comment on lines +142 to +144
if base is not None and verifier_of(base) != args.verifier:
raise SystemExit(
f'baseline {args.baseline} uses the {verifier_of(base)} verify kernel, not {args.verifier}'

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 Allow fully overridden baselines across verifier backends

When --cd-us, --ad, and --f are all supplied, the named baseline contributes no values, but this check still rejects a Triton calculation whenever the timing file also contains the default FlashInfer fresh_b16 row. This breaks the documented explicit-baseline path for users who have forced Triton rows but no matching measured baseline; only validate the run's verifier when at least one baseline metric is actually read from that run.

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 d936dc8: when --cd-us, --ad and --f are all given the named baseline contributes nothing and its verify kernel is not checked; tests/test_repair_stage_a.py covers both paths (rejected without overrides, accepted with them).

Comment thread evidence/repair/README.md
Comment on lines +299 to +300
~/vp-data/repair/runs/timing1/fresh_b* ~/vp-data/repair/runs/nsys1/force_nostate_b* \
~/vp-data/repair/runs/nsys1/force_tritonverify_b* ~/vp-data/repair/runs/nsys1/fresh_tritonverify_b16 \

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 status of the imported no-state measurements

These newly imported force_nostate_b* runs mean the generated FlashInfer table now uses measured state-write differences at B=16, 64, and 256, but the reproduction text immediately below still says the table bounds all writes by bytes and that measured times will replace the bound when the decomposition session lands. That session has now landed, while only B=32 and 128 retain the byte bound, so the provenance instructions contradict the committed oracle output.

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 d936dc8: the reproduction text now says the state writes are measured at B = 16, 64, 256 and bounded by bytes at 32 and 128 in stage_a_oracle., and bounded at every width in stage_a_oracle_triton., with state_writes_source labelling each row.

…hs are measured; name the baseline verify kernel

- stage_a.py: a fully overridden baseline contributes nothing, so its verify
  kernel is not checked; launch flags are also read in --flag=value form.
- tests: the equals form and the overridden-baseline path.
- README: state writes are measured at B = 16, 64, 256 and bounded at 32 and
  128 (FlashInfer table) and bounded at every width (Triton table); the Stage A
  runs verify with FlashInfer because they use the card's FlashInfer decode
  backend, and with SGLang's default backend the verifier is already Triton.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Per repair's #89: with FlashInfer GDN decode (the DFlash card's setting)
verify follows decode onto FlashInfer, and the Triton verify kernel is
2.06-2.34x faster at widths 64-256; the tuned arms decode with Triton and
already verify with it.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed d936dc8.

  • The baseline check. It is skipped only when --cd-us, --ad and --f are all given, which is the case where no baseline run is read. Otherwise it still rejects a baseline that ran a different verify kernel. Tests cover both paths.
  • flag_value. It reads --flag value and --flag=value, and the last occurrence wins, which matches argparse. This is tested.
  • The README states the measured widths correctly. The FlashInfer oracle measures the writes at 16, 64 and 256 and bounds them by bytes at 32 and 128; the Triton oracle bounds them by bytes at every width. That matches each row's state_writes_source.
  • The new paragraph on the baseline's verify kernel matches SGLang at the pin.
    • linear_attn_backend defaults to "triton" (arg_groups/fields/exec_.py).
    • Verify follows decode only when decode is FlashInfer.
    • The SM100 auto-default to FlashInfer decode (attention_hook.py) does not apply on this GH200 (SM90), so with the default backend the verifier is already Triton.
  • Checks.
    • tests/test_repair_stage_a.py passes (3).
    • All four oracle files regenerate byte-identical.
    • pre-commit passes, and the commit is Sam's with no AI attribution.

Codex has not run on d936dc8. The integrator checks are unchanged by this delta.

@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: d936dc8e7f

ℹ️ 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 on lines 171 to 175
nostate = {
int(r['block']): med(r, 'phase_us', 'verify', 'median')
for r in by_name.values()
if r['mode'] == 'force' and no_state(r)
if r['mode'] == 'force' and no_state(r) and verifier_of(r) == args.verifier
}

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 Reject no-state rows for the Triton verifier

When a timing input contains a Triton force run launched with SGLANG_REPAIR_DROP_VERIFY_STATES=1, this filter accepts it as the no-state comparator for --verifier triton. However, patch 0002 applies that environment variable only inside FlashInferGDNKernel, so the Triton run still writes its states; subtracting its timing from another Triton row measures run noise while labeling it as the state-write cost, corrupting V_without_state_writes_us, S_b, and the stateless-audit ceiling. Restrict these comparator rows to FlashInfer or validate that the selected backend actually implements the switch.

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 08ac42b: stage_a.py exits with an explicit error when a row sets SGLANG_REPAIR_DROP_VERIFY_STATES but resolves to a verify kernel other than FlashInfer (patch 0002 acts only in FlashInfer's GDN verify kernel). Checking the other comparators for the same class: --gdn (gdn_state_bench.py times only FlashInfer's gated_delta_rule_mtp) is now rejected with --verifier other than flashinfer, and runs with --enable-linear-replayssm-spec resolve to their own verify label (replayssm_spec) instead of the decode backend's. Forced acceptance (SGLANG_SIMULATE_ACC_LEN, DFlash worker) and the byte bound (both kernels write one FP32 state per position) apply to every kernel. Tests cover the three cases; no committed row is a non-FlashInfer no-state run, and both oracle files regenerate byte for byte.

SGLANG_REPAIR_DROP_VERIFY_STATES acts only inside FlashInfer's GDN verify
kernel and gdn_state_bench.py times only gated_delta_rule_mtp, so a no-state
row on another verify kernel and --gdn with --verifier other than flashinfer
are errors. ReplaySSM spec runs get their own verify label. Tests cover all
three; both oracle files regenerate byte for byte.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed 08ac42b, the fix for Codex's P2 on d936dc8.

  • The no-state check is right. A no-state row (SGLANG_REPAIR_DROP_VERIFY_STATES) that verifies with anything but FlashInfer is now an error. I confirmed in the engine diff 101e5273..5d8e00e3 that patch 0002 touches only gdn_flashinfer.py, so the variable has no effect on another kernel.
  • The audit of the other comparators holds. --gdn (which times FlashInfer's gated_delta_rule_mtp) now errors with any other --verifier. --enable-linear-replayssm-spec runs resolve to their own replayssm_spec label rather than the decode backend's kernel. No committed run uses ReplaySSM, because the README records that it does not start with DFlash on this model.
  • Checks.
    • tests/test_repair_stage_a.py passes (6).
    • No committed row trips the new checks, and all four oracle files regenerate byte-identical.
    • pre-commit passes, and the commit is Sam's with no AI attribution.
    • The Codex thread on d936dc8 has a reply. Codex has not run on 08ac42b.

The integrator checks (1)–(6) are unchanged by this delta.

@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: 08ac42b30d

ℹ️ 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 experiments/repair/stage_a.py Outdated
(args.out_dir / f'stage_a_oracle{args.suffix}.json').write_text(json.dumps(out, indent=2))
if table:
with open(args.out_dir / 'stage_a_oracle.csv', 'w', newline='') as fh:
with open(args.out_dir / f'stage_a_oracle{args.suffix}.csv', 'w', newline='') as fh:

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 Clear stale CSV when no verifier rows match

When --verifier selects a backend absent from the timing input, table is empty, so the JSON is replaced with an empty result but this guarded write leaves any existing suffixed CSV untouched. For example, rerunning the documented Triton command after collecting only FlashInfer rows leaves the previous stage_a_oracle_triton.csv presenting obsolete results that disagree with the newly generated JSON; fail when no rows match or remove/write the CSV in the empty case.

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 2d01f2c: stage_a.py now exits before writing anything when no forced-acceptance row with complete phase times matches the selected verify kernel, and otherwise always writes the JSON and the CSV together from the same table. Auditing the other paths: it also exits on repeated run names (rows were silently overwritten by name) and on a baseline that is not a stock DFlash (fresh) run; the existing checks (baseline on another kernel unless fully overridden, no-state rows off FlashInfer, --gdn off FlashInfer, missing baseline) are unchanged. tests/test_repair_stage_a.py covers every failure path, asserting a pre-existing CSV is left untouched and no JSON is written, plus the normal and overridden-baseline outputs (12 tests). Both committed oracle files regenerate byte for byte.

…anything

stage_a.py now exits before writing when no row matches the selected verify
kernel, when run names repeat, or when the baseline is not a stock DFlash run,
and always writes the JSON and the CSV together from the same table, so no
stale output survives. Tests cover every failure path (stale files untouched)
and the normal and overridden-baseline outputs. Both committed oracle files
regenerate byte for byte.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed 2d01f2c, the fix for Codex's P2 on 08ac42b plus an audit of stage_a.py's output paths.

  • The stale-file problem is fixed. When no row matches the verify kernel, the script now exits before writing anything. JSON and CSV are always written together from the same table.
  • The audit adds three more early exits. Repeated run names (by-name rows were silently overwritten before), a baseline that is not a fresh run, and a missing baseline all exit non-zero before writing. I checked the missing baseline myself: --baseline no_such_run exits 1 and leaves the output directory empty.
  • Checks.
    • tests/test_repair_stage_a.py passes (12), including one parametrized test over the seven failure paths. Each asserts that a pre-existing CSV is left untouched and no JSON is written.
    • All four committed oracle files regenerate byte-identical.
    • pre-commit passes, and the commit is Sam's with no AI attribution.
    • Codex's thread on 08ac42b has a reply. Codex has not run on 2d01f2c.

The integrator checks (1)–(6) are unchanged by this delta.

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

ℹ️ 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 experiments/repair/stage_a.py Outdated
Comment on lines 185 to 186
def no_state(r: dict[str, Any]) -> bool:
return 'SGLANG_REPAIR_DROP_VERIFY_STATES' in (r.get('probe_env') or {})

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 Check the switch value before classifying no-state runs

When a run is recorded with --env SGLANG_REPAIR_DROP_VERIFY_STATES=0, this key-presence test classifies it as a no-state comparator even though patch 0002 activates the switch only when its value equals "1". For FlashInfer inputs, the ordinary verify time can then be subtracted as though state writes were disabled, producing zero or noise-derived state costs; for other verifiers, the otherwise valid row is rejected. Compare the recorded value to "1" rather than checking only for the key.

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 643c8f8: no-state classification reads the value exactly as patch 0002 does (SGLANG_REPAIR_DROP_VERIFY_STATES == "1"), so =0, empty and unset are ordinary runs; tests cover each value and that a Triton run with =0 is not rejected. Checking the other env/flag classifications for presence-versus-value: verify and decode backends are read by value (--flag value and --flag=value); --enable-linear-replayssm-spec is an SGLang store_true flag, so presence is how SGLang reads it, and the row loop now uses the same resolution as verifier_of instead of a substring test; forced acceptance comes from the run's recorded mode, not an env. Both oracle files regenerate byte for byte.

Comment thread evidence/repair/README.md
Comment on lines +155 to +158
- **The Stage A verdicts depend on the verify kernel.** With the Triton kernel (pending
exactness classification), perfect B-token blocks reach the 5x target at B = 64 even paying
DFlash's drafting cost, and P3's two-pass design reaches it at B = 256 (its ceiling at
B = 64). With the default FlashInfer kernel neither does (above). With the FlashInfer kernel

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 Carry the completed decomposition into the manuscript

This new result is not propagated to paper/sections/app_drafting.tex:108-110, which still says the no-state measurement did not finish, treats all state-write costs as byte bounds, reports the old 5.20 estimate, and marks the decomposition pending. Because the paper's repair-a evidence entry points at these updated artifacts, the manuscript now contradicts its cited evidence and omits the newly reported Triton Stage A outcome.

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.

Not part of this PR: the manuscript is owned by the appendix editor, who will carry #89 into Appendix F (paper/sections/app_drafting.tex) in a follow-up PR after this merges, checking every number against the committed oracle files.

…reads it

The patch drops the per-position states only when SGLANG_REPAIR_DROP_VERIFY_STATES
equals 1, so =0, empty and unset are ordinary runs. The ReplaySSM test in the
row loop now uses the same resolution as verifier_of. Tests cover the values;
both oracle files regenerate byte for byte.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed 643c8f8, the follow-up to Codex's run on 2d01f2c.

  • No-state classification now matches the patch. no_state() treats a run as no-state only when SGLANG_REPAIR_DROP_VERIFY_STATES == "1". That is exactly how patch 0002 reads the variable (os.environ.get(...) == "1" in gdn_flashinfer.py), so =0, an empty value and unset are ordinary runs. The committed runs have only "1" or unset, so no row changes class.
  • replay_protocol uses the resolver. It now comes from verifier_of(row) == 'replayssm_spec' rather than a substring test, so it agrees with the label. No committed run uses ReplaySSM.
  • Checks.
    • tests/test_repair_stage_a.py passes (14).
    • All four oracle files regenerate byte-identical.
    • pre-commit passes, and the commit is Sam's with no AI attribution.
    • Codex finished on 2d01f2c and has not run on 643c8f8.

The integrator checks (1)–(6) are unchanged by this delta.

@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: 643c8f8e9e

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

"S_b_ceiling_e2e": 5.491415766180202,
"S_b_ceiling_anchor_free_e2e": 6.842124781759117,
"S_b_ceiling_stateless_audit_e2e": 6.058792409744045,
"audit_saving_needed_for_target_us": -1126.92125530259,

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 Clamp the required audit saving at zero

When the selected verifier already makes the Stage A ceiling exceed the target, as it does for the new Triton rows at B=64 and B=256, audit_saving_needed_for_target_us becomes negative (-1.13 ms and -22.57 ms). A required saving cannot be negative, and the sibling state_share_needed_for_target already clamps this case to zero, so consumers of the generated oracle receive an inconsistent and physically invalid metric; clamp the generated saving to zero or expose it under an explicitly signed-margin field.

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 5d36634: audit_saving_needed_for_target_us is clamped at 0, and a new field S_b_ceiling_meets_target records where the ceiling already reaches the target (Triton rows at B = 64 and 256; false at every FlashInfer width, whose values are unchanged). stage_a_oracle_triton.{json,csv} regenerated, README notes the field, and a test covers a met and an unmet width.

audit_saving_needed_for_target_us was negative for the Triton rows at B = 64
and 256; it is now 0 there and S_b_ceiling_meets_target records that the
ceiling already reaches the target. The FlashInfer values are unchanged
(the new field is false at every width). Test added.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed 5d36634, the fix for Codex's P2 on 643c8f8.

  • The clamp is correct, and only the intended values change. audit_saving_needed_for_target_us is clamped at 0. Comparing the evidence with 643c8f8, the only value changes are the two negative Triton savings: −1,126.9 µs at B = 64 and −22,567.3 µs at B = 256, both now 0.0.
  • The new column S_b_ceiling_meets_target agrees with the ceilings. It is true at Triton B = 64 and 256 (S_b ceiling end to end 5.49 and 9.06, both at least 5) and false at Triton B = 16 (2.17) and at every FlashInfer width (at most 4.78). Every other value is unchanged.
  • The README notes both fields.
  • Checks.
    • tests/test_repair_stage_a.py passes (15).
    • All four oracle files regenerate byte-identical.
    • pre-commit passes, and the commit is Sam's with no AI attribution.

The integrator checks (1)–(6) are unchanged; no other committed number changed.

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