Files
leleka/docs/experiments/decode-tail-5090.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 fcb4f02ba9 deploy: RTX 5090 profile sets LELEKA_ORIGINAL_SERVE_SEED=off (placement class, owner confirmation required)
Seed OFF is a profile setting only: the engine default (seed on) and the laptop profile are unchanged. Placement-class change, NOT bit-identical; it does not fit the strict Original
envelope (p99 <= 0.22, max <= 0.43) and neither does the control; it meets the relative criterion on 1,717 teacher-forced rows (p99 0.2500 vs control 0.2278, max 0.7567 vs 0.6751,
flips 2.10 % vs 2.59 %; limits 1.5x control and 2.8 %). Gain: 108.1 -> 137.2 tok/s decode over turns 1-4 of the frozen 245k session (3 runs per arm). Revert: remove the key or set
LELEKA_ORIGINAL_SERVE_SEED=on in the operator environment. Test: only_the_server_profile_turns_the_prompt_routing_seed_off; leleka-deploy tests 125 passed in WSL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:09:44 +01:00

100 lines
8.7 KiB
Markdown

# 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 (16-41 tok/s): see section 4.
## 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 (pending).
## 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.
The fix is owned by `claude/ple-stall`. Also `assign_slots` (prefill) collects every entry into a Vec per chunk once the cache is full.
## 5. Quality gate, engine-commit A/B, greedy identity
Pending at the time of writing; see the result sections appended below.
## 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 | adaptive planning/queueing runs after the draft launch (`LELEKA_SERVE_ADAPT_DEFER=off` control) | lossless (same decisions, same order) |
| 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-nsk` was dropped for GPU time.
- Per-commit engine A/B has no result yet; the micro numbers (e.g. `choose_swaps` 580 -> 480 us on the laptop) are not 5090 evidence.
### Seed OFF in the RTX 5090 profile (placement class, owner confirmation required before merge)
`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.