Docs: docs/experiments/decode-tail-5090.md takes the branch's records (sections 1-9) and keeps main's seed-off profile text as section 7a, with a merge note on where main differs. Code: no change to main. kar_ple_cache.rs (branchb5d4a0db7equals main a73d09060; main also has the persistent scatter staging buffers) and original_serve_host.rs are main's. The branch's LELEKA_SERVE_ADAPT_DEFER default flip (9b03de2be, deferral off by default) is NOT taken: main's default is the deferral on, and flipping it would change main's behaviour; the opt-out LELEKA_SERVE_ADAPT_DEFER=off already exists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
20 KiB
5090 decode at 247k: what the gap to vanilla Strata was (claude/decode-tail, STRA-245)
Date 2026-10-29. RTX 5090 (32 GB), Ryzen 9 9950X3D, 121 GB RAM, driver 595.99, CUDA 13.2, Ubuntu 26.04; server rnr5090, one heavy job at a time under /data/leleka-e2e/gpu.lock,
the sealed 55 GB KAR memfd held by the holder. Ours = leleka-inference (original serve backend), pinned wave-1 build bin-e2e4 unless a row says otherwise; vanilla = Strata 0.2.6 as
installed (strata launch --model iq3_s --context 256k --kv int8), tail skip as shipped. Greedy, 5-turn single conversation, 300 output tokens per turn, --spec-min-p 0 for ours (the harness
shape; vanilla keeps its own 0.5), --prefix-cache-mib auto, prefill chunk 8192, 11,280 per-layer sized expert slots (11,365 global).
Workload: scripts/e2e/long_session.py over the frozen corpus /data/leleka-e2e/decode/corpus/src/crates (782 .rs files, 14,132,376 chars, sha256 of the file list
1152f45acaa9a62591e50d8f6807f50ce6fe1249db659cdb9e8e4a041ed119a7); prompts 45.8k / 105k / 153k / 199k / 247k tokens. The earlier corpus (~/work/leleka-head/src/crates) no longer exists: every
245k number measured before 2026-10-29 00:40Z (including s1-decode/o-def and the STRA-258/259/260 tables) is unpaired with anything below.
1. Headline
| config (turns 1-4, mean of tokens over seconds) | runs | decode tok/s |
|---|---|---|
| ours, seed ON (shipped default), upstream profile | 3 | 108.1 |
| ours, seed OFF, upstream profile | 3 | 137.2 |
| ours, seed OFF, global slot fill (11,365 slots) | 1 | 139.8 |
vanilla, warm, tail skip as shipped (v-def2, m-vanilla) |
2 | 137.2, 127.5 |
Per turn (tok/s): seed ON 107.0 108.6 109.6 110.1 / 110.3 103.3 104.0 113.9 / 107.0 108.5 108.9 107.2; seed OFF 134.6 139.6 148.7 131.6 / 134.2 138.4 151.0 126.3 / 132.6 138.1 140.5 134.3.
Vanilla: v-def2 139.2 160.7 138.6 117.4 123.4; m-vanilla 123.5 129.9 116.7 142.0 151.9 (the first vanilla arm after the reboot, v-def, ran on a cold page cache and is discarded).
Vanilla varies about 20 % run to run; ours about 3-8 % per turn.
Turn 5 (the 247k prompt) is invalid for ours in every arm without the PLE fix (16-41 tok/s): see section 4. With the fix (plefix-noseed, seed off, one run) all five turns are valid:
125.9 134.4 139.9 134.9 131.8 tok/s, 133.2 over the five turns (tokens over seconds), against vanilla 134.2 (v-def2) and 131.6 (m-vanilla) over the same five turns. Ours with the seed on and the
fix was not measured; with the seed on, turns 1-4 are 108.1 (above), the whole difference to vanilla there is the seed.
2. The prompt-routing seed (placement class, NOT a default)
LELEKA_ORIGINAL_SERVE_SEED (default on) swaps in, at the end of each prompt, the experts the prompt routed most. At 45k-247k prompt tokens it replaces the ranked profile's resident set by a worse one
(the prompt's top experts cover 9-10 % of the decode routing, docs/original-serve.md):
| seed ON | seed OFF | |
|---|---|---|
| VRAM share of routed entries | 80-85 % | 93-96 % |
| CPU / PCIe experts per window, windows 0-20 | ~240 / ~245 | 23-79 / 13-60 |
| ms per round | 16.9-20.0 | 13.4-15.4 |
apply_pending / begin_adaptation, ms per round |
0.5 / 0.15 | 0.1 / 0.1 |
Seed off and the cap LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS are experimental, off by default; they move experts between GPU and CPU, which round differently, so greedy ids are not bit-identical.
Quality gate: section 5 (passes the 1.5x-control criterion on 1,717 rows; class placement, not a bit-identical change).
3. The harness profile was a placeholder
scripts/e2e/run-e2e.sh defaulted LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE to gpu-runs/baseline/profile.bin, a bring-up placeholder in expert-id order (47 % overlap with the ranked upstream profile at 11,280 slots);
vanilla and the product deploy (crates/deploy EXPERT_PROFILE_SHA256) use the upstream data/expert-profile.bin (sha256 8f59b4aa...388975baf). With the seed ON the profile is overwritten anyway, so it made
no difference to the numbers above; with the seed off it is the starting set. The harness now defaults to the upstream file, records its digest, and refuses another one without E2E_ALLOW_PROFILE_OVERRIDE=1.
Every earlier ours-vs-vanilla 5090 measurement through run-e2e.sh used the placeholder (laptop runs used the upstream file).
4. Turn 5: the PLE row cache evicts by scanning all of it
window.ple (host time to gather the 16 PLE rows per verify row) is 0.1-0.2 ms per round in turns 1-3 and 9-11 s over the 153 rounds of turn 5 (about 70 ms per round); it shows as multiples of 53 ms.
Cause (code): KarPleCache::gather (qwen_forward/kar_ple_cache.rs) picks the victim of a missed row, once the 1,048,576-row device cache is full, with entries.iter().filter(..).min_by_key(age): a scan of every entry,
once per missed row. The cache fills after about 1M distinct rows, i.e. around turn 4-5 of this session. Span check (ple.read_rows 0.2 s and ple.device 18 ms of the 10.8 s) and the memory sampler (swap, IO pressure,
direct reclaim flat; vanilla equally full at turn 5: anon 54.7 GB, MemAvailable 9 GB) rule the rest out; a prefix cache of 3000 MiB instead of 5.7 GiB does not change it. Vanilla keeps PLE in RAM and has no such structure.
Also assign_slots (prefill) collected every entry into a Vec per chunk once the cache is full.
Fix (claude/ple-stall a73d0906, a recency queue instead of the scan; cherry-picked here as b5d4a0db): ple-ab, seed off, same binary otherwise (G-noseed against plefix-noseed, one run each):
turn 5 24.5 -> 131.8 tok/s, window.ple 9,907 ms -> 58 ms over the request (63 -> 0.39 ms per round), round.run_window 11,861 -> 1,933 ms; turns 1-4 unchanged (126.1 134.5 138.0 129.9 against
125.9 134.4 139.9 134.9). Greedy identity (ple-id, static tier, teacher-forced replay of night5-long-256k, 353 rows): plefix against the unfixed build 353/353 identical, 0 argmax flips (A/A also exact).
The dt-eng3 arms (A, F: no fix) show the stall again in 3 of 4 arms (turn 5: 28.5, 22.0, 25.9 tok/s; F-nodefer happened not to hit it, 136.5): the stall depends on how many new trigrams the
generated text contains once the cache is full.
5. Quality gate, engine-commit A/B, greedy identity
Seed quality gate (dt-q2/dt-q3; teacher-forced replay of night5-long-256k, 5 requests, 48 forced decode tokens each, static tier, top-16 logprobs, rt-E): the A/A noise floor is exact
(353/353 and 345/345 identical rows). Seed on against seed off (292 common rows): 0 identical, d_top1 median 0.0026 / p99 0.2241 / max 0.5875, argmax flips 4 (1.4 %). Control, a bigger placement change
(placeholder profile, VRAM share 48 % instead of 90 %, against the upstream profile, both seed off; 295 common rows): p99 0.2363, max 0.4378, flips 6 (2.0 %). Against the criterion (p99 and max
<= 1.5x the control, flips <= 2.8 %) the seed change passes on 292 rows (0.224 <= 0.354, 0.588 <= 0.657, 1.4 % <= 2.8 %), but the row count is below the 1,000 the criterion asks for, so dt-q4
(MAX_NEW 240, three processes, rt-Q) repeats it with >= 1000 rows:
| comparison (teacher-forced, static tier) | common rows | d_top1 p99 | d_top1 max | argmax flips |
|---|---|---|---|---|
| control: placeholder-profile placement vs upstream placement, both seed off | 1,660 | 0.2278 | 0.6751 | 43 (2.59 %) |
| seed on vs seed off (upstream profile) | 1,717 | 0.2500 | 0.7567 | 36 (2.10 %) |
Criterion PASS (p99 0.250 <= 0.342, max 0.757 <= 1.013, flips 2.10 % <= 2.8 %, both >= 1000 rows). The class stays placement: no row is bit-identical, greedy ids can differ. The Original's own envelope (p99 <= 0.22, max <= 0.43, flips <= 2.8 %, measured on ~100-token prompts) is marginally exceeded by both the seed (p99 0.224, max 0.59) and the control (p99 0.236): any placement change at this context exceeds it by the same amount.
Engine-commit A/B without the PLE fix (dt-eng3, seed off, 245k frozen corpus, turns 1-4 tok/s; one run per arm): base 406b40a8 (A-noseed) 124.2 134.8 141.2 130.5; all commits (F-noseed)
123.2 137.0 131.8 134.4; F without the deferral 125.2 132.6 141.3 126.4; F again 126.1 134.5 138.0 120.8; 131.1 tok/s over the 16 turns of the four arms: no end-to-end difference is resolvable
(the spread per turn is 3-8 %). The spans of the same runs resolve the host-side effect directly (ms per round, turns 1-4, 585-609 rounds per arm):
| span | base | all commits | all commits, no deferral |
|---|---|---|---|
mtp.finish_ring (snapshot publish) |
0.090 | 0.003 | 0.002 |
draft.launch |
0.127 | 0.041 | 0.034 |
round.draft_committed |
1.790 | 1.664 / 1.696 | 1.701 |
round.adapt + adapt_deferred |
0.108 | 0.092 / 0.085 | 0.082 |
round.apply_pending |
0.157 | 0.278 / 0.255 | 0.169 |
| apply + adapt, together | 0.265 | 0.370 / 0.340 | 0.251 |
adapt.choose / adapt.queue |
- | 0.035 / 0.056 | 0.033 / 0.049 |
The snapshot memo and the chunked page list remove about 0.18 ms of host time per round in draft.launch + mtp.finish_ring (draft_committed falls by 0.09-0.13 ms); at 256k the saving grows with the
context. The deferral does not pay: the 0.09 ms it moves into the draft's shadow comes back as 0.10 ms more apply_pending, because the swap copies start later and are the critical path; it is now
opt-in (LELEKA_SERVE_ADAPT_DEFER=on, 9b03de2b). choose_swaps is 0.035 ms per round (0.14 ms per adaptation): the selection rewrite is not worth more than that.
With the PLE fix on both sides (dt-eng4, seed off, all five turns valid, deferral off), base 406b40a8 + a73d0906 (P) against decode-tail + a73d0906 (Q), arms P Q Q P (two each, 10 turns per side):
| P: base + PLE fix | Q: all engine commits + PLE fix | |
|---|---|---|
| tok/s over the 10 turns (tokens over seconds) | 131.8 | 131.6 (-0.2 %) |
| turns 1-4 only | 129.5 | 130.5 (+0.8 %) |
| per-turn standard deviation, tok/s | 8.2 | 6.5 |
round.draft_committed, ms per round (two runs) |
1.763 / 1.837 | 1.655 / 1.674 |
draft.launch / mtp.finish_ring |
0.133 / 0.093 and 0.127 / 0.092 | 0.034 / 0.003 and 0.033 / 0.002 |
round.adapt (choose + queue) |
0.105 / 0.100 | 0.079 / 0.084 |
round.apply_pending |
0.157 / 0.140 | 0.128 / 0.159 |
What the engine commits are worth: about 0.16 ms of host time per round (draft_committed -0.14, adapt -0.02), about 1 % of a 15 ms round, visible in the spans of the same runs; end to end the difference
(-0.2 % over 10 turns, standard error about 2 %) is not resolvable. No lossy change among them; identity: dt-id2 below.
Greedy identity of the engine commits (dt-id2, PASS): teacher-forced replay of night5-long-256k (5 requests, 48 forced tokens each), production shape, ADAPT_EVERY=4 (the adaptive tier swaps), seed off, one process per build, two identical arms each.
Base 406b40a8 (rt-A) against decode-tail + PLE fix (rt-Q: snapshot memo, chunked page list, choose_swaps selection, adaptive deferral off by default, recency-queue PLE cache): 353 common rows, 353 identical, 0 differing, 0 argmax flips; A/A exact in both builds (353/353). So the engine commits are bit-identical on top-16 logprobs
over this replay, with the adaptive tier on. The PLE fix alone was already proven identical (ple-id, static tier). Limit: 353 rows of 48 forced tokens per request; the deferral path (opt-in) was not part of this run.
6. Commits on claude/decode-tail
| commit | change | class |
|---|---|---|
286c2538, ea657e3e |
validate_snapshot memo (the MTP ring snapshot was scanned page by page about 7 times per round); LELEKA_MTP_SNAPSHOT_MEMO=off control |
lossless |
ee4f2617 |
chunked persistent page list for the ring snapshot (the per-round snapshot cloned 65,536 page Rcs at 256k) | lossless |
1c5a6c73 |
profile spans in begin_adaptation |
instrumentation |
0a3cda37 |
choose_swaps selects instead of sorting (same swaps, same order; unit test against the kept reference) |
lossless |
bb47b296, 9b03de2b |
adaptive planning/queueing after the draft launch; opt-in since 9b03de2b (net loss, section 5) |
lossless (same decisions, same order) |
b5d4a0db |
cherry-pick of claude/ple-stall a73d0906: PLE row cache evicts from a recency queue (turn-5 stall) |
lossless (cache only decides slots) |
5ef2c6eb, 359b4b5a |
LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS (experimental, default 0) |
placement |
69db3ab2, c84fcdcd |
harness: upstream profile + digest guard; long_session.py refuses an empty/short corpus and records the corpus digest |
tooling |
6fd2e897 |
PLE cache profile spans | instrumentation |
Per-round host cost before (o-def profile, seed ON, 245k): apply_pending 0.50 ms, begin_adaptation 0.15, draft.launch 0.23, mtp.finish_ring 0.14, draft.finish 1.49 of which the GPU chain steps ~1.1;
with the seed off apply_pending and begin_adaptation fall to about 0.1 ms each (fewer swaps).
7. Not verified
- No quality gate for the seed change yet; single-turn greedy identity of the engine commits not yet run (section 5).
- Vanilla was run with its shipped route tail skip (lossy); the skip-off pair
v-nskwas dropped for GPU time. - Per-commit engine A/B has no result yet; the micro numbers (e.g.
choose_swaps580 -> 480 us on the laptop) are not 5090 evidence.
Merge note (claude/decode-tail-merge, 2026-10-31): where main differs from this branch
This page is the claude/decode-tail record (commits 48ca624be .. 24c2743c3, 2026-10-29) merged with the one text main had added to it (section 7a). The code side of the merge keeps main's crates/leleka-runtime unchanged, so three statements below describe the branch build, not main:
LELEKA_SERVE_ADAPT_DEFER. The branch (9b03de2be) made the deferred adaptive planning opt-in (=on, default off) after measuring a net loss of about 0.09 ms per round (sections 5 and 8). Main'soriginal_serve_host.rswas not changed by this merge: there the deferral is still on by default andLELEKA_SERVE_ADAPT_DEFER=off(or0) restores the earlier order. Flipping the default would change main's behaviour, so it is not part of this merge; the measurement above stands as the case for doing it separately. Main also usesledger.agrees_with(consumed)where the branch hasledger.committed() == consumed; main's form is kept.- PLE row cache recency queue. Branch
b5d4a0db7is the same change as main'sa73d09060(already in main); main'skar_ple_cache.rsadditionally has the persistent scatter staging buffers (c2198a7b9). Main's file is kept whole. - Seed. Sections 2 and 5 describe
LELEKA_ORIGINAL_SERVE_SEEDas default on in the engine, which is still true of the engine; main's RTX 5090 profile sets it off (section 7a,fcb4f02ba, 2026-10-29), and that is where the seed quality gate of section 5 (1,717 rows) is cited from.
7a. Seed OFF in the RTX 5090 profile (text added on main by fcb4f02ba, 2026-10-29; placement class, owner confirmation required)
deploy/rust-runtime/profiles/rtx5090-32g.json sets engine_env.LELEKA_ORIGINAL_SERVE_SEED=off. The engine default (seed on) and the laptop profile (rtx3080-16g) are unchanged; nothing else in the profile moves.
This is a placement-class change and NOT bit-identical: the seed moves experts between the GPU and the CPU, which round differently, so no logprob row is identical and greedy ids can differ.
It is not a lossless optimisation and it does not fit the strict Original envelope (d_top1 p99 <= 0.22, max <= 0.43, measured on ~100-token prompts): neither seed OFF against ON nor the control below does.
The justification is the relative criterion, teacher-forced replay of night5-long-256k (240 forced tokens per request, static tier, upstream profile, one process per setting, 2026-10-29):
| comparison | common rows | d_top1 p99 | d_top1 max | argmax flips |
|---|---|---|---|---|
| control: placeholder-profile placement against upstream placement, both seed off (a larger placement change: VRAM share 48 % against 90 %) | 1,660 | 0.2278 | 0.6751 | 43 (2.59 %) |
| seed on against seed off (upstream profile) | 1,717 | 0.2500 | 0.7567 | 36 (2.10 %) |
Criterion: p99 and max <= 1.5x the control (0.342 / 1.013), flips <= 2.8 %, >= 1,000 rows on both: met. Same-configuration repeats are exact (A/A: 353/353 and 345/345 rows identical in the earlier 48-token runs), so the differences are the placement.
No perplexity or task-completion evaluation was run. The gain is decode speed at 45k-247k prompts: 108.1 -> 137.2 tok/s over turns 1-4 of the 5-turn 245k session (3 runs per arm, docs/experiments/decode-tail-5090.md).
To revert: remove "LELEKA_ORIGINAL_SERVE_SEED": "off" from engine_env of the profile, or set LELEKA_ORIGINAL_SERVE_SEED=on in the operator's engine environment (the operator's environment wins over the profile, Config::engine_environment).
The owner must confirm this default before the branch is merged.
8. Other levers, results as they land
- Slots footprint (
slots-footprint-ab, claude/slots-footprint7823672f, seed off, 2 + 2 alternating arms): the base arms are valid (all-turn mean 130.3 tok/s, per-turn 119.2 133.9 140.3 125.4 133.0; cache 11,280 slots; peak card use 31,548 of 32,607 MiB, lowest free 1,059 MiB). Both slots arms are INVALID: the build opens 11,664 slots (+384; dense weights 4038 against 4578 MiB) and then every request fails at the first prompt chunk (layer 27, QSA) withdriver error: BudgetExceeded/InputAllocation. No decode number. Reported to the slots DEV for a fix. Fixed buildbin-slots2(claude/slots-footprinteef6f598: the planner sizes against min(card free, context budget - allocated);E2E_GPU_BUDGET31,300 MiB for both arms) inslots-footprint-ab2: both runs valid, cache 11,568 slots (+288), per-turn mean over two runs 128.1 134.2 141.6 137.6 137.2, all-turn mean 135.7 against 130.3 for the base (+5.4 tok/s, +4.2 %), peak card use 31,572 MiB, lowest free 1,035 MiB (base 1,059). Caveats: n = 2 per side, the base runs were taken earlier (09:31-09:55Z) than the slots runs (10:38-10:55Z), not interleaved, and the per-turn spread is 3-8 %, so +4.2 % is an indication, not a settled gain. The product profile still has a 30 GiB budget, so the gain does not reachleleka upuntilgpu_budget_bytesis raised.
9. Headline: combined build against speed-train and vanilla (speedtrain3-ab, 2026-10-29 10:57-11:40Z)
Frozen corpus, seed off for both ours arms, upstream profile, order A B V A B V (alternating, two repeats), all six arms VALID (5 turns, final-turn input >= 246,885 tokens, turn-5 window.ple <= 0.4 ms).
speedtrain = claude/speed-train 47d2d389 (the code of fcb4f02b), speedtrain3 = claude/speed-train3 (speed-train + slots-footprint eef6f598: dense weights in 64 MiB slabs, planner respects the context budget, E2E_GPU_BUDGET 31,300 MiB for both ours arms,
- draft-tail), vanilla = Strata 0.2.6 as shipped (route tail skip ON, which is lossy). Decode tok/s:
| arm | T1 | T2 | T3 | T4 | T5 | all-turn mean |
|---|---|---|---|---|---|---|
| speedtrain (2 runs) | 125.5 | 132.6 | 144.5 | 129.4 | 132.0 | 132.8 |
| speedtrain3 (2 runs) | 133.1 | 141.5 | 150.7 | 141.9 | 146.6 | 142.7 |
| vanilla v-def (2 runs) | 123.7 | 149.3 | 159.6 | 126.9 | 141.8 | 140.2 |
| speedtrain3 - speedtrain | +7.5 | +8.9 | +6.2 | +12.6 | +14.6 | +10.0 (+7.5 %; adjacent pairs +6.4 %, +8.65 %) |
| speedtrain3 - vanilla | +9.4 | -7.8 | -8.9 | +15.1 | +4.7 | +2.5 (+1.8 %) |
Single vanilla runs vary much more (T3 141.2 and 178.1, T5 162.9 and 120.8) than ours (3-8 % per turn), so +1.8 % over vanilla is inside the vanilla noise; the +7.5 % over speed-train is outside ours.
Per-round host budget (ms per round, ours arms, run 1 and 2 of each): round.draft_committed 1.717 / 1.752 -> 1.432 / 1.522; mtp.finish_first_step 0.592 / 0.588 -> 0.161 / 0.158 (draft-tail); round.run_window 13.49 / 13.37 -> 12.96 / 13.02;
round.apply_pending 0.222 / 0.206 -> 0.265 / 0.255; commit.wait 0.261 / 0.258 -> 0.407 / 0.417 (the commit wait now absorbs what the draft used to wait for). Identity of the combined build (speedtrain2-id, the
speed-train2 predecessor): 349/349 rows identical to the base, 0 flips, A/A exact; speedtrain3-id (the speed-train3 build itself) PASS: 349 common rows, 349 identical to the speed-train base, 0 argmax flips, A/A exact in both builds (static tier, seed-independent replay).
Class: ours seed-off is placement class (section 2); vanilla ran with its lossy route tail skip.