Commit Graph
413 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Opus 5.5 3e8e10ed5f perf(serve): default --pcie-frac to the Original's 0.55 with the copy kernel
Job 802 (RTX 5090, paired a/b/b/a, one binary, copy-kernel staging, expert
tier on, 6 prompts x 2 passes x 128 tokens): pcie_frac 0 decodes at 41.9 /
42.7 tok/s mean, 0.55 at 62.2 / 63.6 (+48%), TTFT unchanged (1214/1209 vs
1212/1207 ms). Placement differs between the two (PCIe experts run on the
GPU, which rounds differently from the CPU pool), so outputs differ as
documented for the tier; the tier itself stays opt-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:20:53 +02:00
Pavlo Ratushnyi 8b544a7c5f Merge branch 'claude/port-gpu-bringup' into claude/round-overhead
# Conflicts:
#	crates/leleka-runtime/src/qwen_forward/original_serve_host.rs
#	crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs
#	docs/original-serve.md
2026-10-16 19:19:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 f845d86f47 merge: claude/pool-zero-copy (direct CPU expert pool: borrowed expert bytes, one dispatch per group, one-time admission, mmap page prefetch)
5090 decode mean 18.4 -> 56.5 tok/s on 6 prompts (verify window 169.5 -> 54.5 ms); laptop RTX 3080 mean 2.74 -> 8.10 tok/s
(Original 8.15). Real-model crosscheck: 4320 groups / 57556 expert rows, 0 differing floats. LELEKA_CPU_POOL=legacy keeps the
old path for A/B, =crosscheck runs both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 17:56:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 219e32a211 diag(serve): profile graph capture vs instantiate time of the verifier and the MTP drafter
capture_owned sums its host time (capture, then instantiate + upload) per thread;
the serve profile reports record.capture/record.instantiate for the window and
commit graphs and mtp.capture/mtp.instantiate for the drafter's per-request
round programs. Docs: the verified-window publication order, the per-request
verifier analysis and the PCIe copy kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 17:40:17 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3fe7888262 Revert "perf(serve): refill the prompt's lent expert slots beside the window capture"
Job 801 (RTX 5090, paired, same binary): TTFT unchanged (1215 vs 1218 ms
mean over 12 requests). The ~49 ms refill is host time, not copy time:
queueing 720 slots spends it in original_expert_spans' per-call scan of
every expert's blocks, so moving it into the capture only moved it.
The cached span admission of claude/pool-zero-copy (admitted_expert) is
what would shorten it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 17:39:08 +02:00
Pavlo RatushnyiandClaude Opus 5.5 d9313a95d3 test(driver): device proof of the PCIe span copy (staging layout and ptr2 rebase)
Root-only (LELEKA_VERIFY_WINDOW_GPU=yes): verify_fetch_spans_kernel and
verify_rebase_ptrs_kernel with pcie_stage's launch geometry stage five
experts' gate/up/down spans into staging slots exactly as the DMA path lays
them out and point ptr2[q] at each slot, leaving later table entries alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:27:26 +02:00
Pavlo RatushnyiandClaude Opus 5.5 bad3c6ebdb perf(serve): refill the prompt's lent expert slots beside the window capture
With the expert tier's prompt loan, every request refilled the lent slots
(720 on the 5090 profile, ~49 ms of copies) at the end of the prompt phase
and only then assembled the verifier, whose window/commit graph capture is
~110 ms of host work. The refill is now queued once the canonical GDN image
is uploaded (assemble's after_prepare hook), runs during the capture, and is
completed (sync_queued) before the first window reads the cache, so every
window sees the same resident set as before. A decode phase that stops
before the capture refills as before. LELEKA_SERVE_REFILL_OVERLAP=off keeps
the previous order (A/B control).

The verifier itself is still assembled per request: its window resources
borrow the stack's dense/MoE caches, which the prompt path mutates, and the
QSA owners move one way into its journal (see docs/original-serve.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:52:38 +02:00
Pavlo RatushnyiandClaude Opus 5.5 447276fb42 merge: claude/prefill-throughput (row validation once per chunk, per-process expert scale check, prefill stager for mapped experts, PREFILL-PROFILE tracing)
5090, 16000-token prompt: 311 -> ~1435 tok/s at chunk 2048 (greedy tokens identical), ~2890 tok/s at chunk 8192.
Laptop RTX 3080 (mapped experts): prefill 0.7-3.1 -> 4.5-9.4 tok/s, identical output. Default chunk stays 2048.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:46:01 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ef06b77ad9 docs(prefill): mark the GDN state staging as a likely, unmeasured cause
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:45:32 +02:00
Pavlo RatushnyiandClaude Opus 5.5 125f7820fb docs(prefill): profile, fixes and before/after prefill numbers (RTX 5090, RTX 3080 laptop)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:45:25 +02:00
Pavlo RatushnyiandClaude Opus 5.5 0a1d4e771e perf(serve): retain each admitted expert's bound route instead of rebinding it per call
admitted_expert bound a fresh top-10 route (moe_expert_weights: artifact borrow, topology and seven tensor
descriptors) for every CPU and PCIe expert of every group. The route is immutable bound metadata, so it is
now kept beside the admitted spans; every use still opens the source scope, which checks the route against
the binding and layer and validates the actual gate/up/down descriptors and bank spans.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:30:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a75e8a8fd3 perf(serve): enqueue the MTP draft behind the verifier commit (generate.cpp order)
draft_committed settled the commit first: the host waited the commit event,
took and published the twelve witnesses, and only then launched the draft,
so the commit's GPU time, the publication and the draft ran back to back.
generate.cpp enqueues the draft on the commit's stream and waits only for
its tokens.

The drafter's draft_from_verifier is now also available in two halves
(launch_from_verifier: everything up to the first graph's enqueue, with the
draft stream waiting the verifier's pending commit event on the device;
finish_from_verifier: the read-back, the chain and the ring mutation's close).
The serve port launches the draft against the branch the commit will publish
(original_origin_after, validated with the session still at the window's
origin), publishes the session while the draft runs, and finishes the draft
only once the session holds exactly that origin. The device sees commit then
draft, as before; draft_from_verifier itself is launch + finish unchanged.
LELEKA_SERVE_OVERLAP=off keeps the serialized order (A/B control).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:16:30 +02:00
Pavlo RatushnyiandClaude Opus 5.5 6f0d4e0f96 diag(serve): trace the PCIe span validation of the VRAM tier separately (pcie_spans, pcie_experts)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:13:59 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e618fa1b29 perf(serve): publish the twelve QSA witnesses per round without context synchronizes
publish_committed took the twelve resident QSA index checkpoints one by one:
each a cuMemGetInfo, a cuMemAlloc and a resident transfer that first
synchronizes the whole context, and the superseded checkpoints were freed by
cuMemFree; publish_original_verified_rows then synchronized the context once
more. Those context synchronizes also wait for work the Original runs beside
the commit (the adaptive tier's swap copies).

After the commit event the verifier is the only writer of the twelve images,
so the checkpoints are now one fenced batch (OriginalVerifier::
checkpoint_committed_qsa_all: 48 stream-ordered copies, one stream drain),
checkpoint buffers are pooled per index (a dropped checkpoint returns its
2564 bytes instead of cuMemFree), and the rows are published with
publish_original_verified_rows_fenced. Same copies of the same bytes.
LELEKA_SERVE_PUBLISH=serial keeps the previous path (A/B control).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:11:55 +02:00
Pavlo RatushnyiandClaude Opus 5.5 cdb44943cb perf(serve): stage the window's PCIe share with the Original's copy kernel (pcie mode 2)
generate.cpp's default --pcie-mode is the copy kernel: the plan names each PCIe
expert's device alias, flag B rises at once, and the window graph copies the
blobs into staging after wait B (fetch_blobs + rebase_ptrs), so no host CUDA
call sits inside the window. The port staged the three per-tensor spans by
DMA instead (three or more cuMemcpyHtoDAsync per expert plus a host function,
issued by the pool thread between flag A and the CPU's own share).

The port's source keeps an expert as three registered spans, so the new
verify_fetch_spans_kernel (original_verify_window_pcie.cu, fetch_blobs_kernel's
uint4 grid-stride copy over three aliases per expert; nvcc 13.2.86 sm_120 PTX,
sm_86 companion) writes gate|up|down into staging slot q exactly as the DMA
path did, and rebase_ptrs points ptr2[q] at it: the staged bytes and pointers
the PCIe expert groups read are unchanged.

LELEKA_ORIGINAL_SERVE_PCIE_MODE=auto|dma|kernel (--pcie-mode): auto takes the
kernel when the bank has device aliases (not the pageable low-RAM bank), dma
keeps the previous path. The recorded mode and the per-layer span lengths are
fixed in the verifier bank; publish_gpu_plan refuses a span of another length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:11:55 +02:00
Pavlo RatushnyiandClaude Opus 5.5 59c9102cd5 merge: claude/conversation-cache default on (--prompt-cache 6 as in the Original), coverage smoke and chunk-aware equality checks
Job 413: cancellation, periodic/root/turn checkpoints, reread mode and fallbacks pass; resumed requests are token-identical
to full reads whenever both cut the prompt at the same chunk boundaries (near-tie flips otherwise, as in the Original).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:08:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 75930fb8a1 docs(serve): conversation cache on by default; coverage (jobs 412/413) and the chunking finding
Resumed requests are token-identical to reads that cut the same prefill chunks;
different chunks (a resume point, a root boundary only cut from 0, cache on vs off)
can flip a near tie, as in the Original. The stack is deterministic within and across
processes for identical inputs and chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:08:22 +02:00
Pavlo RatushnyiandClaude Opus 5.5 d166004a10 diag(serve): LELEKA_SERVE_PROFILE host phase profile of the Original serve path
Named wall-clock spans (request reset, prefill read/refill, verifier assembly
steps, per-round window/commit/publish/draft phases, the GPU pool's split,
PCIe spans and plan publication) summed per request and printed as one
DBG profile line. Off by default; one cached boolean test per span when off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:55:01 +02:00
Pavlo RatushnyiandClaude Opus 5.5 51326a5880 chore(prefill): drop an unused import of the host stager
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:46:36 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a9e1d0a3e6 feat(serve): conversation cache on by default (--prompt-cache 6, as in the Original)
StackConfig::new and OriginalServeOptions now enable the cache with the Original's
settings; --prompt-cache 0 turns it off. Tests pin the defaults. Real-model coverage:
jobs 411/412 (and 413 for this exact tree).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:02:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 15a755cadf test(serve): compare resumed requests only where the prefill is chunked alike
Job 412 showed every resumed request whose prefill is cut into the same chunks as the
full read (root fallback, cancel then resume, and restore vs STRATA_CKPT_REREAD) is
token-identical, while two comparisons differed where the chunks differ (a resume point
the full read does not cut at; a root boundary only cut when reading from 0). The same
happens with the cache off: a full read with turn/root boundaries and one without give
different tokens. same_chunks() replays both prompt plans; equal chunks are checked,
others are reported as CONV-INFO, and at least one strict resumed comparison is required.
OriginalServeStack::resume_point() reports where the cache placed the request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:02:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae283e6423 perf(prefill): stage pageable experts through page-locked buffers (prefill.cpp Stager)
With a pageable, file-mapped expert bank (the laptop profile) the copy ring
copied every expert with a pageable cuMemcpyHtoDAsync on the launching
thread: the driver stages it, the mapped file is faulted in on one thread
and the GPU waits for each copy; the runtime had also rescanned every
first-seen expert's bytes for the finite admission, a second read.

The ring now keeps prefill.cpp's Stager in its copy schedule: helper
threads (4, or 32 when the experts are read in place from the model files;
STRATA_STAGER_THREADS) copy each staged expert's gate/up/down bytes, in
launch order, into a ring of page-locked buffers (16, or 4 x threads;
STRATA_STAGER_RING) and check every block scale finite on the copy; the
launching thread DMAs a buffer once it is ready and releases it when its
DMA completed (no CUDA call on a helper). Experts inside page-locked
pin_resident ranges, registered banks and arena-resident experts keep their
direct DMA. A staged expert skips the runtime's host rescan (the helpers
check the same scales). Same bytes reach the same device slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:21:32 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e32c39090a perf(serve): prefetch a file-mapped expert source on all pool workers before admission and compute
With the mapped low-RAM source (load_mapped_expert_source, the Original's --mmap-experts) the direct CPU
tier opens every CPU expert of the group first without scanning it, then advises all their pages
(MADV_WILLNEED) and faults them in on every pool worker and the caller in one read-only phase
(expert_source.cpp prefetch on its fetch threads), and only then admits first-use experts and computes.
The resident source skips the phase. Trace slot 'fetch' times it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:19:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 0bd4ebe529 merge: claude/port-gpu-bringup 3e05437 (laptop profile: mapped expert source, resident RAM budget) into claude/pool-zero-copy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:15:54 +02:00
Pavlo Ratushnyi d0c69fcf21 Merge branch 'claude/port-gpu-bringup' into claude/prefill-throughput 2026-10-16 13:12:34 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3e05437bf2 merge: claude/laptop-profile (RTX 3080 laptop: mapped experts instead of a 50 GB RAM copy, KAR read-only file source, resident RAM budget, regenerated sm_86 resolver image, paired bench harness, docs/laptop-profile.md)
Laptop numbers (indicative, 3 prompts x 2): Original decode 8.15 tok/s / TTFT 7.2 s (KAR PLE), port 2.70 tok/s / 28.4 s;
both bottlenecks (serial CPU expert preparation, prompt-path expert copies) are being fixed on claude/pool-zero-copy and
claude/prefill-throughput. model-format now denies (instead of forbids) unsafe code for one audited mmap owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:10:56 +02:00
Pavlo RatushnyiandClaude Opus 5.5 cfd80e9452 docs: laptop profile (memory map, the Original's low-RAM modes, port gaps, paired laptop numbers)
docs/laptop-profile.md: what lives in VRAM / RAM / NVMe on the RTX 3080 Laptop 16 GB + 48 GB machine for the
Original and the port, why both GGUF shards are strictly needed, the WSL2 cgroup bug that keeps the Original's
resident modes off there, the port's gaps and what this branch adds, and the measured arms (n = 6 each):
unmodified Original 8.15 decode / 12.4 prefill tok/s / TTFT 7.2 s vs port 2.70 / 3.1 / 28.4 s on the same
token IDs and KAR PLE; traced: all port decode time is in run_window (~1.0 s per verify window).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:08:44 +02:00
Pavlo RatushnyiandClaude Opus 5.5 40b998ad65 test(serve): conversation cache coverage smoke (periodic, fallback, sampled, cancel, reread)
original_serve_conversation_coverage_smoke (ignored, real model), --prompt-cache-every
2048 by default: a ~4.8k-token chat read cold twice (same-process determinism, tokens
printed for cross-process comparison); a prompt diverging inside the system prompt
resumes from the periodic checkpoint; a follow-up that edits an earlier user turn falls
back to the root checkpoint and an unrelated prompt starts empty; a seeded sampled
follow-up; a cancel in the decode phase and one during the prefill, each followed by a
request. Every resumed request is compared token for token with the same request read
from 0; each check prints CONV-CHECK and the test fails at the end if any failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:59:34 +02:00
Pavlo RatushnyiandClaude Opus 5.5 90b321b36c merge: claude/conversation-cache follow-ups (cache-off control in the smoke, job 411 record: resumed chat B greedy-equal to a full read, TTFT 9.5 s -> 1.6 s)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:55:54 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e6d3d09a99 docs(serve): conversation cache real-model run (job 411)
Cache off and on, same requests: the resumed chat B (reused 2297 of 2364) produced
the same 38 greedy tokens as B read from 0; TTFT 1645.6 ms vs 10330.8 ms; a new chat
sharing the system prompt resumed from the root checkpoint (reused 2286, TTFT
983.3 ms). One sample per cell; the cache stays off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:55:09 +02:00
Pavlo RatushnyiandClaude Opus 5.5 063e0d8b45 merge: claude/port-gpu-bringup (204ad3d, multi-chunk draft-ring fix) into the conversation cache
Job 411 ran this branch's 562f35d (= e9995d8 + 791a4fa) on the RTX 5090: the conversation
smoke passes with the cache off and on; the resumed chat B equals the full read token for
token (reused 2297/2364, TTFT 1645.6 ms vs 10330.8 ms).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:54:44 +02:00
Pavlo RatushnyiandClaude Opus 5.5 5416f4eab8 perf(prefill): admit each routed expert's bank bytes finite once per bank
original_prompt_moe resolved every routed expert of every layer through
mapped_span, which rescans the expert's whole encoded gate/up/down bytes
(~2.3 MB, one FP16 scale per block) on one host thread, every chunk: about
1.2 GB of host reads per layer with nearly all 512 experts routed. The
registered bank is immutable for its lifetime, so the MoE cache keeps one
admitted bit per (layer, expert); a later chunk takes the same
descriptor/geometry-checked bank_span without the rescan. The bits are
cleared with the bank. Same spans, same refusals on first use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:53:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 19fac1bd78 perf(prefill): validate a chunk's rows in one pass, not once per row
validate_original_rows re-ran the whole-set Sources::validate (all row
positions plus the dense-cache source checks: ~900 tensor lookups and
fstats) for every row, so each of the four per-layer validations was
quadratic in the chunk: ~400k dense-source validations per 2048-token
chunk. The set checks are row-independent; they now run once per set,
followed by the same per-row key checks in the same order. Same refusals,
no arithmetic change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:53:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 49d27973b0 perf(serve): admit PCIe and swap expert sources once, like the CPU tier's
The VRAM tier's PCIe copies and adaptive swaps took their spans from original_expert_spans, which scans
every block scale of the expert's three matrices (~2.7 MB) on every call. With the direct CPU tier they now
go through the same admitted_expert: binding, descriptors and bank spans validated per call, the rows
scanned on first use with the checked spans retained, and the bank eligibility checked as before. The
legacy arm (LELEKA_CPU_POOL=legacy) keeps the per-call scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:51:20 +02:00
Pavlo RatushnyiandClaude Opus 5.5 bbb5b2deab test(serve): long-context smoke serves a list of prompt lengths on one stack
LELEKA_ORIGINAL_SERVE_LONG_TOKENS=8000,16000 loads the model once; every
shorter prompt takes a prefix of the same filler, so each is the prompt a
single-length run builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:50:41 +02:00
Pavlo RatushnyiandClaude Opus 5.5 c9845eed52 fix(experts): split bank copies at page-locked boundaries; Original bench without the subcommand
With part of a file-mapped bank page-locked (`pin_resident`), an H2D copy that starts in registered pages and
runs into unregistered ones is refused by the driver (CUDA_ERROR_INVALID_VALUE, first seen on the laptop run).
`MappedExpertBank::copy_pieces` cuts a `cache_source` slice at every registered boundary and the four copy
sites (prompt copy ring, cache fill, swap fill, PCIe staging) issue one copy per piece; one piece when nothing
is locked, so the default path is unchanged. original_bench.sh: the `strata` binary takes the generate
options directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:49:53 +02:00
Pavlo RatushnyiandClaude Opus 5.5 cffbf88e31 perf(prefill): LELEKA_BRINGUP_TRACE-gated per-stage timing of the batched Original prefill
One PREFILL-PROFILE line per published chunk: input staging, init upload,
PLE, row validation, attention/FFN GR reads, GDN/QSA mixers, MoE (router
prepare, expert span resolution, DMA ring + grouped MMQ, combine), GR
injection, final row, draft-KV recording, publication and the expert-cache
loan. LELEKA_PREFILL_PROFILE_SYNC drains the device at every span end for
GPU attribution. The long-context smoke takes the expert tier from the
environment, serves LELEKA_ORIGINAL_SERVE_LONG_REPEAT passes and prints the
prompt-phase time of each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:48:51 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3b9525af87 perf(serve): zero-copy CPU expert tier over the resident bank, one dispatch per group
CpuExpertPool now opens one source scope per CPU expert (binding, actual gate/up/down descriptors and
formats, the resident bank spans of exactly that expert), admits an expert's encoded rows once (the same
finite-scale guard PreparedJob::new applied to every copy; the admitted spans are retained so the bytes
cannot move) and computes the whole group in one DirectCpuPool dispatch writing the mapped destination in
place. Previously every expert was copied twice (~2.7 MB each), prepared on the coordinator, run in
batches of 12 with a join between them, re-validated by re-opening the source and scattered.

LELEKA_CPU_POOL=legacy keeps the previous path (A/B arm); LELEKA_CPU_POOL=crosscheck runs both on every
group and fails on any differing bit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:48:27 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae2cbf454f perf(cpu-expert): borrowed single-dispatch group path (DirectCpuPool)
The native pool computes a whole layer group straight from borrowed gate/up/down matrices into the
caller's output rows: the caller's thread publishes the group and drains beside the workers (pool.cpp
host_works_), every token is quantized once (expert_source.cpp act_multi), and every borrow ends when
compute_group returns (a caught panic stops and joins the pool first). Jobs now carry the three role
pointers instead of one blob; the owned PreparedJob path points them into its blob, so its kernels read
the same row bytes as before.

tests/borrowed_group_parity.rs: the borrowed path is bit-identical to the owned batches-of-12 path on all
10 gate/up x down format pairs (120 synthetic groups, 1..8 rows, shared experts, partial CPU masks), and
refuses bad extents, overlapping or out-of-range destinations and non-finite inputs without writing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:48:27 +02:00
Pavlo RatushnyiandClaude Opus 5.5 204ad3d058 merge: claude/long-context-fix (draft-ring publication across prefill chunks; 40000-token prompt passes, streamed == resident)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:41:45 +02:00
Pavlo RatushnyiandClaude Opus 5.5 27c8ddf6b5 docs(kv): the 40000-token real-model run (job 312) and the multi-chunk publication fix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:41:22 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a97b08b949 diag(serve): time the window's host work and the CPU pool phases under LELEKA_BRINGUP_TRACE
One DBG window line per verifier window: PLE/ledger setup, sampling setup, the verifier run, the pool
callbacks (GPU split + PCIe spans, plan, prepare/copy, start, join, re-validate, scatter) and the
remaining GPU wait. The smoke corpus also prints the output ids of every repeat pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:37:40 +02:00
Pavlo RatushnyiandClaude Opus 5.5 562f35d584 test(serve): conversation smoke control with the cache off; print request failures
LELEKA_CONVERSATION_CACHE=off runs the same requests with StackConfig::conversation
None (nothing reused, the second read of B must repeat the first), so a failure can
be told apart from the cache. A failed request now prints a CONV FAILED line with
the error and the stack's health before the panic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:33:10 +02:00
Pavlo RatushnyiandClaude Opus 5.5 69442a307d merge: claude/long-context-fix (791a4fa, draft ring lower bound across prompt chunks) for the conversation smoke
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:31:24 +02:00
Pavlo RatushnyiandClaude Opus 5.5 791a4fa8cb fix(serve): keep the draft ring's materialized lower bound across prompt chunks
The second batched chunk of every multi-chunk prompt was refused with
IdentityMismatch at publication: OriginalDraftSession::prepare_publication took
the driver's per-chunk bound (CompletedDraftKv::first_materialized = cell0 + r0,
i.e. the chunk's start) as the ring's whole materialized range and checked it
against end - MTP_ORIGINAL_WINDOW, so [0, start) counted as never recorded.
A chunk that records from its own start where the ring already reaches now
continues the earlier range; a chunk that skipped rows still starts a new one.
Found by job 311 (8000-token prompt, LELEKA_BRINGUP_TRACE): chunk 2 at
first=2048 failed in pending.publish(). The refusal now traces its operands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:06:10 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e9995d8ec3 merge: claude/numerics (parity tooling: KAR PLE row parity test, opt-in residual/ladder/PLE traces, comparison scripts)
Result recorded in LeaseVibe: port vs Original deviation equals the Original's own deviation between its expert settings
(median max |dlogprob| 0.292 vs 0.287, top-1 differs 4/120 vs 3/120); KAR PLE rows bit-identical (1744/1744).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:57:37 +02:00
Pavlo RatushnyiandClaude Opus 5.5 84a6817a5a diag(numerics): ladder comparison tools, CPU-expert Original arm, logprob comparators
Results (3 prompts x 41 teacher-forced rows): port vs Original agree exactly
at the embedding and the first GDN half; relL2 of the residual then grows
smoothly with depth (1e-3 after layer 0 FFN, ~1e-2 by layers 8-13, 5-15e-2
by layers 28-44). The Original's own GPU-expert-cache vs CPU-expert arms show
the same profile and the same logprob spread (median 0.287 vs port 0.292).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:57:00 +02:00
Pavlo RatushnyiandClaude Opus 5.5 1ef80a1fb0 bench(laptop): optional smaller process geometry (LELEKA_LAPTOP_CELLS, experimental)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:39:05 +02:00
Pavlo RatushnyiandClaude Opus 5.5 150561bd07 feat(experts): resident RAM budget over the mapped bank (--resident-budget-gib)
`LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB=N` (VRAM tier on, low-RAM file-mapped bank): after the cache is
filled from the profile, the experts it does not hold are page-locked in RAM in profile order while their
gate/up/down bytes fit N GiB, clamped like FileExpertSource::pin_cache_complement to MemAvailable less the
4 GiB headroom and a 0.25 GiB margin. The Original copies them into a page-locked arena; here the bank's own
file pages are registered read-only in place (`MappedExpertBank::pin_resident`, merged page ranges per
mapping, CU_MEMHOSTREGISTER_READ_ONLY), so they are read once, stay out of reclaim, and their copies are
DMA. The bytes are unchanged. A budget that cannot be kept is a warning (#403) and leaves nothing registered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:37:19 +02:00
Pavlo RatushnyiandClaude Opus 5.5 bbba0f231d bench(laptop): paired Original/port harness on fixed pre-tokenized prompts
* tokenizer example `chat_tokens`: one user turn per line, thinking off, to comma-separated IDs, so both
  engines get exactly the same token IDs (benchmarks/laptop/prompts.txt: 3 prompts, 78-88 tokens).
* leleka-runtime ignored test `original_serve_laptop_bench`: opens the Original serve stack with the
  low-RAM sources (mapped experts, read-only KAR file; resident/memfd still selectable), serves every prompt
  REPEAT times greedily and prints TTFT, prompt/decode phase times, prefill/decode tok/s, memory and the
  output IDs of the first pass.
* scripts/laptop: original_bench.sh drives the unmodified `strata generate --serve` (setup.py's IQ3_S
  arguments, conversation cache off, one GEN at a time, TTFT to the first T line); port_bench.sh runs the
  test; monitor.sh samples process RSS/anon/file/shmem/locked/pinned and GPU VRAM once a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:27:46 +02:00