Skip to content

Backbone: served exactness of each switch and paired plain serving of the routing table - #153

Merged
SamMausberg merged 7 commits into
mainfrom
backbone/served-exactness
Oct 1, 2026
Merged

SamMausberg merged 7 commits into
mainfrom
backbone/served-exactness

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

PR #91 added the backbone microbenchmarks and the opt-in engine patch series (engine/sglang/patches/backbone/0001-0008), but left two things pending: how each engine switch changes served outputs, and what the routing table does to served throughput. This PR adds both for plain decoding, plus the hold-2 GPU tests and the last two norm-folding variants. Results and commands: evidence/backbone/README.md, "Served results".

Exactness of each switch (greedy outputs against stock plain decoding)

The setup is the state-safety runner with 320 prompts, 256 tokens and top-5 logprobs (radix cache, overlap and CUDA graphs on). compare.py classifies each prompt's first divergence.

Switch Pools, concurrency Prompts that diverge Per 1,000 tokens tie / one step / near / large Class
every switch off unpinned, c = 1 0 / 320 0 - bitwise: same token ids and top-5 logprob arrays on 320/320
SGLANG_BACKBONE_MERGE_IN_PROJ=1 (packed GDN in_proj from 64 rows) unpinned, c = 1 0 / 320 0 - bitwise, 320/320 (prefill path)
--bf16-gemm-backend gemv (SGLang's policy) unpinned, c = 1 174 / 320 3.75 164 / 8 / 2 / 0 exact up to rounding
lever v1 (routing table + PDL + merge) pinned cap 8, c = 1 161 / 320 3.40 157 / 3 / 1 / 0 exact up to rounding
lever v1 pinned cap 8, c = 32 (M = 1-8 decode) 174 / 320 3.82 167 / 6 / 1 / 0 exact up to rounding

These are compared with the same runner's reference pairs:

  • Unpinned, cap 16: a stock fresh-server repeat gives 0, and stock at c = 1 against c = 32 gives 3.42 per 1,000 tokens.
  • Pinned, cap 8: a fresh-server repeat gives 0 at c = 1 and 0.06 at c = 32; c = 1 against c = 32 gives 0.63.

"Bitwise" is checked on the raw runs by experiments/backbone/bitwise_runs.py (served/bitwise_*.json): each prompt's full output_ids and top_logprobs arrays are compared. The stock fresh-server repeat at c = 1 is also bitwise on 320/320. Gemv and lever v1 keep the tokens of 146-159 prompts, but no prompt keeps all its logprob values. No run commits a token that is not its own top-1, and the largest margin at a divergence is 0.25 nats. The unpinned servers' KV pools ranged from 93,544 to 160,610 tokens. No prefill reused a cached prefix, and two stock servers with different pools return the same token ids and top-5 logprob arrays on all 320 prompts at c = 1, so at c = 1 pool size did not enter.

The lever's first run in shared1 never started. With other shared servers resident, the old unpinned runner got running caps of 15 and 3 and retried while holding the lock. The rerun uses main's pinned runner with its 52 GB start gate, under timeout --foreground, with a trap that stops the server's own session.

Paired serving, lever v1 against tuned plain decoding

  • Setup: one exclusive hold, order B A A B, bench's harness and confirmation split, 512 output tokens. Both arms ran the backbone engine; A has every switch off.
  • CPU load: foreign CPU averaged 0.31-0.50 cores per point, and no point is invalid.
c B/A, the two pairs A1-A2 spread Decode step (derived)
1 1.035, 1.034 0.07% -116 us (the microbenchmarks bound it at 197 us)
8 1.004, 1.004 0.26% -10 us (the microbenchmarks predict about 90-98 us)
32 1.003, 1.001 0.11% no claim: every decode GEMM stays on cuBLAS at M = 32
128 1.010, 1.010 0.02% -86 us; only the packed in_proj changes, and its microbenchmark predicts 81 us

The c = 8 gap, a tenth of the microbenchmark prediction for the Triton + PDL route, is stated but not explained. The pending in-situ trace is meant to explain it.

Also in this PR

  • experiments/backbone/insitu_gemm.py (committed before its evidence) labels each decode-graph replay of an nsys window. For each projection it reports which implementation ran (cuBLAS, Triton or GEMV), the summed kernel time and the replay span. It keeps only replays with the graph's full kernel count and drops the first and last (Codex r4159430831; same rule as check_labels.py). It was tested on two of the profile workstream's stock reports; no evidence from it is committed yet. tests/test_backbone_served_tools.py tests the replay filter and bitwise_runs.py on the CPU (6 passed).
  • gpu_tests_hold2.log: tests/test_backbone_gemm.py at Backbone GEMMs and RMSNorm: microbenchmarks, a skinny GEMM and an opt-in engine patch series #91's head, 25 of 25 passed on the GPU. This includes the merge-cutoff and Hopper-gate tests that had not run on a GPU before Backbone GEMMs and RMSNorm: microbenchmarks, a skinny GEMM and an opt-in engine patch series #91 merged.
  • chain_fold_variants_microbench.json: the scaled-norm prologue (patch 0005) and the SiLU-only fold. Every variant loses at every M from 1 to 16 (103-257 us against 31-52 us per layer, except the SiLU fold at M = 1, which ties). Folding is closed as a negative result.
  • README.md, evidence/README.md and engine/sglang/README.md now give these results instead of "pending".

Not covered

  • Serving against tuned MTP.
  • The nsys trace of plain decoding with and without the lever at c = 1 and 16 (hold 3, exclusive, queued). M = 16 is DFlash block 16's verify shape at c = 1, which the stack workstream's G arm uses.
  • The packed projection in decode: at c = 1 decode stays below its 64-row cutoff, so its served bitwise result covers prefill only.
  • The lever's Triton route at M = 9-16: the pinned c = 32 pass caps decode at 8 rows.
  • DFlash equality, which the stack workstream's equality hold runs.

Hold 3's results (MTP serving and the trace) will come in a separate pull request, so this one can be reviewed as it stands.

Review rounds

  • Head 3347ec2:
    • Reviewer (blocking): "bitwise" rested on drift = 0, which ignores entries below -4 nats. Fixed in a76bc4c: bitwise_runs.py checks the full arrays, and the README and PR scope each bitwise claim to that comparison (which prompts, concurrency, pools).
    • Reviewer (suggestion): fold range in this body corrected.
    • Codex r4159430831 (P2), partial boundary replays in insitu_gemm.py: fixed in 9f9f878, with a test.

… reports

insitu_gemm.py labels each target decode-graph replay of a plain-decoding nsys
window with the profiling workstream's attribute.label_all and splits every
weight-GEMM kernel by implementation (cuBLAS, the backbone Triton kernel, the
Hopper GEMV). It reports the median replay span and summed GEMM time per
projection, so the served engine's routes can be compared with the layer
skeletons' prediction.
Greedy outputs on the state-safety prompt set against stock plain decoding:
with every switch off and with the packed GDN input projection the outputs
are bitwise equal on all 320 prompts at concurrency 1; SGLang's Hopper GEMV
backend (3.75 divergences per 1,000 tokens) and the routing table lever v1
(3.40 at c = 1 and 3.82 at c = 32, pinned pools, cap 8) are exact up to
rounding, every first divergence a tie, one BF16 step or near.

Paired B A A B serving against tuned plain decoding in one exclusive hold:
lever v1 is 3.4% faster at c = 1 and 1.0% at c = 128 (the packed projection's
predicted 81 us per step against 86 us served), and 0.4% at c = 8, about a
tenth of what the microbenchmarks predict for the Triton route there; why is
not yet traced. The GPU tests of PR #91 pass on the GPU (25 of 25), and the
scaled-norm and SiLU-only folding variants lose at every M from 1 to 16.
@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-01T19:18:41.539408Z a76bc4c 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.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (3347ec2, 1 blocking: the "bitwise" claims rest on a drift statistic that does not cover every top-5 logprob)

Checked: everything else is right.

  • Exactness tables. Every row matches served/exactness_c1_unpinned.json and exactness_lever_v1_pinned.json: 0, 3.42, 0, 0, 3.75; and 0, 0.06, 0.63, 3.40, 3.82.
    • All events are tie, one step or near, with no large. The largest margin is 0.25 nats, and self_consistency shows no not_argmax in any run.
    • Each class is set against the matching floor and cap: gemv's 3.75 against 3.42 at cap 16, and lever v1's 3.40 and 3.82 at five to six times the cap-8 floor of 0.63, which the README states, along with the dependence on the cap.
  • Paired serving. It matches served/plain_v1/pairs.csv and points.csv:
    • B/A is 1.0336 and 1.0353 at c = 1, 1.0037 and 1.0042 at 8, 1.0013 and 1.0027 at 32, and 1.0098 and 1.0102 at 128;
    • 16 points over two sessions, none invalid, foreign CPU 0.31-0.50.
    • The README says "two pairs from one session", makes no claim at c = 32, and states the c = 8 shortfall against the 90-98 us prediction as not yet known, without inventing a cause.
  • GPU tests. gpu_tests_hold2.log shows 25 passed, and the README names 50978e2 with engine 59deb68e29.
  • Folding. The fold-variant table matches chain_fold_variants_microbench.json, and the scaled prologue at 2.2-3.8 times stock is right. Folding is reported as a measured loss.
  • insitu_gemm.py comes in before any evidence from it.
  • Host identity: 0 hits. Attribution: clean.

Blocking: "bitwise" (off, merge, and the two stock servers with different pools).

Suggestion (PR body only). "111-257 us against 33-52 us" misses the SiLU fold's 102.6-110.4 us at M = 2-16 and the GDN Triton rows' 30.8 us. The README's table is right. Write "103-257 us against 31-52 us".

Codex is still running on 3347ec2. Pre-commit runs in the CPU window on the fix head.

compare.py's logprob drift covers only shared top-k entries above -4 nats, so
it cannot show that two runs return equal top-5 logprob arrays. bitwise_runs.py
compares the output token ids and the full top-k arrays of every prompt and
fails on a missing run or mismatched prompt sets.

@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: 3347ec2875

ℹ️ 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/backbone/insitu_gemm.py Outdated
Comment on lines +71 to +72
for i, corr in enumerate(kept['corr']):
seq = in_graph[in_graph['corr'] == corr]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude partial boundary replays before summarizing

When Nsight collection begins or ends in the middle of a graph replay, kept still includes that truncated replay; the existing experiments/profiling/check_labels.py explicitly drops boundary replays for this reason. If the first replay is partial, the i == 0 branch publishes incomplete kernel counts and names, while the span and timing aggregates also include partial data, potentially misreporting which implementation the served engine dispatched. Filter to complete replays before this loop and select the count exemplar from that filtered set.

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 9f9f878. complete_replays() keeps only replays with the graph's full kernel count, then drops the first and last of them, as check_labels.py does. The count and name exemplar is taken from the kept set, and the medians use only kept replays. tests/test_backbone_served_tools.py covers a replay cut at each end and a missing replay.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Update to my verdict on 3347ec2 (still REQUEST CHANGES): Codex's comment r4159430831 is valid. Add it to my one item.

insitu_gemm.py keeps the replays that nsys collection cuts at the start or end of the window. A partial first replay then becomes the exemplar for kernel counts and names, and partial data enters the span and time totals. experiments/profiling/check_labels.py already drops boundary replays for this reason.

Filter to complete replays before summarizing, take the exemplar from that set, and add a test with a truncated first and last replay. No evidence from this script is committed yet, so this is the moment to fix it.

…tools

Codex on 3347ec2: a replay cut by the nsys window could set the kernel
counts and names and enter the medians. complete_replays keeps only replays
with the graph's full kernel count and then drops the first and last, as
check_labels.py does; the exemplar comes from the kept set. pandas is now
imported only where a report is read, so the filter and bitwise_runs.py have
CPU tests (tests/test_backbone_served_tools.py).
Reviewer on 3347ec2: identical tokens with zero drift do not show equal top-5
logprobs, since compare.py's drift ignores entries below -4 nats. bitwise_runs.py
now compares the full output_ids and top_logprobs arrays: off, merge and the
stock fresh-server repeat are equal on all 320 prompts at concurrency 1;
gemv and lever v1 keep the tokens of 146 to 159 prompts but no prompt's full
logprob arrays. The README scopes each bitwise claim to that comparison.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a76bc4c57a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on a76bc4c: Codex has not yet reviewed this head, and pre-commit and the new tests are queued in the CPU window. I will confirm or withdraw once both finish.)

