Repository navigation
Repair: P9 remainder verify, reuse program and c = 8/16; same-session verify control; B = 256 kernel trace - #150
Conversation
…cles (draft share at c > 1)
…elong to nsys start); add the B = 256 verify trace session
…lk at every correction slot After a correction at J a reused window has m = 15 - J positions left, so a program could verify m + 1 positions instead of a padded block of 16. runs/p9_verify_widths.sh times the verify phase at forced widths 2..16 (m = 1..15); p9_program_cost.py now sweeps the correction slot (walks of 14 down to 1 slots) instead of fixing it at 4.
…baselines --width-timing takes the forced-acceptance verify at widths 2..16 from one session (runs/p9_verify_widths.sh) and charges a reused cycle after a correction at J the baseline cycle minus its draft minus V(16) - V(m + 1) of that session, always-reuse and with the omniscient gate. It needs a c = 1 baseline. A batched baseline (analyze_timing.py's c > 1 summary) is accepted: the cycle is the batch period and a reuse saves the batched draft divided by c per request, with the per-request rate, which is an upper bound on the saving when the draft's cost is concave in rows. The bootstrap computes each replicate with numpy weights from the same random draws, so the committed intervals reproduce while the run takes seconds instead of minutes. --draft-saving-us replaces the saved draft with a given value, such as the growth of the batched draft per added request, which is what one reusing request saves while the others still draft.
The per-cycle figures divided by the state commit kernel's launches, but that kernel runs twice per verify cycle (38 launches for about 19.75 cycles in the B = 256 trace), so every per-cycle time came out halved. Cycles are now the most-launched GDN kernel's launches over the 24 GDN layers; each top kernel also reports its mean time per launch.
…d for all c requests --draft-saving-us now takes s, how much one reusing request shortens the batch cycle, and credits c s per reuse: the shorter period serves every request in the batch, which commits c r_F tokens per unit time. The default (s = draft(c) / c) already credited draft(c); passing the measured per-request draft growth credited only s, c times too little.
…r GDN kernels The most-launched kernel in the GDN category was not the verify kernel in the B = 256 trace (547 launches against the verify kernel's 474): prefill's chunked GDN kernels share the category. Cycles are now the launches of the named verify kernel (FlashInfer's gdn_verify_kernel_mtp or SGLang's Triton fused_sigmoid_gating_delta_rule_update) over the 24 GDN layers, and the other GDN kernels get their own category. Normalization kernels (FlashInfer's fused add-RMSNorm is a CUTLASS kernel) no longer count as GEMMs.
…ify control and B = 256 trace session_x2 (exclusive, 2026-10-01 16:13-16:59 UTC; FlashInfer GDN verify kernel unless noted). P9 at c = 1 with the measured m + 1 verify (V(2) = 3.83 to V(16) = 4.78 ms): top-16 +1.17 (+1.09, +1.26), top-8 +0.39; top-1, 2 and 4 stay rejected for always-reuse. The reuse program takes 133-315 us per reuse as one CUDA graph. At c = 8 and 16 the draft is 25% and 20% of the cycle and grows 73 and 55 us per added request: with the even share top-16 stays positive (+0.70, +0.48); one request reusing alone is rejected at every K. Same-session control: the cross-session decomposition holds within 1.5%. Kernel trace at B = 256: the verify kernel is 32.7 ms of the 45.2 ms profiled pass, the conv update 6.5 ms.
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: 2b49f5c8a1
ℹ️ 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".
| cycles = verify_launches / GDN_LAYERS | ||
| per_cycle = {k: v / 1e3 / cycles for k, v in sorted(by_cat.items())} if cycles else {} |
There was a problem hiding this comment.
Count actual verify cycles rather than all verify launches
When the profiling window includes prefill or warm-up work, verify_launches is not necessarily a multiple of the 24 GDN layers, so dividing it by 24 counts those extra launches as fractional decode cycles and understates every per-cycle category. The committed verify_kernels_b256.json demonstrates this: 474 launches produce 19.75 “cycles,” while its 38 state-commit launches correspond to 19 cycles because that kernel runs twice per cycle. Count the real cycle marker (accounting for its two launches) and charge all window kernels to those cycles.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 51a20fb (code) and 31a6a65 (evidence). The trace holds 19 complete cycles (24 verify launches and 2 state-commit launches each) plus a trailing cycle that nsys stop cut off after 18 verify launches. Dividing all launches by 24 charged that fragment as 0.75 of a cycle. Charging everything to 19 commit-delimited cycles instead would have added the fragment's ~25 ms of verify work to the per-cycle cost. nsys_kernels.py now reads the kernel timeline (nsys export to SQLite) and charges only kernels that start before the end of the last state commit, divided by the whole cycles in that span: 456 launches / 24 = 19. It reports the cut-off kernels separately (479 kernels, 34.9 ms) and fails when the span is not a whole number of 24-layer cycles or holds no commit. Per cycle: verify kernel 32.68 ms (unchanged, = 24 x 1.362 ms), conv update 6.48, GEMMs 5.87. Tests: tests/test_repair_nsys_kernels.py.
|
Verdict: REQUEST CHANGES (2b49f5c, 2 blocking, both small; the accounting and every P9 number check out) Checked
Blocking
Pre-commit and |
…omplete cycles The B = 256 trace holds 19 complete verify cycles (24 verify launches and two state-commit launches each) and a trailing cycle that nsys stop cut off after 18 verify launches. Counting 474 launches / 24 = 19.75 cycles charged that fragment as three quarters of a cycle (Codex on #150). The script now reads the kernel timeline from the report's SQLite export, charges the kernels that start before the end of the last state commit to the complete cycles in that span, reports the cut-off kernels separately, and fails when the span does not hold a whole number of 24-layer cycles or no commit at all. Tests cover the truncated tail and both failures.
… the marginal oracle commands verify_kernels_b256.json regenerated with 51a20fb: the 19 complete cycles up to the last state commit, the cut-off trailing cycle (18 verify launches, 34.9 ms) left out. Per cycle: verify kernel 32.68 ms, conv update 6.48, GEMMs 5.87, the rest 2.43. The README states the two _marginal oracle commands in full (review of #150).
|
@codex review |
|
Verdict: APPROVE (provisional, on 31a6a65: Codex is still running on this head, and pre-commit plus 31a6a65 and 51a20fb resolve both items.
|
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Verdict: APPROVE (confirmed on 31a6a65) This confirms my provisional approval. Codex found no issues on this head (19:03 UTC), and pre-commit from main to 31a6a65 is clean. |
…epair tasks done p12_static_screen.provenance.json: the run's commit a05df1d (local, never pushed) recovered from the run worktree's reflog, the scripts' SHA-256 and git blobs, identical at 694c0bc on main, the input hash, lock and time. jacobi_probe_provenance.json copies both probe runs' run.json records (17bbeac and engine 5d8e00e3e1, both clean) with input and trace hashes. TASKS.md: the engine Jacobi task (#165) and the P9 cost task (#150) are done (Codex and review on #165).
…ejections; the measured widths do The free-verify bound rejects none of the tested sets, but the verify measured at each remaining width (#150, already in the notes) still rejects reuse with the top-1, top-2 and top-4 sets. The sentence that said the rejections do not extend to a narrower verify now says which bound it means. Requested by the repair agent.
Evidence from the repair workstream's
session_x2hold (2026-10-01 16:13-16:59 UTC) and the analysis code it needed. It answers four questions left open by #97 and #109: what verifying only the remainder of a reused window costs, what the reuse program costs on the GPU, whether reuse still pays at concurrency 8 and 16, and whether the cross-session verify decomposition (#89) holds within one session. It adds a kernel trace of the B = 256 verify pass.Every timing here uses FlashInfer's GDN verify kernel (
--linear-attn-decode-backend flashinfer, as on the DFlash model card and in the P9 baseline), except the Triton column of the control. SGLang's default on sm_90 is the Triton verify kernel, which the bench's tuned DFlash arms already use, so the FlashInfer-versus-Triton ratios do not stack on tuned DFlash.Results (
evidence/repair/README.md)P9 remainder verify (c = 1). V(B) at B = 2..16 runs from 3.83 to 4.78 ms: two positions cost 80% of sixteen. Charging each reused cycle its measured m + 1 verify, the always-reuse oracle gives top-16 +1.17 (+1.09, +1.26), top-8 +0.39 (+0.31, +0.47), and keeps top-4 (-0.27; -0.39, -0.17), top-2 and top-1 rejected; the omniscient gate bounds any gated program at +2.16 for top-16. Fresh DFlash commits about 10.2 tokens over the two cycles around a boundary, so these are gains of about a tenth (always reuse) and a fifth (perfect gate) on them, as upper bounds under the stated scopes.
Reuse program. The fixed-shape program's messages and greedy walk take 133-315 us per reuse as one CUDA graph, almost independent of rank and batch; eagerly 3.2-5.8 ms.
Concurrency 8 and 16. The draft is 31%, 25% and 20% of the cycle at c = 1, 8 and 16, and the batched draft grows by only 73 and 55 us per added request. At c > 1 one reusing request only removes its own draft row, and the shorter batch period serves every request in the batch. Crediting the request an even share of the batched draft (an upper bound when the draft's cost is concave in rows), top-16 stays positive (+0.70 at c = 8, +0.48 at c = 16). Crediting the measured growth per added request instead, always-reuse by one request is rejected at every K, top-16 included (-0.19 and -0.18), and one reuse step of the program costs more GPU time than the draft row it removes. The omniscient gate still bounds a gated program at +1.27 for top-16.
Same-session verify control. FlashInfer / no per-position states / Triton: 4.78 / 4.60 / 4.57 ms at B = 16 and 44.70 / 40.72 / 19.19 ms at B = 256, within 1.5% of the cross-session values in #89.
Kernel trace at B = 256. Over the 19 complete cycles in the window, the FlashInfer verify kernel takes 1.36 ms per layer (5.3 us per position per layer), 32.7 ms per cycle or 72% of the profiled verify phase; the causal conv update kernel takes 6.5 ms per cycle. Derived, not measured: if the Triton path leaves the conv kernel unchanged, the conv update is about a third of the Triton pass at B = 256.
Code
serve_probe.py: closed-loop concurrency (--concurrency); Nsight options moved tonsys start.analyze_timing.py: batched summary (full-batch cycles, draft share) for c > 1 runs.p9_support_oracle.py:--width-timing(measured m + 1 verify, always-reuse and gated); c > 1 baselines, with--draft-saving-usfor a per-request saving credited c times (the shorter batch period serves every request); the bootstrap is computed with numpy from the same draws, and the regenerated c = 1 JSON equals the committed one to 2e-13 in every shared field.nsys_kernels.py: reads the kernel timeline (nsys exportto SQLite) and charges the kernels up to the end of the last state commit to the whole cycles in that span (verify-kernel launches / 24 GDN layers); a cycle cut off bynsys stopis reported, not charged (Codex r4159272133). Prefill's GDN kernels and normalization kernels get their own categories.p9_program_cost.py,p12_static_screen.pyand the run scripts inexperiments/repair/runs/. The P12 screen's evidence is not in this PR (its shared-lock run is still queued).Validation
tests/test_repair_p9.py(16 tests, including the new width, batched-baseline, draft-saving and bootstrap-equivalence tests) andtests/test_repair_stage_a.py, run in the SGLang venv (torch);tests/test_repair_nsys_kernels.py(3 tests: categories, a truncated trailing cycle, partial windows fail); pre-commit on every changed file.Not covered
The Triton verify kernel's width sweep and kernel trace were not run. The c > 1 oracle takes acceptance from the c = 1 support table. The exact Jacobi probes in the engine (P2) and the P12 screen come in later PRs.
Review
_marginaloracle commands are written out in full (31a6a65); the cycle count as above.