Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
7.3 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 (traced, old placement; QP, ms per round, mean of 770 rounds)
| # | stage | ms | critical path | GPU while it runs | verdict |
|---|---|---|---|---|---|
| 1 | verify end -> scan kernels, 4-byte status D2H, context sync, host accept | 0.045 | serial | idle 0.041 | accept decision itself 4 us; scan into the graph tail saves at most 0.04 |
| 2 | commit graph + round graph launch | 0.186 (untraced 0.031) | serial | commit graph 0.124 beside it | tracer; nothing to win |
| 3 | MTP round graph | 0.595 | serial, GPU-bound | busy | draft kernels (6d), not host |
| 4 | MTP chain steps (2.45 per round) | 1.160 | serial, GPU-bound | busy | draft kernels / fewer steps (6d) |
| 5 | chain turnaround: D2H of id and probability, stop rule, step launch | 0.304 (untraced 0.074) | serial | idle 0.195 traced | device-side chaining would remove at most the untraced 0.07 |
| 6 | last draft -> window build | 0.087 | serial | idle 0.068 | host compute 0.060: plan, checkpoints, ledger; see section 3 spans |
| 7 | tier-swap wait on copy stream 70 | 0.371 mean, 1.48 in the 25 % swap rounds | serial | copies only | placement policy (section 5) |
| 8 | PLE staging for the next window's rows + launch prep | 0.207 | serial | idle | rows are known while the chain runs: this stage's work (section 4) |
| 9 | verify graph launch to its first kernel | 1.345 | serial | idle | tracer artefact |
Overlapped and therefore not on the path: the commit graph (0.126 ms, ends 2.1 ms before the draft), the controller's bookkeeping under the round graph (0.25 ms of 0.595), 0.45 of the 0.83 ms of tier-swap copy time per round.
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.
RESULTS_PLACEHOLDER