diff --git a/docs/experiments/step-ledger.md b/docs/experiments/step-ledger.md index 49339ff2..c268fcf4 100644 --- a/docs/experiments/step-ledger.md +++ b/docs/experiments/step-ledger.md @@ -1,4 +1,4 @@ -# Step ledger: every place where Leleka (LEL) loses to vanilla Strata (VANL), per step of the round and of the request +# Step ledger: every place where Leleka (LEL) loses to vanilla Strata (VANL), in pipeline order, request to decode Owner rule (2026-11-09): every step where we lose is recorded, even 0.02 ms. A row is never dropped as "below noise", "under 1 %", "neutral" or "NO-GO because small". This file is the single register; the narrative and the measurements behind it stay in `docs/experiments/codex-compare-speed-gap.md` (cited as *gap doc*). @@ -10,28 +10,89 @@ Owner rule (2026-11-09): every step where we lose is recorded, even 0.02 ms. A r **Sources.** `CUPTI` = one 15 s window over replay request 29 (67k context), runs `/data/leleka-e2e/spd-gap/runs/cupti/{CL.1,CM.1,VANL}/win-r29.lct`, scripts `scripts/e2e/codex/speed/{cupti_layer_phases,cupti_doorbell_latency,cupti_verify_graph,cupti_stream_overlap,kernel_roles}.py` and `decode_rounds.py`. One window per arm: the greedy trajectories differ a little (hit mix, window width), so a per-kernel mean can carry the entry mix. `PROFILE` = the product's own `LELEKA_SERVE_PROFILE` lines (`runs/main/P`). `LOG` = engine logs of the replay cells. `ORCH` = figure given by the orchestrator session, not re-derived here. -## 1. Round, verify window (ms per round) +**Order (owner rule 2026-11-09).** The ledger follows the request linearly, from the request into the engine, through prefill, to the decode round (draft, verify graph, accept, commit, publication of the tokens, next round). Work goes in this order: step N is closed (`fixed`, or `proved-equal` with a section measurement) before step N+1. Prefill and host are led by `hex-finish`, the decode part (verify graph, accept on the device, branch overlap, their streams) by `device`; both run in parallel, each in its own order. After each group of steps comes the end-to-end paired A/B of the group. + +Row ids are stable (they are cited in `codex-compare-speed-gap.md` and in reports); the section decides the order, not the number. + + +## A. Request into the engine (HTTP and gateway, tokenizer, prefix cache) + +No per-step figure exists for A1-A3; each is a `not measured` row that needs a section measurement before it can be closed. + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| A1 | HTTP, gateway and proxy time per request | not measured per step | not measured per step | the sum 'rest' per request is Q10: 22 ms against 32 ms | LOG | hex-finish | open | +| A2 | tokenizer and prompt assembly | not measured | not measured | n/a | none | hex-finish | open | +| A3 | prefix-cache lookup and import (cached tokens per request, import time) | not measured | not measured | n/a (replay logs `cached_tokens`; import time only in `last_import_split`) | none | hex-finish | open | +| Q10 | gateway, proxy, serialization ("rest" per request) | 22 ms | 32 ms | -10 ms | LOG | hex-finish | proved-equal (LEL ahead) | + +## B. Prefill (chunks, expert ring and copies, refill, QSA, GDN, first token), then the hand-over to decode + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| Q8 | request time per output token, prefill + decode | 0.59 + 5.63 = 6.22 ms | 0.36 + 4.61 = 4.97 ms | +1.25 ms (decode +1.02, prefill +0.23) | LOG | both | open | +| Q1 | prefill per request at equal uncached tokens | 726 ms | 431 ms | +295 ms | LOG | hex-finish | open | +| 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 | +| Q3 | prefill throughput over uncached tokens | 930-1050 tok/s | 1460-1560 tok/s | -35 % | LOG | hex-finish | open | +| Q4 | `prefill.read` fixed part (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 | +| 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 | PROFILE `prof-l5` | hex-finish | open | +| 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 | +| 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 | device | open | + +## C. Decode round: summary, then draft, verify graph, accept, commit, publication, next round + +Round-level totals first (they are the sum of the steps below). | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | | R1 | round wall (graph start to start) | 17.864 | 15.886 | +1.978 | CUPTI | device | open | -| R2 | verify graph GPU span | 13.561 | 11.743 | +1.818 | CUPTI | device | open | -| R3 | verify end to next verify start (draft, commit, host, CPU-leg join) | 4.304 | 4.144 | +0.160 | CUPTI | hex-finish | open | | R4 | GPU idle over the round | 2.574 | 3.103 | -0.529 (busy 85.6 % against 80.5 %) | CUPTI | device | proved-equal (LEL ahead) | -| R5 | verify graph launch call (host) | 1.485 | 1.509 | -0.024 | CUPTI | device | proved-equal (LEL ahead) | -| R6 | idle inside the verify graph (2052 gaps against 1193 per round, mean 0.1 us) | 0.213 | 0.119 | +0.094 | CUPTI | device | open | -| R7 | first doorbell after graph start (embed, first layer mixer) | 0.132 | 0.117 | +0.015 | CUPTI | device | open | -| R8 | tail after the last layer's `add_hits` (final write, head, argmax) | 0.463 | 0.373 | +0.090 | CUPTI | device | open | +| Q9 | round count: tokens per round | 3.59-3.66 | 2.95 | +0.64..+0.71 tokens per round (+22 %): our adaptive window pays +3.1 ms for +0.65 tokens | LOG | device | proved-equal (net +2.8 % decode, kept) | -## 2. Verify graph: structure (per round, 47-48 layers) +## C1. Draft (chain from the previous commit to the verify window's tokens) + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| O9 | draft chain steps and idle between them | 0.27 | not given | +0.27 | ORCH | hex-finish | open | +| O8 | draft finite and q8 guard checks (`mtp_original_finite` 158.8 x 0.87 us, `mtp_original_q8_guard` 28 x 0.87 us per round, 186.8 launches) | 0.162 | none | +0.162 | CUPTI | hex-finish | open | +| K13 | draft chain role total (chain GR kernels, `mtp_*`) | 3.544 | 2.471 | +1.073 (includes the draft head and checks of R3 and O8; VANL books its draft in the shared GR kernels) | CUPTI role table | hex-finish | open | +| O12 | draft finish follows the window width (0.93 ms at T 3.0, 2.5 ms at T 6.2) | window price | | part of the +3.1 ms for +0.65 tokens per round | PROFILE | hex-finish | open | +| O2 | kernels outside big graphs | 630 | 147 | +483 | CUPTI | hex-finish | open | +| O3 | graph executions per round | 5.38 | 4.47 | +0.91 | CUPTI | hex-finish | open | + +## C2. Verify graph: embed, 48 layers (mixer half, FFN half), final write and head + +Structure first, then the layer steps in graph order: embed (R7), mixer half (V3 and the kernels in it), FFN half (V2/V4 and the kernels in it), tail (R8). | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | | V1 | streams in the verify graph | 1 | 11 | wall time with two or more streams active: 0 against 2.03 ms | CUPTI | device | fixing | -| V2 | FFN phase (doorbell to `add_hits` end) | 6.600 | 5.293 | +1.307 | CUPTI | device | open | +| R2 | verify graph GPU span | 13.561 | 11.743 | +1.818 | CUPTI | device | open | +| V9 | verify graph kernel time sum | 13.349 | 13.728 | -0.379 (VANL runs kernels concurrently: its span is shorter than its sum) | CUPTI | device | proved-equal (LEL ahead) | +| V8 | launches per verify graph | 2061 | 2098 | -37 | CUPTI | device | proved-equal (LEL ahead) | +| R5 | verify graph launch call (host) | 1.485 | 1.509 | -0.024 | CUPTI | device | proved-equal (LEL ahead) | +| R6 | idle inside the verify graph (2052 gaps against 1193 per round, mean 0.1 us) | 0.213 | 0.119 | +0.094 | CUPTI | device | open | +| R7 | first doorbell after graph start (embed, first layer mixer) | 0.132 | 0.117 | +0.015 | CUPTI | device | open | | V3 | mixer phase (`add_hits` end to next doorbell) | 6.366 | 5.963 | +0.403 | CUPTI | device | fixing | | V3a | GDN gates and gate projection on side streams (`LELEKA_SM120_SIDE_MIXER=1`, existing, off) | mixer 5.913, round 17.508 (`CM.1`) | mixer 5.963 | section delta mixer -0.453, round -0.356; mixer phase now equal to VANL | CUPTI | device | fixing (identity `spd-sqid1`, A/B `spd-sm1` queued/running) | | V3b | QSA indexer chain and query chain on side streams (`LELEKA_SM120_SIDE_QSA`, code `0c30105d4`, off) | in line | 0.509 ms of overlap with the main stream (main+qsa) | not yet measured; VANL mixer phase is already matched by V3a | CUPTI (VANL) | device | fixing (window `spd-sqw`, identity `spd-sqid1`) | +| K6 | attention role in total (norm/RoPE, appends, scores, top-k, resolve, chunk, merge, gate) | 1.357 | 1.125 | +0.232 | CUPTI role table | device | open | +| K1 | attention decode chunk (`leleka_qsa_decode_chunk_daily` 18.3 us, 12 per graph) against `attn_chunk_kernel_pre75` (17.1 us) | 0.220 | 0.206 | +0.014 | CUPTI | device | open | +| K2 | indexer block scores (`leleka_qsa_decode_scores` 14.2 us against `block_scores_multi` 17.1 us) | 0.170 | 0.205 | -0.035 | CUPTI | device | proved-equal (LEL ahead) | +| K3 | block top-k cluster (17.3 us against 18.0 us) | 0.208 | 0.216 | -0.008 | CUPTI | device | proved-equal (LEL ahead) | +| K4 | KV miss copy / copy kernel (11.1 us against 11.6 us) | 0.133 | 0.139 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | +| K5 | KV resolve (7.8 us against 8.4 us) | 0.094 | 0.100 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | +| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | open | +| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | open | +| K7b | GDN alpha/beta (`chain_gdn_ab_multi` 36 x 8.5 us against `gdn_ab_multi` 22.9 x 10.5 us plus the rest) | 0.307 | 0.344 | -0.037 | CUPTI | device | proved-equal (LEL ahead) | +| K12 | dense projections, lm head, MMVQ/MMVF role (`head_n*`, `bf16_f32_mmvf_multi`) | 3.892 | 4.589 | -0.697 | CUPTI | device | proved-equal (LEL ahead) | +| S1 | `ATTN_DAILY` (decode attention) | on since lever 1 | on | paired decode +1.85 % with S2 (CI excludes zero), identity PASS (teacher-forced, 2057 of 2057 rows); no section delta of its own | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | +| S3 | `SIDE_MIXER=2` | GDN part off by default, QSA part not ported before `0c30105d4` | on | V3a, V3b | CUPTI | device | fixing | +| S8 | `MMVQ_IL` (2-4 and 5-8 columns) | not ported | on | estimate 0.10-0.40; CUPTI role K12 shows our dense projections faster by 0.70 in total | upstream plan | device | open | +| S10 | batched K/V append and indexer append | per row (`verify_qsa_append_analytic` 138 x 1.04 us, `mtp_original_append` 49 x 1.6 us) | batched (`append` 12 x 3.0 us, `kv_append_q8` 14.6 x 2.2 us) | estimate 0.05-0.10 | upstream plan, CUPTI | device | open | +| V2 | FFN phase (doorbell to `add_hits` end) | 6.600 | 5.293 | +1.307 | CUPTI | device | open | | V4 | doorbell to first routed expert (gate/up) start, us | 27.6 | 15.0 | +12.6 us x 48 = +0.60 ms | CUPTI | device | fixing | | V4a | shared expert on a side stream, forked after the doorbell, joined before the combine (`LELEKA_SM120_SIDE_SHARED`, code `255159a89`, off) | 27.6 us before the first expert | 15.0 us | section delta pending (`spd-sqw` window `CE.1`) | CUPTI | device | fixing | | V4b | routed experts on their own branch (VANL: plan wait, VRAM experts, `fetch_blobs`, CPU wait, `add_hits` on a side stream; main stream does the shared expert and the next norm) | all on the capture stream | branch | rest of V2 after V4a, not yet known | CUPTI | device | open | @@ -39,70 +100,48 @@ Owner rule (2026-11-09): every step where we lose is recorded, even 0.02 ms. A r | V5 | flag waits on the CPU leg (`verify_wait_flag_ge` 96 x 26.9 us + `chain_wait_copy_i32` 48 x 5.4 us against `wait_flag_ge` 144 x 8.1 us) | 2.836 | 1.160 | +1.676 | CUPTI | device | open | | V6 | PCIe fetch and CPU-row hand-over (doorbell, mapped copies, `fetch_blobs`, `add_hits`, `rebase_ptrs`) | 0.488 | 2.109 | -1.621 | CUPTI | device | proved-equal (LEL ahead) | | V7 | V5 + V6, the whole miss-leg handling | 3.324 | 3.269 | +0.055 (+0.17 by an earlier count of the same sets) | CUPTI | device | open | -| V8 | launches per verify graph | 2061 | 2098 | -37 | CUPTI | device | proved-equal (LEL ahead) | -| V9 | verify graph kernel time sum | 13.349 | 13.728 | -0.379 (VANL runs kernels concurrently: its span is shorter than its sum) | CUPTI | device | proved-equal (LEL ahead) | - -## 3. Verify graph: kernels (ms per round unless marked) - -Pairs are by role; a per-kernel mean carries the entry mix of the single window. - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| K1 | attention decode chunk (`leleka_qsa_decode_chunk_daily` 18.3 us, 12 per graph) against `attn_chunk_kernel_pre75` (17.1 us) | 0.220 | 0.206 | +0.014 | CUPTI | device | open | -| K2 | indexer block scores (`leleka_qsa_decode_scores` 14.2 us against `block_scores_multi` 17.1 us) | 0.170 | 0.205 | -0.035 | CUPTI | device | proved-equal (LEL ahead) | -| K3 | block top-k cluster (17.3 us against 18.0 us) | 0.208 | 0.216 | -0.008 | CUPTI | device | proved-equal (LEL ahead) | -| K4 | KV miss copy / copy kernel (11.1 us against 11.6 us) | 0.133 | 0.139 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | -| K5 | KV resolve (7.8 us against 8.4 us) | 0.094 | 0.100 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | -| K6 | attention role in total (norm/RoPE, appends, scores, top-k, resolve, chunk, merge, gate) | 1.357 | 1.125 | +0.232 | CUPTI role table | device | open | -| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | open | -| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | open | -| K7b | GDN alpha/beta (`chain_gdn_ab_multi` 36 x 8.5 us against `gdn_ab_multi` 22.9 x 10.5 us plus the rest) | 0.307 | 0.344 | -0.037 | CUPTI | device | proved-equal (LEL ahead) | +| K11 | routed experts in the verify graph, role total (gate/up/SwiGLU, down) | 2.507 | 2.484 | +0.023 (entry mix differs; at equal entry counts LEL is faster: `window_moe_down_20` 13.6 us with 40 entries against 17.4 us, `sm120_moe_gu_swiglu_22` 12.3 us with 50 entries against 26 us with 40) | CUPTI | device | open | +| K15 | hit tally `add_hits` (48 x 1.2 us against 48 x 1.3 us) | 0.059 | 0.063 | -0.004 | CUPTI | device | proved-equal (LEL ahead) | +| S2 | `GU_SWIGLU` (routed expert gate/up + SwiGLU + q8_1) | on since lever 1 | on | as S1 | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | +| S7 | sub16 routed-expert kernels beyond `GU_SWIGLU` | warp-per-row | sub16 | estimate 0.20-0.35; the CUPTI pair K11 does not show LEL slower, so this must be re-measured by kernel before any work | upstream plan | device | open | +| S11 | float4 combine | not ported | `combine_k10_vec4` 50.6 x 1.2 us | estimate 0.05-0.10 | upstream plan | device | open | | K8 | hyper-connection down (`chain_gr_down_t2w8_nb4` 11.1 us against `gr_down_staged` 11.5 us) | 1.063 | 1.112 | -0.049 | CUPTI | device | proved-equal (LEL ahead) | | K9 | hyper-connection up (`chain_gr_up8` 8.5 us against `gr_up75` + `gr_up_multi` variants) | 0.817 | 0.877 | -0.060 | CUPTI | device | proved-equal (LEL ahead) | | K10 | hyper-connection split (`chain_gr_split` 96 x 3.1 us against `gr_norm_split` 97 x 2.9 us) | 0.299 | 0.280 | +0.019 | CUPTI | device | open | -| K11 | routed experts in the verify graph, role total (gate/up/SwiGLU, down) | 2.507 | 2.484 | +0.023 (entry mix differs; at equal entry counts LEL is faster: `window_moe_down_20` 13.6 us with 40 entries against 17.4 us, `sm120_moe_gu_swiglu_22` 12.3 us with 50 entries against 26 us with 40) | CUPTI | device | open | -| K12 | dense projections, lm head, MMVQ/MMVF role (`head_n*`, `bf16_f32_mmvf_multi`) | 3.892 | 4.589 | -0.697 | CUPTI | device | proved-equal (LEL ahead) | -| K13 | draft chain role total (chain GR kernels, `mtp_*`) | 3.544 | 2.471 | +1.073 (includes the draft head and checks of R3 and O8; VANL books its draft in the shared GR kernels) | CUPTI role table | hex-finish | open | -| K14 | small kernels (norms, PLE, copies, sampler) | 0.049 | 0.253 | -0.204 | CUPTI role table | device | proved-equal (LEL ahead) | -| K15 | hit tally `add_hits` (48 x 1.2 us against 48 x 1.3 us) | 0.059 | 0.063 | -0.004 | CUPTI | device | proved-equal (LEL ahead) | - -## 4. sm_120 default set of vanilla and the remaining upstream items (`sm120_series.hpp`, `docs/upstream-port-plan.md` rows 2.1/2.2) - -Estimates in the last column are from our microseconds, not measurements (gap doc, "Kernel level"). - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | --- | --- | --- | --- | --- | --- | -| S1 | `ATTN_DAILY` (decode attention) | on since lever 1 | on | paired decode +1.85 % with S2 (CI excludes zero), identity PASS (teacher-forced, 2057 of 2057 rows); no section delta of its own | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | -| S2 | `GU_SWIGLU` (routed expert gate/up + SwiGLU + q8_1) | on since lever 1 | on | as S1 | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | -| S3 | `SIDE_MIXER=2` | GDN part off by default, QSA part not ported before `0c30105d4` | on | V3a, V3b | CUPTI | device | fixing | | S4 | `GR_DOWN_TG` | 9.7 us (`chain_gr_down_t2w8_nb4`) | 18.4 us | -8.7 us | gap doc | device | proved-equal (LEL ahead) | | S5 | `GR_UP75` (hoisted row loads) | partial | on | estimate 0.05-0.10 | upstream plan | device | open | -| S6 | `COMMIT_BATCH` + state-only GDN commit (commit graph 158 kernels, 0.463 ms) | not ported | on (`gdn_step_commit_layers` 0.9 per round, 0.095 ms) | estimate 0.25-0.35 | upstream plan, CUPTI | device | open | -| S7 | sub16 routed-expert kernels beyond `GU_SWIGLU` | warp-per-row | sub16 | estimate 0.20-0.35; the CUPTI pair K11 does not show LEL slower, so this must be re-measured by kernel before any work | upstream plan | device | open | -| S8 | `MMVQ_IL` (2-4 and 5-8 columns) | not ported | on | estimate 0.10-0.40; CUPTI role K12 shows our dense projections faster by 0.70 in total | upstream plan | device | open | +| K14 | small kernels (norms, PLE, copies, sampler) | 0.049 | 0.253 | -0.204 | CUPTI role table | device | proved-equal (LEL ahead) | +| R8 | tail after the last layer's `add_hits` (final write, head, argmax) | 0.463 | 0.373 | +0.090 | CUPTI | device | open | | S9 | `HEAD_MIX_MULTI` | not ported | on | estimate 0.06-0.10 | upstream plan | device | open | -| S10 | batched K/V append and indexer append | per row (`verify_qsa_append_analytic` 138 x 1.04 us, `mtp_original_append` 49 x 1.6 us) | batched (`append` 12 x 3.0 us, `kv_append_q8` 14.6 x 2.2 us) | estimate 0.05-0.10 | upstream plan, CUPTI | device | open | -| S11 | float4 combine | not ported | `combine_k10_vec4` 50.6 x 1.2 us | estimate 0.05-0.10 | upstream plan | device | open | -## 5. Outside the verify graph, per round +## C3. Accept (verdict of the window on the device) and the hand-over to the next draft | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | -| O1 | kernels per round | 2691 | 2245 | +446 | CUPTI | hex-finish | open | -| O2 | kernels outside big graphs | 630 | 147 | +483 | CUPTI | hex-finish | open | -| O3 | graph executions per round | 5.38 | 4.47 | +0.91 | CUPTI | hex-finish | open | +| O7 | verify end to first draft kernel, ms | 0.32 | 0.08 (accept decided on the device) | +0.24 | ORCH | hex-finish | open | + +## C4. Commit (accepted-prefix graph, GDN replay, QSA tail restore, re-append, PLE history) + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| S6 | `COMMIT_BATCH` + state-only GDN commit (commit graph 158 kernels, 0.463 ms) | not ported | on (`gdn_step_commit_layers` 0.9 per round, 0.095 ms) | estimate 0.25-0.35 | upstream plan, CUPTI | device | open | +| O11 | commit graph (158 kernels, `verify_gdn_conv_commit` 36 x 1.7 us) | 0.463 | 0.095 (`gdn_step_commit_layers`) | +0.37 (S6) | CUPTI | device | open | +| O10 | fused commit (`LELEKA_DRAFT_FUSED_COMMIT`) | measured | | -0.024 | ORCH | hex-finish | fixing | + +## C5. Publication of the tokens, host work and syncs around the round + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| R3 | verify end to next verify start (draft, commit, host, CPU-leg join) | 4.304 | 4.144 | +0.160 | CUPTI | hex-finish | open | | O4 | API calls per round | 207 | 20 | +187 | CUPTI | hex-finish | open | | O5 | copies per round (count, MB) | 121 (71.5 MB) | 12 (23.6 MB) | +109 copies, +47.9 MB | CUPTI | hex-finish | open | | O6 | syncs per round (count, host time) | 27.8 (2.468 ms) | 89 (0.926 ms) | -61 syncs, +1.542 ms of host sync time (overlapped with GPU work: R3 is only +0.16) | CUPTI | hex-finish | open | -| O7 | verify end to first draft kernel, ms | 0.32 | 0.08 (accept decided on the device) | +0.24 | ORCH | hex-finish | open | -| O8 | draft finite and q8 guard checks (`mtp_original_finite` 158.8 x 0.87 us, `mtp_original_q8_guard` 28 x 0.87 us per round, 186.8 launches) | 0.162 | none | +0.162 | CUPTI | hex-finish | open | -| O9 | draft chain steps and idle between them | 0.27 | not given | +0.27 | ORCH | hex-finish | open | -| O10 | fused commit (`LELEKA_DRAFT_FUSED_COMMIT`) | measured | | -0.024 | ORCH | hex-finish | fixing | -| O11 | commit graph (158 kernels, `verify_gdn_conv_commit` 36 x 1.7 us) | 0.463 | 0.095 (`gdn_step_commit_layers`) | +0.37 (S6) | CUPTI | device | open | -| O12 | draft finish follows the window width (0.93 ms at T 3.0, 2.5 ms at T 6.2) | window price | | part of the +3.1 ms for +0.65 tokens per round | PROFILE | hex-finish | open | | O13 | host work around a group (split 3, spans 2, publish plan 6, open and zero 5 us; 48 groups) | 0.8 | not measured | n/a | PROFILE | hex-finish | open | +| O1 | kernels per round | 2691 | 2245 | +446 | CUPTI | hex-finish | open | -## 6. Hit rate and tier placement +## C6. Between rounds and requests: expert tier (hit rate, placement) + +The tier adapts every 4 rounds and survives across requests. | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | @@ -115,38 +154,28 @@ Estimates in the last column are from our microseconds, not measurements (gap do | H7 | first rounds of a request see an unadapted tier | | | not isolated | gap doc | device | open | | H8 | CPU expert compute per expert (2 MB) | 39 us (52 GB/s) | 44 us | -5 us | PROFILE | hex-finish | proved-equal (LEL ahead) | -## 7. Request lifecycle - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| Q1 | prefill per request at equal uncached tokens | 726 ms | 431 ms | +295 ms | LOG | hex-finish | open | -| 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 | -| Q3 | prefill throughput over uncached tokens | 930-1050 tok/s | 1460-1560 tok/s | -35 % | LOG | hex-finish | open | -| Q4 | `prefill.read` fixed part (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 | -| 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 | PROFILE `prof-l5` | 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 | -| 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 | device | open | -| Q8 | request time per output token, prefill + decode | 0.59 + 5.63 = 6.22 ms | 0.36 + 4.61 = 4.97 ms | +1.25 ms (decode +1.02, prefill +0.23) | LOG | both | open | -| Q9 | round count: tokens per round | 3.59-3.66 | 2.95 | +0.64..+0.71 tokens per round (+22 %): our adaptive window pays +3.1 ms for +0.65 tokens | LOG | device | proved-equal (net +2.8 % decode, kept) | -| Q10 | gateway, proxy, serialization ("rest" per request) | 22 ms | 32 ms | -10 ms | LOG | hex-finish | proved-equal (LEL ahead) | - ## Counts -Computed by `scripts/e2e/codex/speed/ledger_counts.py` (2026-11-09): 81 rows. +Computed by `scripts/e2e/codex/speed/ledger_counts.py` (2026-11-09): 86 rows. | status | rows | device | hex-finish | both | | --- | ---: | ---: | ---: | ---: | -| open | 47 | 28 | 18 | 1 | +| open | 52 | 28 | 23 | 1 | | fixing | 14 | 12 | 2 | 0 | | fixed | 0 | 0 | 0 | 0 | | proved-equal | 20 | 18 | 2 | 0 | Nothing is `fixed` yet: the closing rule needs a section delta, identity and the set A/B for the same row, and no row has all three. -## Order of work (easiest first, device rows; each ends with a section delta, identity and the final set A/B) -1. V3a: read the A/B `spd-sm1` and the `CM.1` window against the identity of `spd-sqid1` (already built and queued). -2. V4a, V3b: windows `spd-sqw` (`CE.1`, `CN.1`, `CT.1`), identity, A/B `spd-sqe`, `spd-sqn`. -3. K1, K10, K7a, R6, R7, R8: single-kernel and launch-count rows read from the same windows; each needs a named cause and a kernel-level change. -4. V5 and V4b: the flag waits and the routed-expert branch, after V4a and V3b have moved the baseline. -5. S5, S9, S10, S11, S6 (commit), S7, S8, then Q7 and the hit-rate rows H1..H7 on the device side. +## Order of work in the device part (linear in the graph; step N closed before step N+1) + +The device part starts at the verify graph; the draft (C1) and the host (C5) belong to `hex-finish`. + +1. C2, structure: V1 closes when V3a, V3b, V4a and V4b are closed. +2. C2, mixer half in graph order: V3a (GDN branch; A/B `spd-sm1`, identity `spd-sqid1`), V3b (QSA branch; window `CN.1`, A/B `spd-sqn`), then the kernels of the half: K1, K6, K7, K7a, S1, S8, S10. +3. C2, FFN half: V4a (shared expert; window `CE.1`, A/B `spd-sqe`), V4b (routed-expert branch), V5, V7, K11, S2, S7, S11, then K10, S5 and the tail R8, S9. +4. C3 accept (O7), C4 commit (S6, O11). +5. C6 hit rate and tier placement (device side: H1..H7). + +Each step is closed with: section delta (CUPTI of that step), identity, and the end-to-end paired A/B after the group.