ledger Q5: ring prefetch after the slot-wrap fix (identity PASS, section delta negative, stays off)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-11 01:38:56 +01:00
co-authored by Claude Sonnet 5.5
parent 781f2afb97
commit 8736d8ceb7
+1 -1
View File
@@ -35,7 +35,7 @@ No per-step figure exists for A1-A3; each is a `not measured` row that needs a s
| Q2 | prefill latency by uncached tokens (< 64, 64-256, 256-1024, 1024-4096, >= 4096), median ms | 430, 530, 722, 1002, 4405 | 268, 292, 435, 715, 2184 | +162, +238, +287, +287, +2221 | LOG | hex-finish | open AFTER THE STREAM THRESHOLD 2026-11-10: VANL means from the VANL engine logs (`read in X ms`, 3 reps): 64-256 tokens 294 ms (n=121), 256-1024 447 (n=72), 1-4k 820 (n=23), > 4k 2062 (n=8); ours `prefill.read` with `STRATA_PREFILL_STREAM_MIN=1536`: 64-256 about 400-620, 256-1024 521, 1000-1536 729, 1536-4096 830, 4k+ 1245-1500: at parity from 1 to 4k tokens and ahead beyond 4.9k, behind by +75..+170 ms below 1k tokens (VANL reads 64-256 tokens in 294 ms = 14 GB / 50 GB/s with the rest of the chunk hidden under the DMA; ours has the DMA at 45 GB/s and about 130 ms of GDN/QSA unoverlapped). Open: ring prefetch (sub-agent, switch off), U6. |
| Q3 | prefill throughput over uncached tokens | 930-1050 tok/s | 1460-1560 tok/s | -35 % | LOG | hex-finish | open see Q2 (2026-11-10): the gap that remains is below 1k tokens, not a throughput gap above it. |
| Q4 | prefill: fixed part of the chunk read (code `prefill.read`, 581 ms + 0.134 ms per token; 485 ms for 239 tokens) | 485-581 ms | whole prefill of that size class 292 ms | +193 and more | PROFILE | hex-finish | open: root cause found (see Q5) RING FINDINGS 2026-11-10 (jobs `prefill-ring-host-spans-profile`, `prefill-ring-copied-megabytes-profile`, pkg-s11/s12, 15 requests): `moe.ring` is DMA-bound, not host-bound. Host spans of the copy ring per request with a 1.4k tail: init 10.5 ms (`init_sync` 0.0), stage 50.7, gather 36.3, enqueue 30.1 (about 130 ms, parallel with the DMA), `finish_statuses` (host waits for the GPU/DMA) 335.8 ms; the wait grows about 200 ms fixed + 0.08 ms per tail token. Experts copied over PCIe per request: 7,002 (14.3 GB) at a 279-token tail, 8,794 (18.4 GB) at 1,243, 11,576 (24.0 GB) at 1,454, 12,762 (26.5 GB) at 2,837; 146-266 per layer, 45-55 % of the routed experts are not resident. GB / 45 GB/s = 319, 410, 459, 590 ms vs ring wall 332, 428, 462, ~590: the ring runs at the PCIe rate. So synchronisation fixes (step A: syncs, cuMemGetInfo, gather by 16) buy nothing. Offline prefetch study (`LELEKA_PREFILL_ROUTE_TRACE`, 30 requests): the experts the layer's last 3-16 chunks missed predict the next chunk's missing set with 60 % precision at 150 experts per layer (86 hits), an upper bound of about -150..-190 ms per request for a prefetch under the GDN/QSA stage; not built (complex, 40 % wasted bandwidth). PREFETCH FIRST GPU RUN 2026-11-10 (pkg-s14, `LELEKA_PREFILL_RING_PREFETCH=1`, sub-agent branch merged, default off): 9 of 30 requests failed with `class=InvalidDimension` and the chunk hashes differ (60 PREFILL-R lines vs 31): the implementation is NOT correct yet; driver error trace job queued (`prefill-ring-prefetch-failure-driver-error-trace`). Remains OFF. |
| 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). |
| 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). 2026-11-10 ring expert prefetch (`LELEKA_PREFILL_RING_PREFETCH`, `prefill-ring-prefetch-slot-wrap-fixed-identity-and-profile`, pkg-s17 `b800bba09`, 30 requests, stream 1536): the first GPU runs failed 9 of 30 with `stage.slot_not_gathered` at layers 46/47 (sources 410-460 > slots 384: prefetch hits skip staging, the wrap met a live un-gathered slot; fixed by `stage_target`, CPU test sources=460/slots=384). After the fix: identity PASS, 0 failures, chunk residual hashes 31 of 31 identical to the shipped FR.1, in the plain form (PE) and with detached drains (PED). Section delta FAIL: `prefill.read` summed over the 30 requests 26,643 ms (FP.1, shipped) -> 29,228 (PEP, +2,585) and 29,922 (PEDP); in the 11 requests where the prefetch ran it is +60..+190 ms each (mean +124 ms), the other requests are +9 ms (boot noise; request 0, the cold one, +930/+2,046). Counters per request: issued 14.4 GB, hit 8.4-12.9 GB (60-90 %), wasted 1.5-6.0 GB. Reading: the ring is PCIe-DMA-bound (Q4/Q5, 45 GB/s), so reading ahead adds traffic (the wasted share) on the link that is already the limit and gains no overlap. Verdict: stays OFF, not a gain; rows Q4/Q5 close on the sub-1k tail by U6 (expert-major bank, deferred) only. Caveat: arms ran in different boots and packages (pkg-s14 vs pkg-s17), the effect is larger than the +9 ms noise of the unaffected requests. |
| 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 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. BATCH COPY 2026-11-10 (job `prefill-ring-prefetch-and-refill-batch-identity-and-profile`, pkg-s14, `LELEKA_REFILL_BATCH=1`): production refill with the batch: `refill.batch_calls` 6, `batch_copies` 2,997, `per_copy` 0, `refill.queue` 41.7 to 1.0 ms but `refill.sync` 23.8 to 57.0 ms, `prefill.refill` 65.9 to 58.3 ms (-7.6 ms per request): the host issue was already overlapped with the DMA, the refill is bytes-bound (999 slots x 2 MB = 2 GB = 45 ms at 45 GB/s). R hashes of all chunks identical to shipped (31 of 31), 0 failed requests. The isolated GPU test `refill_batch_copy_gpu_slots_equal_per_copy` (Vec registered by cuMemHostRegister, 3,072 pieces) faults with error 719 on the batch arm while the per-copy arm is exact: the known driver bug of the batch entry with page-locked sources (docs/windows.md, 3080), here on driver 595.99 too; the production bank evidently takes another route. Verdict: -7.6 ms is too small to justify a driver entry that faults in some memory kinds; `LELEKA_REFILL_BATCH` stays OFF; Q6 stays bytes-bound (floor = lent slots x 2 MB / 45 GB/s). 2026-11-10 driver check `prefill-raw-batch-copy-page-locked-driver-check` (5090, driver 595.99): `pcie_copy_gpu_raw_batch_page_locked`, `..._raw_batch_mixed`, `pcie_copy_gpu_production_page_locked`, `..._production_pageable` all pass (4/4, ~0.9 s each), so a raw batched copy from page-locked memory works on this driver; the CUDA 719 of the slots-equal GPU test is specific to that test's registered Vec, not to batch copy. Switch stays OFF (gain -7.6 ms, bytes-bound). |