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>
445 lines
36 KiB
Markdown
445 lines
36 KiB
Markdown
# Original mode17 serve path
|
|
|
|
Status: source-complete at the wiring level, **not GPU-run** (no device was available when this was written).
|
|
Nothing here certifies quality or speed; selection is an operator choice, as for the other experimental modes.
|
|
|
|
## What it is
|
|
|
|
`generate.cpp`'s serve loop as a backend: the Original batched prompt read, then `OriginalSpecController`
|
|
(spec 4, suffix draft 3, verify windows up to 6) over the native `OriginalVerifier` with MTP drafting and
|
|
accepted-prefix commit. The preview path (the Rust-native decoder chain) is unchanged.
|
|
|
|
| piece | file |
|
|
| --- | --- |
|
|
| backend selection and owner loop | `crates/leleka-runtime/src/backend_original_serve.rs` |
|
|
| per-request flow (admit, reset, prefill, decode) | `qwen_forward/original_serve_request.rs`, `original_serve_stack.rs` |
|
|
| verifier assembly per decode phase | `qwen_forward/original_serve_verifier.rs` |
|
|
| the owners behind the serve port | `qwen_forward/original_serve_host.rs`, `original_serve_native.rs` |
|
|
| expert tier, lineage ledger, mode17 constants | `original_serve_pool.rs`, `original_serve_ledger.rs`, `original_serve_config.rs` |
|
|
| VRAM expert tier (R4 residency, PCIe share, adaptive swaps, prompt loan) | `qwen_forward/original_serve_residency.rs`; driver `original_verify_gpu_plan.rs`, `original_expert_cache.rs` |
|
|
| verified-window publication into `QwenSession` | `qwen_forward/session_original_verified.rs` |
|
|
|
|
## Selecting it
|
|
|
|
`leleka-inference ... [--backend-mode auto|original|preview] [--original-prefill-capacity N] [--mtp-rt-dir PATH] [--spec-min-p F] [--kv int8] [--kv-resident CELLS]`
|
|
|
|
`--kv` / `--kv-resident` select the QSA KV storage and the resident window (default INT8, 32768 cells per layer
|
|
in VRAM, the rest streamed from pinned host memory); see `docs/kv-streaming.md`.
|
|
|
|
* `auto` (default): the Original path when every compiled asset and every verifier window asset/producer it
|
|
needs is present in the build (`leleka_cuda_driver::unsealed_original_serve_assets()`: native head,
|
|
sampler, verifier and MTP-session PTX, the window kernels `unsealed_window_assets()`, and any producer in
|
|
`UNBOUND_PRODUCERS`) **and** the configuration can feed it (inherited sealed KAR archive, MTP pack, no KAR
|
|
expert source, no experimental mode, context within the trained size); otherwise the preview path, with the
|
|
reason on stderr. An `--experimental-*` flag selects preview
|
|
unless the mode is given explicitly.
|
|
* `original`: never falls back. Refuses naming what is missing, e.g. the unbound window producers or an
|
|
unsealed PTX; refuses a KAR expert source (the Original executors read the pinned model's own mapped
|
|
routed experts, not a KAR level decode).
|
|
* `preview`: never starts the Original path.
|
|
|
|
The load must be the explicit KAR PLE MTP load, as for the windowed256 modes.
|
|
|
|
## VRAM expert tier (off by default)
|
|
|
|
`StackConfig::expert_tier` (`ExpertTierConfig`), selected for `leleka-inference` and the smoke by environment:
|
|
|
|
| variable | Original flag | default |
|
|
| --- | --- | --- |
|
|
| `LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS` = `auto` \| N | `--expert-cache` | off (a profile alone means auto) |
|
|
| `LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes` | `--expert-cache-per-layer` | global |
|
|
| `LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=P` | `--expert-profile` | none |
|
|
| `LELEKA_ORIGINAL_SERVE_PCIE_FRAC` | `--pcie-frac` | 0.55 over a pinned bank (job 802); 0 over the pageable low-RAM bank unless set |
|
|
| `LELEKA_ORIGINAL_SERVE_PCIE_MODE` = `auto` \| `dma` \| `kernel` | `--pcie-mode` | auto (the copy kernel when the bank has device aliases) |
|
|
| `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY` / `_ADAPT_SWAPS` | `--adapt-every` / `--adapt-swaps` | 4 / 96 |
|
|
| `LELEKA_ORIGINAL_SERVE_VRAM_RESERVE_MIB` / `_DECODE_RESERVE_MIB` | `--vram-reserve-mib` / port only | 700 / 1024 (auto sizing) |
|
|
| `LELEKA_ORIGINAL_SERVE_PREFILL_BORROW=no` | `--no-prefill-borrow` | borrow (with a profile) |
|
|
|
|
What runs, literally after generate.cpp / expert_source.cpp:
|
|
|
|
* The cache is opened after every other owner (`original_cache_startup::open`: auto/explicit, profile-sized slots,
|
|
3/4 retry), filled from the profile in rank order through the registered model bank (per-layer skips a full
|
|
layer, global stops at the first refusal) and slot 0 is read back.
|
|
* Each verify-window layer group is split on its own routed ids (`split_group`): resident experts are VRAM groups,
|
|
the last `nmiss * pcie_num >> 8` misses (at most the staging blobs, at most 64) are staged over PCIe, the rest go
|
|
to the CPU pool, which computes only its entries and zeroes the GPU's. Staging (`--pcie-mode`): the copy kernel
|
|
(mode 2, generate.cpp's default) - the plan carries the device aliases of each PCIe expert's three registered spans
|
|
(`ptr2[3q+r]`), flag B rises at once, and the window graph copies them into staging slot `q` after wait B
|
|
(`verify_fetch_spans_kernel`, `original_verify_window_pcie.cu`: fetch_blobs over three spans, gate|up|down exactly as
|
|
the DMA wrote them) and rebases `ptr2[q]`; no host CUDA call sits inside the window. `dma` (mode 0) keeps the
|
|
per-span `cuMemcpyHtoDAsync` on the copy stream and the host-function flag B. The pageable low-RAM bank has no
|
|
aliases: `auto` takes DMA there. The plan is published (flag A) before the CPU starts. Every VRAM pointer is a
|
|
fenced slot whose owner is checked against the doorbell's ids.
|
|
* Adaptive tier: per (layer, expert) routed counts; every `adapt_every` rounds the most-routed misses (count >= 2)
|
|
replace the least-routed residents of their layer while the gain is >= 1.5, best `adapt_swaps`, then counts
|
|
decay by 0.7. Swaps copy on the tier's own stream; an evicted expert is a miss at once, the new one resident
|
|
when the copies' event completed (polled at each round start; waited at a request start).
|
|
* Prompt loan: with a profile the prompt path borrows the cache's last slots (the configured chunk must leave 128
|
|
slots); the unlent prefix serves its hits; every lent slot is refilled from the bank before the decode phase,
|
|
also after a failure or cancellation.
|
|
|
|
GPU experts round differently from the CPU's (bench/results/2026-09-27-cache-parity); a reply with the tier on may
|
|
differ slightly from one without it, and a repeated greedy request may differ after adaptive swaps.
|
|
|
|
Deviations: the loan is sized for the configured chunk, not per request (`Prefill::relayout`): the prompt executor
|
|
is built for exactly one capacity; without a loan the prompt path has no cache hits (the driver only serves them
|
|
from a lent prefix); `expert_cache_cpu_order`, remote caches, layer splits and the resident RAM mode are not
|
|
ported (`cpu_order` only concerns the S2 hit kernel, not native packs).
|
|
|
|
Proof without a model: `LELEKA_EXPERT_TIER_GPU=yes cargo test -p leleka-runtime --lib -- --ignored
|
|
original_serve_residency_gpu` (synthetic IQ4_XS/IQ4_NL experts: placement, bit-identical CPU entries, GPU entries
|
|
within 3e-2 relative L1 of the CPU path; RTX 5090 2026-10-16: worst 1.155e-2). Not yet run on a device: the PCIe
|
|
DMA share and adaptive swaps (they need the registered model bank), and every real-model run.
|
|
|
|
## Request plumbing
|
|
|
|
* Admission: `n + max_new + 8 <= context_tokens` (generate.cpp), before any work.
|
|
* Sampling: the request's `SamplingParams` map field for field to the driver `SamplerParams`
|
|
(`driver_sampler_params`); a greedy request without penalties takes the plain argmax. Unseeded requests
|
|
take a clock seed. Penalty history is the literal per-row window (tail of the committed tokens + the
|
|
window prefix), uploaded per window.
|
|
* Rope / context: `RopeConstants::from_serving_context()` (the analytic RoPE form of the process serving
|
|
context) feeds both the verifier's QSA append and the draft K/V policy.
|
|
* MTP: the digest-pinned pack of the binding, or the Original `--mtp DIR` bank (`--mtp-rt-dir`); coupled draft
|
|
sampling only with `STRATA_SPEC_COUPLED` as in the Original.
|
|
* Without the conversation cache every request starts at position 0: the session, the draft ring and the twelve
|
|
resident QSA layers are rolled back to the empty-prompt checkpoints taken at load.
|
|
|
|
## Conversation cache
|
|
|
|
`--prompt-cache N` (`StackConfig::conversation`; **on by default** with the Original's 6 after jobs 411-413 below;
|
|
`--prompt-cache 0` turns it off), `--prompt-cache-every N` (16384), `--prompt-cache-root N` (2048),
|
|
`--turn-token ID` (248045, negative = none), `STRATA_CKPT_REREAD=1` (re-read instead of restore, the Original's
|
|
check of a checkpoint). Code: `qwen_forward/original_serve_conversation.rs` over the golden-tested policy in
|
|
`conversation/manager.rs`.
|
|
|
|
* Where a request starts: the live session when the prompt extends exactly what it holds, else the deepest kept
|
|
checkpoint that is a prefix of the prompt, else the empty prompt; only `prompt[resume..n-1]` is prefilled.
|
|
`Usage::reused_input_tokens` and the `leleka-serve request outcome=... reused=` line report `resume`.
|
|
* Checkpoints (generate.cpp `checkpoint_at`): at the last `<|im_start|>` of the prompt, at the first one of a
|
|
prompt read from 0 when at least `--prompt-cache-root` in (the pinned root), and every `--prompt-cache-every`
|
|
fresh tokens; `--prompt-cache` of them, root pinned, the rest LRU.
|
|
* A checkpoint is the session's Original checkpoint (immutable GDN/PLE host priors and the twelve resident QSA
|
|
witnesses: index checkpoint + mapped K/V prefix) plus the MTP ring's immutable snapshot, taken together at a
|
|
published chunk boundary (~118 MB of host RAM per checkpoint, as in the Original; the K/V stays positional).
|
|
A restore re-stamps it onto the session's current branch generation
|
|
(`OriginalSessionCheckpoint::rebased_onto_current`), rolls the session and the resident layers back
|
|
(index/K-V epoch and coverage are re-checked by the driver), re-anchors the ring at its snapshot
|
|
(`OriginalDraftSession::resume_at`) and runs the drafter's `kv_restore(resume)`.
|
|
* Live continuation is used only when the draft ring stands at the session's position after the decode phase
|
|
(then `settle_state` reads the GDN/PLE state back). generate.cpp skips the draft of the last window on
|
|
EOS/length and continues with that gap in the ring; this port's draft lineage does not admit the gap, so such
|
|
a request resumes from its last turn checkpoint instead (it re-reads the reply).
|
|
* Not bound: parking whole conversations in host RAM (`--conversation-cache-mib`, opt-in in the Original too). The port's answer for a
|
|
pool of agents is the content-addressed cross-session prefix cache of `docs/prefix-cache.md` (`--prefix-cache-mib`), which replaces
|
|
this cache when it is on.
|
|
* Any failure of the cache drops it and the request reads its whole prompt; a failed or broken request drops it.
|
|
* What "the same answer" means: the batched prefill's arithmetic depends on how the prompt is cut into chunks, and
|
|
a resumed request is cut differently from a full read (it starts at the resume point; a root boundary is only
|
|
cut when reading from 0). A near tie can then flip a token, exactly as in the Original. A resumed request is
|
|
token-identical to a read that cuts the same chunks (jobs 411-413); turning the cache on or off also changes
|
|
the cuts of a full read (turn/root boundaries), so cache-on and cache-off replies may differ the same way.
|
|
|
|
## Verified-window publication
|
|
|
|
The verifier owns the canonical GDN image, the PLE history and the twelve QSA index/K-V journals for a decode
|
|
phase. After each commit event the host publishes the accepted rows (position, predecessors and the twelve
|
|
resident QSA witnesses, read from the verifier's own journal) to the session. The recurrent GDN/PLE state
|
|
lags and is read back once at the end of the phase when a consumer needs it (`StackConfig::settle_state`);
|
|
while it lags the session refuses prompt transactions and checkpoints.
|
|
|
|
Per round, in generate.cpp's order: the commit graph is enqueued, the MTP draft is launched behind it (the draft
|
|
stream waits the commit event on the device: `OriginalMtpDrafter::launch_from_verifier`, against the branch the
|
|
commit will publish, validated while the session still stands at the window's origin), then the host waits the
|
|
commit event and publishes the session while the draft runs, and the draft is read back and its ring published
|
|
only once the session holds exactly that origin (`finish_from_verifier`). The twelve witness checkpoints are one
|
|
fenced batch after the commit event (`OriginalVerifier::checkpoint_committed_qsa_all`: stream-ordered copies, one
|
|
drain, pooled checkpoint buffers) and the rows are published without a context synchronize
|
|
(`publish_original_verified_rows_fenced`); a context synchronize would also wait for the adaptive swaps the
|
|
Original runs beside the commit. A/B controls: `LELEKA_SERVE_OVERLAP=off` (settle, then draft) and
|
|
`LELEKA_SERVE_PUBLISH=serial` (per-layer checkpoints with a context synchronize each).
|
|
|
|
## Running the GPU smoke
|
|
|
|
```
|
|
LELEKA_ORIGINAL_SERVE_SMOKE=yes \
|
|
LELEKA_STRA169_KAR_FD=… LELEKA_STRA169_KAR_PROVENANCE=… \
|
|
LELEKA_STRA169_IQ3S_SHARD0=… LELEKA_STRA169_IQ3S_SHARD1=… \
|
|
LELEKA_STRA169_MTP_PACK=… LELEKA_STRA169_MTP_STAGING=… \
|
|
[LELEKA_ORIGINAL_SERVE_RT_DIR=…] [LELEKA_ORIGINAL_SERVE_CAPACITY=1024] [LELEKA_ORIGINAL_SERVE_BUDGET_GIB=28] \
|
|
cargo test -p leleka-runtime --features cuda-driver -- --ignored original_serve_smoke
|
|
```
|
|
|
|
The long-context variant (`original_serve_long_context_streamed_kv_smoke`, `LELEKA_ORIGINAL_SERVE_LONG_SMOKE=yes`,
|
|
`LELEKA_ORIGINAL_SERVE_LONG_TOKENS`, `LELEKA_ORIGINAL_SERVE_KV_RESIDENT`, `LELEKA_ORIGINAL_SERVE_MAX_CONTEXT`) is
|
|
described in `docs/kv-streaming.md`.
|
|
|
|
It opens the stack, serves a greedy request twice (the second must reproduce the first across a reset),
|
|
a sampled request with penalties, a request cancelled after its first committed round, and a final request
|
|
that must reproduce the first. While `UNBOUND_PRODUCERS` is non-empty the stack refuses to open with the
|
|
first missing producer's name; that is the expected result until they are bound.
|
|
|
|
## Open items
|
|
|
|
* The compiled assets the probe lists as unsealed: the native head, sampler, MTP session PTX and the two window
|
|
kernels (`original_verify_window_moe_experts.ptx`, `original_verify_window_qsa_gate.ptx`) were sealed with nvcc
|
|
13.2.86 on 2026-10-15 (GPU load is verified separately by the host smokes; no numerical claim). A window asset
|
|
whose bytes stop matching its pin fails the whole window before capture. Remaining placeholders
|
|
(`mmq_original_group_*`, `mtp_original_scalar_{gr,norm}`, `native_parity`) are still reported as unsealed. All 21 former window producers are bound by the
|
|
planner; the runtime attaches projections, hyper-connection/PLE, QSA and router/shared-expert operands
|
|
(`dense_original_verify.rs`, `cache_original_verify.rs`) to every window graph.
|
|
* A new `OriginalVerifier` is assembled and its graphs captured for every request: ~110 ms of each TTFT on the 5090
|
|
(job 800: canonical GDN upload 17 ms, seven graph captures 91 ms) plus ~13 ms of teardown. Keeping one alive is not
|
|
a local change: every window binding (`OriginalVerifyWindowResources<'a>`: projections, hc/PLE, QSA, MoE weights,
|
|
the GDN journal) borrows the stack's own dense and MoE caches, which the stack owns (self-reference; the crate
|
|
forbids `unsafe`) and which the prompt path mutates between decode phases (`&mut MoeWeightCache`, shared experts
|
|
reloaded by `ensure_original_verify_shared`), and the twelve QSA owners move one way into the verifier's journal
|
|
while the prompt path needs them back. A re-seed path needs the bindings to own (or `Rc`) their buffers, shared
|
|
experts pinned at fixed addresses, and a journal that lends and re-admits the same physical owners. The prompt's
|
|
lent-slot refill (~49 ms per request) is host time spent in `original_expert_spans`' per-call scan, not copy time:
|
|
queueing it beside the capture saved nothing (job 801, reverted); cached span admission would.
|
|
* Routed experts run on the all-CPU pool unless the VRAM expert tier is selected (above); it is not yet measured
|
|
on the real model. The prefill chunk is an operator choice (default 2048) instead of the Original's
|
|
slot-derived ladder.
|
|
* Short prompts also take the batched prefill (the Original reads <= 64 tokens through verify windows).
|
|
* `draft_first` (CLI only), scaled RoPE tables (`STRATA_ROPE_TABLE`), multi-stage and vision requests are not
|
|
supported.
|
|
* Conversation cache: parking and live continuation after an undrafted last window are not bound; no long
|
|
multi-turn agent session (many requests, eviction under the 6-checkpoint chain) has run on the GPU yet. The
|
|
one-token prompt (no prompt append, so no streamed-KV resolver) is fixed by
|
|
`OriginalQsaMappedJournal::ensure_resolver` at assemble (model-free GPU test and the real-model smokes pass).
|
|
* `LELEKA_SERVE_PROFILE=1` prints one `DBG profile request:` line per request (named host phase spans, see
|
|
`original_serve_profile.rs`); jobs 800-803 below are the first measurements.
|
|
|
|
## Running the conversation smoke
|
|
|
|
Same inputs as the serve smoke; `--exact backend::original_serve_smoke::original_serve_conversation_smoke_resume_matches_a_full_read`.
|
|
It serves a one-token prompt first, then chat A, then chat B = A + reply + a new user turn (must resume,
|
|
`reused > 0`), then B again read from 0 (`forget_conversation`), asserting equal greedy tokens and printing TTFT
|
|
on the `CONV` lines, then a new chat sharing the system prompt (root checkpoint). Optional
|
|
`LELEKA_CONVERSATION_SYSTEM_REPEAT` (120), `LELEKA_CONVERSATION_MAX_NEW` (48), `STRATA_CKPT_REREAD=1`;
|
|
`LELEKA_CONVERSATION_CACHE=off` is the control (same requests, nothing reused).
|
|
|
|
Job 411 (RTX 5090, 2026-10-16, branch `claude/conversation-cache` 562f35d = bring-up e9995d8 + 791a4fa, capacity
|
|
1024, budget 24 GiB, greedy, max_new 48, one run each, no warm-up beyond the requests listed):
|
|
|
|
| request | n | reused | TTFT ms (cache on) | TTFT ms (cache off control) |
|
|
| --- | --- | --- | --- | --- |
|
|
| one-token prompt (first after open) | 1 | 0 | 684 | 1155 |
|
|
| chat A (cold) | 2300 | 0 | 9787 | 9183 |
|
|
| chat B = A + reply + new turn | 2364 | 2297 | 1646 | 9547 (reused 0) |
|
|
| chat B read from 0 (`forget_conversation`) | 2364 | 0 | 10331 | 9619 |
|
|
| new chat, same system prompt (root) | 2301 | 2286 | 983 | 9144 (reused 0) |
|
|
|
|
Greedy tokens of B resumed == B read from 0 (38 tokens, identical) in the cache-on run; the off run also
|
|
repeats B exactly. Chat A's last two of 48 tokens differ between the two runs: not run-to-run noise but the
|
|
chunking above (with the cache on A is cut at its root and turn boundaries, with it off it is not). This is one
|
|
sample per cell, not a performance qualification.
|
|
|
|
Coverage: `original_serve_conversation_coverage_smoke` (`--prompt-cache-every 2048`, a ~4.8k-token chat) checks
|
|
the periodic checkpoint, the root fallback of a follow-up that edits an earlier turn, an unrelated prompt (empty),
|
|
a seeded sampled follow-up, cancellation in the decode and in the prefill (each followed by a request), and
|
|
same-process determinism. Each resumed request is compared with the same request read from 0 only when both cut
|
|
the same prefill chunks (`same_chunks` replays both prompt plans; otherwise a `CONV-INFO` line) and at least one
|
|
strict resumed comparison must hold. Job 413 (a9e1d0a, cache on by default, capacity 1024, greedy max_new 48):
|
|
|
|
| request | n | reused | TTFT ms | vs read from 0 |
|
|
| --- | --- | --- | --- | --- |
|
|
| chat A cold (x2 in one process, and in every process of jobs 412/413) | 4770 | 0 | 18066-20044 | identical |
|
|
| P: diverges inside the system prompt at 4278 | 4778 | 4096 (periodic) | 3623 (full 18373) | other chunks; differs at 1 of 48 |
|
|
| F: edits the earlier user turn | 4842 | 4764 (root) | 1653 (full 19085) | identical |
|
|
| U: unrelated prompt | 26 | 0 | 1171 | - |
|
|
| S: seeded sampled follow-up of U | 73 | 23 | - | other chunks; differs |
|
|
| Q2: next turn after a decode cancel | 113 | 110 | 510 (full 1857) | identical |
|
|
| A after a prefill cancel | 4770 | 0 | 18240 | identical to A cold |
|
|
|
|
With `STRATA_CKPT_REREAD=1` (separate process) F, S and Q2 re-read are token-identical to the restored ones
|
|
(S: same chunks, unlike the full read); P differs because the re-read from 0 also cuts the root boundary. The
|
|
existing serve smoke passes with the cache on by default. Job 412 (same requests, cache off) shows the stack is
|
|
deterministic within and across processes for identical inputs and identical chunks.
|
|
|
|
## Round overhead (jobs 800-804)
|
|
|
|
RTX 5090, Ryzen 9 9950X3D, driver 595.99.02; one binary per job with A/B environment switches; 6 prompts of
|
|
`~/work/gpu-runs/prompts.txt` x 2 passes x 128 greedy tokens (`LELEKA_SMOKE_MIN_P=0.5`), expert tier on (2048 slots,
|
|
per layer, profile, `PCIE_FRAC=0.55`), `LELEKA_SERVE_PROFILE=1`. "Static" = `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0`
|
|
(placement independent of copy timing, so arms are compared token for token). Per-round figures are profile sums
|
|
over the 12 corpus requests divided by their rounds.
|
|
|
|
Job 803 (round-overhead 3e8e10e on port-gpu-bringup f845d86, static, arms A B C D D C B A):
|
|
|
|
| arm | decode tok/s (12 req) | ms/round | window | PCIe plan | publish | draft | vs old |
|
|
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
| old (serial publish, no overlap, DMA) | 47.5 / 47.4 | 52.5 / 52.6 | 50.0 / 50.1 | 2.36 | 0.24 | 2.48 | - |
|
|
| new (all three) | 49.1 / 49.2 | 50.8 / 50.6 | 48.6 / 48.4 | 0.10 | 0.20 | 2.19 | 12/12 identical (x2) |
|
|
| new, DMA staging | 49.1 / 47.7 | 51.0 / 52.3 | 48.8 / 50.0 | 2.24-2.34 | 0.17 | 2.18 | 10/12, 12/12 |
|
|
| new, no overlap | 48.9 / 48.9 | 50.9 / 50.9 | 48.5 / 48.5 | 0.09 | 0.19 | 2.44 | 12/12 identical (x2) |
|
|
|
|
"Identical" = every corpus request's tokens and round count, plus the smoke's greedy, seeded-sampled and short
|
|
requests. The 10/12 DMA arm differs from its own repeat as well: the two other DMA-staged arms (old x2, DMA-2) agree.
|
|
TTFT is unchanged by these (793-803 ms means; the conversation cache resumes pass 1).
|
|
|
|
With the adaptive tier (default) the fenced publication removed the per-round context synchronizes (publish 1.9 ->
|
|
0.2 ms, draft 3.3 -> 2.2 ms) but the swap copies then overlap the next window and its CPU share (CPU pool +1-2
|
|
ms/round; 62.6 / 63.8 vs 63.7 / 64.4 tok/s with `LELEKA_SERVE_PUBLISH=serial`); the swaps are now awaited at the
|
|
round start (3eb7405, job 804).
|
|
|
|
Job 802 (`--pcie-frac` 0 vs 0.55 with the copy kernel, adaptive, a b b a): 41.9 / 42.7 vs 62.2 / 63.6 tok/s, TTFT
|
|
1214 / 1209 vs 1212 / 1207 ms; the default is now 0.55 (placement differs, so tokens do).
|
|
|
|
Job 801: queueing the prompt's lent-slot refill beside the window capture saved nothing (TTFT 1215 vs 1218 ms; the
|
|
~49 ms is host span validation) and was reverted.
|
|
|
|
Job 800 profile of the old path (adaptive, before the merge of f845d86) per round: window 36.6 ms (CPU share 25.0,
|
|
PCIe plan 1.6 of it), publish 1.3 (twelve checkpoints, each with a context synchronize that waits for the swaps),
|
|
draft 3.5; per request: verifier assembly 111 ms (canonical GDN upload 17, seven graph captures 92), teardown 13.
|
|
|
|
Job 804 (3eb7405-era binary rt-b8, static, o m x x m o): sharing the verify window's sealed modules across the
|
|
per-request verifiers (`Context::window_modules`, `LELEKA_WINDOW_MODULE_CACHE=off` to disable) cut the verifier
|
|
assembly from 118 / 118 to 70 / 70 ms (module loading 49 -> 0.4 ms; capture 29 and instantiate 21 ms remain) and
|
|
the TTFT mean over the 12 requests from 807 / 812 to 763 / 755 ms, outputs 12/12 identical, decode unchanged
|
|
(49.2 / 49.4 vs 49.1 / 49.2 tok/s). Re-using the previous verifier's graph executables through cuGraphExecUpdate
|
|
(6fa92c1) broke the stack in both arms that enabled it (window `CudaExecution` after a few requests; the 3080
|
|
laptop saw the same on its third request) and was reverted (c45bcaa); the root cause was not isolated: the failure
|
|
appears only when the update is accepted (with the module cache off the functions differ, the update is refused,
|
|
the graph is instantiated and the runs pass).
|
|
|
|
### Expert residency (job 805, rt-b9 = round-overhead 973e0d2 on port-gpu-bringup 0850cfe)
|
|
|
|
`~/work/gpu-runs/baseline/profile.bin` is a placeholder: `make_profile.py --no-base` without a trace, i.e. every
|
|
(layer, expert) pair in index order interleaved across the layers. With it, static residency serves 7-9 % of the
|
|
routed entries from VRAM (random placement: 2048 of 24,576 experts is 8.3 %). Same 6 prompts x 2 passes x 128 tokens:
|
|
|
|
| residency | profile | decode tok/s (12 req, 2 runs) | VRAM hits per request |
|
|
| --- | --- | --- | --- |
|
|
| static | placeholder | 49.9 / 49.9 | 7-9 % |
|
|
| static | shipped `data/expert-profile.bin` (sha256 8f59b4aa, the laptop's) | 51.0 / 51.0 | 4-19 % |
|
|
| static | trace of 12 unrelated prompts x 256 tokens (`LELEKA_ORIGINAL_SERVE_DUMP_ROUTING` + `make_profile.py`) | 54.9 / 54.9 | 12-22 % |
|
|
| adaptive (default) | placeholder | 66.8 / 67.0 | pass 0: 15-43 %, pass 1: 31-64 % |
|
|
| adaptive | shipped | 67.2 / 67.2 | pass 0: 11-50 %, pass 1: 31-59 % |
|
|
| adaptive | trace | 67.1 | pass 0: 15-48 %, pass 1: 35-62 % |
|
|
| adaptive, swaps polled (`LELEKA_SERVE_SWAP_WAIT=off`) | placeholder | 64.8 | |
|
|
| adaptive, old host path (serial publish, no overlap, DMA, polled) | placeholder | 69.2 (one run) | |
|
|
|
|
The adaptive tier's gain is residency matched to the conversation being served (it swaps in what these very
|
|
requests route): no static ranking from another workload gets there, and under adaptation the starting profile
|
|
hardly matters. The prompt's own routing (computed by the prefill) would be the earliest signal for a first
|
|
request; that needs a hook in the prompt path and is not done. The single old-path run was faster than the new
|
|
default with adaptation (window 32.9 vs 35.4 ms at an equal CPU share): job 807 separates the PCIe staging mode.
|
|
|
|
### Gap to the unmodified Original (job 809)
|
|
|
|
`stra169-ladder/build-sm120/strata --serve` (spec 4, suffix draft 3, min_p 0.5, per-layer 2048 slots from the
|
|
placeholder profile, pcie 0.55, int8 KV, KAR PLE L2, `--mtp data/mtp-rt --prefill 2048`), one process, the port's
|
|
6 prompts x 2 passes x 128 greedy tokens (`~/work/gpu-runs/round-profile/original-serve.sh`, holder job, alone on the
|
|
GPU). Decode = produced tokens / decode phase ms, over the requests of 100+ tokens:
|
|
|
|
| engine (placeholder profile) | decode tok/s pass 0 | pass 1 | mean | prompt phase ms |
|
|
| --- | --- | --- | --- | --- |
|
|
| Original | 52.8 | 74.7 | 63.8 | 639 |
|
|
| port, adaptive (job 805 a-ph-1, 9 long requests) | 57.1 | 69.8 | 64.2 | 648 |
|
|
| port, static (job 805 s-ph-1) | 47.7 | 49.1 | 48.4 | 658 |
|
|
|
|
On this workload the port's decode matches the Original's (64.2 vs 63.8 mean); the Original is faster on repeats
|
|
(74.7 vs 69.8) and slower on first-time prompts (52.8 vs 57.1). One run each, no CI: not a performance claim.
|
|
Greedy ids against the Original (pass 0, first differing token index): static port identical on prompts 1, 4, 5 and
|
|
differs at 19 / 4 / 100 on prompts 0, 2, 3; adaptive port identical on prompt 1 and differs at 6 / 4 / 28 / 77 / 7
|
|
on the rest. GPU and CPU experts round differently and each engine places a different set on the GPU, so this is
|
|
the documented cache-parity envelope, not a gate; prompt 2 diverging at token 4 in both port modes (the Original
|
|
stops at 90 tokens, the port runs to 128) is the one worth a logit-level look.
|
|
|
|
## Residency seeded from the prompt's own routing (`claude/seed-residency`, experimental, off by default)
|
|
|
|
The adaptive tier needs rounds to learn a request's experts (job 805: a first request gains +13-20 % from it, a repeated
|
|
one +35 %). The prompt's prefill already holds the signal: the MoE stage reads the route ids on the host to group the rows
|
|
by expert (`OriginalMoePromptLayer::counts`, as prefill.cpp `m.cnt`; the Original does not use it for residency, its
|
|
`--dump-routing` records decode windows only). `LELEKA_ORIGINAL_SERVE_SEED=on|N` (N = most swaps) collects those counts per
|
|
(layer, expert) (a host-side add of <= 512 entries per layer, no device work and no extra synchronize), and after the
|
|
lent slots are refilled swaps the most-routed missing experts of every layer into the slots of the least-routed
|
|
resident ones (the adaptive tier's own ranking, `choose_swaps`, counts >= 2 and gain >= 1.5) as ONE batch on the tier's
|
|
copy stream; the verifier assembly overlaps the copies and the first round's `apply_pending` lands them. Related knobs:
|
|
`_SEED_KEEP` (credit for every resident expert: the blend with the profile), `_SEED_USAGE` (add the prompt counts to the
|
|
adaptive counts), `_SEED_DECAY` (fade earlier prompt chunks; 0 = last chunk only), `LELEKA_SEED_TRACE=1`. The seed turns
|
|
`LELEKA_REFILL_DEFER` off for its requests. Code: `original_serve_seed.rs`, the hook in `cache_original_prompt.rs`.
|
|
|
|
Method: one process per run, `LELEKA_SMOKE_ARMS` / `LELEKA_LAPTOP_ARMS` / `LELEKA_ORIGINAL_SERVE_LONG_ARMS`
|
|
(`backend_original_serve_arms.rs`): every request starts from a first-request state (`reset_expert_tier`: the profile's
|
|
placement slot for slot, empty adaptive counts, a fresh controller; conversation cache off), the arms of one prompt run
|
|
back to back in reversed order on alternate prompts, each prompt twice, other cold-start orders per job. Hit rates are the
|
|
VRAM share of window entries over the first 8 / 16 / 32 rounds (`@8`...). `static+id=b` is an A/A control of `static`,
|
|
`static+seed=1` the hook-only control (captures the counts, one swap).
|
|
|
|
RTX 5090, first requests, 128 new tokens, `baseline/profile.bin` (placeholder) start, 2048 slots per layer, jobs 973 / 975
|
|
(sd-a4; the same on the trace profile within 1 tok/s):
|
|
|
|
| arm (12 corpus prompts of 56-101 tokens) | decode tok/s | VRAM @8 / @32 rounds | prompt phase ms |
|
|
| --- | --- | --- | --- |
|
|
| static | 47.9 | 8.3 / 8.3 % | 633 |
|
|
| static, A/A repeat | 48.2 | 8.3 / 8.3 % | 601 |
|
|
| static + hook only (seed=1) | 47.3 | 8.5 / 8.4 % | 601 |
|
|
| static + seed | 63.9 | 52.5 / 45.8 % | 683 (~1800 swaps, 85-90 ms to queue) |
|
|
| adaptive | 56.1 | 13.4 / 29.0 % | 601 |
|
|
| adaptive + seed | 67.4 | 53.7 / 51.8 % | 706 |
|
|
|
|
The 300 / 1200 / 2600-token natural prompts: static 52.2, static + seed 77.2, adaptive 60.7, adaptive + seed 79.5 tok/s
|
|
(VRAM @8: 7 / 64 / 12 / 62 %); prompt phase +83 ms. Trace-profile start (job 975): static 51.5 / 52.6, static + seed
|
|
65.3 / 75.6, adaptive 59.2 / 59.7, adaptive + seed 68.9 / 81.8 tok/s (corpus / natural prompts). The hook alone costs
|
|
nothing measurable (prompt phase 601 vs 601 ms, 1457 vs 1459 ms); the seed costs ~85 ms at the prompt end and is repaid
|
|
after ~15 tokens. Static + seed beats a fresh adaptive tier by 14-27 % on these prompts: the prompt's top experts cover
|
|
38-57 % of the decode's routed entries (job 976 `DBG seed-coverage`; the profile's set 7-9 %, the best static set for the
|
|
decode itself 61-87 %).
|
|
|
|
Replicate on the merged base (sd-b1 = this branch + port-gpu-bringup 5e0bd84 with the span cache, prefill kernels and ms-trim,
|
|
job 977, a third cold-start order, placeholder profile, corpus + natural prompts, 20 requests per arm): static 48.4,
|
|
static + seed 65.6 (+36 %), adaptive 56.4, adaptive + seed 69.2 tok/s; VRAM @8 8 / 51 / 13 / 52 %; seed greedy ids
|
|
identical to static in 0 / 14 requests (A/A 10 / 12). The laptop on that base (lap4): 9.1 / 15.2 / 11.4 / 17.7 tok/s.
|
|
|
|
16000-token prompts do NOT work: the prompt's top experts cover 9-10 % of the decode routing (the starting set 8 %), also
|
|
with the last chunk alone (`decay=0`), for synthetic notes (job 971, 974) and for this repository's source (job 974); the
|
|
decode's own best static set would cover 56-73 %. The seed is neutral there (VRAM @all 8-10 %, tok/s within noise, +90 ms)
|
|
and adaptive (+ seed, 5-12 % over adaptive alone; job 977: 46.3 vs 49.1 tok/s, static 38.8 vs 43.2) is the only one that learns the answer's experts. The signal is the
|
|
content match between the prompt and the answer; averaging 16000 rows washes it out.
|
|
|
|
RTX 3080 laptop (16 GB, mapped pageable bank, no PCIe share, profile `data/expert-profile.bin`, 300 / 1200 / 2600-token
|
|
prompts, 128 new tokens, jobs lap1-lap4): static 9.1-10.0, static + seed 14.8-16.1 (+60 %), adaptive 9.7-11.4, adaptive +
|
|
seed 16.3-17.9 tok/s; VRAM @8 17 -> 74 %. The seed costs +0.8-1.1 s on the prompt phase (the ~2500 swaps are copied from
|
|
pageable memory and the queueing returns after the staging), repaid after ~20 tokens; `seed=1024` halves both
|
|
(12.6 tok/s, +0.25 s).
|
|
|
|
Quality: a seed moves experts between the GPU and the CPU, whose rounding differs (cache-parity bench), and greedy ids are
|
|
not invariant to it. Static arms, ids against the same prompt of `static`: seed on 0-1 / 12 identical (first difference
|
|
at token 2-100, median ~10) on the 5090, 0-1 / 6 on the laptop. The placement-only control (job 973 vs 975, the same
|
|
static arm with the placeholder vs the trace profile, no seed) is 0 / 6 identical, first differences at token 2-58, and
|
|
`static + seed=1` (one swapped expert) is 1 / 12: the divergence is the known GPU/CPU envelope, not a property of the
|
|
seed. Repeats of the same configuration agree (`static + id=b`: 12/12 with the trace profile, 10/12 on the placeholder,
|
|
the two differences after token 58; laptop 4-5 / 6). No quality gate was run (no perplexity / task eval), so the seed
|
|
stays experimental.
|
|
|
|
Recommendation: keep it off by default; enable it (`=on`) for chat- and agent-sized prompts (up to a few thousand tokens)
|
|
where the answer continues the prompt's domain, on both machines; it is a loss-free no-op (+0.1 s) on long prompts, so a
|
|
length cap is a choice, not a need. Not measured: a real multi-turn agent loop, where the conversation cache already skips
|
|
most of the prefill (the seed then sees only the new rows).
|
|
|
|
**Long prompts (STRA-245 decode gap, 2026-10-29, `claude/decode-tail`).** On the frozen 5-turn 245k session (prompts 45,766 / 105k / 153k / 199k / 247k tokens, RTX 5090, upstream ranked profile sha256 `8f59b4aa...`, 11,280 slots, `bin-e2e4`, 300 greedy tokens per turn) the seed
|
|
hurt: with the seed (default) the VRAM share of routed entries was 80-85 %, windows 0-20 of every request served about 230-250 CPU and 230-255 PCIe experts, 17.5-20 ms per round, 107-110 tok/s; with `LELEKA_ORIGINAL_SERVE_SEED=off`
|
|
93-96 %, 23-79 CPU experts in windows 0-20, 13.4-15.4 ms per round, 132-149 tok/s (turn 5 of both arms stalled on the PLE reads, a host-memory artifact, and is not counted). The seed keeps `keep=0`, so at 45k+ rows it replaces the profile's good set by the prompt's top experts (9-10 % of the decode routing, as measured at 16k above).
|
|
`LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS` (EXPERIMENTAL, default 0 = no cap, so the seed stays on for every prompt as before) skips the seed for a prefill that routed more rows than that; `LELEKA_ORIGINAL_SERVE_SEED=off` is the other way to remove it. Both are placement-class changes: GPU and CPU round differently, so greedy ids are not invariant to them (see Quality above), and neither is a default until a quality gate has passed.
|
|
|
|
### 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.
|