ledger: Q6 refill deferral on top of the default set (no gain), batch copy plan
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bf13908627
commit
cdb0958b6d
@@ -38,7 +38,7 @@ No per-step figure exists for A1-A3; each is a `not measured` row that needs a s
|
||||
| Q5 | `moe.ring` in a small tail (72-80 % of the chunk, 48 layers x 7.4 ms, 355 ms for 238 tokens) | 355 ms | vanilla reads tails of up to 64 tokens through verify windows | +355 ms for the smallest tails. Root cause: `prompt_options` (`original_serve_stack_prefill_phase.rs`) sets `force_batched: true`; the planner already emits `PromptPath::Verify` actions for tails <= 64 tokens but the executor's `verify_window` hook (`original_prompt_executor_drop.rs:63`) is not implemented | PROFILE `prof-l5` | hex-finish | fixing (design pending) STREAM THRESHOLD 2026-11-10: vanilla streams every non-resident expert (overlapped with the mixers) from 1024-row chunks (`kStreamAllMinDefault`), ours from 4096 (`STRATA_PREFILL_STREAM_MIN`, `settings/kv.rs`, set when the expert cache was off and only 60 % of the experts were routed). Profile `prefill-expert-stream-from-1024-rows-profile` (shipped / 1024 / 256, 15 requests): prefill.read at tails 2,837 / 2,622 / 2,453 / 1,602 / 1,454 tokens 1129 / 1029 / 1001 / 782 / 799 ms became 876 / 863 / 818 / 702 / 702; no change below 1,300 tokens, worse from 256 rows (279 tokens 465 to 747). Threshold 1536. Job `prefill-expert-stream-from-1536-rows-identity-and-profile` (30 requests): PREFILL-R chunk residual hashes IDENTICAL, 31 of 31 (shipped vs stream), no failures; prefill.read by tail class (mean ms, shipped to stream): < 1000 tokens 530 to 521 (-9), 1000-1536 723 to 729 (+6), 1536-4096 1010 to 830 (-180, -17.8 %), > 4096 1245 to 1280 (+35, noise); over 29 warm requests -45 ms per request (prefill.phase 921 to 877). `STRATA_PREFILL_STREAM_MIN=1536` is set in the three 5090 profiles (not the 3080: tier off there, different trade). Two more levers remain (not done): the prefetch of Q4 and vanilla's CPU share (lossy, off in the reference arm). |
|
||||
| B1 | prefill GDN and QSA stages of a small tail (per stage split) | `prof-l5/Q.1` has moe, moe.ring, gdn, qsa, input per chunk | none for vanilla | n/a | PROFILE | hex-finish | open |
|
||||
| B2 | first token sampling and publication after prefill | not measured | not measured | n/a | none | hex-finish | open |
|
||||
| Q6 | `prefill.refill` of the lent expert slots (2,226 copy spans) | 137-140 ms per request | none | +138 ms; deferring it into the decode assembly (`LELEKA_REFILL_DEFER`): decode -0.92 % (CI -1.63..-0.21), end-to-end +0.56 % (CI -0.15..+1.27) | PROFILE, A/B `ab-l5v2` | hex-finish | fixing |
|
||||
| Q6 | `prefill.refill` of the lent expert slots (2,226 copy spans) | 137-140 ms per request | none | +138 ms; deferring it into the decode assembly (`LELEKA_REFILL_DEFER`): decode -0.92 % (CI -1.63..-0.21), end-to-end +0.56 % (CI -0.15..+1.27) | PROFILE, A/B `ab-l5v2` | hex-finish | fixing PROFILE 2026-11-10 (job `prefill-refill-deferred-with-default-set-profile`, default set + stream 1536, YP without / YRP with `LELEKA_REFILL_DEFER`, 14 warm requests each): `prefill.refill` 93.9 vs 70.7 ms and `refill.sync` 23.3 vs 23.3, `refill.queue` 70.0 vs 70.2 ms (the host time to issue the copies stays, now behind the decode assembly); `decode.reuse` 13.0 vs 13.0; wall per output token 5.95 vs 6.01 ms (sums 155.0 vs 154.7 s, 26,047 vs 25,729 tokens): no gain from the deferral on top of Q7 (the host assembly it overlapped with is 13 ms now, not 98). The cost is HOST issue of about 1,000 slots x 3 `cuMemcpyHtoDAsync` = 70 us per slot; plan: one `cuMemcpyBatchAsync_v2` per few hundred copies (driver 595.99 exports it), bitwise (same bytes and order), switch `LELEKA_REFILL_BATCH` off, in progress as a sub-agent branch (host-side tests + ignored GPU test); expected -50..-60 ms per request. `LELEKA_REFILL_DEFER` stays off. |
|
||||
| Q7 | `decode.assemble` (graph re-recording per request: `record_all` 83 ms of 98-109 ms, nine graphs, 54-62 capture + 27-30 instantiate) | 98-109 ms per request | none (vanilla keeps its graphs) | +98-109 ms | PROFILE | both | fixing (code 7570247d9, wired behind `LELEKA_DECODE_GRAPH_REUSE`, identity and section delta pending on the GPU): the speed session's handles, `park`/`rearm`/`reseed` and this side's key, `GraphReuse::begin`/`end`, QSA owner loan, drafter decision, shared-expert pin and stack wiring are merged and tested host-side and on the lifecycle fake; compare `decode.assemble` with `decode.reuse`, `decode.disassemble` with `decode.keep`, `record.*`, the first-draft capture, VRAM at the low-water mark; design and scenarios `docs/experiments/decode-graph-reuse.md` GPU (job `host-decode-graph-reuse-identity-and-profile`, package `pkg-s6` = our wiring + the speed session's handles/re-arm, 4 profiled boots x 30 requests): REUSE WORKS. Per request, shipped (AP.1/AP.2): `decode.assemble` 103.5/104.1 ms (`record_all` 86.5/86.9, capture 34.0, instantiate 22.2) + `decode.disassemble` 14.7/12.3 = 118/116 ms. With `LELEKA_DECODE_GRAPH_REUSE=1` (RGP.1/RGP.2): `decode.assemble` 6.0 + `decode.reuse` 14.0/13.8 + `decode.keep` 0.7/0.6 = 20.7/20.4 ms, `record_all` 5.4 (the one full assembly of the first request averaged over 30), `record.capture` 1.1, `record.instantiate` 1.3: section delta about -97 ms per request (a reused request costs ~18 ms: re-arm with the 118 MB reseed). 29 of 30 requests reused, 1 full assembly, zero `decode graphs recorded again` lines (no retire), all HTTP 200. VRAM low-water unchanged (535 MiB free in both). ms/token (unpaired, free-running): 6.18/6.19 shipped against 6.10/6.12 with reuse. Identity: teacher-forced bitwise job queued (`host-draft-switches-teacher-forced-identity`, P4); free-running hashes cannot decide it BITWISE IDENTITY PASS (job `host-draft-switches-teacher-forced-identity`, test binary `rt-pf9`, night5-long-256k, teacher forced, 5 requests to 243k, 240 forced tokens each): top-16 logprob rows 2057 of 2057 identical in both arms, draft trace 1036 of 1036 lines identical, A/A floor identical (q_tail_gate PASS, d_top1 0.0000, flips 0). FIXED for the section: -97 ms per request (118 to 20.7 ms) and identity; ON by default in the three 5090 profiles (`LELEKA_DECODE_GRAPH_REUSE=1`, test `the_switches_that_passed_the_bitwise_gate_are_on_for_the_5090_profiles_only`); the end-to-end paired A/B of the group is still to come GROUP A/B 2026-11-10 (job `host-draft-switches-group-ab`, n=10 per arm, 30 requests each, free-running): the group arm X = chain pipeline + check merge + park fast (reuse RG is NOT in X; its own paired e2e arm is still to run). Decode ms/token A 6.33, X 6.30, paired -0.03 +-0.08 (no regression, no gain visible); session time A 329 +-19 s, X 340 +-20 s but output lengths differ run to run (free-running), so time per equal-output pair is the fair figure: 66 pairs with output within 2 %, mean X-A -73 ms (se 46), median -5 ms. Section deltas stand (Q7 -97 ms per request); the e2e effect is below the A/B noise (about 3 % of session time), CLOSED on section + bitwise identity; ON in the three 5090 profiles; e2e confirmation by RG paired arm pending. SECTION DELTA 2026-11-10 (job `host-set-profile-paired-section-deltas`, one profiled boot per arm, 15 requests, package pkg-s9; AP shipped, YP = check merge + park fast + graph reuse): `decode.assemble` 97.8 ms median + `decode.disassemble` 12.0 ms (= 109.8 ms per request) became `decode.reuse` 13.1 ms + `decode.keep` 0.63 ms (= 13.8 ms) on 14 of 15 requests; the first request records (assemble 178 ms, `record_all` 162 ms vs 81.6 ms shipped, the one-time cost of building the held set); over all 15: 1,726 ms to 373 ms = -90 ms per request including the cold one (-96 ms on the 14 warm ones). Matches the earlier -97 ms. FIXED: section delta + bitwise identity (teacher-forced 2057/2057 rows); ON in the 5090 profiles. |
|
||||
| B3 | prefill: prefix-cache parking in the request path (code `prefix.export_kv` 19.0 + `export_index` 2.3 + `park_tail` 14.7 + `park_block` 6.5 + `after_prefill` 9.4 + `after_chunk` 0.7 + `after_decode` 12.5, mean per request) | 65.1 ms | vanilla parks the conversation (checkpoints) inside its own prompt time, not separable | n/a until the instrumented vanilla | PROFILE `runs/dc1` | hex-finish | fixing (code a88a77b25, switches `LELEKA_PREFIX_PARK_FAST=1` and `LELEKA_PREFIX_PARK_ASYNC=1`, both off by default, identity and section delta pending). Reading of the code: the seven listed spans are nested, not additive (`export_kv` and `export_index` sit inside `park_block` and `park_tail`, which sit inside `after_prefill`, `after_chunk` and `after_decode`), so the request-path total is `after_prefill` + `after_chunk` + `after_decode` = 22.6 ms, not 65.1 ms. FAST: one context drain per park instead of 12, K/V pages copied into unzeroed vectors, index rows take the device-read staging as the result (same bytes; compare `prefix.export_kv` and `prefix.export_index`, new `prefix.export_drain`; the sub-spans `export.copy_fast` and `export.index_copy_fast` replace `export.sync`, `export.alloc`, `export.copy`, `export.index_alloc`, `export.index_copy`). ASYNC (with `--prefix-cache-tail reply`): the `after_decode` part (12.5 ms) is taken after the terminal event of the request, before the prefix summary and before the next request, and reported on the line `DBG profile park_deferred` (sum the `request` and `park_deferred` lines for an equal-work comparison); the tail node is in the store before the next request exactly as before. Not deferred: `after_prefill` and `after_chunk` (the last page also holds cells the decode overwrites and the recurrent state the decode advances, so a later park gives other bytes). Not done: pooled buffers (the store retains the vectors) and threaded copies of the 12 layers. GPU run 2026-11-09 (`prefill-prefix-park-identity-and-profile`): FAST kept the prefix reuse and cut the three `after_*` sections by 2.0 ms (23.5 to 21.5; the first-touch page faults of fresh host memory dominate and stay); ASYNC was refused by the runner (the busy mark `active` was still set while the owner ran the deferred step, so the next request got `runtime_capacity`). Fixed in the next commit: the busy mark is released before the deferred step, so a request that arrives meanwhile is admitted and waits in the control queue (test `a_request_arriving_during_the_deferred_tail_is_admitted_and_queued_not_refused`); pass criterion for the rerun: `cached_tokens` equal to shipped for all 30 and no `engine refused` in requests.log. Pre-faulted buffer pool not built: the store keeps every parked vector, so a pool is the store budget held pre-touched (tens of GiB, or sizes that do not match the variable tail) and needs a store free list or a slab type; allocator tuning (`MALLOC_TOP_PAD_`, `MALLOC_TRIM_THRESHOLD_`) can be tried without code BITWISE IDENTITY PASS (job `host-draft-switches-teacher-forced-identity`, test binary `rt-pf9`, night5-long-256k, teacher forced, 5 requests to 243k, 240 forced tokens each): top-16 logprob rows 2057 of 2057 identical in both arms, draft trace 1036 of 1036 lines identical, A/A floor identical (q_tail_gate PASS, d_top1 0.0000, flips 0). FAST: identity PASS and section -2.0 ms per request: ON by default in the three 5090 profiles (`LELEKA_PREFIX_PARK_FAST=1`); ASYNC is not in the default (admission fix queued for the rerun `prefill-prefix-park-async-fix-identity-and-profile`) ASYNC rerun 2026-11-10 (job `prefill-prefix-park-async-fix-identity-and-profile`, after fix 955a72e37): no `engine_refused`/`runtime_capacity` in any of the 8 boots; `cached_tokens` equal to the shipped arm for 30 of 30 requests in every arm (1,202,318 total); `prefix.after_response` 8.7 ms median on the `park_deferred` line, the work leaves the request path (`prefix.export_kv` 17.0 to 7.6 ms median, `park_tail` 13.7-15.2 to 6.3 ms) but `prefix.after_prefill` is 9.6/9.9 ms vs 10.5/11.1 (shipped) and 9.4 (FAST): the request path gains nothing measurable beyond FAST. FAST CLOSED (bitwise identity + section delta, ON in 5090 profiles); ASYNC stays OFF (no delta beyond FAST, adds a deferred step). SECTION DELTA 2026-11-10 (same job): `prefix.after_prefill` + `prefix.after_decode` per request AP 13.30 + 10.01 = 23.3 ms, YP 13.01 + 7.21 = 20.2 ms (-3.1 ms, -13 %; earlier job: -2.0 ms); `prefix.park_tail` 16.8 to 15.3 ms, `prefix.export_drain` 3 context drains per park instead of 12 (counter 0.00/3), `prefix.export_index` 3.50 to 2.89 ms; `prefix.export_kv` 22.6 to 25.3 ms (the copies themselves are the same bytes). FAST FIXED: section delta -2..-3 ms per request + bitwise identity; ON in the 5090 profiles. ASYNC stays OFF. |
|
||||
| B4 | decode hand-over: tear-down of the request (code `decode.disassemble`) | 11.7 ms per request | none | +11.7 ms | PROFILE `runs/dc1` | hex-finish | open |
|
||||
|
||||
Reference in New Issue
Block a user