From d735a793b8cd4300e41bd380bec2f45ddbecd205 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 13 Nov 2026 00:38:21 +0100 Subject: [PATCH] host-round doc: untraced ground truth and the PLE-on-chain design Co-Authored-By: Claude Sonnet 5.5 --- docs/experiments/host-round.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/experiments/host-round.md b/docs/experiments/host-round.md index 9911e97b..c9cbc5fa 100644 --- a/docs/experiments/host-round.md +++ b/docs/experiments/host-round.md @@ -35,4 +35,32 @@ the draft chain's GPU time. 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=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