Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
19 KiB
Host round (plan stage 6c): the host work between two verify graphs
Branch claude/host-round, started 2026-11-12. Question: of the 4.30 ms per round that the CUPTI windows put between two verify graphs, which host
microseconds are serial on the critical path, which can be overlapped, removed or moved, and what do the bit-identical ones buy in tok/s?
tok/s = tokens per round / round ms (3.3-3.6 tokens per round, round 17.9 ms at the owner default: 184 tok/s).
1. Sources and how far each can be trusted
| source | what it is | trust |
|---|---|---|
critical-path-67k-existing-windows/between-graphs.md (server, scripts/e2e/codex/speed/between_graphs_report.py) |
CUPTI windows QP/QQ/QT of the 67k replay, release profile set of 2026-11-11, old placement (per-layer quota, PCIe share 0.45) | stage order and GPU/host split are real; every driver call is inflated by the tracer |
docs/experiments/draft-round-5090.md section 2 |
the same host spans untraced (LELEKA_SERVE_PROFILE): commit enqueue 0.004 ms, graph launch 0.008, draft.launch 0.027, about 0.030 ms of host per chain step |
untraced ground truth for the draft |
docs/experiments/step-ledger.md "Launch to first kernel without a tracer" |
a verify-sized graph launched untraced: cudaGraphLaunch returns in 6 us, first kernel within tens of us |
the 1.345 ms of CUPTI between the launch call and the first verify kernel is the tracer's |
| step A of plan 6b for the owner default | the first two jobs (…-default-vs-quota-no-pcie065-and-twin, …-twin-rerun) never started an engine: the arm profile carried LELEKA_SPEC_STATS, which profile_limits.rs refuses; the fix named in the commit message never reached spd_arm_guard.py. No window of the current default existed |
none |
this stage, job decode-host-round-cupti-windows-67k-owner-default-release-83bdd85bb482-and-twin-and-step-profile |
CUPTI windows of release 83bdd85bb4 (owner default, quota=no + PCIe 0.65) with a twin, and one untraced run with the step profile (DBG profile request lines) |
section 3 |
The tracer matters for the ranking: the traced stages draft_launch (0.186) and chain_turn (0.304) are mostly driver-call inflation (untraced about 0.03 +
2.45 x 0.03 = 0.10 ms), verify_launch (1.345) is entirely inflation. What stays real is anything that blocks on a stream or a copy: the PLE staging, the tier-swap wait,
the draft chain's GPU time.
2. Timeline of one round at the owner default (release 83bdd85bb4, quota=no + PCIe 0.65)
Job decode-host-round-cupti-windows-67k-owner-default-release-83bdd85bb482-and-twin-and-step-profile (2026-11-13, pkg ours-pkg-83bdd85bb482, PROVENANCE git_commit
83bdd85bb4, tarball sha256 3837a32b3101b92f2c7da125290fc594e534536bc926b992202468de951ed51c, arm guard ok on all arms, 67k replay nestng-crm-r2, 30 requests):
arm DC.1 and its A/A twin DCT.1, three 15 s CUPTI windows each (over requests 11, 20, 29), and arm DP.1 with the step profile. between_graphs_report.py, rounds pooled over the six windows
(4,075 rounds; the windows differ a lot: graph 19.5 / 14.1 / 11.0 ms and between graphs 5.7 / 4.3 / 3.4 ms by the request's context, so the twins differ by 0.4 ms in the pooled mean):
| # | stage (traced) | ms | DC | DCT | untraced evidence | on the critical path | verdict |
|---|---|---|---|---|---|---|---|
| 1 | verify end -> scan kernels, status D2H, host accept (tail_wake, scan_status, accept_host) |
0.044 | 0.045 | 0.044 | the decision itself is 4 us | serial | scan into the graph tail saves at most 0.04 |
| 2 | commit + round graph launch (draft_launch) |
0.170 | 0.173 | 0.167 | draft.launch 0.009 (DP.1) |
serial | tracer; nothing to win |
| 3 | MTP round graph (draft_round) |
0.595 | 0.591 | 0.598 | GPU-bound | serial | draft kernels (6d) |
| 4 | MTP chain steps (chain_steps) |
1.338 | 1.241 | 1.447 | GPU-bound, 0.473 ms each | serial | draft kernels / fewer steps (6d) |
| 5 | chain turnaround (chain_turn) |
0.327 | 0.306 | 0.349 | about 0.03 ms of host per step untraced (draft-round-5090.md) |
serial | at most 0.07-0.08 real |
| 6 | last draft -> window build (post_draft) |
0.075 | 0.075 | 0.076 | host compute 0.056 | serial | plan, checkpoints, ledger (new spans round.plan, round.checkpoints) |
| 7 | tier-swap wait on stream 70 (swap_wait) |
0.395 | 0.338 | 0.459 | round.apply_pending 0.395 (DP.1) |
serial; 0 in 75 % of the rounds, 1.5-2.2 ms in the swap rounds | placement policy |
| 8 | PLE staging + launch prep (ple_staging, launch_prep) |
0.205 | 0.197 | 0.213 | window.ple 0.206 (DP.1) |
serial | rows are known while the chain runs |
| 9 | verify launch call -> first verify kernel (verify_launch) |
1.230 | 1.218 | 1.244 | untraced launch 6 us (microbench) | serial in the trace only | tracer artefact |
| between graphs | 4.380 | 4.185 | 4.598 | graph 14.62 ms pooled |
Untraced (DP.1, profile spans, ms per round, 13,778 rounds, T 4.44 rows, 3.69 tokens per round): round.apply_pending 0.395, window.ple 0.206, window.verifier 14.997, draft.finish 1.955
(the host waiting for the draft chain), round.draft_committed 2.441, commit.wait 0.095 + commit.publish 0.113 + round.adapt_deferred 0.267 (all three hidden under the round graph), draft.launch 0.009;
round.verify_commit 15.616 + round.finish 2.444 = 18.06 ms per round. So of the 4.38 ms the traced timeline shows, the host-attributable serial part that survives the tracer is
the swap wait (0.395) and the PLE gather (0.206): 0.60 ms, 3.3 % of the round, plus about 0.15 ms of chain turns, window build and accept that no overlap can remove entirely.
Overlapped and therefore not on the path: the commit graph (0.126 ms, ends about 2 ms before the draft), the controller's bookkeeping under the round graph (0.47 ms of 0.6 ms), the tier-swap copies that fit under the chain.
3. Untraced ground truth (host spans of LELEKA_SERVE_PROFILE, ms per round)
Existing profiled runs, pkg-s18, 67k replay, old placement (host-pcie-share-higher-probes-profile, arms AP = share 0.45, Q65 = share 0.65, 2 blocks each,
read with host_round_spans.py): round.apply_pending 0.39 / 0.37, window.ple 0.195 / 0.196, draft.finish 1.97 / 1.91 (the host waiting for the chain), round.verify_commit 17.1 / 15.4,
round.draft_committed 2.32 / 2.25, commit.wait 0.093, commit.publish 0.128, round.adapt_deferred 0.114 (all three hidden under the round graph), draft.launch 0.012, tokens per round 3.66 / 3.54.
So the real serial host cost between two verify graphs is the swap wait (round.apply_pending, 0.39 mean, about 1.5 ms in the quarter of rounds that swap) and the PLE gather
(window.ple, 0.195, 0.035 ms per row), not the draft launches the tracer inflates.
4. LELEKA_PLE_ON_CHAIN (bit-identical, switch off by default)
Row k of the next window needs its token and the two before it. The accepted token is known when the draft launches, draft id j when chain step j has been read back.
The host sits in cuStreamSynchronize behind every step (0.47 ms of GPU each), so it now gathers every row whose token is known right after it has enqueued the next step:
OriginalMtpDrafter::finish_chain calls a host closure (while_gpu_drafts(known ids)) between the enqueue and the read-back of every step (and once before the round graph is read back);
OriginalServeHost::finish_draft passes PleOnChainWork::gather_known, which asks KarPleCache::gather_ahead for the row. The cache keeps the decoded values keyed by the sixteen row numbers
and the window's own gather takes them (ple.ahead_hit); only the last draft's row is gathered after the chain.
- Same values: the decoded value of a row depends only on its packet (
kar_ple_cache.rs), the window asks for exactly the same sixteen rows, and a row nobody asks for is only dropped.LELEKA_PLE_ON_CHAIN=verifyalso gathers every taken row directly and compares all 2560 floats bit for bit (leleka-ple-on-chain: MISMATCHon a difference). - No serial wait on the draft: the gather's copies and kernel run on the legacy default stream and end with
cuStreamSynchronize(0)instead of the context-widecuCtxSynchronizethat everyDeviceBuffercopy and fixed kernel ends with (compute_drain::LocalDrain, thread-local, only alive inside the hook; all streams of the crate are NON_BLOCKING, so the default stream does not order itself against the draft stream). - Swap rounds: a small host-to-device copy queued behind tier-swap copies waits for the copy engine, which is what made the 2026-10-31 attempt (
claude/round-overlap, row 0 only, neutral) hold the host up while it should launch the next step. The hook therefore does nothing while the swap batch's event has not completed (OriginalExpertCache::swap_copies_running, a read-onlycuEventQuery); a later call catches up once the copies are done. - Default path unchanged: with the switch off the hook is a no-op closure; the chain-step refactor (generic closure instead of a dyn,
run_chain_step, the pipelined chain in its own file) moves no kernel.
New profile spans: ple.ahead (host time in the hook), ple.ahead_hit (rows taken from the cache), round.plan, round.checkpoints, round.adopt.
Sectional delta (job decode-ple-rows-on-chain-vs-default-step-profile-pairs, package 22d9689e73, PROVENANCE git_commit 22d9689e73, tarball sha256 4fc6ef4f...)
67k replay (nestng-crm-r2, 30 requests, first 3 dropped), step profile in both arms, three blocks each, order DP WP WP DP DP WP, arm guard ok on all six
(the WP engine logs carry leleka-serve ple-on-chain: mode=On, the DP logs none; expert tier adaptation: every 4 rounds, up to 96 swaps in all). host_round_spans.py, ms per round, paired difference WP - DP over 3 blocks:
| span | DP | WP | difference | +-95 % | spread of the DP blocks |
|---|---|---|---|---|---|
window.ple (serial PLE gather before the window) |
0.194 | 0.060 | -0.134 | 0.002 | 0.001 |
mtp.finish_first_step (host waiting for the round graph) |
0.355 | 0.306 | -0.049 | 0.004 | 0.001 |
ple.ahead (host time in the hook, hidden under the draft) |
- | 0.152 | |||
ple.ahead_hit rows taken from the cache per round |
- | 3.1 of 4.4 rows | |||
GPU time of one chain step (gpu.mtp_chain_step / calls) |
0.459 | 0.459 | 0.000 | ||
host wall of one chain step (mtp.chain_step / calls) |
0.486 | 0.485 | 0.000 | ||
round.apply_pending |
0.384 | 0.402 | +0.018 | 0.034 | 0.023 |
| tokens per round | 3.55 | 3.66 | +0.11 | 0.32 | 0.04 |
The hook is hidden: a chain step costs the same with and without it (0.485 ms host, 0.459 ms GPU), draft.finish grows only with the number of steps the adaptive window chose
(3.15 -> 3.26-3.38 steps per round in the WP blocks), and the round graph's wait shrinks by the row it gathers. The serial gain is therefore the 0.134 ms of window.ple
(70 %: the last draft's row and the rows skipped while swap copies run stay). Paired end-to-end numbers of the same job, 3 blocks (ab_report.py): decode tok/s 203.8 -> 206.2
(+1.2 %, CI -1.6..+4.0 %), ms/round +0.34 (CI -4.6..+8.5 %), tokens per round +0.11 (CI -5.9..+12.3 %): they resolve nothing, the adaptive window moves tokens per round by
more than the 0.134 ms (0.75 % of a 17.4 ms round) is worth. 0.134 ms at 17.4 ms per round and 3.55 tokens per round is +1.4 tok/s (+0.75 %).
5. Tier-swap wait (placement policy; not a default before the control gate)
round.apply_pending is OriginalServePool::apply_pending -> OriginalExpertCache::wait_swaps (LELEKA_SERVE_SWAP_WAIT, default wait): the swap copies of the previous round's adaptation
must land before the next window, so that they do not read host memory while the CPU pool streams its experts (job 803) and the resident set does not depend on when the copies finished.
A swap round (every 4th) queues up to 96 swaps = 172 host-to-device copies = about 3.3 ms of copy engine time, started 0.3-0.5 ms into the draft, which lasts 2.2-2.4 ms:
1.5-2.2 ms of the copies outlive the draft and the host waits for them (0.35-0.40 ms per round on average, 0.395 in DP.1 of the owner-default release).
Proposal (no code, two existing environment variables): adapt every 2 rounds with up to 48 swaps (T): the same swap throughput per round, in bursts of about 1.65 ms that fit under the draft.
Arm TW (every 2, still 96 swaps: twice the throughput) is the "PW" arm of the 2026-11-12 slots/adapt A/B, re-measured on the owner-default placement.
Job decode-tier-swap-bursts-every2-swaps48-vs-default-step-profile-pairs (package 71354841ed, PROVENANCE git_commit 71354841ed, tarball sha256 1b0cdbf0..., arm guard ok on
all 12 arms, the engine's expert tier adaptation: every N rounds, up to M swaps line equals the arm), block 1 with the step profile, blocks 1-3 without:
| arm | round.apply_pending ms per round (block 1, profile) |
decode tok/s (3 blocks) | vs D | ms/round | tokens/round | VRAM share of routed experts |
|---|---|---|---|---|---|---|
| D (4 rounds, 96) | 0.351 | 206.80 | 17.38 | 3.59 | 90.97 % | |
| T (2 rounds, 48) | 0.098 | 209.96 | +1.53 %, CI +0.26..+2.79 % | 17.37 (-0.01, CI -5.7..+5.6 %) | 3.65 | 91.00 % (+0.04) |
| TW (2 rounds, 96) | 0.331 | 209.77 | +1.43 %, CI -0.67..+3.54 % | 16.89 (-0.49, CI -12..+6.4 %) | 3.54 | 91.43 % (+0.46, CI +0.19..+0.83) |
T removes 0.25 ms of wait per round (-72 %) and the decode gain (+3.2 tok/s) is the size of that (1.4 % of the round). TW keeps the full copy burst, so its wait stays (0.331) and its gain comes from twice the swap throughput (VRAM share +0.46 points), as in the earlier A/B; T and TW are equal in decode tok/s (-0.09 %, CI -2.8..+2.6 %). As always for the adaptive tier, byte-identical requests are 4-5 of 90 per pair (placement noise); the quality verdict is the teacher-forced control gate.
Control-relative placement gate of the tier bursts (job decode-tier-swap-bursts-placement-gate-teacher-forced-owner-default-vs-every2-swaps48-vs-every2-swaps96-vs-pcie-share-055-control)
Teacher-forced night5-long-256k (5 requests to 243k, 240 forced tokens each, top-16 logprob rows, adaptive tier ADAPT 4, EXPERT_SLOTS 8000), ONE test binary (rt-host-round-ple-on-chain-71354841ede0, sha256 1af19f5b...,
MANIFEST.sha256 checked), reference idP1 = the owner-default placement (quota=no, PCIe share 0.65); the A/A floor (arm I2 against arm I1) is 0 in all four processes (2069 / 2065 / 2053 / 2041 rows identical, 0 flips).
Each candidate against the reference, arm I1 (arm I2 gives the same numbers):
| process | change | common rows | argmax flips | d_top1 p99 | d_top1 max | draft trace |
|---|---|---|---|---|---|---|
| idP2 | T: adapt every 2 rounds, up to 48 swaps | 1788 | 31 (1.73 %) | 0.1915 | 0.796 | differs by construction (placement) |
| idP3 | TW: adapt every 2 rounds, up to 96 swaps | 1770 | 40 (2.26 %) | 0.2010 | 0.371 | differs |
| idP4 | CONTROL: PCIe share 0.55 (an ordinary placement change) | 1731 | 29 (1.68 %) | 0.2062 | 0.398 | differs |
Rule of ledger H4 (q_tail_gate --control): p99, max and flip rate each <= 1.25 x the control's, i.e. p99 <= 0.258, max <= 0.497, flips <= 2.09 %. Against this control T passes p99 and flips but its single-row max
is 0.796 (one row; the max of a placement change is heavy-tailed: the 2026-11-12 controls on the old placement gave 0.746 and 0.665 with the same p99), TW passes p99 and max but its flip rate is 2.26 % against the limit 2.09 %.
Read against the worst of the earlier controls (p99 0.224, max 0.746, flips 2.56 % -> limits 0.28 / 0.93 / 3.2 %) both pass. Verdict: not a clean pass against a single control, so neither is a default. The spread of
the control itself is the open question: job decode-tier-swap-bursts-placement-gate-more-controls-owner-default-pcie-share-075-and-035 adds the shares 0.75 and 0.35 against the same reference (queued).
6. Cumulative paired A/B: PLE rows on the chain + tier bursts T against the default
Job decode-host-round-cumulative-ple-on-chain-plus-tier-bursts-vs-default-paired-ab-5-blocks-with-twin (package 71354841ed, PROVENANCE git_commit 71354841ed, tarball sha256
1b0cdbf0b448cd83ace0c22e31a90526481811d97d36d9bbefe92c43c7101943, arm guard ok on all 15 arms, no profile, 67k replay nestng-crm-r2, 30 requests, first 3 dropped = 27 per block, five blocks, orders rotated):
D = the default of this build, DT = its A/A twin, C = LELEKA_PLE_ON_CHAIN=on + adapt every 2 rounds with up to 48 swaps. ab_report.py, paired differences over 5 blocks:
| comparison | decode tok/s | end-to-end tok/s | tokens/round | ms/round | VRAM share |
|---|---|---|---|---|---|
| C against D | 206.23 -> 211.80, +5.57 +- 0.78 (+2.70 %, CI +2.32..+3.08 %) | 186.90 -> 191.31, +2.36 % (CI +0.18..+4.54 %) | 3.55 -> 3.66 (+3.2 %, CI -3.5..+9.7 %) | 17.19 -> 17.27 (+0.45 %, CI -5.8..+6.7 %) | 90.90 -> 90.91 |
| A/A floor: DT against D | 206.23 -> 207.30, +1.07 +- 1.28 (+0.52 %, CI -0.10..+1.14 %) | +0.93 % (CI -1.0..+2.9 %) | +2.1 % (CI -3.1..+7.4 %) | +1.60 % (CI -3.2..+6.4 %) | -0.17 |
| C against the twin DT | 207.30 -> 211.80, +4.50 +- 0.81 (+2.17 %, CI +1.78..+2.56 %) | +1.42 % (CI +0.56..+2.27 %) | +1.0 % | -1.13 % | +0.17 |
The decode gain is resolved above the A/A floor against both bases (CI of C against DT excludes 0 and the +0.52 % of the twin). ms/round and tokens/round do not resolve: the adaptive window moves tokens per round by more than the 0.4 ms the change is worth (the byte-identical requests are 7 of 150, placement noise as in every adaptive-tier A/B). Parts: PLE rows on the chain -0.134 ms measured sectionally (+0.75 %), the tier bursts -0.25 ms of swap wait (+1.5 %, section 5). 17.19 ms per round and 3.55 tokens per round are 206 tok/s in this replay (the e2e sessions are 184 tok/s at the owner default: tok/s = tokens per round / round ms holds for each).
7. What is left of the 4.38 ms (untraced, per round)
| item | ms | kind |
|---|---|---|
| draft round graph + chain steps (GPU) | 1.8-2.0 | 6d / kernels |
| host turn of a chain step (27 us x 3.2 steps) | 0.085 | needs a device-side stop rule; the untraced cost is below what the on-device chain (0.08) was expected to save, no work done |
| swap wait with T (0.098 measured, 0.395 at the default) | 0.098 | the copies of the longest chains still outlive the draft; a burst sized by the measured draft time would take the rest, placement class |
| PLE gather of the last draft's row (+ rows skipped while swap copies run) | 0.060 | the token is known only at the end of the chain |
| scan, status, accept, wake | 0.044 | scan + status into the verify graph tail: at most -0.04 |
window build, ledger, launch prep (round.plan, round.checkpoints, round.adopt are 0.001 each) |
~0.03 | nothing to move |
| commit wait + publish + deferred adaptation | 0.47 | hidden under the 0.6 ms round graph |
The bit-identical host items that remain add up to about 0.1-0.15 ms (under 1 %). The 220 tok/s target (+19 % over 184) cannot come from this stage: the host between two verify graphs is 2.6 ms of GPU-bound draft plus about 0.5 ms of host work that is now mostly overlapped; the verify graph (13-15 ms, of which 3.8 ms are waits for the CPU/PCIe rows) and the tokens per round are where the milliseconds are.