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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
* 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>