Files
leleka/docs/experiments/host-round.md
T
2026-11-13 06:47:40 +01:00

9.1 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=verify also gathers every taken row directly and compares all 2560 floats bit for bit (leleka-ple-on-chain: MISMATCH on 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-wide cuCtxSynchronize that every DeviceBuffer copy 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-only cuEventQuery); 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