a76bc4c resolves both items from my review of 3347ec2.

  • Bitwise on the raw runs. experiments/backbone/bitwise_runs.py (committed at d482ec7, before the two JSON files) compares each prompt's full output_ids and top-5 top_logprobs arrays. It refuses runs that cover different prompts or that lack logprobs. I reran it on the raw runs under ~/vp-data/backbone/compare/{unpinned,pinned} with the committed pairs files, and both outputs match the committed served/bitwise_c1_unpinned.json and served/bitwise_lever_v1_pinned.json pair for pair.
  • Table and text. The new "Bitwise-equal prompts" column matches the JSONs: 320/320 for the stock repeat, off and merge; 312 and 245 for the pinned floors; 0 for c1 against c32 at cap 16, gemv and both lever passes. Equal token ids (153, 146, 316, 279, 159 and 146) are 320 minus each row's divergent prompts. The claims are now scoped to 320 prompts at concurrency 1 and to token ids plus top-5 logprobs, in this README, README.md and engine/sglang/README.md. The merge claim's "more than half of the set" follows from the manifest's median of 78 input tokens.
  • Codex r4159430831. insitu_gemm.py keeps only replays of the modal graph with its full kernel count, drops the first and last of those, and exits when none remain. Two tests cover this. No insitu_gemm output is committed yet (the README still calls it pending), so no evidence needs regenerating.
  • No hostname or IP, no AI attribution in the three new commits.

Optional: a few rewritten lines in evidence/backbone/README.md (the merge bullet, the gemv/lever bullet) and in engine/sglang/README.md run well past the file's wrap width.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (confirmed on a76bc4c)

This confirms my provisional approval. Codex found no issues on this head (19:18 UTC), pre-commit from 0f890a0 to a76bc4c is clean, and tests/test_backbone_served_tools.py passes (6 tests).

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